| author | wenzelm | 
| Tue, 25 Aug 2020 13:44:09 +0200 | |
| changeset 72204 | cb746b19e1d7 | 
| parent 69605 | a96320074298 | 
| permissions | -rw-r--r-- | 
| 36899 
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
 boehmes parents: 
36898diff
changeset | 1 | (* Title: HOL/SMT_Examples/SMT_Examples.thy | 
| 36898 | 2 | Author: Sascha Boehme, TU Muenchen | 
| 3 | *) | |
| 4 | ||
| 63167 | 5 | section \<open>Examples for the SMT binding\<close> | 
| 36898 | 6 | |
| 7 | theory SMT_Examples | |
| 36899 
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
 boehmes parents: 
36898diff
changeset | 8 | imports Complex_Main | 
| 36898 | 9 | begin | 
| 10 | ||
| 69605 | 11 | external_file \<open>SMT_Examples.certs\<close> | 
| 58367 
8af1e68d7e1a
renamed SMT certificate files, following 'SMT2' -> 'SMT' renaming
 blanchet parents: 
58061diff
changeset | 12 | declare [[smt_certificates = "SMT_Examples.certs"]] | 
| 58061 | 13 | declare [[smt_read_only_certificates = true]] | 
| 36898 | 14 | |
| 15 | ||
| 63167 | 16 | section \<open>Propositional and first-order logic\<close> | 
| 36898 | 17 | |
| 58061 | 18 | lemma "True" by smt | 
| 19 | lemma "p \<or> \<not>p" by smt | |
| 20 | lemma "(p \<and> True) = p" by smt | |
| 21 | lemma "(p \<or> q) \<and> \<not>p \<Longrightarrow> q" by smt | |
| 22 | lemma "(a \<and> b) \<or> (c \<and> d) \<Longrightarrow> (a \<and> b) \<or> (c \<and> d)" by smt | |
| 23 | lemma "(p1 \<and> p2) \<or> p3 \<longrightarrow> (p1 \<longrightarrow> (p3 \<and> p2) \<or> (p1 \<and> p3)) \<or> p1" by smt | |
| 24 | lemma "P = P = P = P = P = P = P = P = P = P" by smt | |
| 36898 | 25 | |
| 46084 
dd7fb9e651ad
regenerate SMT example certificates, to reflect "set" type constructor
 blanchet parents: 
45972diff
changeset | 26 | lemma | 
| 56079 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 27 | assumes "a \<or> b \<or> c \<or> d" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 28 | and "e \<or> f \<or> (a \<and> d)" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 29 | and "\<not> (a \<or> (c \<and> ~c)) \<or> b" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 30 | and "\<not> (b \<and> (x \<or> \<not> x)) \<or> c" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 31 | and "\<not> (d \<or> False) \<or> c" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 32 | and "\<not> (c \<or> (\<not> p \<and> (p \<or> (q \<and> \<not> q))))" | 
| 36898 | 33 | shows False | 
| 58061 | 34 | using assms by smt | 
| 36898 | 35 | |
| 36 | axiomatization symm_f :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" where | |
| 37 | symm_f: "symm_f x y = symm_f y x" | |
| 56109 | 38 | |
| 66740 | 39 | lemma "a = a \<and> symm_f a b = symm_f b a" | 
| 40 | by (smt symm_f) | |
| 36898 | 41 | |
| 46084 
dd7fb9e651ad
regenerate SMT example certificates, to reflect "set" type constructor
 blanchet parents: 
45972diff
changeset | 42 | (* | 
| 36898 | 43 | Taken from ~~/src/HOL/ex/SAT_Examples.thy. | 
| 44 | Translated from TPTP problem library: PUZ015-2.006.dimacs | |
| 45 | *) | |
| 46084 
dd7fb9e651ad
regenerate SMT example certificates, to reflect "set" type constructor
 blanchet parents: 
