equal
deleted
inserted
replaced
13 val genreif : Proof.context -> thm list -> term -> thm |
13 val genreif : Proof.context -> thm list -> term -> thm |
14 end; |
14 end; |
15 |
15 |
16 structure Reflection : REFLECTION = |
16 structure Reflection : REFLECTION = |
17 struct |
17 struct |
18 |
|
19 val ext2 = @{thm ext2}; |
|
20 val nth_Cons_0 = @{thm nth_Cons_0}; |
|
21 val nth_Cons_Suc = @{thm nth_Cons_Suc}; |
|
22 |
18 |
23 (* Make a congruence rule out of a defining equation for the interpretation *) |
19 (* Make a congruence rule out of a defining equation for the interpretation *) |
24 (* th is one defining equation of f, i.e. |
20 (* th is one defining equation of f, i.e. |
25 th is "f (Cp ?t1 ... ?tn) = P(f ?t1, .., f ?tn)" *) |
21 th is "f (Cp ?t1 ... ?tn) = P(f ?t1, .., f ?tn)" *) |
26 (* Cp is a constructor pattern and P is a pattern *) |
22 (* Cp is a constructor pattern and P is a pattern *) |
57 SOME v => v |
53 SOME v => v |
58 | NONE => t) |
54 | NONE => t) |
59 |
55 |
60 fun mk_def (Abs(x,xT,t),v) = HOLogic.mk_Trueprop ((HOLogic.all_const xT)$ Abs(x,xT,HOLogic.mk_eq(v$(Bound 0), t))) |
56 fun mk_def (Abs(x,xT,t),v) = HOLogic.mk_Trueprop ((HOLogic.all_const xT)$ Abs(x,xT,HOLogic.mk_eq(v$(Bound 0), t))) |
61 | mk_def (t, v) = HOLogic.mk_Trueprop (HOLogic.mk_eq (v, t)) |
57 | mk_def (t, v) = HOLogic.mk_Trueprop (HOLogic.mk_eq (v, t)) |
62 fun tryext x = (x RS ext2 handle THM _ => x) |
58 fun tryext x = (x RS @{lemma "(\<forall>x. f x = g x) \<Longrightarrow> f = g" by blast} handle THM _ => x) |
63 val cong = |
59 val cong = |
64 (Goal.prove ctxt'' [] (map mk_def env) |
60 (Goal.prove ctxt'' [] (map mk_def env) |
65 (HOLogic.mk_Trueprop (HOLogic.mk_eq (lhs, replace_fterms rhs))) |
61 (HOLogic.mk_Trueprop (HOLogic.mk_eq (lhs, replace_fterms rhs))) |
66 (fn {context, prems, ...} => |
62 (fn {context, prems, ...} => |
67 Local_Defs.unfold_tac context (map tryext prems) THEN rtac th' 1)) RS sym |
63 Local_Defs.unfold_tac context (map tryext prems) THEN rtac th' 1)) RS sym |
293 | trytrans (th::ths) = |
289 | trytrans (th::ths) = |
294 (FWD trans [reifth, th RS sym] handle THM _ => trytrans ths) |
290 (FWD trans [reifth, th RS sym] handle THM _ => trytrans ths) |
295 val th = trytrans corr_thms |
291 val th = trytrans corr_thms |
296 val ft = (Thm.dest_arg1 o Thm.dest_arg o Thm.dest_arg o cprop_of) th |
292 val ft = (Thm.dest_arg1 o Thm.dest_arg o Thm.dest_arg o cprop_of) th |
297 val rth = conv ft |
293 val rth = conv ft |
298 in simplify (HOL_basic_ss addsimps raw_eqs addsimps [nth_Cons_0, nth_Cons_Suc]) |
294 in |
|
295 simplify (HOL_basic_ss addsimps raw_eqs addsimps @{thms nth_Cons_0 nth_Cons_Suc}) |
299 (simplify (HOL_basic_ss addsimps [rth]) th) |
296 (simplify (HOL_basic_ss addsimps [rth]) th) |
300 end |
297 end |
301 |
298 |
302 fun genreify_tac ctxt eqs to = SUBGOAL (fn (goal, i) => |
299 fun genreify_tac ctxt eqs to = SUBGOAL (fn (goal, i) => |
303 let |
300 let |