equal
deleted
inserted
replaced
39 struct |
39 struct |
40 |
40 |
41 fun mk_meta_eq r = r RS @{thm eq_reflection}; |
41 fun mk_meta_eq r = r RS @{thm eq_reflection}; |
42 fun safe_mk_meta_eq r = mk_meta_eq r handle Thm.THM _ => r; |
42 fun safe_mk_meta_eq r = mk_meta_eq r handle Thm.THM _ => r; |
43 |
43 |
44 fun mk_eq th = case concl_of th |
44 fun mk_eq th = |
|
45 (case Thm.concl_of th of |
45 (*expects Trueprop if not == *) |
46 (*expects Trueprop if not == *) |
46 of Const (@{const_name Pure.eq},_) $ _ $ _ => th |
47 Const (@{const_name Pure.eq},_) $ _ $ _ => th |
47 | _ $ (Const (@{const_name HOL.eq}, _) $ _ $ _) => mk_meta_eq th |
48 | _ $ (Const (@{const_name HOL.eq}, _) $ _ $ _) => mk_meta_eq th |
48 | _ $ (Const (@{const_name Not}, _) $ _) => th RS @{thm Eq_FalseI} |
49 | _ $ (Const (@{const_name Not}, _) $ _) => th RS @{thm Eq_FalseI} |
49 | _ => th RS @{thm Eq_TrueI} |
50 | _ => th RS @{thm Eq_TrueI}) |
50 |
51 |
51 fun mk_eq_True (_: Proof.context) r = |
52 fun mk_eq_True (_: Proof.context) r = |
52 SOME (r RS @{thm meta_eq_to_obj_eq} RS @{thm Eq_TrueI}) handle Thm.THM _ => NONE; |
53 SOME (r RS @{thm meta_eq_to_obj_eq} RS @{thm Eq_TrueI}) handle Thm.THM _ => NONE; |
53 |
54 |
54 (* Produce theorems of the form |
55 (* Produce theorems of the form |
85 let |
86 let |
86 val rl' = Seq.hd (TRYALL (fn i => fn st => |
87 val rl' = Seq.hd (TRYALL (fn i => fn st => |
87 resolve_tac ctxt [lift_meta_eq_to_obj_eq i st] i st) rl) |
88 resolve_tac ctxt [lift_meta_eq_to_obj_eq i st] i st) rl) |
88 in |
89 in |
89 mk_meta_eq rl' handle THM _ => |
90 mk_meta_eq rl' handle THM _ => |
90 if can Logic.dest_equals (concl_of rl') then rl' |
91 if can Logic.dest_equals (Thm.concl_of rl') then rl' |
91 else error "Conclusion of congruence rules must be =-equality" |
92 else error "Conclusion of congruence rules must be =-equality" |
92 end |> zero_var_indexes; |
93 end |> zero_var_indexes; |
93 |
94 |
94 fun mk_atomize ctxt pairs = |
95 fun mk_atomize ctxt pairs = |
95 let |
96 let |
99 val thm_ctxt = Variable.declare_thm thm ctxt; |
100 val thm_ctxt = Variable.declare_thm thm ctxt; |
100 fun res_fixed rls = |
101 fun res_fixed rls = |
101 if Thm.maxidx_of (Thm.adjust_maxidx_thm ~1 thm) = ~1 then res thm rls |
102 if Thm.maxidx_of (Thm.adjust_maxidx_thm ~1 thm) = ~1 then res thm rls |
102 else Variable.trade (K (fn [thm'] => res thm' rls)) thm_ctxt [thm]; |
103 else Variable.trade (K (fn [thm'] => res thm' rls)) thm_ctxt [thm]; |
103 in |
104 in |
104 case concl_of thm |
105 case Thm.concl_of thm |
105 of Const (@{const_name Trueprop}, _) $ p => (case head_of p |
106 of Const (@{const_name Trueprop}, _) $ p => (case head_of p |
106 of Const (a, _) => (case AList.lookup (op =) pairs a |
107 of Const (a, _) => (case AList.lookup (op =) pairs a |
107 of SOME rls => (maps atoms (res_fixed rls) handle THM _ => [thm]) |
108 of SOME rls => (maps atoms (res_fixed rls) handle THM _ => [thm]) |
108 | NONE => [thm]) |
109 | NONE => [thm]) |
109 | _ => [thm]) |
110 | _ => [thm]) |