681 unfolding UNION_def EMPTY_def INSERT_def |
684 unfolding UNION_def EMPTY_def INSERT_def |
682 apply(rule_tac f="(op &)" in arg_cong2) |
685 apply(rule_tac f="(op &)" in arg_cong2) |
683 apply(rule_tac f="(op =)" in arg_cong2) |
686 apply(rule_tac f="(op =)" in arg_cong2) |
684 apply(simp only: QUOT_TYPE_I_fset.thm11[symmetric]) |
687 apply(simp only: QUOT_TYPE_I_fset.thm11[symmetric]) |
685 apply(rule append_respects_fst) |
688 apply(rule append_respects_fst) |
686 apply(simp only:QUOT_TYPE_I_fset.REP_ABS_rsp) |
689 apply(simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
687 apply(rule list_eq_sym) |
690 apply(rule list_eq_sym) |
688 apply(simp) |
691 apply(simp) |
689 apply(rule_tac f="(op =)" in arg_cong2) |
692 apply(rule_tac f="(op =)" in arg_cong2) |
690 apply(simp only: QUOT_TYPE_I_fset.thm11[symmetric]) |
693 apply(simp only: QUOT_TYPE_I_fset.thm11[symmetric]) |
691 apply(rule append_respects_fst) |
694 apply(rule append_respects_fst) |
741 ML {* val in_t = (symmetric (unlam_def @{context} @{context} @{thm IN_def})) *} |
744 ML {* val in_t = (symmetric (unlam_def @{context} @{context} @{thm IN_def})) *} |
742 ML {* val uniont = symmetric (unlam_def @{context} @{context} @{thm UNION_def}) *} |
745 ML {* val uniont = symmetric (unlam_def @{context} @{context} @{thm UNION_def}) *} |
743 ML {* val cardt = symmetric (unlam_def @{context} @{context} @{thm CARD_def}) *} |
746 ML {* val cardt = symmetric (unlam_def @{context} @{context} @{thm CARD_def}) *} |
744 ML {* val insertt = symmetric (unlam_def @{context} @{context} @{thm INSERT_def}) *} |
747 ML {* val insertt = symmetric (unlam_def @{context} @{context} @{thm INSERT_def}) *} |
745 |
748 |
|
749 thm m1 |
|
750 |
746 ML {* |
751 ML {* |
747 val m1_novars = snd(no_vars ((Context.Theory @{theory}),@{thm m1})) |
752 val m1_novars = snd(no_vars ((Context.Theory @{theory}),@{thm m1})) |
748 val goal = build_goal m1_novars consts @{typ "'a list"} mk_rep_abs |
753 val goal = build_goal m1_novars consts @{typ "'a list"} mk_rep_abs |
749 val cgoal = cterm_of @{theory} goal |
754 val cgoal = cterm_of @{theory} goal |
750 val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite false [emptyt, in_t] cgoal) |
755 val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite false [emptyt, in_t] cgoal) |
751 *} |
756 *} |
752 |
757 |
753 prove {* HOLogic.mk_Trueprop (Thm.term_of cgoal2) *} |
758 prove {* HOLogic.mk_Trueprop (Thm.term_of cgoal2) *} |
754 apply(rule_tac f="(op =)" in arg_cong2) |
759 apply(rule_tac f="(op =)" in arg_cong2) |
755 unfolding IN_def EMPTY_def |
760 unfolding IN_def EMPTY_def |
756 apply (rule_tac mem_respects) |
761 apply (rule_tac mem_respects) |
757 apply (simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
762 apply (simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
758 apply (simp_all) |
763 apply (simp_all) |
759 apply (rule list_eq_sym) |
764 apply (rule list_eq_sym) |
760 done |
765 done |
761 |
766 |
762 thm length_append (* Not true but worth checking that the goal is correct *) |
767 thm length_append (* Not true but worth checking that the goal is correct *) |
763 ML {* |
768 ML {* |
764 val m1_novars = snd(no_vars ((Context.Theory @{theory}),@{thm length_append})) |
769 val m1_novars = snd(no_vars ((Context.Theory @{theory}),@{thm length_append})) |
765 val goal = build_goal m1_novars consts @{typ "'a list"} mk_rep_abs |
770 val goal = build_goal m1_novars consts @{typ "'a list"} mk_rep_abs |
766 val cgoal = cterm_of @{theory} goal |
771 val cgoal = cterm_of @{theory} goal |
767 val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite false [emptyt, in_t, cardt, uniont] cgoal) |
772 val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite false [emptyt, in_t, cardt, uniont] cgoal) |
768 *} |
773 *} |
|
774 (*prove {* HOLogic.mk_Trueprop (Thm.term_of cgoal2) *} |
|
775 unfolding CARD_def UNION_def |
|
776 apply(rule_tac f="(op =)" in arg_cong2)*) |
769 |
777 |
770 thm m2 |
778 thm m2 |
771 ML {* |
779 ML {* |
772 val m1_novars = snd(no_vars ((Context.Theory @{theory}),@{thm m2})) |
780 val m1_novars = snd(no_vars ((Context.Theory @{theory}),@{thm m2})) |
773 val goal = build_goal m1_novars consts @{typ "'a list"} mk_rep_abs |
781 val goal = build_goal m1_novars consts @{typ "'a list"} mk_rep_abs |
781 unfolding INSERT_def |
789 unfolding INSERT_def |
782 apply (simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
790 apply (simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
783 apply (rule cons_preserves) |
791 apply (rule cons_preserves) |
784 apply (simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
792 apply (simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
785 apply (rule list_eq_sym) |
793 apply (rule list_eq_sym) |
786 apply(rule_tac f="(op \<or>)" in arg_cong2) |
794 apply (rule_tac f="(op \<or>)" in arg_cong2) |
787 apply (simp) |
795 apply (simp) |
788 apply (rule_tac mem_respects) |
796 apply (rule_tac mem_respects) |
789 apply (simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
797 apply (simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
790 apply (rule list_eq_sym) |
798 apply (rule list_eq_sym) |
791 done |
799 done |
|
800 |
|
801 notation ( output) "prop" ("#_" [1000] 1000) |
|
802 |
|
803 ML {* @{thm arg_cong2} *} |
|
804 ML {* rtac *} |
|
805 ML {* Term.dest_Const @{term "op ="} *} |
|
806 |
|
807 ML {* |
|
808 fun dest_cbinop t = |
|
809 let |
|
810 val (t2, rhs) = Thm.dest_comb t; |
|
811 val (bop, lhs) = Thm.dest_comb t2; |
|
812 in |
|
813 (bop, (lhs, rhs)) |
|
814 end |
|
815 *} |
|
816 ML {* |
|
817 fun dest_ceq t = |
|
818 let |
|
819 val (bop, pair) = dest_cbinop t; |
|
820 val (bop_s, _) = Term.dest_Const (Thm.term_of bop); |
|
821 in |
|
822 if bop_s = "op =" then pair else (raise CTERM ("Not an equality", [t])) |
|
823 end |
|
824 *} |
|
825 ML {* |
|
826 fun foo_conv ctxt t = |
|
827 let |
|
828 val (lhs, rhs) = dest_ceq t; |
|
829 val (bop, _) = dest_cbinop lhs; |
|
830 (* val _ = tracing (Syntax.string_of_term ctxt (Thm.term_of lhs))*) |
|
831 in |
|
832 @{thm arg_cong2} |
|
833 end |
|
834 *} |
|
835 ML {* |
|
836 fun foo_tac ctxt thm = |
|
837 let |
|
838 val concl = Thm.concl_of thm; |
|
839 val (_, cconcl) = Thm.dest_comb (Thm.cterm_of @{theory} concl); |
|
840 val (_, cconcl) = Thm.dest_comb cconcl; |
|
841 val rewr = foo_conv ctxt cconcl; |
|
842 val _ = tracing (Syntax.string_of_term ctxt (Thm.term_of cconcl)) |
|
843 in |
|
844 Seq.single thm |
|
845 end |
|
846 *} |
|
847 ML {* Thm.assume @{cprop "0 = 0"} *} |
|
848 |
|
849 prove {* HOLogic.mk_Trueprop (Thm.term_of cgoal2) *} |
|
850 apply (tactic {* foo_tac @{context} *}) |
|
851 |
|
852 (* |
|
853 datatype obj1 = |
|
854 OVAR1 "string" |
|
855 | OBJ1 "(string * (string \<Rightarrow> obj1)) list" |
|
856 | INVOKE1 "obj1 \<Rightarrow> string" |
|
857 | UPDATE1 "obj1 \<Rightarrow> string \<Rightarrow> (string \<Rightarrow> obj1)" |
|
858 *) |