src/HOL/SMT_Examples/SMT_Tests.thy
changeset 57214 c4986877deea
parent 57168 af95a414136a
child 57232 8cecd655eef4
equal deleted inserted replaced
57213:9daec42f6784 57214:c4986877deea
   728   sorry
   728   sorry
   729 
   729 
   730 
   730 
   731 subsubsection {* Type definitions *}
   731 subsubsection {* Type definitions *}
   732 
   732 
   733 definition "three = {1, 2, 3::int}"
   733 typedef int' = "UNIV::int set" by (rule UNIV_witness)
   734 
   734 
   735 typedef three = three
   735 definition n0 where "n0 = Abs_int' 0"
   736   unfolding three_def by auto
   736 definition n1 where "n1 = Abs_int' 1"
   737 
   737 definition n2 where "n2 = Abs_int' 2"
   738 definition n1 where "n1 = Abs_three 1"
   738 definition plus' where "plus' n m = Abs_int' (Rep_int' n + Rep_int' m)"
   739 definition n2 where "n2 = Abs_three 2"
   739 
   740 definition n3 where "n3 = Abs_three 3"
   740 lemma
   741 definition nplus where "nplus n m = Abs_three (Rep_three n + Rep_three m)"
   741   "n0 \<noteq> n1"
   742 
   742   "plus' n1 n1 = n2"
   743 lemma three_def': "(n \<in> three) = (n = 1 \<or> n = 2 \<or> n = 3)"
   743   "plus' n0 n2 = n2"
   744   by (auto simp add: three_def)
   744   by (smt2 n0_def n1_def n2_def plus'_def Abs_int'_inverse Rep_int'_inverse UNIV_I)+
   745 
       
   746 lemma
       
   747   "n1 = n1"
       
   748   "n2 = n2"
       
   749   "n1 \<noteq> n2"
       
   750   "nplus n1 n1 = n2"
       
   751   "nplus n1 n2 = n3"
       
   752   using n1_def n2_def n3_def nplus_def
       
   753   using three_def' Rep_three Abs_three_inverse
       
   754   by smt2+
       
   755 
   745 
   756 
   746 
   757 subsection {* With support by the SMT solver (but without proofs) *}
   747 subsection {* With support by the SMT solver (but without proofs) *}
   758 
   748 
   759 subsubsection {* Algebraic datatypes *}
   749 subsubsection {* Algebraic datatypes *}
   871 
   861 
   872 
   862 
   873 subsubsection {* Type definitions *}
   863 subsubsection {* Type definitions *}
   874 
   864 
   875 lemma
   865 lemma
   876   "n1 = n1"
   866   "n0 \<noteq> n1"
   877   "n2 = n2"
   867   "plus' n1 n1 = n2"
   878   "n1 \<noteq> n2"
   868   "plus' n0 n2 = n2"
   879   "nplus n1 n1 = n2"
       
   880   "nplus n1 n2 = n3"
       
   881   using n1_def n2_def n3_def nplus_def
       
   882   using [[smt2_oracle, z3_new_extensions]]
   869   using [[smt2_oracle, z3_new_extensions]]
   883   by smt2+
   870   by (smt2 n0_def n1_def n2_def plus'_def)+
   884 
   871 
   885 
   872 
   886 section {* Function updates *}
   873 section {* Function updates *}
   887 
   874 
   888 lemma
   875 lemma