45972diff
changeset | 46 | lemma | 
| 36898 | 47 | assumes "~x0" | 
| 48 | and "~x30" | |
| 49 | and "~x29" | |
| 50 | and "~x59" | |
| 56079 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 51 | and "x1 \<or> x31 \<or> x0" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 52 | and "x2 \<or> x32 \<or> x1" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 53 | and "x3 \<or> x33 \<or> x2" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 54 | and "x4 \<or> x34 \<or> x3" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 55 | and "x35 \<or> x4" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 56 | and "x5 \<or> x36 \<or> x30" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 57 | and "x6 \<or> x37 \<or> x5 \<or> x31" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 58 | and "x7 \<or> x38 \<or> x6 \<or> x32" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 59 | and "x8 \<or> x39 \<or> x7 \<or> x33" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 60 | and "x9 \<or> x40 \<or> x8 \<or> x34" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 61 | and "x41 \<or> x9 \<or> x35" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 62 | and "x10 \<or> x42 \<or> x36" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 63 | and "x11 \<or> x43 \<or> x10 \<or> x37" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 64 | and "x12 \<or> x44 \<or> x11 \<or> x38" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 65 | and "x13 \<or> x45 \<or> x12 \<or> x39" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 66 | and "x14 \<or> x46 \<or> x13 \<or> x40" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 67 | and "x47 \<or> x14 \<or> x41" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 68 | and "x15 \<or> x48 \<or> x42" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 69 | and "x16 \<or> x49 \<or> x15 \<or> x43" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 70 | and "x17 \<or> x50 \<or> x16 \<or> x44" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 71 | and "x18 \<or> x51 \<or> x17 \<or> x45" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 72 | and "x19 \<or> x52 \<or> x18 \<or> x46" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 73 | and "x53 \<or> x19 \<or> x47" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 74 | and "x20 \<or> x54 \<or> x48" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 75 | and "x21 \<or> x55 \<or> x20 \<or> x49" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 76 | and "x22 \<or> x56 \<or> x21 \<or> x50" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 77 | and "x23 \<or> x57 \<or> x22 \<or> x51" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 78 | and "x24 \<or> x58 \<or> x23 \<or> x52" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 79 | and "x59 \<or> x24 \<or> x53" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 80 | and "x25 \<or> x54" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 81 | and "x26 \<or> x25 \<or> x55" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 82 | and "x27 \<or> x26 \<or> x56" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 83 | and "x28 \<or> x27 \<or> x57" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 84 | and "x29 \<or> x28 \<or> x58" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 85 | and "~x1 \<or> ~x31" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 86 | and "~x1 \<or> ~x0" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 87 | and "~x31 \<or> ~x0" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 88 | and "~x2 \<or> ~x32" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 89 | and "~x2 \<or> ~x1" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 90 | and "~x32 \<or> ~x1" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 91 | and "~x3 \<or> ~x33" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 92 | and "~x3 \<or> ~x2" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 93 | and "~x33 \<or> ~x2" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 94 | and "~x4 \<or> ~x34" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 95 | and "~x4 \<or> ~x3" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 96 | and "~x34 \<or> ~x3" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 97 | and "~x35 \<or> ~x4" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 98 | and "~x5 \<or> ~x36" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 99 | and "~x5 \<or> ~x30" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 100 | and "~x36 \<or> ~x30" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 101 | and "~x6 \<or> ~x37" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 102 | and "~x6 \<or> ~x5" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 103 | and "~x6 \<or> ~x31" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 104 | and "~x37 \<or> ~x5" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 105 | and "~x37 \<or> ~x31" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 106 | and "~x5 \<or> ~x31" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 107 | and "~x7 \<or> ~x38" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 108 | and "~x7 \<or> ~x6" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 109 | and "~x7 \<or> ~x32" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 110 | and "~x38 \<or> ~x6" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 111 | and "~x38 \<or> ~x32" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 112 | and "~x6 \<or> ~x32" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 113 | and "~x8 \<or> ~x39" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 114 | and "~x8 \<or> ~x7" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 115 | and "~x8 \<or> ~x33" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 116 | and "~x39 \<or> ~x7" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 117 | and "~x39 \<or> ~x33" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 118 | and "~x7 \<or> ~x33" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 119 | and "~x9 \<or> ~x40" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 120 | and "~x9 \<or> ~x8" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 121 | and "~x9 \<or> ~x34" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 122 | and "~x40 \<or> ~x8" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 123 | and "~x40 \<or> ~x34" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 124 | and "~x8 \<or> ~x34" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 125 | and "~x41 \<or> ~x9" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 126 | and "~x41 \<or> ~x35" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 127 | and "~x9 \<or> ~x35" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 128 | and "~x10 \<or> ~x42" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 129 | and "~x10 \<or> ~x36" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 130 | and "~x42 \<or> ~x36" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 131 | and "~x11 \<or> ~x43" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 132 | and "~x11 \<or> ~x10" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 133 | and "~x11 \<or> ~x37" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 134 | and "~x43 \<or> ~x10" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 135 | and "~x43 \<or> ~x37" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 136 | and "~x10 \<or> ~x37" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 137 | and "~x12 \<or> ~x44" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 138 | and "~x12 \<or> ~x11" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 139 | and "~x12 \<or> ~x38" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 140 | and "~x44 \<or> ~x11" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 141 | and "~x44 \<or> ~x38" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 142 | and "~x11 \<or> ~x38" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 143 | and "~x13 \<or> ~x45" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 144 | and "~x13 \<or> ~x12" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 145 | and "~x13 \<or> ~x39" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 146 | and "~x45 \<or> ~x12" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 147 | and "~x45 \<or> ~x39" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 148 | and "~x12 \<or> ~x39" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 149 | and "~x14 \<or> ~x46" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 150 | and "~x14 \<or> ~x13" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 151 | and "~x14 \<or> ~x40" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 152 | and "~x46 \<or> ~x13" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 153 | and "~x46 \<or> ~x40" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 154 | and "~x13 \<or> ~x40" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 155 | and "~x47 \<or> ~x14" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 156 | and "~x47 \<or> ~x41" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 157 | and "~x14 \<or> ~x41" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 158 | and "~x15 \<or> ~x48" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 159 | and "~x15 \<or> ~x42" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 160 | and "~x48 \<or> ~x42" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 161 | and "~x16 \<or> ~x49" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 162 | and "~x16 \<or> ~x15" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 163 | and "~x16 \<or> ~x43" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 164 | and "~x49 \<or> ~x15" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 165 | and "~x49 \<or> ~x43" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 166 | and "~x15 \<or> ~x43" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 167 | and "~x17 \<or> ~x50" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 168 | and "~x17 \<or> ~x16" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 169 | and "~x17 \<or> ~x44" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 170 | and "~x50 \<or> ~x16" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 171 | and "~x50 \<or> ~x44" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 172 | and "~x16 \<or> ~x44" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 173 | and "~x18 \<or> ~x51" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 174 | and "~x18 \<or> ~x17" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 175 | and "~x18 \<or> ~x45" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 176 | and "~x51 \<or> ~x17" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 177 | and "~x51 \<or> ~x45" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 178 | and "~x17 \<or> ~x45" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 179 | and "~x19 \<or> ~x52" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 180 | and "~x19 \<or> ~x18" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 181 | and "~x19 \<or> ~x46" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 182 | and "~x52 \<or> ~x18" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 183 | and "~x52 \<or> ~x46" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 184 | and "~x18 \<or> ~x46" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 185 | and "~x53 \<or> ~x19" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 186 | and "~x53 \<or> ~x47" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 187 | and "~x19 \<or> ~x47" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 188 | and "~x20 \<or> ~x54" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 189 | and "~x20 \<or> ~x48" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 190 | and "~x54 \<or> ~x48" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 191 | and "~x21 \<or> ~x55" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 192 | and "~x21 \<or> ~x20" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 193 | and "~x21 \<or> ~x49" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 194 | and "~x55 \<or> ~x20" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 195 | and "~x55 \<or> ~x49" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 196 | and "~x20 \<or> ~x49" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 197 | and "~x22 \<or> ~x56" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 198 | and "~x22 \<or> ~x21" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 199 | and "~x22 \<or> ~x50" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 200 | and "~x56 \<or> ~x21" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 201 | and "~x56 \<or> ~x50" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 202 | and "~x21 \<or> ~x50" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 203 | and "~x23 \<or> ~x57" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 204 | and "~x23 \<or> ~x22" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 205 | and "~x23 \<or> ~x51" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 206 | and "~x57 \<or> ~x22" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 207 | and "~x57 \<or> ~x51" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 208 | and "~x22 \<or> ~x51" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 209 | and "~x24 \<or> ~x58" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 210 | and "~x24 \<or> ~x23" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 211 | and "~x24 \<or> ~x52" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 212 | and "~x58 \<or> ~x23" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 213 | and "~x58 \<or> ~x52" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 214 | and "~x23 \<or> ~x52" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 215 | and "~x59 \<or> ~x24" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 216 | and "~x59 \<or> ~x53" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 217 | and "~x24 \<or> ~x53" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 218 | and "~x25 \<or> ~x54" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 219 | and "~x26 \<or> ~x25" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 220 | and "~x26 \<or> ~x55" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 221 | and "~x25 \<or> ~x55" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 222 | and "~x27 \<or> ~x26" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 223 | and "~x27 \<or> ~x56" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 224 | and "~x26 \<or> ~x56" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 225 | and "~x28 \<or> ~x27" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 226 | and "~x28 \<or> ~x57" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 227 | and "~x27 \<or> ~x57" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 228 | and "~x29 \<or> ~x28" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 229 | and "~x29 \<or> ~x58" | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 230 | and "~x28 \<or> ~x58" | 
| 36898 | 231 | shows False | 
| 58061 | 232 | using assms by smt | 
| 36898 | 233 | |
| 234 | lemma "\<forall>x::int. P x \<longrightarrow> (\<forall>y::int. P x \<or> P y)" | |
| 58061 | 235 | by smt | 
| 36898 | 236 | |
| 46084 
dd7fb9e651ad
regenerate SMT example certificates, to reflect "set" type constructor
 blanchet parents: 
