104 | _ => r RS P_imp_P_eq_True; |
104 | _ => r RS P_imp_P_eq_True; |
105 (* last 2 lines requires all formulae to be of the from Trueprop(.) *) |
105 (* last 2 lines requires all formulae to be of the from Trueprop(.) *) |
106 |
106 |
107 fun gen_all th = forall_elim_vars (#maxidx(rep_thm th)+1) th; |
107 fun gen_all th = forall_elim_vars (#maxidx(rep_thm th)+1) th; |
108 |
108 |
109 val simp_thms = map prover |
|
110 [ "(x=x) = True", |
|
111 "(~True) = False", "(~False) = True", "(~ ~ P) = P", |
|
112 "(~P) ~= P", "P ~= (~P)", "(P ~= Q) = (P = (~Q))", |
|
113 "(True=P) = P", "(P=True) = P", |
|
114 "(True --> P) = P", "(False --> P) = True", |
|
115 "(P --> True) = True", "(P --> P) = True", |
|
116 "(P --> False) = (~P)", "(P --> ~P) = (~P)", |
|
117 "(P & True) = P", "(True & P) = P", |
|
118 "(P & False) = False", "(False & P) = False", "(P & P) = P", |
|
119 "(P | True) = True", "(True | P) = True", |
|
120 "(P | False) = P", "(False | P) = P", "(P | P) = P", |
|
121 "((~P) = (~Q)) = (P=Q)", |
|
122 "(!x.P) = P", "(? x.P) = P", "? x. x=t", |
|
123 "(? x. x=t & P(x)) = P(t)", "(? x. t=x & P(x)) = P(t)", |
|
124 "(! x. x=t --> P(x)) = P(t)", "(! x. t=x --> P(x)) = P(t)" ]; |
|
125 |
|
126 in |
109 in |
|
110 |
|
111 val simp_thms = map prover |
|
112 [ "(x=x) = True", |
|
113 "(~True) = False", "(~False) = True", "(~ ~ P) = P", |
|
114 "(~P) ~= P", "P ~= (~P)", "(P ~= Q) = (P = (~Q))", |
|
115 "(True=P) = P", "(P=True) = P", |
|
116 "(True --> P) = P", "(False --> P) = True", |
|
117 "(P --> True) = True", "(P --> P) = True", |
|
118 "(P --> False) = (~P)", "(P --> ~P) = (~P)", |
|
119 "(P & True) = P", "(True & P) = P", |
|
120 "(P & False) = False", "(False & P) = False", "(P & P) = P", |
|
121 "(P | True) = True", "(True | P) = True", |
|
122 "(P | False) = P", "(False | P) = P", "(P | P) = P", |
|
123 "((~P) = (~Q)) = (P=Q)", |
|
124 "(!x.P) = P", "(? x.P) = P", "? x. x=t", |
|
125 "(? x. x=t & P(x)) = P(t)", "(? x. t=x & P(x)) = P(t)", |
|
126 "(! x. x=t --> P(x)) = P(t)", "(! x. t=x --> P(x)) = P(t)" ]; |
127 |
127 |
128 val meta_eq_to_obj_eq = prove_goal HOL.thy "x==y ==> x=y" |
128 val meta_eq_to_obj_eq = prove_goal HOL.thy "x==y ==> x=y" |
129 (fn [prem] => [rewtac prem, rtac refl 1]); |
129 (fn [prem] => [rewtac prem, rtac refl 1]); |
130 |
130 |
131 val eq_sym_conv = prover "(x=y) = (y=x)"; |
131 val eq_sym_conv = prover "(x=y) = (y=x)"; |
199 "(ALL x. P x | Q) = ((ALL x.P x) | Q)", |
199 "(ALL x. P x | Q) = ((ALL x.P x) | Q)", |
200 "(ALL x. P | Q x) = (P | (ALL x.Q x))", |
200 "(ALL x. P | Q x) = (P | (ALL x.Q x))", |
201 "(ALL x. P x --> Q) = ((EX x.P x) --> Q)", |
201 "(ALL x. P x --> Q) = ((EX x.P x) --> Q)", |
202 "(ALL x. P --> Q x) = (P --> (ALL x.Q x))"]; |
202 "(ALL x. P --> Q x) = (P --> (ALL x.Q x))"]; |
203 |
203 |
204 val HOL_ss = empty_ss |
|
205 setmksimps (mksimps mksimps_pairs) |
|
206 setsolver (fn prems => resolve_tac (TrueI::refl::prems) ORELSE' atac |
|
207 ORELSE' etac FalseE) |
|
208 setsubgoaler asm_simp_tac |
|
209 addsimps ([if_True, if_False, o_apply, imp_disj, conj_assoc, disj_assoc, |
|
210 cases_simp] |
|
211 @ ex_simps @ all_simps @ simp_thms) |
|
212 addcongs [imp_cong]; |
|
213 |
|
214 |
|
215 (*In general it seems wrong to add distributive laws by default: they |
204 (*In general it seems wrong to add distributive laws by default: they |
216 might cause exponential blow-up. But imp_disj has been in for a while |
205 might cause exponential blow-up. But imp_disj has been in for a while |
217 and cannot be removed without affecting existing proofs. Moreover, |
206 and cannot be removed without affecting existing proofs. Moreover, |
218 rewriting by "(P|Q --> R) = ((P-->R)&(Q-->R))" might be justified on the |
207 rewriting by "(P|Q --> R) = ((P-->R)&(Q-->R))" might be justified on the |
219 grounds that it allows simplification of R in the two cases.*) |
208 grounds that it allows simplification of R in the two cases.*) |
316 |
305 |
317 prove "ex_disj_distrib" "(? x. P(x) | Q(x)) = ((? x. P(x)) | (? x. Q(x)))"; |
306 prove "ex_disj_distrib" "(? x. P(x) | Q(x)) = ((? x. P(x)) | (? x. Q(x)))"; |
318 prove "all_conj_distrib" "(!x. P(x) & Q(x)) = ((! x. P(x)) & (! x. Q(x)))"; |
307 prove "all_conj_distrib" "(!x. P(x) & Q(x)) = ((! x. P(x)) & (! x. Q(x)))"; |
319 |
308 |
320 |
309 |
|
310 val HOL_ss = empty_ss |
|
311 setmksimps (mksimps mksimps_pairs) |
|
312 setsolver (fn prems => resolve_tac (TrueI::refl::prems) ORELSE' atac |
|
313 ORELSE' etac FalseE) |
|
314 setsubgoaler asm_simp_tac |
|
315 addsimps ([if_True, if_False, o_apply, imp_disj, conj_assoc, disj_assoc, |
|
316 de_Morgan_conj, de_Morgan_disj, not_all, not_ex, cases_simp] |
|
317 @ ex_simps @ all_simps @ simp_thms) |
|
318 addcongs [imp_cong]; |
|
319 |
|
320 |
321 qed_goal "if_cancel" HOL.thy "(if c then x else x) = x" |
321 qed_goal "if_cancel" HOL.thy "(if c then x else x) = x" |
322 (fn _ => [simp_tac (HOL_ss setloop (split_tac [expand_if])) 1]); |
322 (fn _ => [simp_tac (HOL_ss setloop (split_tac [expand_if])) 1]); |
323 |
323 |
324 qed_goal "if_distrib" HOL.thy |
324 qed_goal "if_distrib" HOL.thy |
325 "f(if c then x else y) = (if c then f x else f y)" |
325 "f(if c then x else y) = (if c then f x else f y)" |