equal
deleted
inserted
replaced
1 (* Title: Pure/Proof/proof_rewrite_rules.ML |
1 (* Title: Pure/Proof/proof_rewrite_rules.ML |
2 ID: $Id$ |
|
3 Author: Stefan Berghofer, TU Muenchen |
2 Author: Stefan Berghofer, TU Muenchen |
4 |
3 |
5 Simplification functions for proof terms involving meta level rules. |
4 Simplification functions for proof terms involving meta level rules. |
6 *) |
5 *) |
7 |
6 |
194 |
193 |
195 fun rewrite_terms r = |
194 fun rewrite_terms r = |
196 let |
195 let |
197 fun rew_term Ts t = |
196 fun rew_term Ts t = |
198 let |
197 let |
199 val frees = map Free (Name.invent_list (add_term_names (t, [])) "xa" (length Ts) ~~ Ts); |
198 val frees = |
|
199 map Free (Name.invent_list (OldTerm.add_term_names (t, [])) "xa" (length Ts) ~~ Ts); |
200 val t' = r (subst_bounds (frees, t)); |
200 val t' = r (subst_bounds (frees, t)); |
201 fun strip [] t = t |
201 fun strip [] t = t |
202 | strip (_ :: xs) (Abs (_, _, t)) = strip xs t; |
202 | strip (_ :: xs) (Abs (_, _, t)) = strip xs t; |
203 in |
203 in |
204 strip Ts (fold lambda frees t') |
204 strip Ts (fold lambda frees t') |
226 | insert_refl defs Ts prf = (case strip_combt prf of |
226 | insert_refl defs Ts prf = (case strip_combt prf of |
227 (PThm (_, ((s, prop, SOME Ts), _)), ts) => |
227 (PThm (_, ((s, prop, SOME Ts), _)), ts) => |
228 if member (op =) defs s then |
228 if member (op =) defs s then |
229 let |
229 let |
230 val vs = vars_of prop; |
230 val vs = vars_of prop; |
231 val tvars = term_tvars prop; |
231 val tvars = OldTerm.term_tvars prop; |
232 val (_, rhs) = Logic.dest_equals prop; |
232 val (_, rhs) = Logic.dest_equals prop; |
233 val rhs' = Term.betapplys (subst_TVars (map fst tvars ~~ Ts) |
233 val rhs' = Term.betapplys (subst_TVars (map fst tvars ~~ Ts) |
234 (fold_rev (fn x => fn b => Abs ("", dummyT, abstract_over (x, b))) vs rhs), |
234 (fold_rev (fn x => fn b => Abs ("", dummyT, abstract_over (x, b))) vs rhs), |
235 map the ts); |
235 map the ts); |
236 in |
236 in |
247 val f = if not r then I else |
247 val f = if not r then I else |
248 let |
248 let |
249 val cnames = map (fst o dest_Const o fst) defs'; |
249 val cnames = map (fst o dest_Const o fst) defs'; |
250 val thms = fold_proof_atoms true |
250 val thms = fold_proof_atoms true |
251 (fn PThm (_, ((name, prop, _), _)) => |
251 (fn PThm (_, ((name, prop, _), _)) => |
252 if member (op =) defnames name orelse null (term_consts prop inter cnames) then I |
252 if member (op =) defnames name orelse |
|
253 not (exists_Const (member (op =) cnames o #1) prop) |
|
254 then I |
253 else cons (name, SOME prop) |
255 else cons (name, SOME prop) |
254 | _ => I) [prf] []; |
256 | _ => I) [prf] []; |
255 in Reconstruct.expand_proof thy thms end; |
257 in Reconstruct.expand_proof thy thms end; |
256 in |
258 in |
257 rewrite_terms (Pattern.rewrite_term thy defs' []) |
259 rewrite_terms (Pattern.rewrite_term thy defs' []) |