45972diff
changeset | 237 | lemma | 
| 36898 | 238 | assumes "(\<forall>x y. P x y = x)" | 
| 239 | shows "(\<exists>y. P x y) = P x c" | |
| 58061 | 240 | using assms by smt | 
| 36898 | 241 | |
| 46084 
dd7fb9e651ad
regenerate SMT example certificates, to reflect "set" type constructor
 blanchet parents: 
45972diff
changeset | 242 | lemma | 
| 36898 | 243 | assumes "(\<forall>x y. P x y = x)" | 
| 244 | and "(\<forall>x. \<exists>y. P x y) = (\<forall>x. P x c)" | |
| 67613 | 245 | shows "(\<exists>y. P x y) = P x c" | 
| 58061 | 246 | using assms by smt | 
| 36898 | 247 | |
| 248 | lemma | |
| 249 | assumes "if P x then \<not>(\<exists>y. P y) else (\<forall>y. \<not>P y)" | |
| 250 | shows "P x \<longrightarrow> P y" | |
| 58061 | 251 | using assms by smt | 
| 36898 | 252 | |
| 253 | ||
| 63167 | 254 | section \<open>Arithmetic\<close> | 
| 36898 | 255 | |
| 63167 | 256 | subsection \<open>Linear arithmetic over integers and reals\<close> | 
| 36898 | 257 | |
| 58061 | 258 | lemma "(3::int) = 3" by smt | 
| 259 | lemma "(3::real) = 3" by smt | |
| 260 | lemma "(3 :: int) + 1 = 4" by smt | |
| 261 | lemma "x + (y + z) = y + (z + (x::int))" by smt | |
| 262 | lemma "max (3::int) 8 > 5" by smt | |
| 61945 | 263 | lemma "\<bar>x :: real\<bar> + \<bar>y\<bar> \<ge> \<bar>x + y\<bar>" by smt | 
| 58061 | 264 | lemma "P ((2::int) < 3) = P True" by smt | 
| 265 | lemma "x + 3 \<ge> 4 \<or> x < (1::int)" by smt | |
| 36898 | 266 | |
| 267 | lemma | |
| 268 | assumes "x \<ge> (3::int)" and "y = x + 4" | |
| 46084 
dd7fb9e651ad
regenerate SMT example certificates, to reflect "set" type constructor
 blanchet parents: 
