76 val types_sorts: thm -> (indexname-> typ option) * (indexname-> sort option) |
76 val types_sorts: thm -> (indexname-> typ option) * (indexname-> sort option) |
77 val flexflex_unique: thm -> thm |
77 val flexflex_unique: thm -> thm |
78 val standard: thm -> thm |
78 val standard: thm -> thm |
79 val standard': thm -> thm |
79 val standard': thm -> thm |
80 val get_def: theory -> xstring -> thm |
80 val get_def: theory -> xstring -> thm |
81 val store_thm: bstring -> thm -> thm |
81 val store_thm: binding -> thm -> thm |
82 val store_standard_thm: bstring -> thm -> thm |
82 val store_standard_thm: binding -> thm -> thm |
83 val store_thm_open: bstring -> thm -> thm |
83 val store_thm_open: binding -> thm -> thm |
84 val store_standard_thm_open: bstring -> thm -> thm |
84 val store_standard_thm_open: binding -> thm -> thm |
85 val compose_single: thm * int * thm -> thm |
85 val compose_single: thm * int * thm -> thm |
86 val imp_cong_rule: thm -> thm -> thm |
86 val imp_cong_rule: thm -> thm -> thm |
87 val arg_cong_rule: cterm -> thm -> thm |
87 val arg_cong_rule: cterm -> thm -> thm |
88 val binop_cong_rule: cterm -> thm -> thm -> thm |
88 val binop_cong_rule: cterm -> thm -> thm -> thm |
89 val fun_cong_rule: thm -> cterm -> thm |
89 val fun_cong_rule: thm -> cterm -> thm |
453 val read_prop = certify o SimpleSyntax.read_prop; |
453 val read_prop = certify o SimpleSyntax.read_prop; |
454 |
454 |
455 fun get_def thy = Thm.axiom thy o Name_Space.intern (Theory.axiom_space thy) o Thm.def_name; |
455 fun get_def thy = Thm.axiom thy o Name_Space.intern (Theory.axiom_space thy) o Thm.def_name; |
456 |
456 |
457 fun store_thm name th = |
457 fun store_thm name th = |
458 Context.>>> (Context.map_theory_result (PureThy.store_thm (Binding.name name, th))); |
458 Context.>>> (Context.map_theory_result (PureThy.store_thm (name, th))); |
459 |
459 |
460 fun store_thm_open name th = |
460 fun store_thm_open name th = |
461 Context.>>> (Context.map_theory_result (PureThy.store_thm_open (Binding.name name, th))); |
461 Context.>>> (Context.map_theory_result (PureThy.store_thm_open (name, th))); |
462 |
462 |
463 fun store_standard_thm name th = store_thm name (standard th); |
463 fun store_standard_thm name th = store_thm name (standard th); |
464 fun store_standard_thm_open name thm = store_thm_open name (standard' thm); |
464 fun store_standard_thm_open name thm = store_thm_open name (standard' thm); |
465 |
465 |
466 val reflexive_thm = |
466 val reflexive_thm = |
467 let val cx = certify (Var(("x",0),TVar(("'a",0),[]))) |
467 let val cx = certify (Var(("x",0),TVar(("'a",0),[]))) |
468 in store_standard_thm_open "reflexive" (Thm.reflexive cx) end; |
468 in store_standard_thm_open (Binding.name "reflexive") (Thm.reflexive cx) end; |
469 |
469 |
470 val symmetric_thm = |
470 val symmetric_thm = |
471 let val xy = read_prop "x::'a == y::'a" |
471 let |
472 in store_standard_thm_open "symmetric" (Thm.implies_intr xy (Thm.symmetric (Thm.assume xy))) end; |
472 val xy = read_prop "x::'a == y::'a"; |
|
473 val thm = Thm.implies_intr xy (Thm.symmetric (Thm.assume xy)); |
|
474 in store_standard_thm_open (Binding.name "symmetric") thm end; |
473 |
475 |
474 val transitive_thm = |
476 val transitive_thm = |
475 let val xy = read_prop "x::'a == y::'a" |
477 let |
476 val yz = read_prop "y::'a == z::'a" |
478 val xy = read_prop "x::'a == y::'a"; |
477 val xythm = Thm.assume xy and yzthm = Thm.assume yz |
479 val yz = read_prop "y::'a == z::'a"; |
478 in store_standard_thm_open "transitive" (Thm.implies_intr yz (Thm.transitive xythm yzthm)) end; |
480 val xythm = Thm.assume xy; |
|
481 val yzthm = Thm.assume yz; |
|
482 val thm = Thm.implies_intr yz (Thm.transitive xythm yzthm); |
|
483 in store_standard_thm_open (Binding.name "transitive") thm end; |
479 |
484 |
480 fun symmetric_fun thm = thm RS symmetric_thm; |
485 fun symmetric_fun thm = thm RS symmetric_thm; |
481 |
486 |
482 fun extensional eq = |
487 fun extensional eq = |
483 let val eq' = |
488 let val eq' = |
484 abstract_rule "x" (Thm.dest_arg (fst (Thm.dest_equals (cprop_of eq)))) eq |
489 abstract_rule "x" (Thm.dest_arg (fst (Thm.dest_equals (cprop_of eq)))) eq |
485 in equal_elim (eta_conversion (cprop_of eq')) eq' end; |
490 in equal_elim (eta_conversion (cprop_of eq')) eq' end; |
486 |
491 |
487 val equals_cong = |
492 val equals_cong = |
488 store_standard_thm_open "equals_cong" (Thm.reflexive (read_prop "x::'a == y::'a")); |
493 store_standard_thm_open (Binding.name "equals_cong") |
|
494 (Thm.reflexive (read_prop "x::'a == y::'a")); |
489 |
495 |
490 val imp_cong = |
496 val imp_cong = |
491 let |
497 let |
492 val ABC = read_prop "A ==> B::prop == C::prop" |
498 val ABC = read_prop "A ==> B::prop == C::prop" |
493 val AB = read_prop "A ==> B" |
499 val AB = read_prop "A ==> B" |
494 val AC = read_prop "A ==> C" |
500 val AC = read_prop "A ==> C" |
495 val A = read_prop "A" |
501 val A = read_prop "A" |
496 in |
502 in |
497 store_standard_thm_open "imp_cong" (implies_intr ABC (equal_intr |
503 store_standard_thm_open (Binding.name "imp_cong") (implies_intr ABC (equal_intr |
498 (implies_intr AB (implies_intr A |
504 (implies_intr AB (implies_intr A |
499 (equal_elim (implies_elim (assume ABC) (assume A)) |
505 (equal_elim (implies_elim (assume ABC) (assume A)) |
500 (implies_elim (assume AB) (assume A))))) |
506 (implies_elim (assume AB) (assume A))))) |
501 (implies_intr AC (implies_intr A |
507 (implies_intr AC (implies_intr A |
502 (equal_elim (symmetric (implies_elim (assume ABC) (assume A))) |
508 (equal_elim (symmetric (implies_elim (assume ABC) (assume A))) |
575 |
582 |
576 |
583 |
577 (*** Some useful meta-theorems ***) |
584 (*** Some useful meta-theorems ***) |
578 |
585 |
579 (*The rule V/V, obtains assumption solving for eresolve_tac*) |
586 (*The rule V/V, obtains assumption solving for eresolve_tac*) |
580 val asm_rl = store_standard_thm_open "asm_rl" (Thm.trivial (read_prop "?psi")); |
587 val asm_rl = store_standard_thm_open (Binding.name "asm_rl") (Thm.trivial (read_prop "?psi")); |
581 val _ = store_thm_open "_" asm_rl; |
588 val _ = store_thm_open (Binding.name "_") asm_rl; |
582 |
589 |
583 (*Meta-level cut rule: [| V==>W; V |] ==> W *) |
590 (*Meta-level cut rule: [| V==>W; V |] ==> W *) |
584 val cut_rl = |
591 val cut_rl = |
585 store_standard_thm_open "cut_rl" |
592 store_standard_thm_open (Binding.name "cut_rl") |
586 (Thm.trivial (read_prop "?psi ==> ?theta")); |
593 (Thm.trivial (read_prop "?psi ==> ?theta")); |
587 |
594 |
588 (*Generalized elim rule for one conclusion; cut_rl with reversed premises: |
595 (*Generalized elim rule for one conclusion; cut_rl with reversed premises: |
589 [| PROP V; PROP V ==> PROP W |] ==> PROP W *) |
596 [| PROP V; PROP V ==> PROP W |] ==> PROP W *) |
590 val revcut_rl = |
597 val revcut_rl = |
591 let val V = read_prop "V" |
598 let |
592 and VW = read_prop "V ==> W"; |
599 val V = read_prop "V"; |
|
600 val VW = read_prop "V ==> W"; |
593 in |
601 in |
594 store_standard_thm_open "revcut_rl" |
602 store_standard_thm_open (Binding.name "revcut_rl") |
595 (implies_intr V (implies_intr VW (implies_elim (assume VW) (assume V)))) |
603 (implies_intr V (implies_intr VW (implies_elim (assume VW) (assume V)))) |
596 end; |
604 end; |
597 |
605 |
598 (*for deleting an unwanted assumption*) |
606 (*for deleting an unwanted assumption*) |
599 val thin_rl = |
607 val thin_rl = |
600 let val V = read_prop "V" |
608 let |
601 and W = read_prop "W"; |
609 val V = read_prop "V"; |
602 in store_standard_thm_open "thin_rl" (implies_intr V (implies_intr W (assume W))) end; |
610 val W = read_prop "W"; |
|
611 val thm = implies_intr V (implies_intr W (assume W)); |
|
612 in store_standard_thm_open (Binding.name "thin_rl") thm end; |
603 |
613 |
604 (* (!!x. PROP ?V) == PROP ?V Allows removal of redundant parameters*) |
614 (* (!!x. PROP ?V) == PROP ?V Allows removal of redundant parameters*) |
605 val triv_forall_equality = |
615 val triv_forall_equality = |
606 let val V = read_prop "V" |
616 let |
607 and QV = read_prop "!!x::'a. V" |
617 val V = read_prop "V"; |
608 and x = certify (Free ("x", Term.aT [])); |
618 val QV = read_prop "!!x::'a. V"; |
|
619 val x = certify (Free ("x", Term.aT [])); |
609 in |
620 in |
610 store_standard_thm_open "triv_forall_equality" |
621 store_standard_thm_open (Binding.name "triv_forall_equality") |
611 (equal_intr (implies_intr QV (forall_elim x (assume QV))) |
622 (equal_intr (implies_intr QV (forall_elim x (assume QV))) |
612 (implies_intr V (forall_intr x (assume V)))) |
623 (implies_intr V (forall_intr x (assume V)))) |
613 end; |
624 end; |
614 |
625 |
615 (* (PROP ?Phi ==> PROP ?Phi ==> PROP ?Psi) ==> |
626 (* (PROP ?Phi ==> PROP ?Phi ==> PROP ?Psi) ==> |
616 (PROP ?Phi ==> PROP ?Psi) |
627 (PROP ?Phi ==> PROP ?Psi) |
617 *) |
628 *) |
618 val distinct_prems_rl = |
629 val distinct_prems_rl = |
619 let |
630 let |
620 val AAB = read_prop "Phi ==> Phi ==> Psi" |
631 val AAB = read_prop "Phi ==> Phi ==> Psi"; |
621 val A = read_prop "Phi"; |
632 val A = read_prop "Phi"; |
622 in |
633 in |
623 store_standard_thm_open "distinct_prems_rl" |
634 store_standard_thm_open (Binding.name "distinct_prems_rl") |
624 (implies_intr_list [AAB, A] (implies_elim_list (assume AAB) [assume A, assume A])) |
635 (implies_intr_list [AAB, A] (implies_elim_list (assume AAB) [assume A, assume A])) |
625 end; |
636 end; |
626 |
637 |
627 (* (PROP ?PhiA ==> PROP ?PhiB ==> PROP ?Psi) ==> |
638 (* (PROP ?PhiA ==> PROP ?PhiB ==> PROP ?Psi) ==> |
628 (PROP ?PhiB ==> PROP ?PhiA ==> PROP ?Psi) |
639 (PROP ?PhiB ==> PROP ?PhiA ==> PROP ?Psi) |
629 `thm COMP swap_prems_rl' swaps the first two premises of `thm' |
640 `thm COMP swap_prems_rl' swaps the first two premises of `thm' |
630 *) |
641 *) |
631 val swap_prems_rl = |
642 val swap_prems_rl = |
632 let val cmajor = read_prop "PhiA ==> PhiB ==> Psi"; |
643 let |
633 val major = assume cmajor; |
644 val cmajor = read_prop "PhiA ==> PhiB ==> Psi"; |
634 val cminor1 = read_prop "PhiA"; |
645 val major = assume cmajor; |
635 val minor1 = assume cminor1; |
646 val cminor1 = read_prop "PhiA"; |
636 val cminor2 = read_prop "PhiB"; |
647 val minor1 = assume cminor1; |
637 val minor2 = assume cminor2; |
648 val cminor2 = read_prop "PhiB"; |
638 in store_standard_thm_open "swap_prems_rl" |
649 val minor2 = assume cminor2; |
639 (implies_intr cmajor (implies_intr cminor2 (implies_intr cminor1 |
650 in |
640 (implies_elim (implies_elim major minor1) minor2)))) |
651 store_standard_thm_open (Binding.name "swap_prems_rl") |
|
652 (implies_intr cmajor (implies_intr cminor2 (implies_intr cminor1 |
|
653 (implies_elim (implies_elim major minor1) minor2)))) |
641 end; |
654 end; |
642 |
655 |
643 (* [| PROP ?phi ==> PROP ?psi; PROP ?psi ==> PROP ?phi |] |
656 (* [| PROP ?phi ==> PROP ?psi; PROP ?psi ==> PROP ?phi |] |
644 ==> PROP ?phi == PROP ?psi |
657 ==> PROP ?phi == PROP ?psi |
645 Introduction rule for == as a meta-theorem. |
658 Introduction rule for == as a meta-theorem. |
646 *) |
659 *) |
647 val equal_intr_rule = |
660 val equal_intr_rule = |
648 let val PQ = read_prop "phi ==> psi" |
661 let |
649 and QP = read_prop "psi ==> phi" |
662 val PQ = read_prop "phi ==> psi"; |
|
663 val QP = read_prop "psi ==> phi"; |
650 in |
664 in |
651 store_standard_thm_open "equal_intr_rule" |
665 store_standard_thm_open (Binding.name "equal_intr_rule") |
652 (implies_intr PQ (implies_intr QP (equal_intr (assume PQ) (assume QP)))) |
666 (implies_intr PQ (implies_intr QP (equal_intr (assume PQ) (assume QP)))) |
653 end; |
667 end; |
654 |
668 |
655 (* PROP ?phi == PROP ?psi ==> PROP ?phi ==> PROP ?psi *) |
669 (* PROP ?phi == PROP ?psi ==> PROP ?phi ==> PROP ?psi *) |
656 val equal_elim_rule1 = |
670 val equal_elim_rule1 = |
657 let val eq = read_prop "phi::prop == psi::prop" |
671 let |
658 and P = read_prop "phi" |
672 val eq = read_prop "phi::prop == psi::prop"; |
659 in store_standard_thm_open "equal_elim_rule1" |
673 val P = read_prop "phi"; |
660 (Thm.equal_elim (assume eq) (assume P) |> implies_intr_list [eq, P]) |
674 in |
|
675 store_standard_thm_open (Binding.name "equal_elim_rule1") |
|
676 (Thm.equal_elim (assume eq) (assume P) |> implies_intr_list [eq, P]) |
661 end; |
677 end; |
662 |
678 |
663 (* PROP ?psi == PROP ?phi ==> PROP ?phi ==> PROP ?psi *) |
679 (* PROP ?psi == PROP ?phi ==> PROP ?phi ==> PROP ?psi *) |
664 val equal_elim_rule2 = |
680 val equal_elim_rule2 = |
665 store_standard_thm_open "equal_elim_rule2" (symmetric_thm RS equal_elim_rule1); |
681 store_standard_thm_open (Binding.name "equal_elim_rule2") |
|
682 (symmetric_thm RS equal_elim_rule1); |
666 |
683 |
667 (* PROP ?phi ==> PROP ?phi ==> PROP ?psi ==> PROP ?psi *) |
684 (* PROP ?phi ==> PROP ?phi ==> PROP ?psi ==> PROP ?psi *) |
668 val remdups_rl = |
685 val remdups_rl = |
669 let val P = read_prop "phi" and Q = read_prop "psi"; |
686 let |
670 in store_standard_thm_open "remdups_rl" (implies_intr_list [P, P, Q] (Thm.assume Q)) end; |
687 val P = read_prop "phi"; |
|
688 val Q = read_prop "psi"; |
|
689 val thm = implies_intr_list [P, P, Q] (Thm.assume Q); |
|
690 in store_standard_thm_open (Binding.name "remdups_rl") thm end; |
671 |
691 |
672 |
692 |
673 |
693 |
674 (** embedded terms and types **) |
694 (** embedded terms and types **) |
675 |
695 |