src/HOL/SMT_Examples/SMT_Tests.thy
changeset 57696 fb71c6f100f8
parent 57232 8cecd655eef4
child 57994 68b283f9f826
equal deleted inserted replaced
57695:987c9ceeaafd 57696:fb71c6f100f8
   221   "(p \<or> q) \<and> \<not> p \<Longrightarrow> q"
   221   "(p \<or> q) \<and> \<not> p \<Longrightarrow> q"
   222   "(a \<and> b) \<or> (c \<and> d) \<Longrightarrow> (a \<and> b) \<or> (c \<and> d)"
   222   "(a \<and> b) \<or> (c \<and> d) \<Longrightarrow> (a \<and> b) \<or> (c \<and> d)"
   223   by smt2+
   223   by smt2+
   224 
   224 
   225 
   225 
   226 section {* Natural numbers *}
       
   227 
       
   228 lemma
       
   229   "(0::nat) = 0"
       
   230   "(1::nat) = 1"
       
   231   "(0::nat) < 1"
       
   232   "(0::nat) \<le> 1"
       
   233   "(123456789::nat) < 2345678901"
       
   234   by smt2+
       
   235 
       
   236 lemma
       
   237   "Suc 0 = 1"
       
   238   "Suc x = x + 1"
       
   239   "x < Suc x"
       
   240   "(Suc x = Suc y) = (x = y)"
       
   241   "Suc (x + y) < Suc x + Suc y"
       
   242   by smt2+
       
   243 
       
   244 lemma
       
   245   "(x::nat) + 0 = x"
       
   246   "0 + x = x"
       
   247   "x + y = y + x"
       
   248   "x + (y + z) = (x + y) + z"
       
   249   "(x + y = 0) = (x = 0 \<and> y = 0)"
       
   250   by smt2+
       
   251 
       
   252 lemma
       
   253   "(x::nat) - 0 = x"
       
   254   "x < y \<longrightarrow> x - y = 0"
       
   255   "x - y = 0 \<or> y - x = 0"
       
   256   "(x - y) + y = (if x < y then y else x)"
       
   257   "x - y - z = x - (y + z)"
       
   258   by smt2+
       
   259 
       
   260 lemma
       
   261   "(x::nat) * 0 = 0"
       
   262   "0 * x = 0"
       
   263   "x * 1 = x"
       
   264   "1 * x = x"
       
   265   "3 * x = x * 3"
       
   266   by smt2+
       
   267 
       
   268 lemma
       
   269   "(0::nat) div 0 = 0"
       
   270   "(x::nat) div 0 = 0"
       
   271   "(0::nat) div 1 = 0"
       
   272   "(1::nat) div 1 = 1"
       
   273   "(3::nat) div 1 = 3"
       
   274   "(x::nat) div 1 = x"
       
   275   "(0::nat) div 3 = 0"
       
   276   "(1::nat) div 3 = 0"
       
   277   "(3::nat) div 3 = 1"
       
   278   "(x::nat) div 3 \<le> x"
       
   279   "(x div 3 = x) = (x = 0)"
       
   280   using [[z3_new_extensions]]
       
   281   by smt2+
       
   282 
       
   283 lemma
       
   284   "(0::nat) mod 0 = 0"
       
   285   "(x::nat) mod 0 = x"
       
   286   "(0::nat) mod 1 = 0"
       
   287   "(1::nat) mod 1 = 0"
       
   288   "(3::nat) mod 1 = 0"
       
   289   "(x::nat) mod 1 = 0"
       
   290   "(0::nat) mod 3 = 0"
       
   291   "(1::nat) mod 3 = 1"
       
   292   "(3::nat) mod 3 = 0"
       
   293   "x mod 3 < 3"
       
   294   "(x mod 3 = x) = (x < 3)"
       
   295   using [[z3_new_extensions]]
       
   296   by smt2+
       
   297 
       
   298 lemma
       
   299   "(x::nat) = x div 1 * 1 + x mod 1"
       
   300   "x = x div 3 * 3 + x mod 3"
       
   301   using [[z3_new_extensions]]
       
   302   by smt2+
       
   303 
       
   304 lemma
       
   305   "min (x::nat) y \<le> x"
       
   306   "min x y \<le> y"
       
   307   "min x y \<le> x + y"
       
   308   "z < x \<and> z < y \<longrightarrow> z < min x y"
       
   309   "min x y = min y x"
       
   310   "min x 0 = 0"
       
   311   by smt2+
       
   312 
       
   313 lemma
       
   314   "max (x::nat) y \<ge> x"
       
   315   "max x y \<ge> y"
       
   316   "max x y \<ge> (x - y) + (y - x)"
       
   317   "z > x \<and> z > y \<longrightarrow> z > max x y"
       
   318   "max x y = max y x"
       
   319   "max x 0 = x"
       
   320   by smt2+
       
   321 
       
   322 lemma
       
   323   "0 \<le> (x::nat)"
       
   324   "0 < x \<and> x \<le> 1 \<longrightarrow> x = 1"
       
   325   "x \<le> x"
       
   326   "x \<le> y \<longrightarrow> 3 * x \<le> 3 * y"
       
   327   "x < y \<longrightarrow> 3 * x < 3 * y"
       
   328   "x < y \<longrightarrow> x \<le> y"
       
   329   "(x < y) = (x + 1 \<le> y)"
       
   330   "\<not> (x < x)"
       
   331   "x \<le> y \<longrightarrow> y \<le> z \<longrightarrow> x \<le> z"
       
   332   "x < y \<longrightarrow> y \<le> z \<longrightarrow> x \<le> z"
       
   333   "x \<le> y \<longrightarrow> y < z \<longrightarrow> x \<le> z"
       
   334   "x < y \<longrightarrow> y < z \<longrightarrow> x < z"
       
   335   "x < y \<and> y < z \<longrightarrow> \<not> (z < x)"
       
   336   by smt2+
       
   337 
       
   338 
       
   339 section {* Integers *}
   226 section {* Integers *}
   340 
   227 
   341 lemma
   228 lemma
   342   "(0::int) = 0"
   229   "(0::int) = 0"
   343   "(0::int) = (- 0)"
   230   "(0::int) = (- 0)"