45972diff
changeset | 269 | shows "y - x > 0" | 
| 58061 | 270 | using assms by smt | 
| 36898 | 271 | |
| 58061 | 272 | lemma "let x = (2 :: int) in x + x \<noteq> 5" by smt | 
| 36898 | 273 | |
| 274 | lemma | |
| 275 | fixes x :: real | |
| 276 | assumes "3 * x + 7 * a < 4" and "3 < 2 * x" | |
| 277 | shows "a < 0" | |
| 58061 | 278 | using assms by smt | 
| 36898 | 279 | |
| 58061 | 280 | lemma "(0 \<le> y + -1 * x \<or> \<not> 0 \<le> x \<or> 0 \<le> (x::int)) = (\<not> False)" by smt | 
| 36898 | 281 | |
| 282 | lemma " | |
| 56079 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 283 | (n < m \<and> m < n') \<or> (n < m \<and> m = n') \<or> (n < n' \<and> n' < m) \<or> | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 284 | (n = n' \<and> n' < m) \<or> (n = m \<and> m < n') \<or> | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 285 | (n' < m \<and> m < n) \<or> (n' < m \<and> m = n) \<or> | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 286 | (n' < n \<and> n < m) \<or> (n' = n \<and> n < m) \<or> (n' = m \<and> m < n) \<or> | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 287 | (m < n \<and> n < n') \<or> (m < n \<and> n' = n) \<or> (m < n' \<and> n' < n) \<or> | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 288 | (m = n \<and> n < n') \<or> (m = n' \<and> n' < n) \<or> | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 289 | (n' = m \<and> m = (n::int))" | 
| 58061 | 290 | by smt | 
| 36898 | 291 | |
| 63167 | 292 | text\<open> | 
| 36898 | 293 | The following example was taken from HOL/ex/PresburgerEx.thy, where it says: | 
| 294 | ||
| 295 | This following theorem proves that all solutions to the | |
| 296 |   recurrence relation $x_{i+2} = |x_{i+1}| - x_i$ are periodic with
 | |
| 297 | period 9. The example was brought to our attention by John | |
| 298 | Harrison. It does does not require Presburger arithmetic but merely | |
| 299 | quantifier-free linear arithmetic and holds for the rationals as well. | |
| 300 | ||
| 46084 
dd7fb9e651ad
regenerate SMT example certificates, to reflect "set" type constructor
 blanchet parents: 
