wneuper@59571
|
1 |
(* Title: Tactics; tac_ for interaction with frontend, input for internal use.
|
wneuper@59304
|
2 |
Author: Walther Neuper 170121
|
wneuper@59304
|
3 |
(c) due to copyright terms
|
wneuper@59304
|
4 |
|
wneuper@59304
|
5 |
regular expression for search:
|
wneuper@59304
|
6 |
|
wneuper@59304
|
7 |
Add_Find|Add_Given|Add_Relation|Apply_Assumption|Apply_Method|Begin_Sequ|Begin_Trans|Split_And|Split_Or|Split_Intersect|Conclude_And|Conclude_Or|Collect_Trues|End_Sequ|End_Trans|End_Ruleset|End_Subproblem|End_Intersect|End_Proof|CAScmd|Calculate|Check_Postcond|Check_elementwise|Del_Find|Del_Given|Del_Relation|Derive|Detail_Set|Detail_Set_Inst|End_Detail|Empty_Tac|Free_Solve|Init_Proof|Model_Problem Or_to_List|Refine_Problem|Refine_Tacitly| Rewrite|Rewrite_Asm|Rewrite_Inst|Rewrite_Set|Rewrite_Set_Inst|Specify_Method|Specify_Problem|Specify_Theory|Subproblem|Substitute|Tac|Take|Take_Inst
|
wneuper@59304
|
8 |
|
wneuper@59304
|
9 |
*)
|
wneuper@59298
|
10 |
signature TACTIC =
|
wneuper@59298
|
11 |
sig
|
wneuper@59571
|
12 |
datatype T =
|
wneuper@59416
|
13 |
Add_Find' of Rule.cterm' * Model.itm list | Add_Given' of Rule.cterm' * Model.itm list
|
wneuper@59416
|
14 |
| Add_Relation' of Rule.cterm' * Model.itm list
|
wneuper@59302
|
15 |
| Apply_Assumption' of term list * term
|
wneuper@59572
|
16 |
| Apply_Method' of Celem.metID * term option * Istate.T * Proof.context
|
wneuper@59302
|
17 |
|
wneuper@59302
|
18 |
| Begin_Sequ' | Begin_Trans' of term
|
wneuper@59302
|
19 |
| Split_And' of term | Split_Or' of term | Split_Intersect' of term
|
wneuper@59302
|
20 |
| Conclude_And' of term | Conclude_Or' of term | Collect_Trues' of term
|
wneuper@59302
|
21 |
| End_Sequ' | End_Trans' of Selem.result
|
wneuper@59302
|
22 |
| End_Ruleset' of term | End_Subproblem' of term | End_Intersect' of term | End_Proof''
|
wneuper@59302
|
23 |
|
wneuper@59302
|
24 |
| CAScmd' of term
|
wneuper@59416
|
25 |
| Calculate' of Rule.theory' * string * term * (term * Celem.thm')
|
wneuper@59405
|
26 |
| Check_Postcond' of Celem.pblID * Selem.result
|
wneuper@59416
|
27 |
| Check_elementwise' of term * Rule.cterm' * Selem.result
|
wneuper@59416
|
28 |
| Del_Find' of Rule.cterm' | Del_Given' of Rule.cterm' | Del_Relation' of Rule.cterm'
|
wneuper@59302
|
29 |
|
wneuper@59416
|
30 |
| Derive' of Rule.rls
|
wneuper@59416
|
31 |
| Detail_Set' of Rule.theory' * bool * Rule.rls * term * Selem.result
|
wneuper@59416
|
32 |
| Detail_Set_Inst' of Rule.theory' * bool * Rule.subst * Rule.rls * term * Selem.result
|
wneuper@59302
|
33 |
| End_Detail' of Selem.result
|
wneuper@59302
|
34 |
|
wneuper@59302
|
35 |
| Empty_Tac_
|
wneuper@59302
|
36 |
| Free_Solve'
|
wneuper@59302
|
37 |
|
wneuper@59416
|
38 |
| Init_Proof' of Rule.cterm' list * Celem.spec
|
wneuper@59405
|
39 |
| Model_Problem' of Celem.pblID * Model.itm list * Model.itm list
|
wneuper@59302
|
40 |
| Or_to_List' of term * term
|
wneuper@59405
|
41 |
| Refine_Problem' of Celem.pblID * (Model.itm list * (bool * term) list)
|
wneuper@59416
|
42 |
| Refine_Tacitly' of Celem.pblID * Celem.pblID * Rule.domID * Celem.metID * Model.itm list
|
wneuper@59302
|
43 |
|
wneuper@59416
|
44 |
| Rewrite' of Rule.theory' * Rule.rew_ord' * Rule.rls * bool * Celem.thm'' * term * Selem.result
|
wneuper@59416
|
45 |
| Rewrite_Asm' of Rule.theory' * Rule.rew_ord' * Rule.rls * bool * Celem.thm'' * term * Selem.result
|
wneuper@59416
|
46 |
| Rewrite_Inst' of Rule.theory' * Rule.rew_ord' * Rule.rls * bool * Rule.subst * Celem.thm'' * term * Selem.result
|
wneuper@59416
|
47 |
| Rewrite_Set' of Rule.theory' * bool * Rule.rls * term * Selem.result
|
wneuper@59416
|
48 |
| Rewrite_Set_Inst' of Rule.theory' * bool * Rule.subst * Rule.rls * term * Selem.result
|
wneuper@59302
|
49 |
|
wneuper@59405
|
50 |
| Specify_Method' of Celem.metID * Model.ori list * Model.itm list
|
wneuper@59405
|
51 |
| Specify_Problem' of Celem.pblID * (bool * (Model.itm list * (bool * term) list))
|
wneuper@59416
|
52 |
| Specify_Theory' of Rule.domID
|
wneuper@59405
|
53 |
| Subproblem' of Celem.spec * Model.ori list * term * Selem.fmz_ * Proof.context * term
|
wneuper@59416
|
54 |
| Substitute' of Rule.rew_ord_ * Rule.rls * Selem.subte * term * term
|
wneuper@59302
|
55 |
| Tac_ of theory * string * string * string
|
wneuper@59302
|
56 |
| Take' of term | Take_Inst' of term
|
walther@59728
|
57 |
val string_of : T -> string
|
wneuper@59302
|
58 |
|
wneuper@59571
|
59 |
datatype input =
|
wneuper@59416
|
60 |
Add_Find of Rule.cterm' | Add_Given of Rule.cterm' | Add_Relation of Rule.cterm'
|
wneuper@59416
|
61 |
| Apply_Assumption of Rule.cterm' list
|
wneuper@59405
|
62 |
| Apply_Method of Celem.metID
|
wneuper@59302
|
63 |
(*/--- TODO: re-design ? -----------------------------------------------------------------\*)
|
wneuper@59302
|
64 |
| Begin_Sequ | Begin_Trans
|
wneuper@59302
|
65 |
| Split_And | Split_Or | Split_Intersect
|
wneuper@59302
|
66 |
| Conclude_And | Conclude_Or | Collect_Trues
|
wneuper@59302
|
67 |
| End_Sequ | End_Trans
|
wneuper@59302
|
68 |
| End_Ruleset | End_Subproblem | End_Intersect | End_Proof'
|
wneuper@59302
|
69 |
(*\--- TODO: re-design ? -----------------------------------------------------------------/*)
|
wneuper@59416
|
70 |
| CAScmd of Rule.cterm'
|
wneuper@59302
|
71 |
| Calculate of string
|
wneuper@59405
|
72 |
| Check_Postcond of Celem.pblID
|
wneuper@59416
|
73 |
| Check_elementwise of Rule.cterm'
|
wneuper@59416
|
74 |
| Del_Find of Rule.cterm' | Del_Given of Rule.cterm' | Del_Relation of Rule.cterm'
|
wneuper@59302
|
75 |
|
wneuper@59416
|
76 |
| Derive of Rule.rls'
|
wneuper@59416
|
77 |
| Detail_Set of Rule.rls'
|
wneuper@59416
|
78 |
| Detail_Set_Inst of Selem.subs * Rule.rls'
|
wneuper@59302
|
79 |
| End_Detail
|
wneuper@59302
|
80 |
|
wneuper@59302
|
81 |
| Empty_Tac
|
wneuper@59302
|
82 |
| Free_Solve
|
wneuper@59302
|
83 |
|
wneuper@59416
|
84 |
| Init_Proof of Rule.cterm' list * Celem.spec
|
wneuper@59302
|
85 |
| Model_Problem
|
wneuper@59302
|
86 |
| Or_to_List
|
wneuper@59405
|
87 |
| Refine_Problem of Celem.pblID
|
wneuper@59405
|
88 |
| Refine_Tacitly of Celem.pblID
|
wneuper@59302
|
89 |
|
wneuper@59405
|
90 |
| Rewrite of Celem.thm''
|
wneuper@59405
|
91 |
| Rewrite_Asm of Celem.thm''
|
wneuper@59405
|
92 |
| Rewrite_Inst of Selem.subs * Celem.thm''
|
wneuper@59416
|
93 |
| Rewrite_Set of Rule.rls'
|
wneuper@59416
|
94 |
| Rewrite_Set_Inst of Selem.subs * Rule.rls'
|
wneuper@59302
|
95 |
|
wneuper@59405
|
96 |
| Specify_Method of Celem.metID
|
wneuper@59405
|
97 |
| Specify_Problem of Celem.pblID
|
wneuper@59416
|
98 |
| Specify_Theory of Rule.domID
|
wneuper@59416
|
99 |
| Subproblem of Rule.domID * Celem.pblID
|
wneuper@59302
|
100 |
|
wneuper@59302
|
101 |
| Substitute of Selem.sube
|
wneuper@59302
|
102 |
| Tac of string
|
wneuper@59416
|
103 |
| Take of Rule.cterm' | Take_Inst of Rule.cterm'
|
wneuper@59571
|
104 |
val tac2str : input -> string
|
wneuper@59302
|
105 |
|
walther@59728
|
106 |
val eq_tac : input * input -> bool
|
walther@59728
|
107 |
val is_empty_tac : input -> bool
|
walther@59728
|
108 |
val is_rewtac : input -> bool
|
walther@59728
|
109 |
val is_rewset : input -> bool
|
walther@59728
|
110 |
val rls_of : input -> Rule.rls'
|
wneuper@59571
|
111 |
val tac2IDstr : input -> string
|
walther@59728
|
112 |
val rule2tac : theory -> (term * term) list -> Rule.rule -> input
|
walther@59704
|
113 |
val input_from_T : T -> input
|
walther@59728
|
114 |
val result : T -> term
|
walther@59728
|
115 |
val creates_assms: T -> term list
|
walther@59728
|
116 |
val insert_assumptions: T -> Proof.context -> Proof.context
|
wneuper@59310
|
117 |
(* ---- for tests only: shifted from below to remove the Warning "unused" at fun.def. --------- *)
|
wneuper@59310
|
118 |
(* NONE *)
|
walther@59702
|
119 |
(*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
|
wneuper@59310
|
120 |
(* NONE *)
|
walther@59702
|
121 |
( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
|
wneuper@59298
|
122 |
|
wneuper@59310
|
123 |
(*----- unused code, kept as hints to design ideas ---------------------------------------------*)
|
wneuper@59310
|
124 |
(* NONE *)
|
wneuper@59298
|
125 |
end
|
wneuper@59298
|
126 |
|
walther@59728
|
127 |
(**)
|
wneuper@59571
|
128 |
structure Tactic(**): TACTIC(**) =
|
wneuper@59298
|
129 |
struct
|
walther@59728
|
130 |
(**)
|
wneuper@59298
|
131 |
|
wneuper@59302
|
132 |
(* tactics for user at front-end.
|
wneuper@59571
|
133 |
input propagates the construction of the calc-tree;
|
wneuper@59302
|
134 |
there are
|
wneuper@59302
|
135 |
(a) 'specsteps' for the specify-phase, and others for the solve-phase
|
wneuper@59302
|
136 |
(b) those of the solve-phase are 'initac's and others;
|
wneuper@59302
|
137 |
initacs start with a formula different from the preceding formula.
|
wneuper@59302
|
138 |
see 'type tac_' for the internal representation of tactics
|
wneuper@59302
|
139 |
*)
|
wneuper@59571
|
140 |
datatype input =
|
wneuper@59416
|
141 |
Add_Find of Rule.cterm' | Add_Given of Rule.cterm' | Add_Relation of Rule.cterm'
|
wneuper@59416
|
142 |
| Apply_Assumption of Rule.cterm' list
|
wneuper@59405
|
143 |
| Apply_Method of Celem.metID
|
wneuper@59302
|
144 |
(* creates an "istate" in PblObj.env; in case of "init_form"
|
wneuper@59302
|
145 |
creates a formula at ((lev_on o lev_dn) p, Frm) and in this "ppobj.loc"
|
wneuper@59302
|
146 |
a "SOME istate" at fst of "loc".
|
wneuper@59302
|
147 |
As each step (in the solve-phase) has a resulting formula (at the front-end)
|
wneuper@59302
|
148 |
Apply_Method also does the 1st step in the script (an "initac") if there is no "init_form" *)
|
wneuper@59302
|
149 |
(*/--- TODO: re-design ? -----------------------------------------------------------------\*)
|
wneuper@59302
|
150 |
| Begin_Sequ | Begin_Trans
|
wneuper@59302
|
151 |
| Split_And | Split_Or | Split_Intersect
|
wneuper@59302
|
152 |
| Conclude_And | Conclude_Or | Collect_Trues
|
wneuper@59302
|
153 |
| End_Sequ | End_Trans
|
wneuper@59302
|
154 |
| End_Ruleset | End_Subproblem (* WN0509 drop *) | End_Intersect | End_Proof'
|
wneuper@59302
|
155 |
(*\--- TODO: re-design ? -----------------------------------------------------------------/*)
|
wneuper@59416
|
156 |
| CAScmd of Rule.cterm'
|
wneuper@59302
|
157 |
| Calculate of string
|
wneuper@59405
|
158 |
| Check_Postcond of Celem.pblID
|
wneuper@59416
|
159 |
| Check_elementwise of Rule.cterm'
|
wneuper@59416
|
160 |
| Del_Find of Rule.cterm' | Del_Given of Rule.cterm' | Del_Relation of Rule.cterm'
|
wneuper@59302
|
161 |
|
wneuper@59416
|
162 |
| Derive of Rule.rls' (* WN0509 drop *)
|
wneuper@59416
|
163 |
| Detail_Set of Rule.rls' (* WN0509 drop *)
|
wneuper@59416
|
164 |
| Detail_Set_Inst of Selem.subs * Rule.rls' (* WN0509 drop *)
|
wneuper@59302
|
165 |
| End_Detail (* WN0509 drop *)
|
wneuper@59302
|
166 |
|
wneuper@59302
|
167 |
| Empty_Tac
|
wneuper@59302
|
168 |
| Free_Solve
|
wneuper@59302
|
169 |
|
wneuper@59416
|
170 |
| Init_Proof of Rule.cterm' list * Celem.spec
|
wneuper@59302
|
171 |
| Model_Problem
|
wneuper@59302
|
172 |
| Or_to_List
|
wneuper@59405
|
173 |
| Refine_Problem of Celem.pblID
|
wneuper@59405
|
174 |
| Refine_Tacitly of Celem.pblID
|
wneuper@59302
|
175 |
|
wneuper@59302
|
176 |
(* rewrite-tactics can transport a (thmID, thm) to and (!) from the java-front-end
|
wneuper@59302
|
177 |
because there all the thms are present with both (thmID, thm)
|
wneuper@59302
|
178 |
(where user-views can show both or only one of (thmID, thm)),
|
wneuper@59302
|
179 |
and thm is created from ThmID by assoc_thm'' when entering isabisac *)
|
wneuper@59405
|
180 |
| Rewrite of Celem.thm''
|
wneuper@59405
|
181 |
| Rewrite_Asm of Celem.thm''
|
wneuper@59405
|
182 |
| Rewrite_Inst of Selem.subs * Celem.thm''
|
wneuper@59416
|
183 |
| Rewrite_Set of Rule.rls'
|
wneuper@59416
|
184 |
| Rewrite_Set_Inst of Selem.subs * Rule.rls'
|
wneuper@59302
|
185 |
|
wneuper@59405
|
186 |
| Specify_Method of Celem.metID
|
wneuper@59405
|
187 |
| Specify_Problem of Celem.pblID
|
wneuper@59416
|
188 |
| Specify_Theory of Rule.domID
|
wneuper@59416
|
189 |
| Subproblem of Rule.domID * Celem.pblID (* WN0509 drop *)
|
wneuper@59302
|
190 |
|
wneuper@59302
|
191 |
| Substitute of Selem.sube
|
wneuper@59302
|
192 |
| Tac of string (* WN0509 drop *)
|
wneuper@59416
|
193 |
| Take of Rule.cterm' | Take_Inst of Rule.cterm'
|
wneuper@59302
|
194 |
|
wneuper@59302
|
195 |
fun tac2str ma = case ma of
|
wneuper@59302
|
196 |
Init_Proof (ppc, spec) =>
|
wneuper@59405
|
197 |
"Init_Proof "^(pair2str (strs2str ppc, Celem.spec2str spec))
|
wneuper@59302
|
198 |
| Model_Problem => "Model_Problem "
|
wneuper@59302
|
199 |
| Refine_Tacitly pblID => "Refine_Tacitly " ^ strs2str pblID
|
wneuper@59302
|
200 |
| Refine_Problem pblID => "Refine_Problem " ^ strs2str pblID
|
wneuper@59302
|
201 |
| Add_Given cterm' => "Add_Given " ^ cterm'
|
wneuper@59302
|
202 |
| Del_Given cterm' => "Del_Given " ^ cterm'
|
wneuper@59302
|
203 |
| Add_Find cterm' => "Add_Find " ^ cterm'
|
wneuper@59302
|
204 |
| Del_Find cterm' => "Del_Find " ^ cterm'
|
wneuper@59302
|
205 |
| Add_Relation cterm' => "Add_Relation " ^ cterm'
|
wneuper@59302
|
206 |
| Del_Relation cterm' => "Del_Relation " ^ cterm'
|
wneuper@59302
|
207 |
|
wneuper@59302
|
208 |
| Specify_Theory domID => "Specify_Theory " ^ quote domID
|
wneuper@59302
|
209 |
| Specify_Problem pblID => "Specify_Problem " ^ strs2str pblID
|
wneuper@59302
|
210 |
| Specify_Method metID => "Specify_Method " ^ strs2str metID
|
wneuper@59302
|
211 |
| Apply_Method metID => "Apply_Method " ^ strs2str metID
|
wneuper@59302
|
212 |
| Check_Postcond pblID => "Check_Postcond " ^ strs2str pblID
|
wneuper@59302
|
213 |
| Free_Solve => "Free_Solve"
|
wneuper@59302
|
214 |
|
wneuper@59302
|
215 |
| Rewrite_Inst (subs, (id, thm)) =>
|
wneuper@59416
|
216 |
"Rewrite_Inst " ^ (pair2str (subs2str subs, spair2str (id, thm |> Thm.prop_of |> Rule.term2str)))
|
wneuper@59416
|
217 |
| Rewrite (id, thm) => "Rewrite " ^ spair2str (id, thm |> Thm.prop_of |> Rule.term2str)
|
wneuper@59416
|
218 |
| Rewrite_Asm (id, thm) => "Rewrite_Asm " ^ spair2str (id, thm |> Thm.prop_of |> Rule.term2str)
|
wneuper@59302
|
219 |
| Rewrite_Set_Inst (subs, rls) =>
|
wneuper@59302
|
220 |
"Rewrite_Set_Inst " ^ pair2str (subs2str subs, quote rls)
|
wneuper@59302
|
221 |
| Rewrite_Set rls => "Rewrite_Set " ^ quote rls
|
wneuper@59302
|
222 |
| Detail_Set rls => "Detail_Set " ^ quote rls
|
wneuper@59302
|
223 |
| Detail_Set_Inst (subs, rls) => "Detail_Set_Inst " ^ pair2str (subs2str subs, quote rls)
|
wneuper@59302
|
224 |
| End_Detail => "End_Detail"
|
wneuper@59302
|
225 |
| Derive rls' => "Derive " ^ rls'
|
wneuper@59302
|
226 |
| Calculate op_ => "Calculate " ^ op_
|
wneuper@59302
|
227 |
| Substitute sube => "Substitute " ^ Selem.sube2str sube
|
wneuper@59302
|
228 |
| Apply_Assumption ct's => "Apply_Assumption " ^ strs2str ct's
|
wneuper@59302
|
229 |
|
wneuper@59302
|
230 |
| Take cterm' => "Take " ^ quote cterm'
|
wneuper@59302
|
231 |
| Take_Inst cterm' => "Take_Inst " ^ quote cterm'
|
wneuper@59302
|
232 |
| Subproblem (domID, pblID) => "Subproblem " ^ pair2str (domID, strs2str pblID)
|
wneuper@59302
|
233 |
| End_Subproblem => "End_Subproblem"
|
wneuper@59302
|
234 |
| CAScmd cterm' => "CAScmd " ^ quote cterm'
|
wneuper@59302
|
235 |
|
wneuper@59302
|
236 |
| Check_elementwise cterm'=> "Check_elementwise " ^ quote cterm'
|
wneuper@59302
|
237 |
| Or_to_List => "Or_to_List "
|
wneuper@59302
|
238 |
| Collect_Trues => "Collect_Trues"
|
wneuper@59302
|
239 |
|
wneuper@59302
|
240 |
| Empty_Tac => "Empty_Tac"
|
wneuper@59302
|
241 |
| Tac string => "Tac " ^ string
|
wneuper@59571
|
242 |
| End_Proof' => "input End_Proof'"
|
wneuper@59302
|
243 |
| _ => "tac2str not impl. for ?!";
|
wneuper@59302
|
244 |
|
wneuper@59571
|
245 |
fun is_empty_tac input = case input of Empty_Tac => true | _ => false
|
wneuper@59302
|
246 |
|
wneuper@59302
|
247 |
fun eq_tac (Rewrite (id1, _), Rewrite (id2, _)) = id1 = id2
|
wneuper@59302
|
248 |
| eq_tac (Rewrite_Inst (_, (id1, _)), Rewrite_Inst (_, (id2, _))) = id1 = id2
|
wneuper@59302
|
249 |
| eq_tac (Rewrite_Set id1, Rewrite_Set id2) = id1 = id2
|
wneuper@59302
|
250 |
| eq_tac (Rewrite_Set_Inst (_, id1), Rewrite_Set_Inst (_, id2)) = id1 = id2
|
wneuper@59302
|
251 |
| eq_tac (Calculate id1, Calculate id2) = id1 = id2
|
wneuper@59302
|
252 |
| eq_tac _ = false
|
wneuper@59302
|
253 |
|
wneuper@59302
|
254 |
fun is_rewset (Rewrite_Set_Inst _) = true
|
wneuper@59302
|
255 |
| is_rewset (Rewrite_Set _) = true
|
wneuper@59302
|
256 |
| is_rewset _ = false;
|
wneuper@59302
|
257 |
fun is_rewtac (Rewrite _) = true
|
wneuper@59302
|
258 |
| is_rewtac (Rewrite_Inst _) = true
|
wneuper@59302
|
259 |
| is_rewtac (Rewrite_Asm _) = true
|
wneuper@59571
|
260 |
| is_rewtac input = is_rewset input;
|
wneuper@59302
|
261 |
|
wneuper@59302
|
262 |
fun tac2IDstr ma = case ma of
|
wneuper@59302
|
263 |
Model_Problem => "Model_Problem"
|
wneuper@59302
|
264 |
| Refine_Tacitly _ => "Refine_Tacitly"
|
wneuper@59302
|
265 |
| Refine_Problem _ => "Refine_Problem"
|
wneuper@59302
|
266 |
| Add_Given _ => "Add_Given"
|
wneuper@59302
|
267 |
| Del_Given _ => "Del_Given"
|
wneuper@59302
|
268 |
| Add_Find _ => "Add_Find"
|
wneuper@59302
|
269 |
| Del_Find _ => "Del_Find"
|
wneuper@59302
|
270 |
| Add_Relation _ => "Add_Relation"
|
wneuper@59302
|
271 |
| Del_Relation _ => "Del_Relation"
|
wneuper@59302
|
272 |
|
wneuper@59302
|
273 |
| Specify_Theory _ => "Specify_Theory"
|
wneuper@59302
|
274 |
| Specify_Problem _ => "Specify_Problem"
|
wneuper@59302
|
275 |
| Specify_Method _ => "Specify_Method"
|
wneuper@59302
|
276 |
| Apply_Method _ => "Apply_Method"
|
wneuper@59302
|
277 |
| Check_Postcond _ => "Check_Postcond"
|
wneuper@59302
|
278 |
| Free_Solve => "Free_Solve"
|
wneuper@59302
|
279 |
|
wneuper@59302
|
280 |
| Rewrite_Inst _ => "Rewrite_Inst"
|
wneuper@59302
|
281 |
| Rewrite _ => "Rewrite"
|
wneuper@59302
|
282 |
| Rewrite_Asm _ => "Rewrite_Asm"
|
wneuper@59302
|
283 |
| Rewrite_Set_Inst _ => "Rewrite_Set_Inst"
|
wneuper@59302
|
284 |
| Rewrite_Set _ => "Rewrite_Set"
|
wneuper@59302
|
285 |
| Detail_Set _ => "Detail_Set"
|
wneuper@59302
|
286 |
| Detail_Set_Inst _ => "Detail_Set_Inst"
|
wneuper@59302
|
287 |
| Derive _ => "Derive "
|
wneuper@59302
|
288 |
| Calculate _ => "Calculate "
|
wneuper@59302
|
289 |
| Substitute _ => "Substitute"
|
wneuper@59302
|
290 |
| Apply_Assumption _ => "Apply_Assumption"
|
wneuper@59302
|
291 |
|
wneuper@59302
|
292 |
| Take _ => "Take"
|
wneuper@59302
|
293 |
| Take_Inst _ => "Take_Inst"
|
wneuper@59302
|
294 |
| Subproblem _ => "Subproblem"
|
wneuper@59302
|
295 |
| End_Subproblem => "End_Subproblem"
|
wneuper@59302
|
296 |
| CAScmd _ => "CAScmd"
|
wneuper@59302
|
297 |
|
wneuper@59302
|
298 |
| Check_elementwise _ => "Check_elementwise"
|
wneuper@59302
|
299 |
| Or_to_List => "Or_to_List "
|
wneuper@59302
|
300 |
| Collect_Trues => "Collect_Trues"
|
wneuper@59302
|
301 |
|
wneuper@59302
|
302 |
| Empty_Tac => "Empty_Tac"
|
wneuper@59302
|
303 |
| Tac _ => "Tac "
|
wneuper@59302
|
304 |
| End_Proof' => "End_Proof'"
|
wneuper@59302
|
305 |
| _ => "tac2str not impl. for ?!";
|
wneuper@59302
|
306 |
|
wneuper@59302
|
307 |
fun rls_of (Rewrite_Set_Inst (_, rls)) = rls
|
wneuper@59302
|
308 |
| rls_of (Rewrite_Set rls) = rls
|
wneuper@59571
|
309 |
| rls_of input = error ("rls_of: called with input \"" ^ tac2IDstr input ^ "\"");
|
wneuper@59302
|
310 |
|
wneuper@59416
|
311 |
fun rule2tac thy _ (Rule.Calc (opID, _)) = Calculate (assoc_calc thy opID)
|
wneuper@59416
|
312 |
| rule2tac _ [] (Rule.Thm thm'') = Rewrite thm''
|
wneuper@59416
|
313 |
| rule2tac _ subst (Rule.Thm thm'') =
|
wneuper@59302
|
314 |
Rewrite_Inst (Selem.subst2subs subst, thm'')
|
wneuper@59416
|
315 |
| rule2tac _ [] (Rule.Rls_ rls) = Rewrite_Set (Rule.id_rls rls)
|
wneuper@59416
|
316 |
| rule2tac _ subst (Rule.Rls_ rls) =
|
wneuper@59416
|
317 |
Rewrite_Set_Inst (Selem.subst2subs subst, (Rule.id_rls rls))
|
wneuper@59302
|
318 |
| rule2tac _ _ rule =
|
wneuper@59416
|
319 |
error ("rule2tac: called with \"" ^ Rule.rule2str rule ^ "\"");
|
wneuper@59302
|
320 |
|
wneuper@59571
|
321 |
(* tactics for for internal use, compare "input" for user at the front-end.
|
wneuper@59302
|
322 |
tac_ contains results from check in 'fun applicable_in'.
|
wneuper@59302
|
323 |
This is useful for costly results, e.g. from rewriting;
|
wneuper@59302
|
324 |
however, these results might be changed by Scripts like
|
wneuper@59499
|
325 |
" eq = (Rewrite_Set ''ansatz_rls'' False) eql;" ^
|
wneuper@59302
|
326 |
" eq = (Rewrite_Set equival_trans False) eq;" ^
|
wneuper@59302
|
327 |
TODO.WN120106 ANALOGOUSLY TO Substitute':
|
wneuper@59302
|
328 |
So tac_ contains the term t the result was calculated from
|
wneuper@59302
|
329 |
in order to compare t with t' possibly changed by "Expr "
|
wneuper@59302
|
330 |
and re-calculate result if t<>t'
|
wneuper@59302
|
331 |
TODO.WN161219: replace *every* cterm' by term
|
wneuper@59302
|
332 |
*)
|
wneuper@59571
|
333 |
datatype T =
|
wneuper@59416
|
334 |
Add_Find' of Rule.cterm' * Model.itm list | Add_Given' of Rule.cterm' * Model.itm list
|
wneuper@59416
|
335 |
| Add_Relation' of Rule.cterm' * Model.itm list
|
wneuper@59302
|
336 |
| Apply_Assumption' of term list * term
|
wneuper@59572
|
337 |
| Apply_Method' of Celem.metID * term option * Istate.T * Proof.context
|
wneuper@59302
|
338 |
(*/--- TODO: re-design ? -----------------------------------------------------------------\*)
|
wneuper@59302
|
339 |
| Begin_Sequ' | Begin_Trans' of term
|
wneuper@59302
|
340 |
| Split_And' of term | Split_Or' of term | Split_Intersect' of term
|
wneuper@59302
|
341 |
| Conclude_And' of term | Conclude_Or' of term | Collect_Trues' of term
|
wneuper@59302
|
342 |
| End_Sequ' | End_Trans' of Selem.result
|
wneuper@59302
|
343 |
| End_Ruleset' of term | End_Subproblem' of term | End_Intersect' of term | End_Proof''
|
wneuper@59302
|
344 |
(*\--- TODO: re-design ? -----------------------------------------------------------------/*)
|
wneuper@59302
|
345 |
| CAScmd' of term
|
wneuper@59416
|
346 |
| Calculate' of Rule.theory' * string * term * (term * Celem.thm')
|
wneuper@59405
|
347 |
| Check_Postcond' of Celem.pblID *
|
wneuper@59302
|
348 |
Selem.result (* returnvalue of script in solve *)
|
wneuper@59302
|
349 |
| Check_elementwise' of (*special case:*)
|
wneuper@59302
|
350 |
term * (* (1) the current formula: [x=1,x=...] *)
|
wneuper@59302
|
351 |
string * (* (2) the pred from Check_elementwise *)
|
wneuper@59302
|
352 |
Selem.result (* (3) composed from (1) and (2): {x. pred} *)
|
wneuper@59416
|
353 |
| Del_Find' of Rule.cterm' | Del_Given' of Rule.cterm' | Del_Relation' of Rule.cterm'
|
wneuper@59302
|
354 |
|
wneuper@59416
|
355 |
| Derive' of Rule.rls
|
wneuper@59416
|
356 |
| Detail_Set' of Rule.theory' * bool * Rule.rls * term * Selem.result
|
wneuper@59416
|
357 |
| Detail_Set_Inst' of Rule.theory' * bool * Rule.subst * Rule.rls * term * Selem.result
|
wneuper@59302
|
358 |
| End_Detail' of Selem.result
|
wneuper@59302
|
359 |
|
wneuper@59302
|
360 |
| Empty_Tac_
|
wneuper@59302
|
361 |
| Free_Solve'
|
wneuper@59302
|
362 |
|
wneuper@59416
|
363 |
| Init_Proof' of Rule.cterm' list * Celem.spec
|
wneuper@59405
|
364 |
| Model_Problem' of Celem.pblID *
|
wneuper@59316
|
365 |
Model.itm list * (* the 'untouched' pbl *)
|
wneuper@59316
|
366 |
Model.itm list (* the casually completed met *)
|
wneuper@59302
|
367 |
| Or_to_List' of term * term
|
wneuper@59405
|
368 |
| Refine_Problem' of Celem.pblID * (Model.itm list * (bool * term) list)
|
wneuper@59302
|
369 |
| Refine_Tacitly' of
|
wneuper@59405
|
370 |
Celem.pblID * (* input*)
|
wneuper@59405
|
371 |
Celem.pblID * (* the refined from applicable_in *)
|
wneuper@59416
|
372 |
Rule.domID * (* from new pbt?! filled in specify *)
|
wneuper@59405
|
373 |
Celem.metID * (* from new pbt?! filled in specify *)
|
wneuper@59316
|
374 |
Model.itm list (* drop ! 9.03: remains [] for Model_Problem recognizing its activation *)
|
wneuper@59416
|
375 |
| Rewrite' of Rule.theory' * Rule.rew_ord' * Rule.rls * bool * Celem.thm'' * term * Selem.result
|
wneuper@59416
|
376 |
| Rewrite_Asm' of Rule.theory' * Rule.rew_ord' * Rule.rls * bool * Celem.thm'' * term * Selem.result
|
wneuper@59416
|
377 |
| Rewrite_Inst' of Rule.theory' * Rule.rew_ord' * Rule.rls * bool * Rule.subst * Celem.thm'' * term * Selem.result
|
wneuper@59416
|
378 |
| Rewrite_Set' of Rule.theory' * bool * Rule.rls * term * Selem.result
|
wneuper@59416
|
379 |
| Rewrite_Set_Inst' of Rule.theory' * bool * Rule.subst * Rule.rls * term * Selem.result
|
wneuper@59302
|
380 |
|
wneuper@59405
|
381 |
| Specify_Method' of Celem.metID * Model.ori list * Model.itm list
|
wneuper@59405
|
382 |
| Specify_Problem' of Celem.pblID *
|
wneuper@59578
|
383 |
(bool * (* matches *)
|
wneuper@59578
|
384 |
(Model.itm list * (* ppc *)
|
wneuper@59578
|
385 |
(bool * term) list)) (* preconditions *)
|
wneuper@59416
|
386 |
| Specify_Theory' of Rule.domID
|
wneuper@59302
|
387 |
| Subproblem' of
|
wneuper@59405
|
388 |
Celem.spec *
|
wneuper@59578
|
389 |
(Model.ori list) * (* filled in associate Subproblem' *)
|
wneuper@59578
|
390 |
term * (* filled -"-, headline of calc-head *)
|
wneuper@59533
|
391 |
Selem.fmz_ *
|
wneuper@59578
|
392 |
Proof.context * (* DEPRECATED shifted into loc for all ppobj *)
|
wneuper@59578
|
393 |
term (* Subproblem (thyID, pbl) OR cascmd *)
|
wneuper@59533
|
394 |
| Substitute' of
|
wneuper@59578
|
395 |
Rule.rew_ord_ * (* for re-calculation *)
|
wneuper@59578
|
396 |
Rule.rls * (* for re-calculation *)
|
wneuper@59578
|
397 |
Selem.subte * (* the 'substitution': terms of type bool *)
|
wneuper@59578
|
398 |
term * (* to be substituted into *)
|
wneuper@59578
|
399 |
term (* resulting from the substitution *)
|
wneuper@59302
|
400 |
| Tac_ of theory * string * string * string
|
wneuper@59302
|
401 |
| Take' of term | Take_Inst' of term
|
wneuper@59302
|
402 |
|
walther@59728
|
403 |
fun string_of ma = case ma of
|
wneuper@59405
|
404 |
Init_Proof' (ppc, spec) => "Init_Proof' " ^ pair2str (strs2str ppc, Celem.spec2str spec)
|
wneuper@59302
|
405 |
| Model_Problem' (pblID, _, _) => "Model_Problem' " ^ strs2str pblID
|
wneuper@59302
|
406 |
| Refine_Tacitly'(p, prefin, domID, metID, _) => "Refine_Tacitly' (" ^ strs2str p ^ ", " ^
|
wneuper@59302
|
407 |
strs2str prefin ^ ", " ^ domID ^ ", " ^ strs2str metID ^ ", pbl-itms)"
|
wneuper@59302
|
408 |
| Refine_Problem' _ => "Refine_Problem' (" ^ (*matchs2str ms*)"..." ^ ")"
|
wneuper@59302
|
409 |
| Add_Given' _ => "Add_Given' "(*^cterm'*)
|
wneuper@59302
|
410 |
| Del_Given' _ => "Del_Given' "(*^cterm'*)
|
wneuper@59302
|
411 |
| Add_Find' _ => "Add_Find' "(*^cterm'*)
|
wneuper@59302
|
412 |
| Del_Find' _ => "Del_Find' "(*^cterm'*)
|
wneuper@59302
|
413 |
| Add_Relation' _ => "Add_Relation' "(*^cterm'*)
|
wneuper@59302
|
414 |
| Del_Relation' _ => "Del_Relation' "(*^cterm'*)
|
wneuper@59302
|
415 |
|
wneuper@59302
|
416 |
| Specify_Theory' domID => "Specify_Theory' " ^ quote domID
|
wneuper@59302
|
417 |
| Specify_Problem' (pI, (ok, _)) => "Specify_Problem' " ^
|
wneuper@59302
|
418 |
spair2str (strs2str pI, spair2str (bool2str ok, spair2str ("itms2str_ itms", "items2str pre")))
|
wneuper@59302
|
419 |
| Specify_Method' (pI, oris, _) => "Specify_Method' (" ^
|
wneuper@59405
|
420 |
Celem.metID2str pI ^ ", " ^ Model.oris2str oris ^ ", )"
|
wneuper@59302
|
421 |
|
wneuper@59302
|
422 |
| Apply_Method' (metID, _, _, _) => "Apply_Method' " ^ strs2str metID
|
wneuper@59302
|
423 |
| Check_Postcond' (pblID, (scval, asm)) => "Check_Postcond' " ^
|
wneuper@59416
|
424 |
(spair2str (strs2str pblID, spair2str (Rule.term2str scval, Rule.terms2str asm)))
|
wneuper@59302
|
425 |
|
wneuper@59302
|
426 |
| Free_Solve' => "Free_Solve'"
|
wneuper@59302
|
427 |
|
wneuper@59302
|
428 |
| Rewrite_Inst' (*subs,thm'*) _ => "Rewrite_Inst' "(*^(pair2str (subs2str subs, spair2str thm'))*)
|
wneuper@59302
|
429 |
| Rewrite' _(*thm'*) => "Rewrite' "(*^(spair2str thm')*)
|
wneuper@59302
|
430 |
| Rewrite_Asm' _(*thm'*) => "Rewrite_Asm' "(*^(spair2str thm')*)
|
wneuper@59302
|
431 |
| Rewrite_Set_Inst' _(*subs,thm'*) => "Rewrite_Set_Inst' "(*^(pair2str (subs2str subs, quote rls))*)
|
wneuper@59302
|
432 |
| Rewrite_Set' (thy', pasm, rls', f, (f', asm)) => "Rewrite_Set' (" ^ thy' ^ "," ^ bool2str pasm ^
|
wneuper@59416
|
433 |
"," ^ Rule.id_rls rls' ^ "," ^ Rule.term2str f ^ ",(" ^ Rule.term2str f' ^ "," ^ Rule.terms2str asm ^ "))"
|
wneuper@59302
|
434 |
| End_Detail' _ => "End_Detail' xxx"
|
wneuper@59302
|
435 |
| Detail_Set' _ => "Detail_Set' xxx"
|
wneuper@59302
|
436 |
| Detail_Set_Inst' _ => "Detail_Set_Inst' xxx"
|
wneuper@59302
|
437 |
|
wneuper@59416
|
438 |
| Derive' rls => "Derive' " ^ Rule.id_rls rls
|
wneuper@59302
|
439 |
| Calculate' _ => "Calculate' "
|
wneuper@59302
|
440 |
| Substitute' _ => "Substitute' "(*^(subs2str subs)*)
|
wneuper@59302
|
441 |
| Apply_Assumption' _(* ct's*) => "Apply_Assumption' "(*^(strs2str ct's)*)
|
wneuper@59302
|
442 |
|
wneuper@59302
|
443 |
| Take' _(*cterm'*) => "Take' "(*^(quote cterm' )*)
|
wneuper@59302
|
444 |
| Take_Inst' _(*cterm'*) => "Take_Inst' "(*^(quote cterm' )*)
|
wneuper@59302
|
445 |
| Subproblem' _(*(spec, oris, _, _, _, pbl_form)*) =>
|
wneuper@59302
|
446 |
"Subproblem' "(*^(pair2str (domID, strs2str ,))*)
|
wneuper@59302
|
447 |
| End_Subproblem' _ => "End_Subproblem'"
|
wneuper@59302
|
448 |
| CAScmd' _(*cterm'*) => "CAScmd' "(*^(quote cterm')*)
|
wneuper@59302
|
449 |
|
wneuper@59302
|
450 |
| Empty_Tac_ => "Empty_Tac_"
|
wneuper@59302
|
451 |
| Tac_ (_, form, id, result) => "Tac_ (thy," ^ form ^ "," ^ id ^ "," ^ result ^ ")"
|
walther@59728
|
452 |
| _ => "string_of not impl. for arg";
|
wneuper@59302
|
453 |
|
walther@59704
|
454 |
fun input_from_T (Refine_Tacitly' (pI, _, _, _, _)) = Refine_Tacitly pI
|
walther@59704
|
455 |
| input_from_T (Model_Problem' (_, _, _)) = Model_Problem
|
walther@59704
|
456 |
| input_from_T (Add_Given' (t, _)) = Add_Given t
|
walther@59704
|
457 |
| input_from_T (Add_Find' (t, _)) = Add_Find t
|
walther@59704
|
458 |
| input_from_T (Add_Relation' (t, _)) = Add_Relation t
|
walther@59704
|
459 |
|
walther@59704
|
460 |
| input_from_T (Specify_Theory' dI) = Specify_Theory dI
|
walther@59704
|
461 |
| input_from_T (Specify_Problem' (dI, _)) = Specify_Problem dI
|
walther@59704
|
462 |
| input_from_T (Specify_Method' (dI, _, _)) = Specify_Method dI
|
walther@59704
|
463 |
|
walther@59704
|
464 |
| input_from_T (Rewrite' (_, _, _, _, thm, _, _)) = Rewrite thm
|
walther@59704
|
465 |
| input_from_T (Rewrite_Inst' (_, _, _, _, sub, thm, _, _)) = Rewrite_Inst (Selem.subst2subs sub, thm)
|
walther@59704
|
466 |
|
walther@59704
|
467 |
| input_from_T (Rewrite_Set' (_, _, rls, _, _)) = Rewrite_Set (Rule.id_rls rls)
|
walther@59704
|
468 |
| input_from_T (Detail_Set' (_, _, rls, _, _)) = Detail_Set (Rule.id_rls rls)
|
walther@59704
|
469 |
|
walther@59704
|
470 |
| input_from_T (Rewrite_Set_Inst' (_, _, sub, rls, _, _)) =
|
walther@59704
|
471 |
Rewrite_Set_Inst (Selem.subst2subs sub, Rule.id_rls rls)
|
walther@59704
|
472 |
| input_from_T (Detail_Set_Inst' (_, _, sub, rls, _, _)) =
|
walther@59704
|
473 |
Detail_Set_Inst (Selem.subst2subs sub, Rule.id_rls rls)
|
walther@59704
|
474 |
|
walther@59704
|
475 |
| input_from_T (Calculate' (_, op_, _, _)) = Calculate (op_)
|
walther@59704
|
476 |
| input_from_T (Check_elementwise' (_, pred, _)) = Check_elementwise pred
|
walther@59704
|
477 |
|
walther@59704
|
478 |
| input_from_T (Or_to_List' _) = Or_to_List
|
walther@59704
|
479 |
| input_from_T (Take' term) = Take (Rule.term2str term)
|
walther@59704
|
480 |
| input_from_T (Substitute' (_, _, subte, _, _)) = Substitute (Selem.subte2sube subte)
|
walther@59704
|
481 |
| input_from_T (Tac_ (_, _, id, _)) = Tac id
|
walther@59704
|
482 |
|
walther@59704
|
483 |
| input_from_T (Subproblem' ((domID, pblID, _), _, _, _,_ ,_)) = Subproblem (domID, pblID)
|
walther@59704
|
484 |
| input_from_T (Check_Postcond' (pblID, _)) = Check_Postcond pblID
|
walther@59704
|
485 |
| input_from_T Empty_Tac_ = Empty_Tac
|
walther@59728
|
486 |
| input_from_T m = error (": not impl. for "^(string_of m));
|
walther@59704
|
487 |
|
walther@59728
|
488 |
fun res (Rewrite_Inst' (_ , _, _, _, _, _, _, res)) = res
|
walther@59728
|
489 |
| res (Rewrite' (_, _, _, _, _, _, res)) = res
|
walther@59728
|
490 |
| res (Rewrite_Set_Inst' (_, _, _, _, _, res)) = res
|
walther@59728
|
491 |
| res (Rewrite_Set' (_, _, _, _, res)) = res
|
walther@59728
|
492 |
| res (Calculate' (_, _, _, (t, _))) = (t, [])
|
walther@59728
|
493 |
| res (Check_elementwise' (_, _, res)) = res
|
walther@59728
|
494 |
| res (Subproblem' (_, _, _, _, _, t)) = (t, [])
|
walther@59728
|
495 |
| res (Take' t) = (t, [])
|
walther@59728
|
496 |
| res (Substitute' (_, _, _, _, t)) = (t, [])
|
walther@59728
|
497 |
| res (Or_to_List' (_, t)) = (t, [])
|
walther@59728
|
498 |
| res m = raise ERROR ("result: not impl.for " ^ string_of m)
|
walther@59728
|
499 |
|
walther@59728
|
500 |
(*fun result m = (fst o res) m; TODO*)
|
walther@59728
|
501 |
fun result tac = (fst o res) tac;
|
walther@59728
|
502 |
fun creates_assms tac = (snd o res) tac;
|
walther@59728
|
503 |
|
walther@59728
|
504 |
fun insert_assumptions tac ctxt = ContextC.insert_assumptions (creates_assms tac) ctxt
|
walther@59728
|
505 |
|
walther@59728
|
506 |
(**)end(**)
|