391 lemma "x * y \<le> (0 :: int) \<Longrightarrow> x \<le> 0 \<or> y \<le> 0" |
391 lemma "x * y \<le> (0 :: int) \<Longrightarrow> x \<le> 0 \<or> y \<le> 0" |
392 using [[z3_with_extensions]] [[z3_new_extensions]] |
392 using [[z3_with_extensions]] [[z3_new_extensions]] |
393 by smt (* smt2 FIXME: "th-lemma" tactic fails *) |
393 by smt (* smt2 FIXME: "th-lemma" tactic fails *) |
394 |
394 |
395 |
395 |
396 subsection {* Linear arithmetic for natural numbers *} |
|
397 |
|
398 lemma "2 * (x::nat) ~= 1" by smt2 |
|
399 |
|
400 lemma "a < 3 \<Longrightarrow> (7::nat) > 2 * a" by smt2 |
|
401 |
|
402 lemma "let x = (1::nat) + y in x - y > 0 * x" by smt2 |
|
403 |
|
404 lemma |
|
405 "let x = (1::nat) + y in |
|
406 let P = (if x > 0 then True else False) in |
|
407 False \<or> P = (x - 1 = y) \<or> (\<not>P \<longrightarrow> False)" |
|
408 by smt2 |
|
409 |
|
410 lemma "int (nat \<bar>x::int\<bar>) = \<bar>x\<bar>" by smt2 |
|
411 |
|
412 definition prime_nat :: "nat \<Rightarrow> bool" where |
|
413 "prime_nat p = (1 < p \<and> (\<forall>m. m dvd p --> m = 1 \<or> m = p))" |
|
414 lemma "prime_nat (4*m + 1) \<Longrightarrow> m \<ge> (1::nat)" by (smt2 prime_nat_def) |
|
415 |
|
416 |
|
417 section {* Pairs *} |
396 section {* Pairs *} |
418 |
397 |
419 lemma "fst (x, y) = a \<Longrightarrow> x = a" |
398 lemma "fst (x, y) = a \<Longrightarrow> x = a" |
420 using fst_conv by smt2 |
399 using fst_conv by smt2 |
421 |
400 |
442 "f (\<forall>x. g x) \<Longrightarrow> True" |
421 "f (\<forall>x. g x) \<Longrightarrow> True" |
443 by smt2+ |
422 by smt2+ |
444 |
423 |
445 lemma True using let_rsp by smt2 |
424 lemma True using let_rsp by smt2 |
446 lemma "le = op \<le> \<Longrightarrow> le (3::int) 42" by smt2 |
425 lemma "le = op \<le> \<Longrightarrow> le (3::int) 42" by smt2 |
447 lemma "map (\<lambda>i::nat. i + 1) [0, 1] = [1, 2]" by (smt2 list.map) |
426 lemma "map (\<lambda>i::int. i + 1) [0, 1] = [1, 2]" by (smt2 list.map) |
448 lemma "(ALL x. P x) \<or> ~ All P" by smt2 |
427 lemma "(ALL x. P x) \<or> ~ All P" by smt2 |
449 |
428 |
450 fun dec_10 :: "nat \<Rightarrow> nat" where |
429 fun dec_10 :: "int \<Rightarrow> int" where |
451 "dec_10 n = (if n < 10 then n else dec_10 (n - 10))" |
430 "dec_10 n = (if n < 10 then n else dec_10 (n - 10))" |
452 |
431 |
453 lemma "dec_10 (4 * dec_10 4) = 6" by (smt2 dec_10.simps) |
432 lemma "dec_10 (4 * dec_10 4) = 6" by (smt2 dec_10.simps) |
454 |
433 |
455 axiomatization |
434 axiomatization |
456 eval_dioph :: "int list \<Rightarrow> nat list \<Rightarrow> int" |
435 eval_dioph :: "int list \<Rightarrow> int list \<Rightarrow> int" |
457 where |
436 where |
458 eval_dioph_mod: |
437 eval_dioph_mod: "eval_dioph ks xs mod n = eval_dioph ks (map (\<lambda>x. x mod n) xs) mod n" |
459 "eval_dioph ks xs mod int n = eval_dioph ks (map (\<lambda>x. x mod n) xs) mod int n" |
|
460 and |
438 and |
461 eval_dioph_div_mult: |
439 eval_dioph_div_mult: |
462 "eval_dioph ks (map (\<lambda>x. x div n) xs) * int n + |
440 "eval_dioph ks (map (\<lambda>x. x div n) xs) * n + |
463 eval_dioph ks (map (\<lambda>x. x mod n) xs) = eval_dioph ks xs" |
441 eval_dioph ks (map (\<lambda>x. x mod n) xs) = eval_dioph ks xs" |
464 |
442 |
465 lemma |
443 lemma |
466 "(eval_dioph ks xs = l) = |
444 "(eval_dioph ks xs = l) = |
467 (eval_dioph ks (map (\<lambda>x. x mod 2) xs) mod 2 = l mod 2 \<and> |
445 (eval_dioph ks (map (\<lambda>x. x mod 2) xs) mod 2 = l mod 2 \<and> |
468 eval_dioph ks (map (\<lambda>x. x div 2) xs) = |
446 eval_dioph ks (map (\<lambda>x. x div 2) xs) = (l - eval_dioph ks (map (\<lambda>x. x mod 2) xs)) div 2)" |
469 (l - eval_dioph ks (map (\<lambda>x. x mod 2) xs)) div 2)" |
447 using [[smt2_oracle = true]] (*FIXME*) |
470 using [[smt2_oracle=true]] (*FIXME*) |
|
471 using [[z3_new_extensions]] |
448 using [[z3_new_extensions]] |
472 by (smt2 eval_dioph_mod[where n=2] eval_dioph_div_mult[where n=2]) |
449 by (smt2 eval_dioph_mod[where n=2] eval_dioph_div_mult[where n=2]) |
473 |
450 |
474 |
451 |
475 context complete_lattice |
452 context complete_lattice |