45972diff
changeset | 301 | Warning: it takes (in 2006) over 4.2 minutes! | 
| 36898 | 302 | |
| 303 | There, it is proved by "arith". SMT is able to prove this within a fraction | |
| 304 | of one second. With proof reconstruction, it takes about 13 seconds on a Core2 | |
| 305 | processor. | |
| 63167 | 306 | \<close> | 
| 36898 | 307 | |
| 61945 | 308 | lemma "\<lbrakk> x3 = \<bar>x2\<bar> - x1; x4 = \<bar>x3\<bar> - x2; x5 = \<bar>x4\<bar> - x3; | 
| 309 | x6 = \<bar>x5\<bar> - x4; x7 = \<bar>x6\<bar> - x5; x8 = \<bar>x7\<bar> - x6; | |
| 310 | x9 = \<bar>x8\<bar> - x7; x10 = \<bar>x9\<bar> - x8; x11 = \<bar>x10\<bar> - x9 \<rbrakk> | |
| 56079 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 311 | \<Longrightarrow> x1 = x10 \<and> x2 = (x11::int)" | 
| 58061 | 312 | by smt | 
| 36898 | 313 | |
| 314 | ||
| 58061 | 315 | lemma "let P = 2 * x + 1 > x + (x::real) in P \<or> False \<or> P" by smt | 
| 36898 | 316 | |
| 48069 
e9b2782c4f99
restricted Z3 by default to a fragment where proof reconstruction should not fail (for better integration with Sledgehammer) -- the full set of supported Z3 features can still be used by enabling the configuration option "z3_with_extensions"
 boehmes parents: 
47155diff
changeset | 317 | lemma "x + (let y = x mod 2 in 2 * y + 1) \<ge> x + (1::int)" | 
| 58061 | 318 | using [[z3_extensions]] by smt | 
| 36898 | 319 | |
| 48069 
e9b2782c4f99
restricted Z3 by default to a fragment where proof reconstruction should not fail (for better integration with Sledgehammer) -- the full set of supported Z3 features can still be used by enabling the configuration option "z3_with_extensions"
 boehmes parents: 
47155diff
changeset | 320 | lemma "x + (let y = x mod 2 in y + y) < x + (3::int)" | 
| 58061 | 321 | using [[z3_extensions]] by smt | 
| 36898 | 322 | |
| 323 | lemma | |
| 324 | assumes "x \<noteq> (0::real)" | |
| 61945 | 325 | shows "x + x \<noteq> (let P = (\<bar>x\<bar> > 1) in if P \<or> \<not> P then 4 else 2) * x" | 
| 58061 | 326 | using assms [[z3_extensions]] by smt | 
| 36898 | 327 | |
| 328 | ||
| 63167 | 329 | subsection \<open>Linear arithmetic with quantifiers\<close> | 
| 36898 | 330 | |
| 58061 | 331 | lemma "~ (\<exists>x::int. False)" by smt | 
| 332 | lemma "~ (\<exists>x::real. False)" by smt | |
| 36898 | 333 | |
| 58061 | 334 | lemma "\<exists>x::int. 0 < x" by smt | 
| 36898 | 335 | |
| 336 | lemma "\<exists>x::real. 0 < x" | |
| 58061 | 337 | using [[smt_oracle=true]] (* no Z3 proof *) | 
| 338 | by smt | |
| 36898 | 339 | |
| 58061 | 340 | lemma "\<forall>x::int. \<exists>y. y > x" by smt | 
| 36898 | 341 | |
| 58061 | 342 | lemma "\<forall>x y::int. (x = 0 \<and> y = 1) \<longrightarrow> x \<noteq> y" by smt | 
| 343 | lemma "\<exists>x::int. \<forall>y. x < y \<longrightarrow> y < 0 \<or> y >= 0" by smt | |
| 344 | lemma "\<forall>x y::int. x < y \<longrightarrow> (2 * x + 1) < (2 * y)" by smt | |
| 345 | lemma "\<forall>x y::int. (2 * x + 1) \<noteq> (2 * y)" by smt | |
| 346 | lemma "\<forall>x y::int. x + y > 2 \<or> x + y = 2 \<or> x + y < 2" by smt | |
| 347 | lemma "\<forall>x::int. if x > 0 then x + 1 > 0 else 1 > x" by smt | |
| 67613 | 348 | lemma "if (\<forall>x::int. x < 0 \<or> x > 0) then False else True" by smt | 
| 349 | lemma "(if (\<forall>x::int. x < 0 \<or> x > 0) then -1 else 3) > (0::int)" by smt | |
| 58061 | 350 | lemma "~ (\<exists>x y z::int. 4 * x + -6 * y = (1::int))" by smt | 
| 351 | lemma "\<exists>x::int. \<forall>x y. 0 < x \<and> 0 < y \<longrightarrow> (0::int) < x + y" by smt | |
| 352 | lemma "\<exists>u::int. \<forall>(x::int) y::real. 0 < x \<and> 0 < y \<longrightarrow> -1 < x" by smt | |
| 353 | lemma "\<exists>x::int. (\<forall>y. y \<ge> x \<longrightarrow> y > 0) \<longrightarrow> x > 0" by smt | |
| 354 | lemma "\<forall>(a::int) b::int. 0 < b \<or> b < 1" by smt | |
| 42318 
0fd33b6b22cf
corrected order of steps in Z3 proof reconstruction for elimination of unused quantified variables: first try to eliminate unused variables, then skip over used variables
 boehmes parents: 
