src/Tools/isac/ProgLang/Script.thy
author Walther Neuper <neuper@ist.tugraz.at>
Tue, 03 May 2011 11:16:55 +0200
branchdecompose-isar
changeset 41968 3228aa46fd30
parent 41899 d837e83a4835
child 41969 a350b4ed575b
permissions -rw-r--r--
updated all 'Const ("Let"..' to 'Const ("HOL.Let"..'

This change was from Isabelle2009-2 to Isabelle2011;
it broke the script interpreter.
The error occurred with Apply_Method in init_form,
which returned NONE.
     1 (* Title:  tactics, tacticals etc. for scripts
     2    Author: Walther Neuper 000224
     3    (c) due to copyright terms
     4 12345678901234567890123456789012345678901234567890123456789012345678901234567890
     5         10        20        30        40        50        60        70        80
     6  *)
     7 
     8 theory Script imports Tools begin
     9 
    10 typedecl
    11   ID	(* identifiers for thy, ruleset,... *)
    12 
    13 typedecl
    14   arg	(* argument of subproblem           *)
    15 
    16 consts
    17 
    18 (*types of subproblems' arguments*)
    19   REAL        :: "real => arg"
    20   REAL_LIST   :: "(real list) => arg"
    21   REAL_SET    :: "(real set) => arg"
    22   BOOL        :: "bool => arg"
    23   BOOL_LIST   :: "(bool list) => arg"
    24   REAL_REAL   :: "(real => real) => arg"
    25 
    26 (*tactics*)
    27   Rewrite      :: "[ID, bool, 'a] => 'a"
    28   Rewrite'_Inst:: "[(real * real) list, ID, bool, 'a] => 'a"
    29 			             ("(Rewrite'_Inst (_ _ _))" 11)
    30                                      (*without last argument ^^ for @@*)
    31   Rewrite'_Set :: "[ID, bool, 'a] => 'a" ("(Rewrite'_Set (_ _))" 11)
    32   Rewrite'_Set'_Inst
    33                :: "[(real * real) list, ID, bool, 'a] => 'a"
    34 		                     ("(Rewrite'_Set'_Inst (_ _ _))" 11)
    35                                      (*without last argument ^^ for @@*)
    36   Calculate    :: "[ID, 'a] => 'a" (*WN100816 PLUS, TIMES, POWER miss.in scr*)
    37   Calculate1   :: "[ID, 'a] => 'a" (*FIXXXME: unknown to script-interpreter*)
    38 
    39   (* WN0509 substitution now is rewriting by a list of terms (of type bool)
    40   Substitute   :: "[(real * real) list, 'a] => 'a"*)
    41   Substitute   :: "[bool list, 'a] => 'a"
    42 
    43   Map          :: "['a => 'b, 'a list] => 'b list"
    44   Tac          :: "ID => 'a"         (*deprecated; used in Test.ML*)
    45   Check'_elementwise ::
    46 		  "['a list, 'b set] => 'a list"
    47                                      ("Check'_elementwise (_ _)" 11)
    48   Take         :: "'a => 'a"         (*for non-var args as long as no 'o'*)
    49   SubProblem   :: "[ID * ID list * ID list, arg list] => 'a"
    50 
    51   Or'_to'_List :: "bool => 'a list"  ("Or'_to'_List (_)" 11)
    52   (*=========== record these ^^^ in 'tacs' in Script.ML =========*)
    53 
    54   Assumptions  :: bool
    55   Problem      :: "[ID * ID list] => 'a"
    56 
    57 (*special formulas for frontend 'CAS format'*)
    58   Subproblem   :: "(ID * ID list) => 'a" 
    59 
    60 (*script-expressions (tacticals)*)
    61   Seq      :: "['a => 'a, 'a => 'a, 'a] => 'a" (infixr "@@" 10) (*@ used*)
    62   Try      :: "['a => 'a, 'a] => 'a"
    63   Repeat   :: "['a => 'a, 'a] => 'a" 
    64   Or       :: "['a => 'a, 'a => 'a, 'a] => 'a" (infixr "Or" 10)
    65   While    :: "[bool, 'a => 'a, 'a] => 'a"     ("((While (_) Do)//(_))" 9)
    66 (*WN100723 because of "Error in syntax translation" below...
    67         (*'b => bool doesn't work with "contains_root _"*)
    68   Letpar   :: "['a, 'a => 'b] => 'b"
    69   (*--- defined in Isabelle/scr/HOL/HOL.thy:
    70   Let      :: "['a, 'a => 'b] => 'b"
    71   "_Let"   :: "[letbinds, 'a] => 'a"       ("(let (_)/ in (_))" 10)
    72   If       :: "[bool, 'a, 'a] => 'a"       ("(if (_)/ then (_)/ else (_))" 10)
    73   %x. P x  .. lambda is defined in Isabelles meta logic
    74   --- *)
    75 *)
    76   failtac :: 'a
    77   idletac :: 'a
    78   (*... + RECORD IN 'screxpr' in Script.ML *)
    79 
    80 (*for scripts generated automatically from rls*)
    81   Stepwise      :: "['z,     'z] => 'z" ("((Script Stepwise (_   =))// (_))" 9)
    82   Stepwise'_inst:: "['z,real,'z] => 'z" 
    83 	("((Script Stepwise'_inst (_ _ =))// (_))" 9)
    84 
    85 
    86 (*SHIFT -> resp.thys ----vvv---------------------------------------------*)
    87 (*script-names: initial capital letter,
    88 		type of last arg (=script-body) == result-type !
    89   Xxxx       :: script ids, duplicate result-type 'r in last argument:
    90              "['a, ... , \
    91 	       \         'r] => 'r
    92 *)
    93 			    
    94 (*make'_solution'_set :: "bool => bool list" 
    95 			("(make'_solution'_set (_))" 11)    
    96 					   
    97   max'_on'_interval
    98              :: "[ID * (ID list) * ID, bool,real,real set] => real"
    99                ("(max'_on'_interval (_)/ (_ _ _))" 9)
   100   find'_vals
   101              :: "[ID * (ID list) * ID,
   102 		  real,real,real,real,bool list] => bool list"
   103                ("(find'_vals (_)/ (_ _ _ _ _))" 9)
   104 
   105   make'_fun  :: "[ID * (ID list) * ID, real,real,bool list] => bool"
   106                ("(make'_fun (_)/ (_ _ _))" 9)
   107 
   108   solve'_univar
   109              :: "[ID * (ID list) * ID, bool,real] => bool list"
   110                ("(solve'_univar (_)/ (_ _ ))" 9)
   111   solve'_univar'_err
   112              :: "[ID * (ID list) * ID, bool,real,bool] => bool list"
   113                ("(solve'_univar (_)/ (_ _ _))" 9)
   114 ----------*)
   115 
   116   Testeq     :: "[bool, bool] => bool"
   117                ("((Script Testeq (_ =))// 
   118                   (_))" 9)
   119   
   120   Testeq2    :: "[bool, bool list] => bool list"
   121                ("((Script Testeq2 (_ =))// 
   122                   (_))" 9)
   123   
   124   Testterm   :: "[real, real] => real"
   125                ("((Script Testterm (_ =))// 
   126                   (_))" 9)
   127   
   128   Testchk    :: "[bool, real, real list] => real list"
   129                ("((Script Testchk (_ _ =))// 
   130                   (_))" 9)
   131   (*... + RECORD IN 'subpbls' in Script.ML *)
   132 (*SHIFT -> resp.thys ----^^^----------------------------*)
   133 
   134 (*Makarius 10.03
   135 syntax
   136 
   137   "_Letpar"     :: "[letbinds, 'a] => 'a"      ("(letpar (_)/ in (_))" 10)
   138 
   139 translations
   140 
   141   "_Letpar (_binds b bs) e"  == "_Letpar b (_Letpar bs e)"
   142   "letpar x = a in e"        == "Letpar a (%x. e)"
   143 *** Error in syntax translation rule: rhs contains extra variables
   144 *** ("_Letpar" ("_bind" x a) e)  ->  (Letpar a ("_abs" x e))
   145 *** At command "translations" (line 140 of "/usr/local/isabisac/src/Pure/isac/Scripts/Script").
   146 *)
   147 
   148 ML {* (*the former Script.ML*)
   149 
   150 (*.record all theories defined for Scripts; in order to distinguish them
   151    from general IsacKnowledge defined later on.*)
   152 script_thys := !theory';
   153 
   154 (*--vvv----- SHIFT? or delete ?*)
   155 val IDTyp = Type("Script.ID",[]);
   156 
   157 
   158 val tacs = Unsynchronized.ref (distinct (remove op = ""
   159   ["Calculate",
   160    "Rewrite","Rewrite'_Inst","Rewrite'_Set","Rewrite'_Set'_Inst",
   161    "Substitute","Tac","Check'_elementswise",
   162    "Take","Subproblem","Or'_to'_List"]));
   163 
   164 val screxpr = Unsynchronized.ref (distinct (remove op = ""
   165   ["HOL.Let","If","Repeat","While","Try","Or"]));
   166 
   167 val listfuns = Unsynchronized.ref [(*_all_ functions in Isa99.List.thy *)
   168     "@","filter","concat","foldl","hd","last","set","list_all",
   169     "map","mem","nth","list_update","take","drop",	
   170     "takeWhile","dropWhile","tl","butlast",
   171     "rev","zip","upt","remdups","nodups","replicate",
   172 
   173     "Cons","Nil"];
   174 
   175 val scrfuns = Unsynchronized.ref ([]: string list);
   176 
   177 val listexpr = Unsynchronized.ref (union op = (!listfuns) (!scrfuns));
   178 
   179 val notsimp = Unsynchronized.ref 
   180   (distinct (remove op = "" 
   181              (!tacs @ !screxpr @ (*!subpbls @*) !scrfuns @ !listfuns)));
   182 
   183 val negotiable = Unsynchronized.ref ((!tacs (*@ !subpbls*)));
   184 
   185 val tacpbl = Unsynchronized.ref
   186   (distinct (remove op = "" (!tacs (*@ !subpbls*))));
   187 (*--^^^----- SHIFT? or delete ?*)
   188 
   189 *}
   190 
   191 end