433 |
433 |
434 val eq_commute = mk_meta_eq @{thm eq_commute}; |
434 val eq_commute = mk_meta_eq @{thm eq_commute}; |
435 |
435 |
436 fun sym_conv eq = |
436 fun sym_conv eq = |
437 let val (l,r) = Thm.dest_binop eq |
437 let val (l,r) = Thm.dest_binop eq |
438 in instantiate' [SOME (Thm.ctyp_of_term l)] [SOME l, SOME r] eq_commute |
438 in instantiate' [SOME (Thm.ctyp_of_cterm l)] [SOME l, SOME r] eq_commute |
439 end; |
439 end; |
440 |
440 |
441 (* FIXME : copied from cqe.ML -- complex QE*) |
441 (* FIXME : copied from cqe.ML -- complex QE*) |
442 fun conjuncts ct = |
442 fun conjuncts ct = |
443 case Thm.term_of ct of |
443 case Thm.term_of ct of |
477 (* END FIXME.*) |
477 (* END FIXME.*) |
478 |
478 |
479 (* Conversion for the equivalence of existential statements where |
479 (* Conversion for the equivalence of existential statements where |
480 EX quantifiers are rearranged differently *) |
480 EX quantifiers are rearranged differently *) |
481 fun ext T = Drule.cterm_rule (instantiate' [SOME T] []) @{cpat Ex} |
481 fun ext T = Drule.cterm_rule (instantiate' [SOME T] []) @{cpat Ex} |
482 fun mk_ex v t = Thm.apply (ext (Thm.ctyp_of_term v)) (Thm.lambda v t) |
482 fun mk_ex v t = Thm.apply (ext (Thm.ctyp_of_cterm v)) (Thm.lambda v t) |
483 |
483 |
484 fun choose v th th' = case Thm.concl_of th of |
484 fun choose v th th' = case Thm.concl_of th of |
485 @{term Trueprop} $ (Const(@{const_name Ex},_)$_) => |
485 @{term Trueprop} $ (Const(@{const_name Ex},_)$_) => |
486 let |
486 let |
487 val p = (funpow 2 Thm.dest_arg o Thm.cprop_of) th |
487 val p = (funpow 2 Thm.dest_arg o Thm.cprop_of) th |
488 val T = (hd o Thm.dest_ctyp o Thm.ctyp_of_term) p |
488 val T = (hd o Thm.dest_ctyp o Thm.ctyp_of_cterm) p |
489 val th0 = Conv.fconv_rule (Thm.beta_conversion true) |
489 val th0 = Conv.fconv_rule (Thm.beta_conversion true) |
490 (instantiate' [SOME T] [SOME p, (SOME o Thm.dest_arg o Thm.cprop_of) th'] exE) |
490 (instantiate' [SOME T] [SOME p, (SOME o Thm.dest_arg o Thm.cprop_of) th'] exE) |
491 val pv = (Thm.rhs_of o Thm.beta_conversion true) |
491 val pv = (Thm.rhs_of o Thm.beta_conversion true) |
492 (Thm.apply @{cterm Trueprop} (Thm.apply p v)) |
492 (Thm.apply @{cterm Trueprop} (Thm.apply p v)) |
493 val th1 = Thm.forall_intr v (Thm.implies_intr pv th') |
493 val th1 = Thm.forall_intr v (Thm.implies_intr pv th') |
502 fun mkexi v th = |
502 fun mkexi v th = |
503 let |
503 let |
504 val p = Thm.lambda v (Thm.dest_arg (Thm.cprop_of th)) |
504 val p = Thm.lambda v (Thm.dest_arg (Thm.cprop_of th)) |
505 in Thm.implies_elim |
505 in Thm.implies_elim |
506 (Conv.fconv_rule (Thm.beta_conversion true) |
506 (Conv.fconv_rule (Thm.beta_conversion true) |
507 (instantiate' [SOME (Thm.ctyp_of_term v)] [SOME p, SOME v] @{thm exI})) |
507 (instantiate' [SOME (Thm.ctyp_of_cterm v)] [SOME p, SOME v] @{thm exI})) |
508 th |
508 th |
509 end |
509 end |
510 fun ex_eq_conv t = |
510 fun ex_eq_conv t = |
511 let |
511 let |
512 val (p0,q0) = Thm.dest_binop t |
512 val (p0,q0) = Thm.dest_binop t |
525 fun getname v = case Thm.term_of v of |
525 fun getname v = case Thm.term_of v of |
526 Free(s,_) => s |
526 Free(s,_) => s |
527 | Var ((s,_),_) => s |
527 | Var ((s,_),_) => s |
528 | _ => "x" |
528 | _ => "x" |
529 fun mk_eq s t = Thm.apply (Thm.apply @{cterm "op == :: bool => _"} s) t |
529 fun mk_eq s t = Thm.apply (Thm.apply @{cterm "op == :: bool => _"} s) t |
530 fun mk_exists v th = Drule.arg_cong_rule (ext (Thm.ctyp_of_term v)) |
530 fun mk_exists v th = Drule.arg_cong_rule (ext (Thm.ctyp_of_cterm v)) |
531 (Thm.abstract_rule (getname v) v th) |
531 (Thm.abstract_rule (getname v) v th) |
532 fun simp_ex_conv ctxt = |
532 fun simp_ex_conv ctxt = |
533 Simplifier.rewrite (put_simpset HOL_basic_ss ctxt addsimps @{thms simp_thms(39)}) |
533 Simplifier.rewrite (put_simpset HOL_basic_ss ctxt addsimps @{thms simp_thms(39)}) |
534 |
534 |
535 fun frees t = Thm.add_cterm_frees t []; |
535 fun frees t = Thm.add_cterm_frees t []; |
737 |
737 |
738 fun ring ctxt tm = |
738 fun ring ctxt tm = |
739 let |
739 let |
740 fun mk_forall x p = |
740 fun mk_forall x p = |
741 Thm.apply |
741 Thm.apply |
742 (Drule.cterm_rule (instantiate' [SOME (Thm.ctyp_of_term x)] []) |
742 (Drule.cterm_rule (instantiate' [SOME (Thm.ctyp_of_cterm x)] []) |
743 @{cpat "All:: (?'a => bool) => _"}) (Thm.lambda x p) |
743 @{cpat "All:: (?'a => bool) => _"}) (Thm.lambda x p) |
744 val avs = Thm.add_cterm_frees tm [] |
744 val avs = Thm.add_cterm_frees tm [] |
745 val P' = fold mk_forall avs tm |
745 val P' = fold mk_forall avs tm |
746 val th1 = initial_conv ctxt (mk_neg P') |
746 val th1 = initial_conv ctxt (mk_neg P') |
747 val (evs,bod) = strip_exists(concl th1) in |
747 val (evs,bod) = strip_exists(concl th1) in |
917 (case Semiring_Normalizer.match ctxt tm of |
917 (case Semiring_Normalizer.match ctxt tm of |
918 NONE => NONE |
918 NONE => NONE |
919 | SOME (res as (theory, {is_const = _, dest_const, |
919 | SOME (res as (theory, {is_const = _, dest_const, |
920 mk_const, conv = ring_eq_conv})) => |
920 mk_const, conv = ring_eq_conv})) => |
921 SOME (ring_and_ideal_conv theory |
921 SOME (ring_and_ideal_conv theory |
922 dest_const (mk_const (Thm.ctyp_of_term tm)) (ring_eq_conv ctxt) |
922 dest_const (mk_const (Thm.ctyp_of_cterm tm)) (ring_eq_conv ctxt) |
923 (Semiring_Normalizer.semiring_normalize_wrapper ctxt res))) |
923 (Semiring_Normalizer.semiring_normalize_wrapper ctxt res))) |
924 |
924 |
925 fun presimplify ctxt add_thms del_thms = |
925 fun presimplify ctxt add_thms del_thms = |
926 asm_full_simp_tac (put_simpset HOL_basic_ss ctxt |
926 asm_full_simp_tac (put_simpset HOL_basic_ss ctxt |
927 addsimps (Named_Theorems.get ctxt @{named_theorems algebra}) |
927 addsimps (Named_Theorems.get ctxt @{named_theorems algebra}) |
943 local |
943 local |
944 fun lhs t = case Thm.term_of t of |
944 fun lhs t = case Thm.term_of t of |
945 Const(@{const_name HOL.eq},_)$_$_ => Thm.dest_arg1 t |
945 Const(@{const_name HOL.eq},_)$_$_ => Thm.dest_arg1 t |
946 | _=> raise CTERM ("ideal_tac - lhs",[t]) |
946 | _=> raise CTERM ("ideal_tac - lhs",[t]) |
947 fun exitac NONE = no_tac |
947 fun exitac NONE = no_tac |
948 | exitac (SOME y) = rtac (instantiate' [SOME (Thm.ctyp_of_term y)] [NONE,SOME y] exI) 1 |
948 | exitac (SOME y) = rtac (instantiate' [SOME (Thm.ctyp_of_cterm y)] [NONE,SOME y] exI) 1 |
949 |
949 |
950 val claset = claset_of @{context} |
950 val claset = claset_of @{context} |
951 in |
951 in |
952 fun ideal_tac add_ths del_ths ctxt = |
952 fun ideal_tac add_ths del_ths ctxt = |
953 presimplify ctxt add_ths del_ths |
953 presimplify ctxt add_ths del_ths |