41786diff
changeset | 355 | |
| 36898 | 356 | |
| 63167 | 357 | subsection \<open>Non-linear arithmetic over integers and reals\<close> | 
| 36898 | 358 | |
| 359 | lemma "a > (0::int) \<Longrightarrow> a*b > 0 \<Longrightarrow> b > 0" | |
| 58061 | 360 | using [[smt_oracle, z3_extensions]] | 
| 361 | by smt | |
| 36899 
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
 boehmes parents: 
36898diff
changeset | 362 | |
| 41282 | 363 | lemma "(a::int) * (x + 1 + y) = a * x + a * (y + 1)" | 
| 58061 | 364 | using [[z3_extensions]] | 
| 365 | by smt | |
| 36898 | 366 | |
| 41282 | 367 | lemma "((x::real) * (1 + y) - x * (1 - y)) = (2 * x * y)" | 
| 58061 | 368 | using [[z3_extensions]] | 
| 369 | by smt | |
| 36898 | 370 | |
| 371 | lemma | |
| 372 | "(U::int) + (1 + p) * (b + e) + p * d = | |
| 373 | U + (2 * (1 + p) * (b + e) + (1 + p) * d + d * p) - (1 + p) * (b + d + e)" | |
| 58061 | 374 | using [[z3_extensions]] by smt | 
| 36898 | 375 | |
| 58061 | 376 | lemma [z3_rule]: | 
| 43893 
f3e75541cb78
allow rules with premises to be declared as z3_rule (to circumvent incompleteness of Z3 proof reconstruction)
 boehmes parents: 
42321diff
changeset | 377 | fixes x :: "int" | 
| 
f3e75541cb78
allow rules with premises to be declared as z3_rule (to circumvent incompleteness of Z3 proof reconstruction)
 boehmes parents: 
42321diff
changeset | 378 | assumes "x * y \<le> 0" and "\<not> y \<le> 0" and "\<not> x \<le> 0" | 
| 
f3e75541cb78
allow rules with premises to be declared as z3_rule (to circumvent incompleteness of Z3 proof reconstruction)
 boehmes parents: 
42321diff
changeset | 379 | shows False | 
| 
f3e75541cb78
allow rules with premises to be declared as z3_rule (to circumvent incompleteness of Z3 proof reconstruction)
 boehmes parents: 
42321diff
changeset | 380 | using assms by (metis mult_le_0_iff) | 
| 
f3e75541cb78
allow rules with premises to be declared as z3_rule (to circumvent incompleteness of Z3 proof reconstruction)
 boehmes parents: 
42321diff
changeset | 381 | |
| 36898 | 382 | |
| 67226 | 383 | subsection \<open>Linear arithmetic for natural numbers\<close> | 
| 66298 | 384 | |
| 385 | declare [[smt_nat_as_int]] | |
| 386 | ||
| 387 | lemma "2 * (x::nat) \<noteq> 1" by smt | |
| 388 | ||
| 389 | lemma "a < 3 \<Longrightarrow> (7::nat) > 2 * a" by smt | |
| 390 | ||
| 391 | lemma "let x = (1::nat) + y in x - y > 0 * x" by smt | |
| 392 | ||
| 393 | lemma | |
| 394 | "let x = (1::nat) + y in | |
| 395 | let P = (if x > 0 then True else False) in | |
| 396 | False \<or> P = (x - 1 = y) \<or> (\<not>P \<longrightarrow> False)" | |
| 397 | by smt | |
| 398 | ||
| 67972 
959b0aed2ce5
avoid adding unnecessary quantified lemmas when embedding natural number terms into integer terms: quantified lemmas can cause Z3 to produce complex proofs that are hard to replay in Isabelle
 boehmes parents: 
