1 (* Title: tactics, tacticals etc. for scripts
2 Author: Walther Neuper 000224
3 (c) due to copyright terms
6 theory Script imports Tools begin
9 ID (* identifiers for thy, ruleset,... *)
12 arg (* argument of subproblem *)
16 (*types of subproblems' arguments*)
18 REAL_LIST :: "(real list) => arg"
19 REAL_SET :: "(real set) => arg"
21 BOOL_LIST :: "(bool list) => arg"
22 REAL_REAL :: "(real => real) => arg"
25 Rewrite :: "[ID, bool, 'a] => 'a"
26 Rewrite'_Inst:: "[(real * real) list, ID, bool, 'a] => 'a"
27 ("(Rewrite'_Inst (_ _ _))" 11)
28 (*without last argument ^^ for @@*)
29 Rewrite'_Set :: "[ID, bool, 'a] => 'a" ("(Rewrite'_Set (_ _))" 11)
31 :: "[(real * real) list, ID, bool, 'a] => 'a"
32 ("(Rewrite'_Set'_Inst (_ _ _))" 11)
33 (*without last argument ^^ for @@*)
34 Calculate :: "[ID, 'a] => 'a" (*WN100816 PLUS, TIMES, POWER miss.in scr*)
35 Calculate1 :: "[ID, 'a] => 'a" (*FIXXXME: unknown to script-interpreter*)
37 (* WN0509 substitution now is rewriting by a list of terms (of type bool)
38 Substitute :: "[(real * real) list, 'a] => 'a"*)
39 Substitute :: "[bool list, 'a] => 'a"
41 Map :: "['a => 'b, 'a list] => 'b list"
42 Tac :: "ID => 'a" (*deprecated; used in Test.ML*)
44 "['a list, 'b set] => 'a list"
45 ("Check'_elementwise (_ _)" 11)
46 Take :: "'a => 'a" (*for non-var args as long as no 'o'*)
47 SubProblem :: "[ID * ID list * ID list, arg list] => 'a"
49 Or'_to'_List :: "bool => 'a list" ("Or'_to'_List (_)" 11)
50 (*=========== record these ^^^ in 'tacs' in Script.ML =========*)
53 Problem :: "[ID * ID list] => 'a"
55 (*special formulas for frontend 'CAS format'*)
56 Subproblem :: "(ID * ID list) => 'a"
58 (*script-expressions (tacticals)*)
59 Seq :: "['a => 'a, 'a => 'a, 'a] => 'a" (infixr "@@" 10) (*@ used*)
60 Try :: "['a => 'a, 'a] => 'a"
61 Repeat :: "['a => 'a, 'a] => 'a"
62 Or :: "['a => 'a, 'a => 'a, 'a] => 'a" (infixr "Or" 10)
63 While :: "[bool, 'a => 'a, 'a] => 'a" ("((While (_) Do)//(_))" 9)
64 (*WN100723 because of "Error in syntax translation" below...
65 (*'b => bool doesn't work with "contains_root _"*)
66 Letpar :: "['a, 'a => 'b] => 'b"
67 (*--- defined in Isabelle/scr/HOL/HOL.thy:
68 Let :: "['a, 'a => 'b] => 'b"
69 "_Let" :: "[letbinds, 'a] => 'a" ("(let (_)/ in (_))" 10)
70 If :: "[bool, 'a, 'a] => 'a" ("(if (_)/ then (_)/ else (_))" 10)
71 %x. P x .. lambda is defined in Isabelles meta logic
76 (*... + RECORD IN 'screxpr' in Script.ML *)
78 (*for scripts generated automatically from rls*)
79 Stepwise :: "['z, 'z] => 'z" ("((Script Stepwise (_ =))// (_))" 9)
80 Stepwise'_inst:: "['z,real,'z] => 'z"
81 ("((Script Stepwise'_inst (_ _ =))// (_))" 9)
84 (*SHIFT -> resp.thys ----vvv---------------------------------------------*)
85 (*script-names: initial capital letter,
86 type of last arg (=script-body) == result-type !
87 Xxxx :: script ids, duplicate result-type 'r in last argument:
92 (*make'_solution'_set :: "bool => bool list"
93 ("(make'_solution'_set (_))" 11)
96 :: "[ID * (ID list) * ID, bool,real,real set] => real"
97 ("(max'_on'_interval (_)/ (_ _ _))" 9)
99 :: "[ID * (ID list) * ID,
100 real,real,real,real,bool list] => bool list"
101 ("(find'_vals (_)/ (_ _ _ _ _))" 9)
103 make'_fun :: "[ID * (ID list) * ID, real,real,bool list] => bool"
104 ("(make'_fun (_)/ (_ _ _))" 9)
107 :: "[ID * (ID list) * ID, bool,real] => bool list"
108 ("(solve'_univar (_)/ (_ _ ))" 9)
110 :: "[ID * (ID list) * ID, bool,real,bool] => bool list"
111 ("(solve'_univar (_)/ (_ _ _))" 9)
114 Testeq :: "[bool, bool] => bool"
115 ("((Script Testeq (_ =))//
118 Testeq2 :: "[bool, bool list] => bool list"
119 ("((Script Testeq2 (_ =))//
122 Testterm :: "[real, real] => real"
123 ("((Script Testterm (_ =))//
126 Testchk :: "[bool, real, real list] => real list"
127 ("((Script Testchk (_ _ =))//
129 (*... + RECORD IN 'subpbls' in Script.ML *)
130 (*SHIFT -> resp.thys ----^^^----------------------------*)
135 "_Letpar" :: "[letbinds, 'a] => 'a" ("(letpar (_)/ in (_))" 10)
139 "_Letpar (_binds b bs) e" == "_Letpar b (_Letpar bs e)"
140 "letpar x = a in e" == "Letpar a (%x. e)"
141 *** Error in syntax translation rule: rhs contains extra variables
142 *** ("_Letpar" ("_bind" x a) e) -> (Letpar a ("_abs" x e))
143 *** At command "translations" (line 140 of "/usr/local/isabisac/src/Pure/isac/Scripts/Script").
146 ML {* (*the former Script.ML*)
148 (*--vvv----- SHIFT? or delete ?*)
149 val IDTyp = Type("Script.ID",[]);
151 val tacs = Unsynchronized.ref (distinct (remove op = ""
153 "Rewrite","Rewrite'_Inst","Rewrite'_Set","Rewrite'_Set'_Inst",
154 "Substitute","Tac","Check'_elementswise",
155 "Take","Subproblem","Or'_to'_List"]));
157 val screxpr = Unsynchronized.ref (distinct (remove op = ""
158 ["Let","If","Repeat","While","Try","Or"]));
160 val listfuns = Unsynchronized.ref [(*_all_ functions in Isa99.List.thy *)
161 "@","filter","concat","foldl","hd","last","set","list_all",
162 "map","mem","nth","list_update","take","drop",
163 "takeWhile","dropWhile","tl","butlast",
164 "rev","zip","upt","remdups","nodups","replicate",
168 val scrfuns = Unsynchronized.ref ([]: string list);
170 val listexpr = Unsynchronized.ref (union op = (!listfuns) (!scrfuns));
172 val notsimp = Unsynchronized.ref
173 (distinct (remove op = ""
174 (!tacs @ !screxpr @ (*!subpbls @*) !scrfuns @ !listfuns)));
176 val negotiable = Unsynchronized.ref ((!tacs (*@ !subpbls*)));
178 val tacpbl = Unsynchronized.ref
179 (distinct (remove op = "" (!tacs (*@ !subpbls*))));
180 (*--^^^----- SHIFT? or delete ?*)