author | berghofe |
Wed, 06 Feb 2002 14:09:55 +0100 | |
changeset 12870 | 3905bc0e9002 |
parent 12527 | d6c91bc3e49c |
child 13138 | 6568fee2bd3a |
permissions | -rw-r--r-- |
11522 | 1 |
(* Title: Pure/Proof/reconstruct.ML |
2 |
ID: $Id$ |
|
11539 | 3 |
Author: Stefan Berghofer, TU Muenchen |
4 |
License: GPL (GNU GENERAL PUBLIC LICENSE) |
|
11522 | 5 |
|
6 |
Reconstruction of partial proof terms. |
|
7 |
*) |
|
8 |
||
9 |
signature RECONSTRUCT = |
|
10 |
sig |
|
11 |
val quiet_mode : bool ref |
|
11613 | 12 |
val reconstruct_proof : Sign.sg -> term -> Proofterm.proof -> Proofterm.proof |
11522 | 13 |
val expand_proof : Sign.sg -> string list -> Proofterm.proof -> Proofterm.proof |
14 |
end; |
|
15 |
||
16 |
structure Reconstruct : RECONSTRUCT = |
|
17 |
struct |
|
18 |
||
19 |
open Proofterm; |
|
20 |
||
21 |
val quiet_mode = ref true; |
|
22 |
fun message s = if !quiet_mode then () else writeln s; |
|
23 |
||
24 |
fun vars_of t = rev (foldl_aterms |
|
25 |
(fn (vs, v as Var _) => v ins vs | (vs, _) => vs) ([], t)); |
|
26 |
||
27 |
fun forall_intr (t, prop) = |
|
28 |
let val (a, T) = (case t of Var ((a, _), T) => (a, T) | Free p => p) |
|
29 |
in all T $ Abs (a, T, abstract_over (t, prop)) end; |
|
30 |
||
31 |
fun forall_intr_vfs prop = foldr forall_intr |
|
32 |
(vars_of prop @ sort (make_ord atless) (term_frees prop), prop); |
|
33 |
||
12001 | 34 |
fun forall_intr_prf (t, prf) = |
35 |
let val (a, T) = (case t of Var ((a, _), T) => (a, T) | Free p => p) |
|
36 |
in Abst (a, Some T, prf_abstract_over t prf) end; |
|
37 |
||
38 |
fun forall_intr_vfs_prf prop prf = foldr forall_intr_prf |
|
39 |
(vars_of prop @ sort (make_ord atless) (term_frees prop), prf); |
|
40 |
||
11522 | 41 |
fun merge_envs (Envir.Envir {asol=asol1, iTs=iTs1, maxidx=maxidx1}) |
42 |
(Envir.Envir {asol=asol2, iTs=iTs2, maxidx=maxidx2}) = |
|
43 |
Envir.Envir {asol=Vartab.merge (op aconv) (asol1, asol2), |
|
44 |
iTs=Vartab.merge (op =) (iTs1, iTs2), |
|
45 |
maxidx=Int.max (maxidx1, maxidx2)}; |
|
46 |
||
47 |
fun strip_abs (_::Ts) (Abs (_, _, t)) = strip_abs Ts t |
|
48 |
| strip_abs _ t = t; |
|
49 |
||
50 |
||
51 |
(******************************************************************************** |
|
52 |
generate constraints for proof term |
|
53 |
*********************************************************************************) |
|
54 |
||
55 |
fun mk_var env Ts T = |
|
56 |
let val (env', v) = Envir.genvar "a" (env, rev Ts ---> T) |
|
57 |
in (env', list_comb (v, map Bound (length Ts - 1 downto 0))) end; |
|
58 |
||
59 |
fun mk_tvar (Envir.Envir {iTs, asol, maxidx}, s) = |
|
60 |
(Envir.Envir {iTs = iTs, asol = asol, maxidx = maxidx+1}, |
|
61 |
TVar (("'t", maxidx+1), s)); |
|
62 |
||
63 |
fun mk_abs Ts t = foldl (fn (u, T) => Abs ("", T, u)) (t, Ts); |
|
64 |
||
65 |
fun make_Tconstraints_cprf maxidx cprf = |
|
66 |
let |
|
67 |
fun mk_Tcnstrts maxidx Ts (Abst (s, Some T, cprf)) = |
|
68 |
let val (cs, cprf', maxidx') = mk_Tcnstrts maxidx (T::Ts) cprf; |
|
69 |
in (cs, Abst (s, Some T, cprf'), maxidx') end |
|
70 |
| mk_Tcnstrts maxidx Ts (Abst (s, None, cprf)) = |
|
71 |
let |
|
72 |
val T' = TVar (("'t", maxidx+1), ["logic"]); |
|
73 |
val (cs, cprf', maxidx') = mk_Tcnstrts (maxidx+1) (T'::Ts) cprf; |
|
74 |
in (cs, Abst (s, Some T', cprf'), maxidx') end |
|
75 |
| mk_Tcnstrts maxidx Ts (AbsP (s, Some t, cprf)) = |
|
76 |
let val (cs, cprf', maxidx') = mk_Tcnstrts maxidx Ts cprf; |
|
77 |
in ((mk_abs Ts t, rev Ts ---> propT)::cs, AbsP (s, Some t, cprf'), maxidx') end |
|
78 |
| mk_Tcnstrts maxidx Ts (AbsP (s, None, cprf)) = |
|
79 |
let val (cs, cprf', maxidx') = mk_Tcnstrts maxidx Ts cprf; |
|
80 |
in (cs, AbsP (s, None, cprf'), maxidx') end |
|
11613 | 81 |
| mk_Tcnstrts maxidx Ts (cprf1 %% cprf2) = |
11522 | 82 |
let |
83 |
val (cs, cprf1', maxidx') = mk_Tcnstrts maxidx Ts cprf1; |
|
84 |
val (cs', cprf2', maxidx'') = mk_Tcnstrts maxidx' Ts cprf2; |
|
11613 | 85 |
in (cs' @ cs, cprf1' %% cprf2', maxidx'') end |
86 |
| mk_Tcnstrts maxidx Ts (cprf % Some t) = |
|
11522 | 87 |
let val (cs, cprf', maxidx') = mk_Tcnstrts maxidx Ts cprf; |
88 |
in ((mk_abs Ts t, rev Ts ---> TypeInfer.logicT)::cs, |
|
11613 | 89 |
cprf' % Some t, maxidx') |
11522 | 90 |
end |
11613 | 91 |
| mk_Tcnstrts maxidx Ts (cprf % None) = |
11522 | 92 |
let val (cs, cprf', maxidx') = mk_Tcnstrts maxidx Ts cprf; |
11613 | 93 |
in (cs, cprf % None, maxidx') end |
11522 | 94 |
| mk_Tcnstrts maxidx _ cprf = ([], cprf, maxidx); |
95 |
in mk_Tcnstrts maxidx [] cprf end; |
|
96 |
||
97 |
fun unifyT sg env T U = |
|
98 |
let |
|
99 |
val Envir.Envir {asol, iTs, maxidx} = env; |
|
12527 | 100 |
val (iTs', maxidx') = Type.unify (Sign.tsig_of sg) (iTs, maxidx) (T, U) |
11660 | 101 |
in Envir.Envir {asol=asol, iTs=iTs', maxidx=maxidx'} end |
102 |
handle Type.TUNIFY => error ("Non-unifiable types:\n" ^ |
|
103 |
Sign.string_of_typ sg T ^ "\n\n" ^ Sign.string_of_typ sg U); |
|
11522 | 104 |
|
12236 | 105 |
fun decompose sg env Ts t u = case (Envir.head_norm env t, Envir.head_norm env u) of |
106 |
(Const ("all", _) $ t, Const ("all", _) $ u) => decompose sg env Ts t u |
|
107 |
| (Const ("==>", _) $ t1 $ t2, Const ("==>", _) $ u1 $ u2) => |
|
11660 | 108 |
let val (env', cs) = decompose sg env Ts t1 u1 |
109 |
in apsnd (curry op @ cs) (decompose sg env' Ts t2 u2) end |
|
12236 | 110 |
| (Abs (_, T, t), Abs (_, U, u)) => |
11660 | 111 |
decompose sg (unifyT sg env T U) (T::Ts) t u |
12236 | 112 |
| (t, u) => (env, [(mk_abs Ts t, mk_abs Ts u)]); |
11522 | 113 |
|
11660 | 114 |
fun cantunify sg t u = error ("Non-unifiable terms:\n" ^ |
11522 | 115 |
Sign.string_of_term sg t ^ "\n\n" ^ Sign.string_of_term sg u); |
116 |
||
117 |
fun make_constraints_cprf sg env ts cprf = |
|
118 |
let |
|
119 |
fun add_cnstrt Ts prop prf cs env ts (t, u) = |
|
120 |
let |
|
121 |
val t' = mk_abs Ts t; |
|
12236 | 122 |
val u' = mk_abs Ts u |
11522 | 123 |
in |
12236 | 124 |
(prop, prf, cs, Pattern.unify (sg, env, [(t', u')]), ts) |
125 |
handle Pattern.Pattern => |
|
126 |
let val (env', cs') = decompose sg env [] t' u' |
|
127 |
in (prop, prf, cs @ cs', env', ts) end |
|
128 |
| Pattern.Unif => |
|
129 |
cantunify sg (Envir.norm_term env t') (Envir.norm_term env u') |
|
11522 | 130 |
end; |
131 |
||
132 |
fun mk_cnstrts_atom env ts prop opTs mk_prf = |
|
133 |
let |
|
134 |
val tvars = term_tvars prop; |
|
135 |
val (env', Ts) = if_none (apsome (pair env) opTs) |
|
136 |
(foldl_map (mk_tvar o apsnd snd) (env, tvars)); |
|
137 |
val prop' = subst_TVars (map fst tvars ~~ Ts) (forall_intr_vfs prop); |
|
138 |
in (prop', mk_prf (Some Ts), [], env', ts) end; |
|
139 |
||
140 |
fun mk_cnstrts env _ Hs ts (PBound i) = (nth_elem (i, Hs), PBound i, [], env, ts) |
|
141 |
| mk_cnstrts env Ts Hs ts (Abst (s, Some T, cprf)) = |
|
142 |
let val (t, prf, cnstrts, env', ts') = |
|
143 |
mk_cnstrts env (T::Ts) (map (incr_boundvars 1) Hs) ts cprf; |
|
144 |
in (Const ("all", (T --> propT) --> propT) $ Abs (s, T, t), Abst (s, Some T, prf), |
|
145 |
cnstrts, env', ts') |
|
146 |
end |
|
147 |
| mk_cnstrts env Ts Hs (t::ts) (AbsP (s, Some _, cprf)) = |
|
148 |
let |
|
149 |
val (u, prf, cnstrts, env', ts') = mk_cnstrts env Ts (t::Hs) ts cprf; |
|
150 |
val t' = strip_abs Ts t; |
|
151 |
in (Logic.mk_implies (t', u), AbsP (s, Some t', prf), cnstrts, env', ts') |
|
152 |
end |
|
153 |
| mk_cnstrts env Ts Hs ts (AbsP (s, None, cprf)) = |
|
154 |
let |
|
155 |
val (env', t) = mk_var env Ts propT; |
|
156 |
val (u, prf, cnstrts, env'', ts') = mk_cnstrts env' Ts (t::Hs) ts cprf; |
|
157 |
in (Logic.mk_implies (t, u), AbsP (s, Some t, prf), cnstrts, env'', ts') |
|
158 |
end |
|
11613 | 159 |
| mk_cnstrts env Ts Hs ts (cprf1 %% cprf2) = |
11522 | 160 |
let val (u, prf2, cnstrts, env', ts') = mk_cnstrts env Ts Hs ts cprf2 |
161 |
in (case mk_cnstrts env' Ts Hs ts' cprf1 of |
|
162 |
(Const ("==>", _) $ u' $ t', prf1, cnstrts', env'', ts'') => |
|
11613 | 163 |
add_cnstrt Ts t' (prf1 %% prf2) (cnstrts' @ cnstrts) |
11522 | 164 |
env'' ts'' (u, u') |
165 |
| (t, prf1, cnstrts', env'', ts'') => |
|
166 |
let val (env''', v) = mk_var env'' Ts propT |
|
11613 | 167 |
in add_cnstrt Ts v (prf1 %% prf2) (cnstrts' @ cnstrts) |
11522 | 168 |
env''' ts'' (t, Logic.mk_implies (u, v)) |
169 |
end) |
|
170 |
end |
|
11613 | 171 |
| mk_cnstrts env Ts Hs (t::ts) (cprf % Some _) = |
11522 | 172 |
let val t' = strip_abs Ts t |
173 |
in (case mk_cnstrts env Ts Hs ts cprf of |
|
174 |
(Const ("all", Type ("fun", [Type ("fun", [T, _]), _])) $ f, |
|
175 |
prf, cnstrts, env', ts') => |
|
12236 | 176 |
let val env'' = unifyT sg env' T (Envir.fastype env' Ts t') |
11613 | 177 |
in (betapply (f, t'), prf % Some t', cnstrts, env'', ts') |
11522 | 178 |
end |
179 |
| (u, prf, cnstrts, env', ts') => |
|
180 |
let |
|
12236 | 181 |
val T = Envir.fastype env' Ts t'; |
11522 | 182 |
val (env'', v) = mk_var env' Ts (T --> propT); |
183 |
in |
|
11613 | 184 |
add_cnstrt Ts (v $ t') (prf % Some t') cnstrts env'' ts' |
11522 | 185 |
(u, Const ("all", (T --> propT) --> propT) $ v) |
186 |
end) |
|
187 |
end |
|
11613 | 188 |
| mk_cnstrts env Ts Hs ts (cprf % None) = |
11522 | 189 |
(case mk_cnstrts env Ts Hs ts cprf of |
190 |
(Const ("all", Type ("fun", [Type ("fun", [T, _]), _])) $ f, |
|
191 |
prf, cnstrts, env', ts') => |
|
192 |
let val (env'', t) = mk_var env' Ts T |
|
11613 | 193 |
in (betapply (f, t), prf % Some t, cnstrts, env'', ts') |
11522 | 194 |
end |
195 |
| (u, prf, cnstrts, env', ts') => |
|
196 |
let |
|
197 |
val (env1, T) = mk_tvar (env', ["logic"]); |
|
198 |
val (env2, v) = mk_var env1 Ts (T --> propT); |
|
199 |
val (env3, t) = mk_var env2 Ts T |
|
200 |
in |
|
11613 | 201 |
add_cnstrt Ts (v $ t) (prf % Some t) cnstrts env3 ts' |
11522 | 202 |
(u, Const ("all", (T --> propT) --> propT) $ v) |
203 |
end) |
|
204 |
| mk_cnstrts env _ _ ts (PThm (name, prf, prop, opTs)) = |
|
205 |
mk_cnstrts_atom env ts prop opTs (fn x => PThm (name, prf, prop, x)) |
|
206 |
| mk_cnstrts env _ _ ts (PAxm (name, prop, opTs)) = |
|
207 |
mk_cnstrts_atom env ts prop opTs (fn x => PAxm (name, prop, x)) |
|
208 |
| mk_cnstrts env _ _ ts (Oracle (name, prop, opTs)) = |
|
209 |
mk_cnstrts_atom env ts prop opTs (fn x => Oracle (name, prop, x)) |
|
210 |
| mk_cnstrts env _ _ ts (Hyp t) = (t, Hyp t, [], env, ts) |
|
11613 | 211 |
| mk_cnstrts _ _ _ _ _ = error "reconstruct_proof: minimal proof object" |
11522 | 212 |
in mk_cnstrts env [] [] ts cprf end; |
213 |
||
214 |
fun add_term_ixns (is, Var (i, T)) = add_typ_ixns (i ins is, T) |
|
215 |
| add_term_ixns (is, Free (_, T)) = add_typ_ixns (is, T) |
|
216 |
| add_term_ixns (is, Const (_, T)) = add_typ_ixns (is, T) |
|
217 |
| add_term_ixns (is, t1 $ t2) = add_term_ixns (add_term_ixns (is, t1), t2) |
|
218 |
| add_term_ixns (is, Abs (_, T, t)) = add_term_ixns (add_typ_ixns (is, T), t) |
|
219 |
| add_term_ixns (is, _) = is; |
|
220 |
||
221 |
||
222 |
(******************************************************************************** |
|
223 |
update list of free variables of constraints |
|
224 |
*********************************************************************************) |
|
225 |
||
226 |
fun upd_constrs env cs = |
|
227 |
let |
|
228 |
val Envir.Envir {asol, iTs, ...} = env; |
|
229 |
val dom = Vartab.foldl (uncurry (cons o fst) o Library.swap) |
|
230 |
(Vartab.foldl (uncurry (cons o fst) o Library.swap) ([], asol), iTs); |
|
231 |
val vran = Vartab.foldl (add_typ_ixns o apsnd snd) |
|
232 |
(Vartab.foldl (add_term_ixns o apsnd snd) ([], asol), iTs); |
|
233 |
fun check_cs [] = [] |
|
234 |
| check_cs ((u, p, vs)::ps) = |
|
235 |
let val vs' = vs \\ dom; |
|
236 |
in if vs = vs' then (u, p, vs)::check_cs ps |
|
237 |
else (true, p, vs' union vran)::check_cs ps |
|
238 |
end |
|
239 |
in check_cs cs end; |
|
240 |
||
241 |
(******************************************************************************** |
|
242 |
solution of constraints |
|
243 |
*********************************************************************************) |
|
244 |
||
245 |
fun solve _ [] bigenv = bigenv |
|
246 |
| solve sg cs bigenv = |
|
247 |
let |
|
11660 | 248 |
fun search env [] = error ("Unsolvable constraints:\n" ^ |
249 |
Pretty.string_of (Pretty.chunks (map (fn (_, p, _) => |
|
250 |
Sign.pretty_term sg (Logic.mk_flexpair (pairself |
|
251 |
(Envir.norm_term bigenv) p))) cs))) |
|
11522 | 252 |
| search env ((u, p as (t1, t2), vs)::ps) = |
253 |
if u then |
|
254 |
let |
|
255 |
val tn1 = Envir.norm_term bigenv t1; |
|
256 |
val tn2 = Envir.norm_term bigenv t2 |
|
257 |
in |
|
258 |
if Pattern.pattern tn1 andalso Pattern.pattern tn2 then |
|
259 |
((Pattern.unify (sg, env, [(tn1, tn2)]), ps) handle Pattern.Unif => |
|
260 |
cantunify sg tn1 tn2) |
|
261 |
else |
|
262 |
let val (env', cs') = decompose sg env [] tn1 tn2 |
|
263 |
in if cs' = [(tn1, tn2)] then |
|
264 |
apsnd (cons (false, (tn1, tn2), vs)) (search env ps) |
|
265 |
else search env' (map (fn q => (true, q, vs)) cs' @ ps) |
|
266 |
end |
|
267 |
end |
|
268 |
else apsnd (cons (false, p, vs)) (search env ps); |
|
269 |
val Envir.Envir {maxidx, ...} = bigenv; |
|
270 |
val (env, cs') = search (Envir.empty maxidx) cs; |
|
271 |
in |
|
272 |
solve sg (upd_constrs env cs') (merge_envs bigenv env) |
|
273 |
end; |
|
274 |
||
275 |
||
276 |
(******************************************************************************** |
|
277 |
reconstruction of proofs |
|
278 |
*********************************************************************************) |
|
279 |
||
11613 | 280 |
fun reconstruct_proof sg prop cprf = |
11522 | 281 |
let |
11613 | 282 |
val (cprf' % Some prop', thawf) = freeze_thaw_prf (cprf % Some prop); |
11522 | 283 |
val _ = message "Collecting type constraints..."; |
284 |
val (Tcs, cprf'', maxidx) = make_Tconstraints_cprf 0 cprf'; |
|
285 |
val (ts, Ts) = ListPair.unzip Tcs; |
|
286 |
val tsig = Sign.tsig_of sg; |
|
287 |
val {classrel, arities, ...} = Type.rep_tsig tsig; |
|
288 |
val _ = message "Solving type constraints..."; |
|
289 |
val (ts', _, unifier) = TypeInfer.infer_types (Sign.pretty_term sg) (Sign.pretty_typ sg) |
|
290 |
(Sign.const_type sg) classrel arities [] false (K true) ts Ts; |
|
291 |
val env = Envir.Envir {asol = Vartab.empty, iTs = Vartab.make unifier, maxidx = maxidx}; |
|
292 |
val _ = message "Collecting term constraints..."; |
|
293 |
val (t, prf, cs, env, _) = make_constraints_cprf sg env ts' cprf''; |
|
294 |
val cs' = map (fn p => (true, p, op union |
|
295 |
(pairself (map (fst o dest_Var) o term_vars) p))) (map (pairself (Envir.norm_term env)) ((t, prop')::cs)); |
|
296 |
val _ = message ("Solving remaining constraints (" ^ string_of_int (length cs') ^ ") ..."); |
|
297 |
val env' = solve sg cs' env |
|
298 |
in |
|
299 |
thawf (norm_proof env' prf) |
|
300 |
end; |
|
301 |
||
302 |
||
303 |
(******************************************************************************** |
|
304 |
expand and reconstruct subproofs |
|
305 |
*********************************************************************************) |
|
306 |
||
307 |
fun expand_proof sg names prf = |
|
308 |
let |
|
12870
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
309 |
fun expand maxidx prfs (AbsP (s, t, prf)) = |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
310 |
let val (maxidx', prfs', prf') = expand maxidx prfs prf |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
311 |
in (maxidx', prfs', AbsP (s, t, prf')) end |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
312 |
| expand maxidx prfs (Abst (s, T, prf)) = |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
313 |
let val (maxidx', prfs', prf') = expand maxidx prfs prf |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
314 |
in (maxidx', prfs', Abst (s, T, prf')) end |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
315 |
| expand maxidx prfs (prf1 %% prf2) = |
11522 | 316 |
let |
12870
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
317 |
val (maxidx', prfs', prf1') = expand maxidx prfs prf1; |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
318 |
val (maxidx'', prfs'', prf2') = expand maxidx' prfs' prf2; |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
319 |
in (maxidx'', prfs'', prf1' %% prf2') end |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
320 |
| expand maxidx prfs (prf % t) = |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
321 |
let val (maxidx', prfs', prf') = expand maxidx prfs prf |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
322 |
in (maxidx', prfs', prf' % t) end |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
323 |
| expand maxidx prfs (prf as PThm ((a, _), cprf, prop, Some Ts)) = |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
324 |
if not (a mem names) then (maxidx, prfs, prf) else |
11522 | 325 |
let |
12870
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
326 |
val (maxidx', (i, prf), prfs') = (case assoc (prfs, (a, prop)) of |
11522 | 327 |
None => |
328 |
let |
|
329 |
val _ = message ("Reconstructing proof of " ^ a); |
|
330 |
val _ = message (Sign.string_of_term sg prop); |
|
12870
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
331 |
val i = maxidx + 1; |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
332 |
val prf' = map_proof_terms (Logic.incr_indexes ([], i)) |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
333 |
(incr_tvar i) (forall_intr_vfs_prf prop |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
334 |
(reconstruct_proof sg prop cprf)); |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
335 |
val (maxidx', prfs', prf) = expand |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
336 |
(maxidx_of_proof prf') prfs prf' |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
337 |
in (maxidx', (i, prf), ((a, prop), (i, prf)) :: prfs') end |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
338 |
| Some p => (maxidx, p, prfs)); |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
339 |
val tye = map (fn ((s, j), _) => (s, i + j)) (term_tvars prop) ~~ Ts |
11522 | 340 |
in |
12870
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
341 |
(maxidx', prfs', |
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
342 |
map_proof_terms (subst_TVars tye) (typ_subst_TVars tye) prf) |
11522 | 343 |
end |
12870
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
344 |
| expand maxidx prfs prf = (maxidx, prfs, prf); |
11522 | 345 |
|
12870
3905bc0e9002
Indexes of variables in expanded proofs are now incremented to avoid clashes.
berghofe
parents:
12527
diff
changeset
|
346 |
in #3 (expand (maxidx_of_proof prf) [] prf) end; |
11522 | 347 |
|
348 |
end; |