67613diff
changeset | 399 | lemma "int (nat \<bar>x::int\<bar>) = \<bar>x\<bar>" by (smt int_nat_eq) | 
| 66298 | 400 | |
| 401 | definition prime_nat :: "nat \<Rightarrow> bool" where | |
| 402 | "prime_nat p = (1 < p \<and> (\<forall>m. m dvd p --> m = 1 \<or> m = p))" | |
| 403 | ||
| 404 | lemma "prime_nat (4*m + 1) \<Longrightarrow> m \<ge> (1::nat)" by (smt prime_nat_def) | |
| 405 | ||
| 406 | declare [[smt_nat_as_int = false]] | |
| 407 | ||
| 408 | ||
| 63167 | 409 | section \<open>Pairs\<close> | 
| 36898 | 410 | |
| 41132 | 411 | lemma "fst (x, y) = a \<Longrightarrow> x = a" | 
| 58061 | 412 | using fst_conv by smt | 
| 36898 | 413 | |
| 41132 | 414 | lemma "p1 = (x, y) \<and> p2 = (y, x) \<Longrightarrow> fst p1 = snd p2" | 
| 58061 | 415 | using fst_conv snd_conv by smt | 
| 36898 | 416 | |
| 417 | ||
| 63167 | 418 | section \<open>Higher-order problems and recursion\<close> | 
| 36898 | 419 | |
| 41132 | 420 | lemma "i \<noteq> i1 \<and> i \<noteq> i2 \<Longrightarrow> (f (i1 := v1, i2 := v2)) i = f i" | 
| 58061 | 421 | using fun_upd_same fun_upd_apply by smt | 
| 36898 | 422 | |
| 423 | lemma "(f g (x::'a::type) = (g x \<and> True)) \<or> (f g x = True) \<or> (g x = True)" | |
| 58061 | 424 | by smt | 
| 36898 | 425 | |
| 56109 | 426 | lemma "id x = x \<and> id True = True" | 
| 58061 | 427 | by (smt id_def) | 
| 36898 | 428 | |
| 41132 | 429 | lemma "i \<noteq> i1 \<and> i \<noteq> i2 \<Longrightarrow> ((f (i1 := v1)) (i2 := v2)) i = f i" | 
| 58061 | 430 | using fun_upd_same fun_upd_apply by smt | 
| 36898 | 431 | |
| 41786 
a5899d0ce1a1
added test cases with quantifier occurring in first-order term positions
 boehmes parents: 
41601diff
changeset | 432 | lemma | 
| 
a5899d0ce1a1
added test cases with quantifier occurring in first-order term positions
 boehmes parents: 
41601diff
changeset | 433 | "f (\<exists>x. g x) \<Longrightarrow> True" | 
| 
a5899d0ce1a1
added test cases with quantifier occurring in first-order term positions
 boehmes parents: 
41601diff
changeset | 434 | "f (\<forall>x. g x) \<Longrightarrow> True" | 
| 58061 | 435 | by smt+ | 
| 36899 
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
 boehmes parents: 
36898diff
changeset | 436 | |
| 58061 | 437 | lemma True using let_rsp by smt | 
| 67399 | 438 | lemma "le = (\<le>) \<Longrightarrow> le (3::int) 42" by smt | 
| 58061 | 439 | lemma "map (\<lambda>i::int. i + 1) [0, 1] = [1, 2]" by (smt list.map) | 
| 67613 | 440 | lemma "(\<forall>x. P x) \<or> \<not> All P" by smt | 
| 36898 | 441 | |
| 57696 
fb71c6f100f8
do not embed 'nat' into 'int's in 'smt2' method -- this is highly inefficient and decreases the Sledgehammer success rate significantly
 blanchet parents: 
57232diff
changeset | 442 | fun dec_10 :: "int \<Rightarrow> int" where | 
| 36898 | 443 | "dec_10 n = (if n < 10 then n else dec_10 (n - 10))" | 
| 56109 | 444 | |
| 58061 | 445 | lemma "dec_10 (4 * dec_10 4) = 6" by (smt dec_10.simps) | 
| 36898 | 446 | |
| 447 | axiomatization | |
| 57696 
fb71c6f100f8
do not embed 'nat' into 'int's in 'smt2' method -- this is highly inefficient and decreases the Sledgehammer success rate significantly
 blanchet parents: 
57232diff
changeset | 448 | eval_dioph :: "int list \<Rightarrow> int list \<Rightarrow> int" | 
| 56109 | 449 | where | 
| 57696 
fb71c6f100f8
do not embed 'nat' into 'int's in 'smt2' method -- this is highly inefficient and decreases the Sledgehammer success rate significantly
 blanchet parents: 
57232diff
changeset | 450 | eval_dioph_mod: "eval_dioph ks xs mod n = eval_dioph ks (map (\<lambda>x. x mod n) xs) mod n" | 
| 56109 | 451 | and | 
| 36898 | 452 | eval_dioph_div_mult: | 
| 57696 
fb71c6f100f8
do not embed 'nat' into 'int's in 'smt2' method -- this is highly inefficient and decreases the Sledgehammer success rate significantly
 blanchet parents: 
