walther@59848
|
1 |
(*
|
neuper@37906
|
2 |
authors: Walther Neuper 2002, 2006
|
neuper@37906
|
3 |
(c) due to copyright terms
|
walther@59848
|
4 |
|
walther@59848
|
5 |
tools for rewriting, reverse rewriting, context to thy concerning rewriting
|
neuper@37906
|
6 |
*)
|
neuper@37906
|
7 |
|
walther@59917
|
8 |
signature THEORY_DATA_PRESENTATION =
|
wneuper@59263
|
9 |
sig
|
walther@59906
|
10 |
|
walther@59918
|
11 |
eqtype filename
|
walther@59918
|
12 |
|
wneuper@59263
|
13 |
datatype contthy
|
walther@59906
|
14 |
= ContNOrew of {applto: term, thm_rls: Check_Unique.id, thyID: ThyC.id}
|
walther@59910
|
15 |
| ContNOrewInst of {applto: term, bdvs: subst, thm_rls: Check_Unique.id, thminst: term, thyID: ThyC.id}
|
walther@59906
|
16 |
| ContRls of {applto: term, asms: term list, result: term, rls: Check_Unique.id, thyID: ThyC.id}
|
walther@59910
|
17 |
| ContRlsInst of {applto: term, asms: term list, bdvs: subst, result: term, rls: Check_Unique.id, thyID: ThyC.id}
|
walther@59906
|
18 |
| ContThm of {applat: term, applto: term, asmrls: Rule_Set.id, asms: (term * term) list,
|
walther@59906
|
19 |
lhs: term * term, resasms: term list, result: term, reword: Rewrite_Ord.rew_ord', rhs: term * term,
|
walther@59906
|
20 |
thm: Check_Unique.id, thyID: ThyC.id}
|
walther@59906
|
21 |
| ContThmInst of {applat: term, applto: term, asmrls: Rule_Set.id, asms: (term * term) list,
|
walther@59910
|
22 |
bdvs: subst, lhs: term * term, resasms: term list, result: term, reword: Rewrite_Ord.rew_ord',
|
walther@59906
|
23 |
rhs: term * term, thm: Check_Unique.id, thminst: term, thyID: ThyC.id}
|
walther@59906
|
24 |
| EContThy
|
walther@59918
|
25 |
val guh2filename : Check_Unique.id -> filename
|
walther@59851
|
26 |
val thms_of_rls : Rule_Set.T -> Rule.rule list
|
walther@59918
|
27 |
val theID2filename : Thy_Write.theID -> filename
|
walther@59904
|
28 |
val no_thycontext : Check_Unique.id -> bool
|
walther@59911
|
29 |
val subs_from : Istate.T -> 'a -> Check_Unique.id -> Subst.input
|
walther@59911
|
30 |
val guh2rewtac : Check_Unique.id -> Subst.input -> Tactic.input
|
walther@59846
|
31 |
val get_tac_checked : Ctree.ctree -> Pos.pos' -> Tactic.input
|
walther@59775
|
32 |
val context_thy : Calc.T -> Tactic.input -> contthy
|
walther@59917
|
33 |
val guh2theID : Check_Unique.id -> Thy_Write.theID
|
walther@59906
|
34 |
|
wneuper@59310
|
35 |
(* ---- for tests only: shifted from below to remove the Warning "unused" at fun.def. --------- *)
|
wneuper@59310
|
36 |
(* NONE *)
|
walther@59886
|
37 |
(*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
|
walther@59906
|
38 |
(* NONE *)
|
walther@59886
|
39 |
( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
|
wneuper@59263
|
40 |
end
|
walther@59848
|
41 |
(**)
|
walther@59917
|
42 |
structure Thy_Present(**): THEORY_DATA_PRESENTATION(**) =
|
wneuper@59263
|
43 |
struct
|
walther@59848
|
44 |
(**)
|
wneuper@59313
|
45 |
|
walther@59918
|
46 |
type filename = string;
|
walther@59918
|
47 |
|
wneuper@59263
|
48 |
(* packing return-values to matchTheory, contextToThy for xml-generation *)
|
walther@59887
|
49 |
datatype contthy = (*also an item from Know_Store on Browser ...........#*)
|
walther@59887
|
50 |
EContThy (* not from Know_Store ..............................*)
|
wneuper@59263
|
51 |
| ContThm of (* a theorem in contex ===========================*)
|
walther@59879
|
52 |
{thyID : ThyC.id, (* for *2guh in sub-elems here .*)
|
walther@59904
|
53 |
thm : Check_Unique.id, (* theorem in the context .*)
|
wneuper@59405
|
54 |
applto : term, (* applied to formula ... .*)
|
wneuper@59405
|
55 |
applat : term, (* ... with lhs inserted .*)
|
walther@59857
|
56 |
reword : Rewrite_Ord.rew_ord', (* order used for rewrite .*)
|
wneuper@59405
|
57 |
asms : (term (* asumption instantiated .*)
|
wneuper@59405
|
58 |
* term) list, (* asumption evaluated .*)
|
wneuper@59405
|
59 |
lhs : term (* lhs of the theorem ... #*)
|
wneuper@59405
|
60 |
* term, (* ... instantiated .*)
|
wneuper@59405
|
61 |
rhs : term (* rhs of the theorem ... #*)
|
wneuper@59405
|
62 |
* term, (* ... instantiated .*)
|
wneuper@59405
|
63 |
result : term, (* resulting from the rewrite .*)
|
wneuper@59405
|
64 |
resasms : term list, (* ... with asms stored .*)
|
walther@59867
|
65 |
asmrls : Rule_Set.id (* ruleset for evaluating asms .*)
|
wneuper@59263
|
66 |
}
|
wneuper@59263
|
67 |
| ContThmInst of (* a theorem with bdvs in contex ============ *)
|
walther@59879
|
68 |
{thyID : ThyC.id, (*for *2guh in sub-elems here .*)
|
walther@59904
|
69 |
thm : Check_Unique.id, (*theorem in the context .*)
|
walther@59910
|
70 |
bdvs : subst, (*bound variables to modify... .*)
|
wneuper@59405
|
71 |
thminst : term, (*... theorem instantiated .*)
|
wneuper@59405
|
72 |
applto : term, (*applied to formula ... .*)
|
wneuper@59405
|
73 |
applat : term, (*... with lhs inserted .*)
|
walther@59857
|
74 |
reword : Rewrite_Ord.rew_ord', (*order used for rewrite .*)
|
wneuper@59405
|
75 |
asms : (term (*asumption instantiated .*)
|
wneuper@59405
|
76 |
* term) list, (*asumption evaluated .*)
|
wneuper@59405
|
77 |
lhs : term (*lhs of the theorem ... #*)
|
wneuper@59405
|
78 |
* term, (*... instantiated .*)
|
wneuper@59405
|
79 |
rhs : term (*rhs of the theorem ... #*)
|
wneuper@59405
|
80 |
* term, (*... instantiated .*)
|
wneuper@59405
|
81 |
result : term, (*resulting from the rewrite .*)
|
wneuper@59405
|
82 |
resasms : term list, (*... with asms stored .*)
|
walther@59867
|
83 |
asmrls : Rule_Set.id (*ruleset for evaluating asms .*)
|
wneuper@59263
|
84 |
}
|
wneuper@59263
|
85 |
| ContRls of (* a rule set in contex ========================= *)
|
walther@59879
|
86 |
{thyID : ThyC.id, (*for *2guh in sub-elems here .*)
|
walther@59904
|
87 |
rls : Check_Unique.id, (*rule set in the context .*)
|
wneuper@59405
|
88 |
applto : term, (*rewrite this formula .*)
|
wneuper@59405
|
89 |
result : term, (*resulting from the rewrite .*)
|
wneuper@59405
|
90 |
asms : term list (*... with asms stored .*)
|
wneuper@59263
|
91 |
}
|
wneuper@59263
|
92 |
| ContRlsInst of (* a rule set with bdvs in contex =========== *)
|
walther@59879
|
93 |
{thyID : ThyC.id, (*for *2guh in sub-elems here .*)
|
walther@59904
|
94 |
rls : Check_Unique.id, (*rule set in the context .*)
|
walther@59910
|
95 |
bdvs : subst, (*for bound variables in thms .*)
|
wneuper@59405
|
96 |
applto : term, (*rewrite this formula .*)
|
wneuper@59405
|
97 |
result : term, (*resulting from the rewrite .*)
|
wneuper@59405
|
98 |
asms : term list (*... with asms stored .*)
|
wneuper@59263
|
99 |
}
|
wneuper@59263
|
100 |
| ContNOrew of (* no rewrite for thm or rls ================== *)
|
walther@59879
|
101 |
{thyID : ThyC.id, (*for *2guh in sub-elems here .*)
|
walther@59904
|
102 |
thm_rls : Check_Unique.id, (*thm or rls in the context .*)
|
wneuper@59405
|
103 |
applto : term (*rewrite this formula .*)
|
wneuper@59263
|
104 |
}
|
wneuper@59263
|
105 |
| ContNOrewInst of (* no rewrite for some instantiation ====== *)
|
walther@59879
|
106 |
{thyID : ThyC.id, (*for *2guh in sub-elems here .*)
|
walther@59904
|
107 |
thm_rls : Check_Unique.id, (*thm or rls in the context .*)
|
walther@59910
|
108 |
bdvs : subst, (*for bound variables in thms .*)
|
wneuper@59405
|
109 |
thminst : term, (*... theorem instantiated .*)
|
walther@59850
|
110 |
applto : term (*rewrite this formula .*)
|
wneuper@59263
|
111 |
}
|
neuper@37906
|
112 |
|
neuper@37906
|
113 |
(*.check a rewrite-tac for bdv (RL always used *_Inst !) TODO.WN060718
|
neuper@37906
|
114 |
pass other tacs unchanged.*)
|
walther@59846
|
115 |
fun get_tac_checked pt ((p, _) : Pos.pos') = Ctree.get_obj Ctree.g_tac pt p;
|
neuper@37906
|
116 |
|
wneuper@59252
|
117 |
(* get the formula f at ptp rewritten by the Rewrite_* already applied to f *)
|
walther@59914
|
118 |
fun context_thy (pt, pos as (p, p_)) (tac as Tactic.Rewrite thm'') =
|
walther@59914
|
119 |
let
|
walther@59914
|
120 |
val thm_deriv = ThmC.long_id thm''
|
wneuper@59263
|
121 |
in
|
walther@59921
|
122 |
(case Step.check tac (pt, pos) of
|
walther@59920
|
123 |
Applicable.Yes (Tactic.Rewrite' (thy', ord', erls, _, _, f, (res, asm))) =>
|
wneuper@59263
|
124 |
ContThm
|
walther@59880
|
125 |
{thyID = thy',
|
walther@59917
|
126 |
thm = Thy_Write.thm2guh (Thy_Read.thy_containing_thm thm_deriv) (ThmC.cut_id thm_deriv),
|
walther@59861
|
127 |
applto = f, applat = TermC.empty, reword = ord',
|
walther@59861
|
128 |
asms = [](*asms ~~ asms'*), lhs = (TermC.empty, TermC.empty)(*(lhs, lhs')*), rhs = (TermC.empty, TermC.empty)(*(rhs, rhs')*),
|
walther@59867
|
129 |
result = res, resasms = asm, asmrls = Rule_Set.id erls}
|
walther@59920
|
130 |
| Applicable.No _ =>
|
wneuper@59263
|
131 |
let
|
wneuper@59276
|
132 |
val pp = Ctree.par_pblobj pt p
|
wneuper@59276
|
133 |
val thy' = Ctree.get_obj Ctree.g_domID pt pp
|
wneuper@59263
|
134 |
val f = case p_ of
|
walther@59694
|
135 |
Pos.Frm => Ctree.get_obj Ctree.g_form pt p
|
walther@59694
|
136 |
| Pos.Res => (fst o (Ctree.get_obj Ctree.g_result pt)) p
|
wneuper@59313
|
137 |
| _ => error "context_thy: uncovered position"
|
wneuper@59263
|
138 |
in
|
wneuper@59263
|
139 |
ContNOrew
|
walther@59880
|
140 |
{thyID = thy',
|
wneuper@59263
|
141 |
thm_rls =
|
walther@59917
|
142 |
Thy_Write.thm2guh (Thy_Read.thy_containing_thm thm_deriv) (ThmC.cut_id thm_deriv),
|
wneuper@59263
|
143 |
applto = f}
|
wneuper@59263
|
144 |
end
|
wneuper@59263
|
145 |
| _ => error "context_thy..Rewrite: uncovered case 2")
|
wneuper@59263
|
146 |
end
|
wneuper@59571
|
147 |
| context_thy (pt, pos as (p, p_)) (tac as Tactic.Rewrite_Inst (subs, (thmID, _))) =
|
walther@59854
|
148 |
let val thm = Global_Theory.get_thm (ThyC.Isac ()) thmID
|
wneuper@59263
|
149 |
in
|
walther@59921
|
150 |
(case Step.check tac (pt, pos) of
|
walther@59920
|
151 |
Applicable.Yes (Tactic.Rewrite_Inst' (thy', ord', erls, _, subst, _, f, (res, asm))) =>
|
wneuper@59263
|
152 |
let
|
wneuper@59263
|
153 |
val thm_deriv = Thm.get_name_hint thm
|
walther@59878
|
154 |
val thminst = TermC.inst_bdv subst ((Eval.norm o #prop o Thm.rep_thm) thm)
|
wneuper@59263
|
155 |
in
|
wneuper@59263
|
156 |
ContThmInst
|
walther@59880
|
157 |
{thyID = thy',
|
wneuper@59263
|
158 |
thm =
|
walther@59917
|
159 |
Thy_Write.thm2guh (Thy_Read.thy_containing_thm thm_deriv) (ThmC.cut_id thm_deriv),
|
walther@59861
|
160 |
bdvs = subst, thminst = thminst, applto = f, applat = TermC.empty, reword = ord',
|
walther@59861
|
161 |
asms = [](*asms ~~ asms'*), lhs = (TermC.empty, TermC.empty)(*(lhs, lhs')*), rhs = (TermC.empty, TermC.empty)(*(rhs, rhs')*),
|
walther@59867
|
162 |
result = res, resasms = asm, asmrls = Rule_Set.id erls}
|
wneuper@59263
|
163 |
end
|
walther@59920
|
164 |
| Applicable.No _ =>
|
wneuper@59263
|
165 |
let
|
walther@59854
|
166 |
val thm = Global_Theory.get_thm (ThyC.Isac ()(*WN141021 assoc_thy thy' ERROR*)) thmID
|
wneuper@59263
|
167 |
val thm_deriv = Thm.get_name_hint thm
|
wneuper@59276
|
168 |
val pp = Ctree.par_pblobj pt p
|
wneuper@59276
|
169 |
val thy' = Ctree.get_obj Ctree.g_domID pt pp
|
walther@59911
|
170 |
val subst = Subst.T_from_input (ThyC.get_theory thy') subs
|
walther@59878
|
171 |
val thminst = TermC.inst_bdv subst ((Eval.norm o #prop o Thm.rep_thm) thm)
|
wneuper@59263
|
172 |
val f = case p_ of
|
walther@59694
|
173 |
Pos.Frm => Ctree.get_obj Ctree.g_form pt p
|
walther@59694
|
174 |
| Pos.Res => (fst o (Ctree.get_obj Ctree.g_result pt)) p
|
wneuper@59313
|
175 |
| _ => error "context_thy: uncovered case 3"
|
wneuper@59263
|
176 |
in
|
wneuper@59263
|
177 |
ContNOrewInst
|
walther@59880
|
178 |
{thyID = thy',
|
walther@59917
|
179 |
thm_rls = Thy_Write.thm2guh (Thy_Read.thy_containing_thm thm_deriv) (ThmC.cut_id thm_deriv),
|
wneuper@59263
|
180 |
bdvs = subst, thminst = thminst, applto = f}
|
wneuper@59263
|
181 |
end
|
wneuper@59263
|
182 |
| _ => error "context_thy..Rewrite_Inst: uncovered case 4")
|
wneuper@59263
|
183 |
end
|
wneuper@59571
|
184 |
| context_thy (pt, p) (tac as Tactic.Rewrite_Set rls') =
|
walther@59921
|
185 |
(case Step.check tac (pt, p) of
|
walther@59920
|
186 |
Applicable.Yes (Tactic.Rewrite_Set' (thy', _, _(*rls*), f, (res,asm))) =>
|
wneuper@59263
|
187 |
ContRls
|
walther@59880
|
188 |
{thyID = thy',
|
walther@59917
|
189 |
rls = Thy_Write.rls2guh (Thy_Read.thy_containing_rls thy' rls') rls',
|
wneuper@59263
|
190 |
applto = f, result = res, asms = asm}
|
walther@59920
|
191 |
| _ => error ("context_thy Rewrite_Set: not for Applicable.No"))
|
wneuper@59571
|
192 |
| context_thy (pt,p) (tac as Tactic.Rewrite_Set_Inst (_(*subs*), rls')) =
|
walther@59921
|
193 |
(case Step.check tac (pt, p) of
|
walther@59920
|
194 |
Applicable.Yes (Tactic.Rewrite_Set_Inst' (thy', _, subst, _, f, (res,asm))) =>
|
wneuper@59263
|
195 |
ContRlsInst
|
walther@59880
|
196 |
{thyID = thy',
|
walther@59917
|
197 |
rls = Thy_Write.rls2guh (Thy_Read.thy_containing_rls thy' rls') rls',
|
wneuper@59263
|
198 |
bdvs = subst, applto = f, result = res, asms = asm}
|
walther@59920
|
199 |
| _ => error ("context_thy Rewrite_Set_Inst: not for Applicable.No"))
|
wneuper@59263
|
200 |
| context_thy (_, p) tac =
|
walther@59846
|
201 |
error ("context_thy: not for tac " ^ Tactic.input_to_string tac ^ " at " ^ Pos.pos'2str p)
|
neuper@37906
|
202 |
|
neuper@42372
|
203 |
(* get all theorems in a rule set (recursivley containing rule sets) *)
|
wneuper@59416
|
204 |
fun thm_of_rule Rule.Erule = []
|
wneuper@59416
|
205 |
| thm_of_rule (thm as Rule.Thm _) = [thm]
|
walther@59878
|
206 |
| thm_of_rule (Rule.Eval _) = []
|
wneuper@59416
|
207 |
| thm_of_rule (Rule.Cal1 _) = []
|
wneuper@59416
|
208 |
| thm_of_rule (Rule.Rls_ rls) = thms_of_rls rls
|
walther@59851
|
209 |
and thms_of_rls Rule_Set.Empty = []
|
walther@59851
|
210 |
| thms_of_rls (Rule_Def.Repeat {rules,...}) = (flat o (map thm_of_rule)) rules
|
walther@59878
|
211 |
| thms_of_rls (Rule_Set.Sequence {rules,...}) = (flat o (map thm_of_rule)) rules
|
walther@59850
|
212 |
| thms_of_rls (Rule_Set.Rrls _) = []
|
neuper@37906
|
213 |
|
neuper@37906
|
214 |
|
wneuper@59263
|
215 |
(* filenames not only for thydata, but also for thy's etc *)
|
walther@59917
|
216 |
fun theID2filename theID = Thy_Write.theID2guh theID ^ ".xml"
|
neuper@37906
|
217 |
|
wneuper@59405
|
218 |
fun guh2theID guh =
|
wneuper@59263
|
219 |
let
|
wneuper@59263
|
220 |
val guh' = Symbol.explode guh
|
wneuper@59263
|
221 |
val part = implode (take_fromto 1 4 guh')
|
wneuper@59263
|
222 |
val isa = implode (take_fromto 5 9 guh')
|
wneuper@59263
|
223 |
in
|
wneuper@59263
|
224 |
if not (member op = ["exp_", "thy_", "pbl_", "met_"] part)
|
wneuper@59263
|
225 |
then raise ERROR ("guh '" ^ guh ^ "' does not begin with exp_ | thy_ | pbl_ | met_")
|
wneuper@59263
|
226 |
else
|
wneuper@59263
|
227 |
let
|
wneuper@59263
|
228 |
val chap = case isa of
|
wneuper@59263
|
229 |
"isab_" => "Isabelle"
|
wneuper@59263
|
230 |
| "scri_" => "IsacScripts"
|
wneuper@59263
|
231 |
| "isac_" => "IsacKnowledge"
|
wneuper@59263
|
232 |
| _ =>
|
wneuper@59263
|
233 |
raise ERROR ("guh2theID: '" ^ guh ^ "' does not have isab_ | scri_ | isac_ at position 5..9")
|
wneuper@59263
|
234 |
val rest = takerest (9, guh')
|
wneuper@59263
|
235 |
val thyID = takewhile [] (not o (curry op= "-")) rest
|
wneuper@59263
|
236 |
val rest' = dropuntil (curry op = "-") rest
|
neuper@37906
|
237 |
in case implode rest' of
|
walther@59917
|
238 |
"-part" => [chap] : Thy_Write.theID
|
wneuper@59263
|
239 |
| "" => [chap, implode thyID]
|
wneuper@59263
|
240 |
| "-Theorems" => [chap, implode thyID, "Theorems"]
|
wneuper@59263
|
241 |
| "-Rulesets" => [chap, implode thyID, "Rulesets"]
|
wneuper@59263
|
242 |
| "-Operations" => [chap, implode thyID, "Operations"]
|
wneuper@59263
|
243 |
| "-Orders" => [chap, implode thyID, "Orders"]
|
wneuper@59263
|
244 |
| _ =>
|
wneuper@59263
|
245 |
let val sect = implode (take_fromto 1 5 rest')
|
wneuper@59263
|
246 |
val sect' = case sect of
|
neuper@37906
|
247 |
"-thm-" => "Theorems"
|
neuper@37906
|
248 |
| "-rls-" => "Rulesets"
|
neuper@37906
|
249 |
| "-cal-" => "Operations"
|
neuper@37906
|
250 |
| "-ord-" => "Orders"
|
wneuper@59263
|
251 |
| _ =>
|
wneuper@59263
|
252 |
raise ERROR ("guh2theID: '" ^ guh ^ "' has '" ^ sect ^ "' instead -thm- | -rls- | -cal- | -ord-")
|
wneuper@59263
|
253 |
in
|
wneuper@59263
|
254 |
[chap, implode thyID, sect', implode (takerest (5, rest'))]
|
wneuper@59263
|
255 |
end
|
neuper@37906
|
256 |
end
|
wneuper@59263
|
257 |
end
|
neuper@37906
|
258 |
|
wneuper@59405
|
259 |
fun guh2filename guh = guh ^ ".xml";
|
neuper@37906
|
260 |
|
wneuper@59301
|
261 |
fun guh2rewtac guh [] =
|
wneuper@59263
|
262 |
let
|
wneuper@59263
|
263 |
val (_, thy, sect, xstr) = case guh2theID guh of
|
wneuper@59263
|
264 |
[isa, thy, sect, xstr] => (isa, thy, sect, xstr)
|
wneuper@59263
|
265 |
| _ => error "guh2rewtac: uncovered case"
|
wneuper@59263
|
266 |
in case sect of
|
walther@59881
|
267 |
"Theorems" => Tactic.Rewrite (xstr, ThmC.thm_from_thy (ThyC.get_theory thy) xstr)
|
wneuper@59571
|
268 |
| "Rulesets" => Tactic.Rewrite_Set xstr
|
wneuper@59263
|
269 |
| _ => error ("guh2rewtac: not impl. for '"^xstr^"'")
|
wneuper@59263
|
270 |
end
|
wneuper@59263
|
271 |
| guh2rewtac guh subs =
|
wneuper@59263
|
272 |
let
|
wneuper@59263
|
273 |
val (_, thy, sect, xstr) = case guh2theID guh of
|
wneuper@59263
|
274 |
[isa, thy, sect, xstr] => (isa, thy, sect, xstr)
|
wneuper@59263
|
275 |
| _ => error "guh2rewtac: uncovered case"
|
wneuper@59263
|
276 |
in case sect of
|
wneuper@59263
|
277 |
"Theorems" =>
|
walther@59881
|
278 |
Tactic.Rewrite_Inst (subs, (xstr, ThmC.thm_from_thy (ThyC.get_theory thy) xstr))
|
wneuper@59571
|
279 |
| "Rulesets" => Tactic.Rewrite_Set_Inst (subs, xstr)
|
wneuper@59263
|
280 |
| str => error ("guh2rewtac: not impl. for '" ^ str ^ "'")
|
wneuper@59263
|
281 |
end
|
neuper@37906
|
282 |
|
wneuper@59263
|
283 |
(* the front-end may request a context for any element of the hierarchy *)
|
wneuper@59405
|
284 |
fun no_thycontext guh = (guh2theID guh; false)
|
wneuper@59263
|
285 |
handle ERROR _ => true;
|
neuper@37906
|
286 |
|
wneuper@59263
|
287 |
(* get the substitution of bound variables for matchTheory:
|
neuper@37906
|
288 |
# lookup the thm|rls' in the script
|
neuper@37906
|
289 |
# take the [(bdv, v_),..] from the respective Rewrite_(Set_)Inst
|
neuper@37906
|
290 |
# instantiate this subs with the istates env to [(bdv, x),..]
|
wneuper@59263
|
291 |
# otherwise []
|
wneuper@59263
|
292 |
WN060617 hack assuming that all scripts use only one bound variable
|
wneuper@59263
|
293 |
and use 'v_' as the formal argument for this bound variable*)
|
walther@59906
|
294 |
fun subs_from (Istate.Pstate ({env, ...})) _ guh =
|
wneuper@59263
|
295 |
let
|
wneuper@59263
|
296 |
val (_, _, thyID, sect, xstr) = case guh2theID guh of
|
wneuper@59263
|
297 |
theID as [isa, thyID, sect, xstr] => (theID, isa, thyID, sect, xstr)
|
wneuper@59263
|
298 |
| _ => error "subs_from: uncovered case"
|
wneuper@59263
|
299 |
in
|
wneuper@59263
|
300 |
case sect of
|
wneuper@59263
|
301 |
"Theorems" =>
|
walther@59881
|
302 |
let val thm = Global_Theory.get_thm (ThyC.get_theory thyID) xstr
|
wneuper@59263
|
303 |
in
|
walther@59618
|
304 |
if Auto_Prog.contains_bdv thm
|
wneuper@59263
|
305 |
then
|
wneuper@59263
|
306 |
let
|
walther@59676
|
307 |
val formal_arg = TermC.str2term "v_"
|
walther@59685
|
308 |
val value = subst_atomic env formal_arg
|
walther@59911
|
309 |
in ["(''bdv''," ^ UnparseC.term value ^ ")"] : Subst.input end
|
wneuper@59263
|
310 |
else []
|
wneuper@59263
|
311 |
end
|
wneuper@59263
|
312 |
| "Rulesets" =>
|
wneuper@59263
|
313 |
let
|
walther@59850
|
314 |
val rules = (Rule_Set.get_rules o assoc_rls) xstr
|
wneuper@59263
|
315 |
in
|
walther@59618
|
316 |
if Auto_Prog.contain_bdv rules
|
wneuper@59263
|
317 |
then
|
wneuper@59263
|
318 |
let
|
wneuper@59389
|
319 |
val formal_arg = TermC.str2term "v_"
|
walther@59685
|
320 |
val value = subst_atomic env formal_arg
|
walther@59911
|
321 |
in ["(''bdv''," ^ UnparseC.term value ^ ")"] : Subst.input end
|
wneuper@59263
|
322 |
else []
|
wneuper@59263
|
323 |
end
|
wneuper@59263
|
324 |
| str => error ("subs_from: uncovered case with " ^ str)
|
wneuper@59263
|
325 |
end
|
wneuper@59405
|
326 |
| subs_from _ _ guh = error ("subs_from: uncovered case with " ^ guh)
|
neuper@37906
|
327 |
|
walther@59906
|
328 |
(**)end(**)
|