158 |
158 |
159 fun ctyp_fun f cT = |
159 fun ctyp_fun f cT = |
160 let val {T, thy, ...} = Thm.rep_ctyp cT |
160 let val {T, thy, ...} = Thm.rep_ctyp cT |
161 in Thm.ctyp_of thy (f T) end; |
161 in Thm.ctyp_of thy (f T) end; |
162 |
162 |
163 val cert = cterm_of (Context.the_theory (Context.the_thread_data ())); |
163 fun certify t = Thm.cterm_of (Context.the_theory (Context.the_thread_data ())) t; |
164 |
164 |
165 val implies = cert Term.implies; |
165 val implies = certify Term.implies; |
166 fun mk_implies (A, B) = Thm.capply (Thm.capply implies A) B; |
166 fun mk_implies (A, B) = Thm.capply (Thm.capply implies A) B; |
167 |
167 |
168 (*cterm version of list_implies: [A1,...,An], B goes to [|A1;==>;An|]==>B *) |
168 (*cterm version of list_implies: [A1,...,An], B goes to [|A1;==>;An|]==>B *) |
169 fun list_implies([], B) = B |
169 fun list_implies([], B) = B |
170 | list_implies(A::AS, B) = mk_implies (A, list_implies(AS,B)); |
170 | list_implies(A::AS, B) = mk_implies (A, list_implies(AS,B)); |
516 |
516 |
517 |
517 |
518 |
518 |
519 (*** Meta-Rewriting Rules ***) |
519 (*** Meta-Rewriting Rules ***) |
520 |
520 |
521 val read_prop = cert o SimpleSyntax.read_prop; |
521 val read_prop = certify o SimpleSyntax.read_prop; |
522 |
522 |
523 fun store_thm name thm = hd (PureThy.smart_store_thms (name, [thm])); |
523 fun store_thm name th = |
524 fun store_standard_thm name thm = store_thm name (standard thm); |
524 Context.>>> (Context.map_theory_result (PureThy.store_thm (name, th))); |
525 fun store_thm_open name thm = hd (PureThy.smart_store_thms_open (name, [thm])); |
525 |
|
526 fun store_thm_open name th = |
|
527 Context.>>> (Context.map_theory_result (PureThy.store_thm_open (name, th))); |
|
528 |
|
529 fun store_standard_thm name th = store_thm name (standard th); |
526 fun store_standard_thm_open name thm = store_thm_open name (standard' thm); |
530 fun store_standard_thm_open name thm = store_thm_open name (standard' thm); |
527 |
531 |
528 val reflexive_thm = |
532 val reflexive_thm = |
529 let val cx = cert (Var(("x",0),TVar(("'a",0),[]))) |
533 let val cx = certify (Var(("x",0),TVar(("'a",0),[]))) |
530 in store_standard_thm_open "reflexive" (Thm.reflexive cx) end; |
534 in store_standard_thm_open "reflexive" (Thm.reflexive cx) end; |
531 |
535 |
532 val symmetric_thm = |
536 val symmetric_thm = |
533 let val xy = read_prop "x::'a == y::'a" |
537 let val xy = read_prop "x::'a == y::'a" |
534 in store_standard_thm_open "symmetric" (Thm.implies_intr xy (Thm.symmetric (Thm.assume xy))) end; |
538 in store_standard_thm_open "symmetric" (Thm.implies_intr xy (Thm.symmetric (Thm.assume xy))) end; |
665 |
669 |
666 (* (!!x. PROP ?V) == PROP ?V Allows removal of redundant parameters*) |
670 (* (!!x. PROP ?V) == PROP ?V Allows removal of redundant parameters*) |
667 val triv_forall_equality = |
671 val triv_forall_equality = |
668 let val V = read_prop "V" |
672 let val V = read_prop "V" |
669 and QV = read_prop "!!x::'a. V" |
673 and QV = read_prop "!!x::'a. V" |
670 and x = cert (Free ("x", Term.aT [])); |
674 and x = certify (Free ("x", Term.aT [])); |
671 in |
675 in |
672 store_standard_thm_open "triv_forall_equality" |
676 store_standard_thm_open "triv_forall_equality" |
673 (equal_intr (implies_intr QV (forall_elim x (assume QV))) |
677 (equal_intr (implies_intr QV (forall_elim x (assume QV))) |
674 (implies_intr V (forall_intr x (assume V)))) |
678 (implies_intr V (forall_intr x (assume V)))) |
675 end; |
679 end; |
741 val all = Term.all aT; |
745 val all = Term.all aT; |
742 val x = Free ("x", aT); |
746 val x = Free ("x", aT); |
743 val phi = Free ("phi", propT); |
747 val phi = Free ("phi", propT); |
744 val psi = Free ("psi", aT --> propT); |
748 val psi = Free ("psi", aT --> propT); |
745 |
749 |
746 val cx = cert x; |
750 val cx = certify x; |
747 val cphi = cert phi; |
751 val cphi = certify phi; |
748 val lhs = cert (Logic.mk_implies (phi, all $ Abs ("x", aT, psi $ Bound 0))); |
752 val lhs = certify (Logic.mk_implies (phi, all $ Abs ("x", aT, psi $ Bound 0))); |
749 val rhs = cert (all $ Abs ("x", aT, Logic.mk_implies (phi, psi $ Bound 0))); |
753 val rhs = certify (all $ Abs ("x", aT, Logic.mk_implies (phi, psi $ Bound 0))); |
750 in |
754 in |
751 Thm.equal_intr |
755 Thm.equal_intr |
752 (Thm.implies_elim (Thm.assume lhs) (Thm.assume cphi) |
756 (Thm.implies_elim (Thm.assume lhs) (Thm.assume cphi) |
753 |> Thm.forall_elim cx |
757 |> Thm.forall_elim cx |
754 |> Thm.implies_intr cphi |
758 |> Thm.implies_intr cphi |
855 |
859 |
856 |
860 |
857 (** protected propositions and embedded terms **) |
861 (** protected propositions and embedded terms **) |
858 |
862 |
859 local |
863 local |
860 val A = cert (Free ("A", propT)); |
864 val A = certify (Free ("A", propT)); |
861 val get_axiom = Thm.unvarify o Thm.get_axiom (Context.the_theory (Context.the_thread_data ())); |
865 val get_axiom = Thm.unvarify o Thm.get_axiom (Context.the_theory (Context.the_thread_data ())); |
862 val prop_def = get_axiom "prop_def"; |
866 val prop_def = get_axiom "prop_def"; |
863 val term_def = get_axiom "term_def"; |
867 val term_def = get_axiom "term_def"; |
864 in |
868 in |
865 val protect = Thm.capply (cert Logic.protectC); |
869 val protect = Thm.capply (certify Logic.protectC); |
866 val protectI = store_thm "protectI" (PureThy.kind_rule Thm.internalK (standard |
870 val protectI = store_thm "protectI" (PureThy.kind_rule Thm.internalK (standard |
867 (Thm.equal_elim (Thm.symmetric prop_def) (Thm.assume A)))); |
871 (Thm.equal_elim (Thm.symmetric prop_def) (Thm.assume A)))); |
868 val protectD = store_thm "protectD" (PureThy.kind_rule Thm.internalK (standard |
872 val protectD = store_thm "protectD" (PureThy.kind_rule Thm.internalK (standard |
869 (Thm.equal_elim prop_def (Thm.assume (protect A))))); |
873 (Thm.equal_elim prop_def (Thm.assume (protect A))))); |
870 val protect_cong = store_standard_thm_open "protect_cong" (Thm.reflexive (protect A)); |
874 val protect_cong = store_standard_thm_open "protect_cong" (Thm.reflexive (protect A)); |