57232diff
changeset | 453 | "eval_dioph ks (map (\<lambda>x. x div n) xs) * n + | 
| 36898 | 454 | eval_dioph ks (map (\<lambda>x. x mod n) xs) = eval_dioph ks xs" | 
| 56109 | 455 | |
| 36898 | 456 | lemma | 
| 457 | "(eval_dioph ks xs = l) = | |
| 458 | (eval_dioph ks (map (\<lambda>x. x mod 2) xs) mod 2 = l mod 2 \<and> | |
| 57696 
fb71c6f100f8
do not embed 'nat' into 'int's in 'smt2' method -- this is highly inefficient and decreases the Sledgehammer success rate significantly
 blanchet parents: 
57232diff
changeset | 459 | eval_dioph ks (map (\<lambda>x. x div 2) xs) = (l - eval_dioph ks (map (\<lambda>x. x mod 2) xs)) div 2)" | 
| 58061 | 460 | using [[smt_oracle = true]] (*FIXME*) | 
| 461 | using [[z3_extensions]] | |
| 462 | by (smt eval_dioph_mod[where n=2] eval_dioph_div_mult[where n=2]) | |
| 36898 | 463 | |
| 464 | ||
| 45393 
13ab80eafd71
try different alternatives in discharging extra assumptions when schematic theorems obtained from lambda-lifting can be instantiated in different ways
 boehmes parents: 
43893diff
changeset | 465 | context complete_lattice | 
| 
13ab80eafd71
try different alternatives in discharging extra assumptions when schematic theorems obtained from lambda-lifting can be instantiated in different ways
 boehmes parents: 
43893diff
changeset | 466 | begin | 
| 
13ab80eafd71
try different alternatives in discharging extra assumptions when schematic theorems obtained from lambda-lifting can be instantiated in different ways
 boehmes parents: 
43893diff
changeset | 467 | |
| 46084 
dd7fb9e651ad
regenerate SMT example certificates, to reflect "set" type constructor
 blanchet parents: 
45972diff
changeset | 468 | lemma | 
| 56079 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 469 |   assumes "Sup {a | i::bool. True} \<le> Sup {b | i::bool. True}"
 | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 470 |   and "Sup {b | i::bool. True} \<le> Sup {a | i::bool. True}"
 | 
| 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 471 |   shows "Sup {a | i::bool. True} \<le> Sup {a | i::bool. True}"
 | 
| 58061 | 472 | using assms by (smt order_trans) | 
| 45393 
13ab80eafd71
try different alternatives in discharging extra assumptions when schematic theorems obtained from lambda-lifting can be instantiated in different ways
 boehmes parents: 
43893diff
changeset | 473 | |
| 
13ab80eafd71
try different alternatives in discharging extra assumptions when schematic theorems obtained from lambda-lifting can be instantiated in different ways
 boehmes parents: 
43893diff
changeset | 474 | end | 
| 
13ab80eafd71
try different alternatives in discharging extra assumptions when schematic theorems obtained from lambda-lifting can be instantiated in different ways
 boehmes parents: 
43893diff
changeset | 475 | |
| 
13ab80eafd71
try different alternatives in discharging extra assumptions when schematic theorems obtained from lambda-lifting can be instantiated in different ways
 boehmes parents: 
43893diff
changeset | 476 | |
| 63167 | 477 | section \<open>Monomorphization examples\<close> | 
| 36898 | 478 | |
| 66740 | 479 | definition Pred :: "'a \<Rightarrow> bool" where | 
| 480 | "Pred x = True" | |
| 56079 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 481 | |
| 66740 | 482 | lemma poly_Pred: "Pred x \<and> (Pred [x] \<or> \<not> Pred [x])" | 
| 483 | by (simp add: Pred_def) | |
| 56109 | 484 | |
| 66740 | 485 | lemma "Pred (1::int)" | 
| 486 | by (smt poly_Pred) | |
| 36898 | 487 | |
| 36899 
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
 boehmes parents: 
36898diff
changeset | 488 | axiomatization g :: "'a \<Rightarrow> nat" | 
| 
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
 boehmes parents: 
36898diff
changeset | 489 | axiomatization where | 
| 
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
 boehmes parents: 
36898diff
changeset | 490 | g1: "g (Some x) = g [x]" and | 
| 
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
 boehmes parents: 
36898diff
changeset | 491 | g2: "g None = g []" and | 
| 36898 | 492 | g3: "g xs = length xs" | 
| 56079 
175ac95720d4
use 'smt2' in SMT examples as much as currently possible
 blanchet parents: 
55465diff
changeset | 493 | |
| 58061 | 494 | lemma "g (Some (3::int)) = g (Some True)" by (smt g1 g2 g3 list.size) | 
| 36898 | 495 | |
| 496 | end |