70 val not_P_imp_P_iff_F = prover "~P --> (P = False)" RS mp; |
70 val not_P_imp_P_iff_F = prover "~P --> (P = False)" RS mp; |
71 val not_P_imp_P_eq_False = not_P_imp_P_iff_F RS eq_reflection; |
71 val not_P_imp_P_eq_False = not_P_imp_P_iff_F RS eq_reflection; |
72 |
72 |
73 in |
73 in |
74 |
74 |
75 fun meta_eq r = r RS eq_reflection; |
75 (*Make meta-equalities. The operator below is Trueprop*) |
76 |
76 |
77 fun mk_meta_eq th = case concl_of th of |
77 fun mk_meta_eq r = r RS eq_reflection; |
|
78 |
|
79 fun mk_eq th = case concl_of th of |
78 Const("==",_)$_$_ => th |
80 Const("==",_)$_$_ => th |
79 | _$(Const("op =",_)$_$_) => meta_eq th |
81 | _$(Const("op =",_)$_$_) => mk_meta_eq th |
80 | _$(Const("Not",_)$_) => th RS not_P_imp_P_eq_False |
82 | _$(Const("Not",_)$_) => th RS not_P_imp_P_eq_False |
81 | _ => th RS P_imp_P_eq_True; |
83 | _ => th RS P_imp_P_eq_True; |
82 (* last 2 lines requires all formulae to be of the from Trueprop(.) *) |
84 (* last 2 lines requires all formulae to be of the from Trueprop(.) *) |
83 |
85 |
84 fun mk_meta_eq_True r = Some(r RS meta_eq_to_obj_eq RS P_imp_P_eq_True); |
86 fun mk_eq_True r = Some(r RS meta_eq_to_obj_eq RS P_imp_P_eq_True); |
|
87 |
|
88 fun mk_meta_cong rl = |
|
89 standard(mk_meta_eq(replicate (nprems_of rl) meta_eq_to_obj_eq MRS rl)) |
|
90 handle THM _ => |
|
91 error("Premises and conclusion of congruence rules must be =-equalities"); |
85 |
92 |
86 |
93 |
87 val simp_thms = map prover |
94 val simp_thms = map prover |
88 [ "(x=x) = True", |
95 [ "(x=x) = True", |
89 "(~True) = False", "(~False) = True", "(~ ~ P) = P", |
96 "(~True) = False", "(~False) = True", "(~ ~ P) = P", |
104 "(!x. P) = P", "(? x. P) = P", "? x. x=t", "? x. t=x", |
111 "(!x. P) = P", "(? x. P) = P", "? x. x=t", "? x. t=x", |
105 (*two needed for the one-point-rule quantifier simplification procs*) |
112 (*two needed for the one-point-rule quantifier simplification procs*) |
106 "(? x. x=t & P(x)) = P(t)", (*essential for termination!!*) |
113 "(? x. x=t & P(x)) = P(t)", (*essential for termination!!*) |
107 "(! x. t=x --> P(x)) = P(t)" ]; (*covers a stray case*) |
114 "(! x. t=x --> P(x)) = P(t)" ]; (*covers a stray case*) |
108 |
115 |
109 (*Add congruence rules for = (instead of ==) *) |
116 (* Add congruence rules for = (instead of ==) *) |
|
117 |
|
118 (* ###FIXME: Move to simplifier, |
|
119 taking mk_meta_cong as input, eliminating addeqcongs and deleqcongs *) |
110 infix 4 addcongs delcongs; |
120 infix 4 addcongs delcongs; |
111 |
|
112 fun mk_meta_cong rl = |
|
113 standard(meta_eq(replicate (nprems_of rl) meta_eq_to_obj_eq MRS rl)) |
|
114 handle THM _ => |
|
115 error("Premises and conclusion of congruence rules must be =-equalities"); |
|
116 |
|
117 fun ss addcongs congs = ss addeqcongs (map mk_meta_cong congs); |
121 fun ss addcongs congs = ss addeqcongs (map mk_meta_cong congs); |
118 |
|
119 fun ss delcongs congs = ss deleqcongs (map mk_meta_cong congs); |
122 fun ss delcongs congs = ss deleqcongs (map mk_meta_cong congs); |
120 |
|
121 fun Addcongs congs = (simpset_ref() := simpset() addcongs congs); |
123 fun Addcongs congs = (simpset_ref() := simpset() addcongs congs); |
122 fun Delcongs congs = (simpset_ref() := simpset() delcongs congs); |
124 fun Delcongs congs = (simpset_ref() := simpset() delcongs congs); |
|
125 |
123 |
126 |
124 val imp_cong = impI RSN |
127 val imp_cong = impI RSN |
125 (2, prove_goal HOL.thy "(P=P')--> (P'--> (Q=Q'))--> ((P-->Q) = (P'-->Q'))" |
128 (2, prove_goal HOL.thy "(P=P')--> (P'--> (Q=Q'))--> ((P-->Q) = (P'-->Q'))" |
126 (fn _=> [Blast_tac 1]) RS mp RS mp); |
129 (fn _=> [Blast_tac 1]) RS mp RS mp); |
127 |
130 |
380 val mksimps_pairs = |
383 val mksimps_pairs = |
381 [("op -->", [mp]), ("op &", [conjunct1,conjunct2]), |
384 [("op -->", [mp]), ("op &", [conjunct1,conjunct2]), |
382 ("All", [spec]), ("True", []), ("False", []), |
385 ("All", [spec]), ("True", []), ("False", []), |
383 ("If", [if_bool_eq_conj RS iffD1])]; |
386 ("If", [if_bool_eq_conj RS iffD1])]; |
384 |
387 |
385 (* FIXME: move to Provers/simplifier.ML |
388 (* ###FIXME: move to Provers/simplifier.ML |
386 val mk_atomize: (string * thm list) list -> thm -> thm list |
389 val mk_atomize: (string * thm list) list -> thm -> thm list |
387 *) |
390 *) |
388 (* FIXME: move to Provers/simplifier.ML*) |
391 (* ###FIXME: move to Provers/simplifier.ML *) |
389 fun mk_atomize pairs = |
392 fun mk_atomize pairs = |
390 let fun atoms th = |
393 let fun atoms th = |
391 (case concl_of th of |
394 (case concl_of th of |
392 Const("Trueprop",_) $ p => |
395 Const("Trueprop",_) $ p => |
393 (case head_of p of |
396 (case head_of p of |
397 | None => [th]) |
400 | None => [th]) |
398 | _ => [th]) |
401 | _ => [th]) |
399 | _ => [th]) |
402 | _ => [th]) |
400 in atoms end; |
403 in atoms end; |
401 |
404 |
402 fun mksimps pairs = (map mk_meta_eq o mk_atomize pairs o gen_all); |
405 fun mksimps pairs = (map mk_eq o mk_atomize pairs o gen_all); |
403 |
406 |
404 fun unsafe_solver prems = FIRST'[resolve_tac (reflexive_thm::TrueI::refl::prems), |
407 fun unsafe_solver prems = FIRST'[resolve_tac (reflexive_thm::TrueI::refl::prems), |
405 atac, etac FalseE]; |
408 atac, etac FalseE]; |
406 (*No premature instantiation of variables during simplification*) |
409 (*No premature instantiation of variables during simplification*) |
407 fun safe_solver prems = FIRST'[match_tac (reflexive_thm::TrueI::prems), |
410 fun safe_solver prems = FIRST'[match_tac (reflexive_thm::TrueI::prems), |
409 |
412 |
410 val HOL_basic_ss = empty_ss setsubgoaler asm_simp_tac |
413 val HOL_basic_ss = empty_ss setsubgoaler asm_simp_tac |
411 setSSolver safe_solver |
414 setSSolver safe_solver |
412 setSolver unsafe_solver |
415 setSolver unsafe_solver |
413 setmksimps (mksimps mksimps_pairs) |
416 setmksimps (mksimps mksimps_pairs) |
414 setmkeqTrue mk_meta_eq_True; |
417 setmkeqTrue mk_eq_True; |
415 |
418 |
416 val HOL_ss = |
419 val HOL_ss = |
417 HOL_basic_ss addsimps |
420 HOL_basic_ss addsimps |
418 ([triv_forall_equality, (* prunes params *) |
421 ([triv_forall_equality, (* prunes params *) |
419 True_implies_equals, (* prune asms `True' *) |
422 True_implies_equals, (* prune asms `True' *) |
452 |
455 |
453 |
456 |
454 (*** integration of simplifier with classical reasoner ***) |
457 (*** integration of simplifier with classical reasoner ***) |
455 |
458 |
456 structure Clasimp = ClasimpFun |
459 structure Clasimp = ClasimpFun |
457 (structure Simplifier = Simplifier and Classical = Classical and Blast = Blast |
460 (structure Simplifier = Simplifier |
458 val op addcongs = op addcongs and op delcongs = op delcongs |
461 and Classical = Classical |
459 and op addSaltern = op addSaltern and op addbefore = op addbefore); |
462 and Blast = Blast); |
460 |
|
461 open Clasimp; |
463 open Clasimp; |
462 |
464 |
463 val HOL_css = (HOL_cs, HOL_ss); |
465 val HOL_css = (HOL_cs, HOL_ss); |