| author | wenzelm | 
| Fri, 30 Jun 2023 14:56:38 +0200 | |
| changeset 78232 | 45c7b88d1609 | 
| parent 78177 | ea7a3cc64df5 | 
| child 78936 | ddf255a4ccc3 | 
| permissions | -rw-r--r-- | 
| 58061 | 1 | (* Title: HOL/SMT.thy | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 2 | Author: Sascha Boehme, TU Muenchen | 
| 66551 | 3 | Author: Jasmin Blanchette, VU Amsterdam | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 4 | *) | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 5 | |
| 61626 | 6 | section \<open>Bindings to Satisfiability Modulo Theories (SMT) solvers based on SMT-LIB 2\<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 7 | |
| 58061 | 8 | theory SMT | 
| 72458 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 9 | imports Divides Numeral_Simprocs | 
| 66551 | 10 | keywords "smt_status" :: diag | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 11 | begin | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 12 | |
| 60758 | 13 | subsection \<open>A skolemization tactic and proof method\<close> | 
| 58481 | 14 | |
| 15 | lemma choices: | |
| 16 | "\<And>Q. \<forall>x. \<exists>y ya. Q x y ya \<Longrightarrow> \<exists>f fa. \<forall>x. Q x (f x) (fa x)" | |
| 17 | "\<And>Q. \<forall>x. \<exists>y ya yb. Q x y ya yb \<Longrightarrow> \<exists>f fa fb. \<forall>x. Q x (f x) (fa x) (fb x)" | |
| 18 | "\<And>Q. \<forall>x. \<exists>y ya yb yc. Q x y ya yb yc \<Longrightarrow> \<exists>f fa fb fc. \<forall>x. Q x (f x) (fa x) (fb x) (fc x)" | |
| 58598 | 19 | "\<And>Q. \<forall>x. \<exists>y ya yb yc yd. Q x y ya yb yc yd \<Longrightarrow> | 
| 20 | \<exists>f fa fb fc fd. \<forall>x. Q x (f x) (fa x) (fb x) (fc x) (fd x)" | |
| 21 | "\<And>Q. \<forall>x. \<exists>y ya yb yc yd ye. Q x y ya yb yc yd ye \<Longrightarrow> | |
| 22 | \<exists>f fa fb fc fd fe. \<forall>x. Q x (f x) (fa x) (fb x) (fc x) (fd x) (fe x)" | |
| 23 | "\<And>Q. \<forall>x. \<exists>y ya yb yc yd ye yf. Q x y ya yb yc yd ye yf \<Longrightarrow> | |
| 24 | \<exists>f fa fb fc fd fe ff. \<forall>x. Q x (f x) (fa x) (fb x) (fc x) (fd x) (fe x) (ff x)" | |
| 25 | "\<And>Q. \<forall>x. \<exists>y ya yb yc yd ye yf yg. Q x y ya yb yc yd ye yf yg \<Longrightarrow> | |
| 26 | \<exists>f fa fb fc fd fe ff fg. \<forall>x. Q x (f x) (fa x) (fb x) (fc x) (fd x) (fe x) (ff x) (fg x)" | |
| 58481 | 27 | by metis+ | 
| 28 | ||
| 29 | lemma bchoices: | |
| 30 | "\<And>Q. \<forall>x \<in> S. \<exists>y ya. Q x y ya \<Longrightarrow> \<exists>f fa. \<forall>x \<in> S. Q x (f x) (fa x)" | |
| 31 | "\<And>Q. \<forall>x \<in> S. \<exists>y ya yb. Q x y ya yb \<Longrightarrow> \<exists>f fa fb. \<forall>x \<in> S. Q x (f x) (fa x) (fb x)" | |
| 32 | "\<And>Q. \<forall>x \<in> S. \<exists>y ya yb yc. Q x y ya yb yc \<Longrightarrow> \<exists>f fa fb fc. \<forall>x \<in> S. Q x (f x) (fa x) (fb x) (fc x)" | |
| 58598 | 33 | "\<And>Q. \<forall>x \<in> S. \<exists>y ya yb yc yd. Q x y ya yb yc yd \<Longrightarrow> | 
| 34 | \<exists>f fa fb fc fd. \<forall>x \<in> S. Q x (f x) (fa x) (fb x) (fc x) (fd x)" | |
| 35 | "\<And>Q. \<forall>x \<in> S. \<exists>y ya yb yc yd ye. Q x y ya yb yc yd ye \<Longrightarrow> | |
| 36 | \<exists>f fa fb fc fd fe. \<forall>x \<in> S. Q x (f x) (fa x) (fb x) (fc x) (fd x) (fe x)" | |
| 37 | "\<And>Q. \<forall>x \<in> S. \<exists>y ya yb yc yd ye yf. Q x y ya yb yc yd ye yf \<Longrightarrow> | |
| 38 | \<exists>f fa fb fc fd fe ff. \<forall>x \<in> S. Q x (f x) (fa x) (fb x) (fc x) (fd x) (fe x) (ff x)" | |
| 39 | "\<And>Q. \<forall>x \<in> S. \<exists>y ya yb yc yd ye yf yg. Q x y ya yb yc yd ye yf yg \<Longrightarrow> | |
| 40 | \<exists>f fa fb fc fd fe ff fg. \<forall>x \<in> S. Q x (f x) (fa x) (fb x) (fc x) (fd x) (fe x) (ff x) (fg x)" | |
| 58481 | 41 | by metis+ | 
| 42 | ||
| 60758 | 43 | ML \<open> | 
| 58481 | 44 | fun moura_tac ctxt = | 
| 45 | Atomize_Elim.atomize_elim_tac ctxt THEN' | |
| 46 |   SELECT_GOAL (Clasimp.auto_tac (ctxt addSIs @{thms choice choices bchoice bchoices}) THEN
 | |
| 58598 | 47 | ALLGOALS (Metis_Tactic.metis_tac (take 1 ATP_Proof_Reconstruct.partial_type_encs) | 
| 48 | ATP_Proof_Reconstruct.default_metis_lam_trans ctxt [] ORELSE' | |
| 49 | blast_tac ctxt)) | |
| 60758 | 50 | \<close> | 
| 58481 | 51 | |
| 60758 | 52 | method_setup moura = \<open> | 
| 60201 | 53 | Scan.succeed (SIMPLE_METHOD' o moura_tac) | 
| 60758 | 54 | \<close> "solve skolemization goals, especially those arising from Z3 proofs" | 
| 58481 | 55 | |
| 56 | hide_fact (open) choices bchoices | |
| 57 | ||
| 58 | ||
| 60758 | 59 | subsection \<open>Triggers for quantifier instantiation\<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 60 | |
| 60758 | 61 | text \<open> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 62 | Some SMT solvers support patterns as a quantifier instantiation | 
| 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: 
57246diff
changeset | 63 | heuristics. Patterns may either be positive terms (tagged by "pat") | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 64 | triggering quantifier instantiations -- when the solver finds a | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 65 | term matching a positive pattern, it instantiates the corresponding | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 66 | quantifier accordingly -- or negative terms (tagged by "nopat") | 
| 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: 
57246diff
changeset | 67 | inhibiting quantifier instantiations. A list of patterns | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 68 | of the same kind is called a multipattern, and all patterns in a | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 69 | multipattern are considered conjunctively for quantifier instantiation. | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 70 | A list of multipatterns is called a trigger, and their multipatterns | 
| 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: 
57246diff
changeset | 71 | act disjunctively during quantifier instantiation. Each multipattern | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 72 | should mention at least all quantified variables of the preceding | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 73 | quantifier block. | 
| 60758 | 74 | \<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 75 | |
| 57230 | 76 | typedecl 'a symb_list | 
| 77 | ||
| 78 | consts | |
| 79 | Symb_Nil :: "'a symb_list" | |
| 80 | Symb_Cons :: "'a \<Rightarrow> 'a symb_list \<Rightarrow> 'a symb_list" | |
| 81 | ||
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 82 | typedecl pattern | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 83 | |
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 84 | consts | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 85 | pat :: "'a \<Rightarrow> pattern" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 86 | nopat :: "'a \<Rightarrow> pattern" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 87 | |
| 57230 | 88 | definition trigger :: "pattern symb_list symb_list \<Rightarrow> bool \<Rightarrow> bool" where | 
| 89 | "trigger _ P = P" | |
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 90 | |
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 91 | |
| 60758 | 92 | subsection \<open>Higher-order encoding\<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 93 | |
| 60758 | 94 | text \<open> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 95 | Application is made explicit for constants occurring with varying | 
| 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: 
57246diff
changeset | 96 | numbers of arguments. This is achieved by the introduction of the | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 97 | following constant. | 
| 60758 | 98 | \<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 99 | |
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 100 | definition fun_app :: "'a \<Rightarrow> 'a" where "fun_app f = f" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 101 | |
| 60758 | 102 | text \<open> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 103 | Some solvers support a theory of arrays which can be used to encode | 
| 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: 
57246diff
changeset | 104 | higher-order functions. The following set of lemmas specifies the | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 105 | properties of such (extensional) arrays. | 
| 60758 | 106 | \<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 107 | |
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 108 | lemmas array_rules = ext fun_upd_apply fun_upd_same fun_upd_other fun_upd_upd fun_app_def | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 109 | |
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 110 | |
| 60758 | 111 | subsection \<open>Normalization\<close> | 
| 56103 
6689512f3710
move lemmas to theory file, towards textual proof reconstruction
 blanchet parents: 
56102diff
changeset | 112 | |
| 
6689512f3710
move lemmas to theory file, towards textual proof reconstruction
 blanchet parents: 
56102diff
changeset | 113 | lemma case_bool_if[abs_def]: "case_bool x y P = (if P then x else y)" | 
| 
6689512f3710
move lemmas to theory file, towards textual proof reconstruction
 blanchet parents: 
56102diff
changeset | 114 | by simp | 
| 
6689512f3710
move lemmas to theory file, towards textual proof reconstruction
 blanchet parents: 
56102diff
changeset | 115 | |
| 
6689512f3710
move lemmas to theory file, towards textual proof reconstruction
 blanchet parents: 
56102diff
changeset | 116 | lemmas Ex1_def_raw = Ex1_def[abs_def] | 
| 
6689512f3710
move lemmas to theory file, towards textual proof reconstruction
 blanchet parents: 
56102diff
changeset | 117 | lemmas Ball_def_raw = Ball_def[abs_def] | 
| 
6689512f3710
move lemmas to theory file, towards textual proof reconstruction
 blanchet parents: 
56102diff
changeset | 118 | lemmas Bex_def_raw = Bex_def[abs_def] | 
| 
6689512f3710
move lemmas to theory file, towards textual proof reconstruction
 blanchet parents: 
56102diff
changeset | 119 | lemmas abs_if_raw = abs_if[abs_def] | 
| 
6689512f3710
move lemmas to theory file, towards textual proof reconstruction
 blanchet parents: 
56102diff
changeset | 120 | lemmas min_def_raw = min_def[abs_def] | 
| 
6689512f3710
move lemmas to theory file, towards textual proof reconstruction
 blanchet parents: 
56102diff
changeset | 121 | lemmas max_def_raw = max_def[abs_def] | 
| 
6689512f3710
move lemmas to theory file, towards textual proof reconstruction
 blanchet parents: 
56102diff
changeset | 122 | |
| 66817 | 123 | lemma nat_zero_as_int: | 
| 124 | "0 = nat 0" | |
| 125 | by simp | |
| 126 | ||
| 127 | lemma nat_one_as_int: | |
| 128 | "1 = nat 1" | |
| 129 | by simp | |
| 130 | ||
| 66298 | 131 | lemma nat_numeral_as_int: "numeral = (\<lambda>i. nat (numeral i))" by simp | 
| 67399 | 132 | lemma nat_less_as_int: "(<) = (\<lambda>a b. int a < int b)" by simp | 
| 133 | lemma nat_leq_as_int: "(\<le>) = (\<lambda>a b. int a \<le> int b)" by simp | |
| 66298 | 134 | lemma Suc_as_int: "Suc = (\<lambda>a. nat (int a + 1))" by (rule ext) simp | 
| 67399 | 135 | lemma nat_plus_as_int: "(+) = (\<lambda>a b. nat (int a + int b))" by (rule ext)+ simp | 
| 136 | lemma nat_minus_as_int: "(-) = (\<lambda>a b. nat (int a - int b))" by (rule ext)+ simp | |
| 69064 
5840724b1d71
Prefix form of infix with * on either side no longer needs special treatment
 nipkow parents: 
67972diff
changeset | 137 | lemma nat_times_as_int: "(*) = (\<lambda>a b. nat (int a * int b))" by (simp add: nat_mult_distrib) | 
| 67399 | 138 | lemma nat_div_as_int: "(div) = (\<lambda>a b. nat (int a div int b))" by (simp add: nat_div_distrib) | 
| 139 | lemma nat_mod_as_int: "(mod) = (\<lambda>a b. nat (int a mod int b))" by (simp add: nat_mod_distrib) | |
| 66298 | 140 | |
| 141 | lemma int_Suc: "int (Suc n) = int n + 1" by simp | |
| 142 | lemma int_plus: "int (n + m) = int n + int m" by (rule of_nat_add) | |
| 143 | lemma int_minus: "int (n - m) = int (nat (int n - int m))" by auto | |
| 144 | ||
| 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: 
67399diff
changeset | 145 | lemma nat_int_comparison: | 
| 
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: 
67399diff
changeset | 146 | fixes a b :: nat | 
| 
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: 
67399diff
changeset | 147 | shows "(a = b) = (int a = int b)" | 
| 
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: 
67399diff
changeset | 148 | and "(a < b) = (int a < int b)" | 
| 
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: 
67399diff
changeset | 149 | and "(a \<le> b) = (int a \<le> int b)" | 
| 
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: 
67399diff
changeset | 150 | by simp_all | 
| 
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: 
67399diff
changeset | 151 | |
| 
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: 
67399diff
changeset | 152 | lemma int_ops: | 
| 
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: 
67399diff
changeset | 153 | fixes a b :: nat | 
| 
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: 
67399diff
changeset | 154 | shows "int 0 = 0" | 
| 
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: 
67399diff
changeset | 155 | and "int 1 = 1" | 
| 
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: 
67399diff
changeset | 156 | and "int (numeral n) = numeral n" | 
| 
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: 
67399diff
changeset | 157 | and "int (Suc a) = int a + 1" | 
| 
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: 
67399diff
changeset | 158 | and "int (a + b) = int a + int b" | 
| 
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: 
67399diff
changeset | 159 | and "int (a - b) = (if int a < int b then 0 else int a - int b)" | 
| 
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: 
67399diff
changeset | 160 | and "int (a * b) = int a * int b" | 
| 
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: 
67399diff
changeset | 161 | and "int (a div b) = int a div int b" | 
| 
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: 
67399diff
changeset | 162 | and "int (a mod b) = int a mod int b" | 
| 
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: 
67399diff
changeset | 163 | by (auto intro: zdiv_int zmod_int) | 
| 
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: 
67399diff
changeset | 164 | |
| 
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: 
67399diff
changeset | 165 | lemma int_if: | 
| 
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: 
67399diff
changeset | 166 | fixes a b :: nat | 
| 
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: 
67399diff
changeset | 167 | shows "int (if P then a else b) = (if P then int a else int b)" | 
| 
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: 
67399diff
changeset | 168 | by simp | 
| 
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: 
67399diff
changeset | 169 | |
| 56103 
6689512f3710
move lemmas to theory file, towards textual proof reconstruction
 blanchet parents: 
56102diff
changeset | 170 | |
| 60758 | 171 | subsection \<open>Integer division and modulo for Z3\<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 172 | |
| 60758 | 173 | text \<open> | 
| 61799 | 174 | The following Z3-inspired definitions are overspecified for the case where \<open>l = 0\<close>. This | 
| 175 | Schönheitsfehler is corrected in the \<open>div_as_z3div\<close> and \<open>mod_as_z3mod\<close> theorems. | |
| 60758 | 176 | \<close> | 
| 56102 | 177 | |
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 178 | definition z3div :: "int \<Rightarrow> int \<Rightarrow> int" where | 
| 56102 | 179 | "z3div k l = (if l \<ge> 0 then k div l else - (k div - l))" | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 180 | |
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 181 | definition z3mod :: "int \<Rightarrow> int \<Rightarrow> int" where | 
| 56102 | 182 | "z3mod k l = k mod (if l \<ge> 0 then l else - l)" | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 183 | |
| 56101 | 184 | lemma div_as_z3div: | 
| 56102 | 185 | "\<forall>k l. k div l = (if l = 0 then 0 else if l > 0 then z3div k l else z3div (- k) (- l))" | 
| 56101 | 186 | by (simp add: z3div_def) | 
| 187 | ||
| 188 | lemma mod_as_z3mod: | |
| 56102 | 189 | "\<forall>k l. k mod l = (if l = 0 then k else if l > 0 then z3mod k l else - z3mod (- k) (- l))" | 
| 56101 | 190 | by (simp add: z3mod_def) | 
| 191 | ||
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 192 | |
| 69205 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 193 | subsection \<open>Extra theorems for veriT reconstruction\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 194 | |
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 195 | lemma verit_sko_forall: \<open>(\<forall>x. P x) \<longleftrightarrow> P (SOME x. \<not>P x)\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 196 | using someI[of \<open>\<lambda>x. \<not>P x\<close>] | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 197 | by auto | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 198 | |
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 199 | lemma verit_sko_forall': \<open>P (SOME x. \<not>P x) = A \<Longrightarrow> (\<forall>x. P x) = A\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 200 | by (subst verit_sko_forall) | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 201 | |
| 72458 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 202 | lemma verit_sko_forall'': \<open>B = A \<Longrightarrow> (SOME x. P x) = A \<equiv> (SOME x. P x) = B\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 203 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 204 | |
| 69205 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 205 | lemma verit_sko_forall_indirect: \<open>x = (SOME x. \<not>P x) \<Longrightarrow> (\<forall>x. P x) \<longleftrightarrow> P x\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 206 | using someI[of \<open>\<lambda>x. \<not>P x\<close>] | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 207 | by auto | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 208 | |
| 72458 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 209 | lemma verit_sko_forall_indirect2: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 210 | \<open>x = (SOME x. \<not>P x) \<Longrightarrow> (\<And>x :: 'a. (P x = P' x)) \<Longrightarrow>(\<forall>x. P' x) \<longleftrightarrow> P x\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 211 | using someI[of \<open>\<lambda>x. \<not>P x\<close>] | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 212 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 213 | |
| 69205 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 214 | lemma verit_sko_ex: \<open>(\<exists>x. P x) \<longleftrightarrow> P (SOME x. P x)\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 215 | using someI[of \<open>\<lambda>x. P x\<close>] | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 216 | by auto | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 217 | |
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 218 | lemma verit_sko_ex': \<open>P (SOME x. P x) = A \<Longrightarrow> (\<exists>x. P x) = A\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 219 | by (subst verit_sko_ex) | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 220 | |
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 221 | lemma verit_sko_ex_indirect: \<open>x = (SOME x. P x) \<Longrightarrow> (\<exists>x. P x) \<longleftrightarrow> P x\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 222 | using someI[of \<open>\<lambda>x. P x\<close>] | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 223 | by auto | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 224 | |
| 72458 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 225 | lemma verit_sko_ex_indirect2: \<open>x = (SOME x. P x) \<Longrightarrow> (\<And>x. P x = P' x) \<Longrightarrow> (\<exists>x. P' x) \<longleftrightarrow> P x\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 226 | using someI[of \<open>\<lambda>x. P x\<close>] | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 227 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 228 | |
| 69205 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 229 | lemma verit_Pure_trans: | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 230 | \<open>P \<equiv> Q \<Longrightarrow> Q \<Longrightarrow> P\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 231 | by auto | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 232 | |
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 233 | lemma verit_if_cong: | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 234 | assumes \<open>b \<equiv> c\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 235 | and \<open>c \<Longrightarrow> x \<equiv> u\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 236 | and \<open>\<not> c \<Longrightarrow> y \<equiv> v\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 237 | shows \<open>(if b then x else y) \<equiv> (if c then u else v)\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 238 | using assms if_cong[of b c x u] by auto | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 239 | |
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 240 | lemma verit_if_weak_cong': | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 241 | \<open>b \<equiv> c \<Longrightarrow> (if b then x else y) \<equiv> (if c then x else y)\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 242 | by auto | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 243 | |
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 244 | lemma verit_or_neg: | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 245 | \<open>(A \<Longrightarrow> B) \<Longrightarrow> B \<or> \<not>A\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 246 | \<open>(\<not>A \<Longrightarrow> B) \<Longrightarrow> B \<or> A\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 247 | by auto | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 248 | |
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 249 | lemma verit_subst_bool: \<open>P \<Longrightarrow> f True \<Longrightarrow> f P\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 250 | by auto | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 251 | |
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 252 | lemma verit_and_pos: | 
| 72513 
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72458diff
changeset | 253 | \<open>(a \<Longrightarrow> \<not>(b \<and> c) \<or> A) \<Longrightarrow> \<not>(a \<and> b \<and> c) \<or> A\<close> | 
| 
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72458diff
changeset | 254 | \<open>(a \<Longrightarrow> b \<Longrightarrow> A) \<Longrightarrow> \<not>(a \<and> b) \<or> A\<close> | 
| 69205 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 255 | \<open>(a \<Longrightarrow> A) \<Longrightarrow> \<not>a \<or> A\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 256 | \<open>(\<not>a \<Longrightarrow> A) \<Longrightarrow> a \<or> A\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 257 | by blast+ | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 258 | |
| 72458 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 259 | lemma verit_or_pos: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 260 | \<open>A \<and> A' \<Longrightarrow> (c \<and> A) \<or> (\<not>c \<and> A')\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 261 | \<open>A \<and> A' \<Longrightarrow> (\<not>c \<and> A) \<or> (c \<and> A')\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 262 | by blast+ | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 263 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 264 | |
| 69205 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 265 | lemma verit_la_generic: | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 266 | \<open>(a::int) \<le> x \<or> a = x \<or> a \<ge> x\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 267 | by linarith | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 268 | |
| 72458 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 269 | lemma verit_bfun_elim: | 
| 69205 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 270 | \<open>(if b then P True else P False) = P b\<close> | 
| 72458 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 271 | \<open>(\<forall>b. P' b) = (P' False \<and> P' True)\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 272 | \<open>(\<exists>b. P' b) = (P' False \<or> P' True)\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 273 | by (cases b) (auto simp: all_bool_eq ex_bool_eq) | 
| 69205 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 274 | |
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 275 | lemma verit_eq_true_simplify: | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 276 | \<open>(P = True) \<equiv> P\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 277 | by auto | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 278 | |
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 279 | lemma verit_and_neg: | 
| 72513 
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72458diff
changeset | 280 | \<open>(a \<Longrightarrow> \<not>b \<or> A) \<Longrightarrow> \<not>(a \<and> b) \<or> A\<close> | 
| 
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72458diff
changeset | 281 | \<open>(a \<Longrightarrow> A) \<Longrightarrow> \<not>a \<or> A\<close> | 
| 
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72458diff
changeset | 282 | \<open>(\<not>a \<Longrightarrow> A) \<Longrightarrow> a \<or> A\<close> | 
| 
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72458diff
changeset | 283 | by blast+ | 
| 69205 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 284 | |
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 285 | lemma verit_forall_inst: | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 286 | \<open>A \<longleftrightarrow> B \<Longrightarrow> \<not>A \<or> B\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 287 | \<open>\<not>A \<longleftrightarrow> B \<Longrightarrow> A \<or> B\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 288 | \<open>A \<longleftrightarrow> B \<Longrightarrow> \<not>B \<or> A\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 289 | \<open>A \<longleftrightarrow> \<not>B \<Longrightarrow> B \<or> A\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 290 | \<open>A \<longrightarrow> B \<Longrightarrow> \<not>A \<or> B\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 291 | \<open>\<not>A \<longrightarrow> B \<Longrightarrow> A \<or> B\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 292 | by blast+ | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 293 | |
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 294 | lemma verit_eq_transitive: | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 295 | \<open>A = B \<Longrightarrow> B = C \<Longrightarrow> A = C\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 296 | \<open>A = B \<Longrightarrow> C = B \<Longrightarrow> A = C\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 297 | \<open>B = A \<Longrightarrow> B = C \<Longrightarrow> A = C\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 298 | \<open>B = A \<Longrightarrow> C = B \<Longrightarrow> A = C\<close> | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 299 | by auto | 
| 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 300 | |
| 72458 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 301 | lemma verit_bool_simplify: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 302 | \<open>\<not>(P \<longrightarrow> Q) \<longleftrightarrow> P \<and> \<not>Q\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 303 | \<open>\<not>(P \<or> Q) \<longleftrightarrow> \<not>P \<and> \<not>Q\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 304 | \<open>\<not>(P \<and> Q) \<longleftrightarrow> \<not>P \<or> \<not>Q\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 305 | \<open>(P \<longrightarrow> (Q \<longrightarrow> R)) \<longleftrightarrow> ((P \<and> Q) \<longrightarrow> R)\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 306 | \<open>((P \<longrightarrow> Q) \<longrightarrow> Q) \<longleftrightarrow> P \<or> Q\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 307 | \<open>(Q \<longleftrightarrow> (P \<or> Q)) \<longleftrightarrow> (P \<longrightarrow> Q)\<close> \<comment> \<open>This rule was inverted\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 308 | \<open>P \<and> (P \<longrightarrow> Q) \<longleftrightarrow> P \<and> Q\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 309 | \<open>(P \<longrightarrow> Q) \<and> P \<longleftrightarrow> P \<and> Q\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 310 | (* \<comment>\<open>Additional rules:\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 311 | * \<open>((P \<longrightarrow> Q) \<longrightarrow> P) \<longleftrightarrow> P\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 312 | * \<open>((P \<longrightarrow> Q) \<longrightarrow> Q) \<longleftrightarrow> P \<or> Q\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 313 | * \<open>(P \<longrightarrow> Q) \<or> P\<close> *) | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 314 | unfolding not_imp imp_conjL | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 315 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 316 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 317 | text \<open>We need the last equation for \<^term>\<open>\<not>(\<forall>a b. \<not>P a b)\<close>\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 318 | lemma verit_connective_def: \<comment> \<open>the definition of XOR is missing | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 319 | as the operator is not generated by Isabelle\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 320 | \<open>(A = B) \<longleftrightarrow> ((A \<longrightarrow> B) \<and> (B \<longrightarrow> A))\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 321 | \<open>(If A B C) = ((A \<longrightarrow> B) \<and> (\<not>A \<longrightarrow> C))\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 322 | \<open>(\<exists>x. P x) \<longleftrightarrow> \<not>(\<forall>x. \<not>P x)\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 323 | \<open>\<not>(\<exists>x. P x) \<longleftrightarrow> (\<forall>x. \<not>P x)\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 324 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 325 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 326 | lemma verit_ite_simplify: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 327 | \<open>(If True B C) = B\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 328 | \<open>(If False B C) = C\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 329 | \<open>(If A' B B) = B\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 330 | \<open>(If (\<not>A') B C) = (If A' C B)\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 331 | \<open>(If c (If c A B) C) = (If c A C)\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 332 | \<open>(If c C (If c A B)) = (If c C B)\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 333 | \<open>(If A' True False) = A'\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 334 | \<open>(If A' False True) \<longleftrightarrow> \<not>A'\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 335 | \<open>(If A' True B') \<longleftrightarrow> A'\<or>B'\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 336 | \<open>(If A' B' False) \<longleftrightarrow> A'\<and>B'\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 337 | \<open>(If A' False B') \<longleftrightarrow> \<not>A'\<and>B'\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 338 | \<open>(If A' B' True) \<longleftrightarrow> \<not>A'\<or>B'\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 339 | \<open>x \<and> True \<longleftrightarrow> x\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 340 | \<open>x \<or> False \<longleftrightarrow> x\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 341 | for B C :: 'a and A' B' C' :: bool | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 342 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 343 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 344 | lemma verit_and_simplify1: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 345 | \<open>True \<and> b \<longleftrightarrow> b\<close> \<open>b \<and> True \<longleftrightarrow> b\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 346 | \<open>False \<and> b \<longleftrightarrow> False\<close> \<open>b \<and> False \<longleftrightarrow> False\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 347 | \<open>(c \<and> \<not>c) \<longleftrightarrow> False\<close> \<open>(\<not>c \<and> c) \<longleftrightarrow> False\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 348 | \<open>\<not>\<not>a = a\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 349 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 350 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 351 | lemmas verit_and_simplify = conj_ac de_Morgan_conj disj_not1 | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 352 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 353 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 354 | lemma verit_or_simplify_1: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 355 | \<open>False \<or> b \<longleftrightarrow> b\<close> \<open>b \<or> False \<longleftrightarrow> b\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 356 | \<open>b \<or> \<not>b\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 357 | \<open>\<not>b \<or> b\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 358 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 359 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 360 | lemmas verit_or_simplify = disj_ac | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 361 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 362 | lemma verit_not_simplify: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 363 | \<open>\<not> \<not>b \<longleftrightarrow> b\<close> \<open>\<not>True \<longleftrightarrow> False\<close> \<open>\<not>False \<longleftrightarrow> True\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 364 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 365 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 366 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 367 | lemma verit_implies_simplify: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 368 | \<open>(\<not>a \<longrightarrow> \<not>b) \<longleftrightarrow> (b \<longrightarrow> a)\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 369 | \<open>(False \<longrightarrow> a) \<longleftrightarrow> True\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 370 | \<open>(a \<longrightarrow> True) \<longleftrightarrow> True\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 371 | \<open>(True \<longrightarrow> a) \<longleftrightarrow> a\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 372 | \<open>(a \<longrightarrow> False) \<longleftrightarrow> \<not>a\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 373 | \<open>(a \<longrightarrow> a) \<longleftrightarrow> True\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 374 | \<open>(\<not>a \<longrightarrow> a) \<longleftrightarrow> a\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 375 | \<open>(a \<longrightarrow> \<not>a) \<longleftrightarrow> \<not>a\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 376 | \<open>((a \<longrightarrow> b) \<longrightarrow> b) \<longleftrightarrow> a \<or> b\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 377 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 378 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 379 | lemma verit_equiv_simplify: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 380 | \<open>((\<not>a) = (\<not>b)) \<longleftrightarrow> (a = b)\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 381 | \<open>(a = a) \<longleftrightarrow> True\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 382 | \<open>(a = (\<not>a)) \<longleftrightarrow> False\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 383 | \<open>((\<not>a) = a) \<longleftrightarrow> False\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 384 | \<open>(True = a) \<longleftrightarrow> a\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 385 | \<open>(a = True) \<longleftrightarrow> a\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 386 | \<open>(False = a) \<longleftrightarrow> \<not>a\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 387 | \<open>(a = False) \<longleftrightarrow> \<not>a\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 388 | \<open>\<not>\<not>a \<longleftrightarrow> a\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 389 | \<open>(\<not> False) = True\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 390 | for a b :: bool | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 391 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 392 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 393 | lemmas verit_eq_simplify = | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 394 | semiring_char_0_class.eq_numeral_simps eq_refl zero_neq_one num.simps | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 395 | neg_equal_zero equal_neg_zero one_neq_zero neg_equal_iff_equal | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 396 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 397 | lemma verit_minus_simplify: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 398 | \<open>(a :: 'a :: cancel_comm_monoid_add) - a = 0\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 399 | \<open>(a :: 'a :: cancel_comm_monoid_add) - 0 = a\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 400 |   \<open>0 - (b :: 'b :: {group_add}) = -b\<close>
 | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 401 | \<open>- (- (b :: 'b :: group_add)) = b\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 402 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 403 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 404 | lemma verit_sum_simplify: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 405 | \<open>(a :: 'a :: cancel_comm_monoid_add) + 0 = a\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 406 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 407 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 408 | lemmas verit_prod_simplify = | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 409 | (* already included: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 410 | mult_zero_class.mult_zero_right | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 411 | mult_zero_class.mult_zero_left *) | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 412 | mult_1 | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 413 | mult_1_right | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 414 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 415 | lemma verit_comp_simplify1: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 416 | \<open>(a :: 'a ::order) < a \<longleftrightarrow> False\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 417 | \<open>a \<le> a\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 418 | \<open>\<not>(b' \<le> a') \<longleftrightarrow> (a' :: 'b :: linorder) < b'\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 419 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 420 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 421 | lemmas verit_comp_simplify = | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 422 | verit_comp_simplify1 | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 423 | le_numeral_simps | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 424 | le_num_simps | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 425 | less_numeral_simps | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 426 | less_num_simps | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 427 | zero_less_one | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 428 | zero_le_one | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 429 | less_neg_numeral_simps | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 430 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 431 | lemma verit_la_disequality: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 432 | \<open>(a :: 'a ::linorder) = b \<or> \<not>a \<le> b \<or> \<not>b \<le> a\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 433 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 434 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 435 | context | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 436 | begin | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 437 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 438 | text \<open>For the reconstruction, we need to keep the order of the arguments.\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 439 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 440 | named_theorems smt_arith_multiplication \<open>Theorems to reconstruct arithmetic theorems.\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 441 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 442 | named_theorems smt_arith_combine \<open>Theorems to reconstruct arithmetic theorems.\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 443 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 444 | named_theorems smt_arith_simplify \<open>Theorems to combine theorems in the LA procedure\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 445 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 446 | lemmas [smt_arith_simplify] = | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 447 | div_add dvd_numeral_simp divmod_steps less_num_simps le_num_simps if_True if_False divmod_cancel | 
| 75936 | 448 | dvd_mult dvd_mult2 less_irrefl prod.case numeral_plus_one divmod_step_def order.refl le_zero_eq | 
| 72458 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 449 | le_numeral_simps less_numeral_simps mult.right_neutral simp_thms divides_aux_eq | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 450 | mult_nonneg_nonneg dvd_imp_mod_0 dvd_add zero_less_one mod_mult_self4 numeral_mod_numeral | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 451 | divmod_trivial prod.sel mult.left_neutral div_pos_pos_trivial arith_simps div_add div_mult_self1 | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 452 | add_le_cancel_left add_le_same_cancel2 not_one_le_zero le_numeral_simps add_le_same_cancel1 | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 453 | zero_neq_one zero_le_one le_num_simps add_Suc mod_div_trivial nat.distinct mult_minus_right | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 454 | add.inverse_inverse distrib_left_numeral mult_num_simps numeral_times_numeral add_num_simps | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 455 | divmod_steps rel_simps if_True if_False numeral_div_numeral divmod_cancel prod.case | 
| 75936 | 456 | add_num_simps one_plus_numeral fst_conv arith_simps sub_num_simps dbl_inc_simps | 
| 72458 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 457 | dbl_simps mult_1 add_le_cancel_right left_diff_distrib_numeral add_uminus_conv_diff zero_neq_one | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 458 | zero_le_one One_nat_def add_Suc mod_div_trivial nat.distinct of_int_1 numerals numeral_One | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 459 | of_int_numeral add_uminus_conv_diff zle_diff1_eq add_less_same_cancel2 minus_add_distrib | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 460 | add_uminus_conv_diff mult.left_neutral semiring_class.distrib_right | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 461 | add_diff_cancel_left' add_diff_eq ring_distribs mult_minus_left minus_diff_eq | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 462 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 463 | lemma [smt_arith_simplify]: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 464 | \<open>\<not> (a' :: 'a :: linorder) < b' \<longleftrightarrow> b' \<le> a'\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 465 | \<open>\<not> (a' :: 'a :: linorder) \<le> b' \<longleftrightarrow> b' < a'\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 466 | \<open>(c::int) mod Numeral1 = 0\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 467 | \<open>(a::nat) mod Numeral1 = 0\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 468 | \<open>(c::int) div Numeral1 = c\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 469 | \<open>a div Numeral1 = a\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 470 | \<open>(c::int) mod 1 = 0\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 471 | \<open>a mod 1 = 0\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 472 | \<open>(c::int) div 1 = c\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 473 | \<open>a div 1 = a\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 474 | \<open>\<not>(a' \<noteq> b') \<longleftrightarrow> a' = b'\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 475 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 476 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 477 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 478 | lemma div_mod_decomp: "A = (A div n) * n + (A mod n)" for A :: nat | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 479 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 480 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 481 | lemma div_less_mono: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 482 | fixes A B :: nat | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 483 | assumes "A < B" "0 < n" and | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 484 | mod: "A mod n = 0""B mod n = 0" | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 485 | shows "(A div n) < (B div n)" | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 486 | proof - | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 487 | show ?thesis | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 488 | using assms(1) | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 489 | apply (subst (asm) div_mod_decomp[of "A" n]) | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 490 | apply (subst (asm) div_mod_decomp[of "B" n]) | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 491 | unfolding mod | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 492 | by (use assms(2,3) in \<open>auto simp: ac_simps\<close>) | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 493 | qed | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 494 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 495 | lemma verit_le_mono_div: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 496 | fixes A B :: nat | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 497 | assumes "A < B" "0 < n" | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 498 | shows "(A div n) + (if B mod n = 0 then 1 else 0) \<le> (B div n)" | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 499 | by (auto simp: ac_simps Suc_leI assms less_mult_imp_div_less div_le_mono less_imp_le_nat) | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 500 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 501 | lemmas [smt_arith_multiplication] = | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 502 | verit_le_mono_div[THEN mult_le_mono1, unfolded add_mult_distrib] | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 503 | div_le_mono[THEN mult_le_mono2, unfolded add_mult_distrib] | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 504 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 505 | lemma div_mod_decomp_int: "A = (A div n) * n + (A mod n)" for A :: int | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 506 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 507 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 508 | lemma zdiv_mono_strict: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 509 | fixes A B :: int | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 510 | assumes "A < B" "0 < n" and | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 511 | mod: "A mod n = 0""B mod n = 0" | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 512 | shows "(A div n) < (B div n)" | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 513 | proof - | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 514 | show ?thesis | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 515 | using assms(1) | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 516 | apply (subst (asm) div_mod_decomp_int[of A n]) | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 517 | apply (subst (asm) div_mod_decomp_int[of B n]) | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 518 | unfolding mod | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 519 | by (use assms(2,3) in \<open>auto simp: ac_simps\<close>) | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 520 | qed | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 521 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 522 | lemma verit_le_mono_div_int: | 
| 76106 | 523 | \<open>A div n + (if B mod n = 0 then 1 else 0) \<le> B div n\<close> | 
| 524 | if \<open>A < B\<close> \<open>0 < n\<close> | |
| 525 | for A B n :: int | |
| 72458 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 526 | proof - | 
| 76106 | 527 | from \<open>A < B\<close> \<open>0 < n\<close> have \<open>A div n \<le> B div n\<close> | 
| 528 | by (auto intro: zdiv_mono1) | |
| 529 | show ?thesis | |
| 530 | proof (cases \<open>n dvd B\<close>) | |
| 531 | case False | |
| 532 | with \<open>A div n \<le> B div n\<close> show ?thesis | |
| 533 | by auto | |
| 534 | next | |
| 535 | case True | |
| 536 | then obtain C where \<open>B = n * C\<close> .. | |
| 537 | then have \<open>B div n = C\<close> | |
| 538 | using \<open>0 < n\<close> by simp | |
| 539 | from \<open>0 < n\<close> have \<open>A mod n \<ge> 0\<close> | |
| 540 | by simp | |
| 541 | have \<open>A div n < C\<close> | |
| 542 | proof (rule ccontr) | |
| 543 | assume \<open>\<not> A div n < C\<close> | |
| 544 | then have \<open>C \<le> A div n\<close> | |
| 545 | by simp | |
| 546 | with \<open>B div n = C\<close> \<open>A div n \<le> B div n\<close> | |
| 547 | have \<open>A div n = C\<close> | |
| 548 | by simp | |
| 549 | moreover from \<open>A < B\<close> have \<open>n * (A div n) + A mod n < B\<close> | |
| 550 | by simp | |
| 551 | ultimately have \<open>n * C + A mod n < n * C\<close> | |
| 552 | using \<open>B = n * C\<close> by simp | |
| 553 | moreover have \<open>A mod n \<ge> 0\<close> | |
| 554 | using \<open>0 < n\<close> by simp | |
| 555 | ultimately show False | |
| 556 | by simp | |
| 557 | qed | |
| 558 | with \<open>n dvd B\<close> \<open>B div n = C\<close> show ?thesis | |
| 559 | by simp | |
| 560 | qed | |
| 72458 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 561 | qed | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 562 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 563 | lemma verit_less_mono_div_int2: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 564 | fixes A B :: int | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 565 | assumes "A \<le> B" "0 < -n" | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 566 | shows "(A div n) \<ge> (B div n)" | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 567 | using assms(1) assms(2) zdiv_mono1_neg by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 568 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 569 | lemmas [smt_arith_multiplication] = | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 570 | verit_le_mono_div_int[THEN mult_left_mono, unfolded int_distrib] | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 571 | zdiv_mono1[THEN mult_left_mono, unfolded int_distrib] | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 572 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 573 | lemmas [smt_arith_multiplication] = | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 574 | arg_cong[of _ _ \<open>\<lambda>a :: nat. a div n * p\<close> for n p :: nat, THEN sym] | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 575 | arg_cong[of _ _ \<open>\<lambda>a :: int. a div n * p\<close> for n p :: int, THEN sym] | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 576 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 577 | lemma [smt_arith_combine]: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 578 | "a < b \<Longrightarrow> c < d \<Longrightarrow> a + c + 2 \<le> b + d" | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 579 | "a < b \<Longrightarrow> c \<le> d \<Longrightarrow> a + c + 1 \<le> b + d" | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 580 | "a \<le> b \<Longrightarrow> c < d \<Longrightarrow> a + c + 1 \<le> b + d" for a b c :: int | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 581 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 582 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 583 | lemma [smt_arith_combine]: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 584 | "a < b \<Longrightarrow> c < d \<Longrightarrow> a + c + 2 \<le> b + d" | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 585 | "a < b \<Longrightarrow> c \<le> d \<Longrightarrow> a + c + 1 \<le> b + d" | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 586 | "a \<le> b \<Longrightarrow> c < d \<Longrightarrow> a + c + 1 \<le> b + d" for a b c :: nat | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 587 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 588 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 589 | lemmas [smt_arith_combine] = | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 590 | add_strict_mono | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 591 | add_less_le_mono | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 592 | add_mono | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 593 | add_le_less_mono | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 594 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 595 | lemma [smt_arith_combine]: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 596 | \<open>m < n \<Longrightarrow> c = d \<Longrightarrow> m + c < n + d\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 597 | \<open>m \<le> n \<Longrightarrow> c = d \<Longrightarrow> m + c \<le> n + d\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 598 | \<open>c = d \<Longrightarrow> m < n \<Longrightarrow> m + c < n + d\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 599 | \<open>c = d \<Longrightarrow> m \<le> n \<Longrightarrow> m + c \<le> n + d\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 600 | for m :: \<open>'a :: ordered_cancel_ab_semigroup_add\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 601 | by (auto intro: ordered_cancel_ab_semigroup_add_class.add_strict_right_mono | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 602 | ordered_ab_semigroup_add_class.add_right_mono) | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 603 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 604 | lemma verit_negate_coefficient: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 605 |   \<open>a \<le> (b :: 'a :: {ordered_ab_group_add}) \<Longrightarrow> -a \<ge> -b\<close>
 | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 606 | \<open>a < b \<Longrightarrow> -a > -b\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 607 | \<open>a = b \<Longrightarrow> -a = -b\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 608 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 609 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 610 | end | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 611 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 612 | lemma verit_ite_intro: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 613 | \<open>(if a then P (if a then a' else b') else Q) \<longleftrightarrow> (if a then P a' else Q)\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 614 | \<open>(if a then P' else Q' (if a then a' else b')) \<longleftrightarrow> (if a then P' else Q' b')\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 615 | \<open>A = f (if a then R else S) \<longleftrightarrow> (if a then A = f R else A = f S)\<close> | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 616 | by auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 617 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 618 | lemma verit_ite_if_cong: | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 619 | fixes x y :: bool | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 620 | assumes "b=c" | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 621 | and "c \<equiv> True \<Longrightarrow> x = u" | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 622 | and "c \<equiv> False \<Longrightarrow> y = v" | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 623 | shows "(if b then x else y) \<equiv> (if c then u else v)" | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 624 | proof - | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 625 | have H: "(if b then x else y) = (if c then u else v)" | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 626 | using assms by (auto split: if_splits) | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 627 | |
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 628 | show "(if b then x else y) \<equiv> (if c then u else v)" | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 629 | by (subst H) auto | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 630 | qed | 
| 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 631 | |
| 69205 
8050734eee3e
add reconstruction by veriT in method smt
 fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
69204diff
changeset | 632 | |
| 60758 | 633 | subsection \<open>Setup\<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 634 | |
| 69605 | 635 | ML_file \<open>Tools/SMT/smt_util.ML\<close> | 
| 636 | ML_file \<open>Tools/SMT/smt_failure.ML\<close> | |
| 637 | ML_file \<open>Tools/SMT/smt_config.ML\<close> | |
| 638 | ML_file \<open>Tools/SMT/smt_builtin.ML\<close> | |
| 639 | ML_file \<open>Tools/SMT/smt_datatypes.ML\<close> | |
| 640 | ML_file \<open>Tools/SMT/smt_normalize.ML\<close> | |
| 641 | ML_file \<open>Tools/SMT/smt_translate.ML\<close> | |
| 642 | ML_file \<open>Tools/SMT/smtlib.ML\<close> | |
| 643 | ML_file \<open>Tools/SMT/smtlib_interface.ML\<close> | |
| 644 | ML_file \<open>Tools/SMT/smtlib_proof.ML\<close> | |
| 645 | ML_file \<open>Tools/SMT/smtlib_isar.ML\<close> | |
| 646 | ML_file \<open>Tools/SMT/z3_proof.ML\<close> | |
| 647 | ML_file \<open>Tools/SMT/z3_isar.ML\<close> | |
| 648 | ML_file \<open>Tools/SMT/smt_solver.ML\<close> | |
| 75806 
2b106aae897c
added support for cvc5 (whose interface is almost identical to CVC4)
 blanchet parents: 
75299diff
changeset | 649 | ML_file \<open>Tools/SMT/cvc_interface.ML\<close> | 
| 75299 
da591621d6ae
split veriT reconstruction into Lethe and veriT part
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
75063diff
changeset | 650 | ML_file \<open>Tools/SMT/lethe_proof.ML\<close> | 
| 
da591621d6ae
split veriT reconstruction into Lethe and veriT part
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
75063diff
changeset | 651 | ML_file \<open>Tools/SMT/lethe_isar.ML\<close> | 
| 
da591621d6ae
split veriT reconstruction into Lethe and veriT part
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
75063diff
changeset | 652 | ML_file \<open>Tools/SMT/lethe_proof_parse.ML\<close> | 
| 75806 
2b106aae897c
added support for cvc5 (whose interface is almost identical to CVC4)
 blanchet parents: 
75299diff
changeset | 653 | ML_file \<open>Tools/SMT/cvc_proof_parse.ML\<close> | 
| 69605 | 654 | ML_file \<open>Tools/SMT/conj_disj_perm.ML\<close> | 
| 655 | ML_file \<open>Tools/SMT/smt_replay_methods.ML\<close> | |
| 656 | ML_file \<open>Tools/SMT/smt_replay.ML\<close> | |
| 72458 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 657 | ML_file \<open>Tools/SMT/smt_replay_arith.ML\<close> | 
| 69605 | 658 | ML_file \<open>Tools/SMT/z3_interface.ML\<close> | 
| 659 | ML_file \<open>Tools/SMT/z3_replay_rules.ML\<close> | |
| 660 | ML_file \<open>Tools/SMT/z3_replay_methods.ML\<close> | |
| 661 | ML_file \<open>Tools/SMT/z3_replay.ML\<close> | |
| 75299 
da591621d6ae
split veriT reconstruction into Lethe and veriT part
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
75063diff
changeset | 662 | ML_file \<open>Tools/SMT/lethe_replay_methods.ML\<close> | 
| 78177 
ea7a3cc64df5
early inclusion of cvc5 proof reconstruction; slightly reorganize smt/z3_reals;
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
76106diff
changeset | 663 | ML_file \<open>Tools/SMT/cvc5_replay_methods.ML\<close> | 
| 69605 | 664 | ML_file \<open>Tools/SMT/verit_replay_methods.ML\<close> | 
| 75956 
1e2a9d2251b0
remove duplicate parsing for alethe; fix skolemization;
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
75936diff
changeset | 665 | ML_file \<open>Tools/SMT/verit_strategies.ML\<close> | 
| 69605 | 666 | ML_file \<open>Tools/SMT/verit_replay.ML\<close> | 
| 78177 
ea7a3cc64df5
early inclusion of cvc5 proof reconstruction; slightly reorganize smt/z3_reals;
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
76106diff
changeset | 667 | ML_file \<open>Tools/SMT/cvc5_replay.ML\<close> | 
| 69605 | 668 | ML_file \<open>Tools/SMT/smt_systems.ML\<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 669 | |
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 670 | |
| 60758 | 671 | subsection \<open>Configuration\<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 672 | |
| 60758 | 673 | text \<open> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 674 | The current configuration can be printed by the command | 
| 61799 | 675 | \<open>smt_status\<close>, which shows the values of most options. | 
| 60758 | 676 | \<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 677 | |
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 678 | |
| 60758 | 679 | subsection \<open>General configuration options\<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 680 | |
| 60758 | 681 | text \<open> | 
| 61799 | 682 | The option \<open>smt_solver\<close> can be used to change the target SMT | 
| 683 | solver. The possible values can be obtained from the \<open>smt_status\<close> | |
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 684 | command. | 
| 60758 | 685 | \<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 686 | |
| 58061 | 687 | declare [[smt_solver = z3]] | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 688 | |
| 60758 | 689 | text \<open> | 
| 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: 
57246diff
changeset | 690 | Since SMT solvers are potentially nonterminating, there is a timeout | 
| 
fb71c6f100f8
do not embed 'nat' into 'int's in 'smt2' method -- this is highly inefficient and decreases the Sledgehammer success rate significantly
 blanchet parents: 
57246diff
changeset | 691 | (given in seconds) to restrict their runtime. | 
| 60758 | 692 | \<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 693 | |
| 73389 | 694 | declare [[smt_timeout = 0]] | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 695 | |
| 60758 | 696 | text \<open> | 
| 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: 
57246diff
changeset | 697 | SMT solvers apply randomized heuristics. In case a problem is not | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 698 | solvable by an SMT solver, changing the following option might help. | 
| 60758 | 699 | \<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 700 | |
| 58061 | 701 | declare [[smt_random_seed = 1]] | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 702 | |
| 60758 | 703 | text \<open> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 704 | In general, the binding to SMT solvers runs as an oracle, i.e, the SMT | 
| 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: 
57246diff
changeset | 705 | solvers are fully trusted without additional checks. The following | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 706 | option can cause the SMT solver to run in proof-producing mode, giving | 
| 75063 
7ff39293e265
added possibility of extra options to SMT slices
 blanchet parents: 
74740diff
changeset | 707 | a checkable certificate. This is currently implemented only for veriT and | 
| 
7ff39293e265
added possibility of extra options to SMT slices
 blanchet parents: 
74740diff
changeset | 708 | Z3. | 
| 60758 | 709 | \<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 710 | |
| 58061 | 711 | declare [[smt_oracle = false]] | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 712 | |
| 60758 | 713 | text \<open> | 
| 75063 
7ff39293e265
added possibility of extra options to SMT slices
 blanchet parents: 
74740diff
changeset | 714 | Each SMT solver provides several command-line options to tweak its | 
| 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: 
57246diff
changeset | 715 | behaviour. They can be passed to the solver by setting the following | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 716 | options. | 
| 60758 | 717 | \<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 718 | |
| 75063 
7ff39293e265
added possibility of extra options to SMT slices
 blanchet parents: 
74740diff
changeset | 719 | declare [[cvc4_options = ""]] | 
| 78177 
ea7a3cc64df5
early inclusion of cvc5 proof reconstruction; slightly reorganize smt/z3_reals;
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
76106diff
changeset | 720 | declare [[cvc5_options = "--proof-format-mode=alethe --proof-granularity=dsl-rewrite"]] | 
| 72458 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 721 | declare [[verit_options = ""]] | 
| 58061 | 722 | declare [[z3_options = ""]] | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 723 | |
| 60758 | 724 | text \<open> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 725 | The SMT method provides an inference mechanism to detect simple triggers | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 726 | in quantified formulas, which might increase the number of problems | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 727 | solvable by SMT solvers (note: triggers guide quantifier instantiations | 
| 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: 
57246diff
changeset | 728 | in the SMT solver). To turn it on, set the following option. | 
| 60758 | 729 | \<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 730 | |
| 58061 | 731 | declare [[smt_infer_triggers = false]] | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 732 | |
| 60758 | 733 | text \<open> | 
| 58360 | 734 | Enable the following option to use built-in support for datatypes, | 
| 75806 
2b106aae897c
added support for cvc5 (whose interface is almost identical to CVC4)
 blanchet parents: 
75299diff
changeset | 735 | codatatypes, and records in CVC4 and cvc5. Currently, this is implemented | 
| 
2b106aae897c
added support for cvc5 (whose interface is almost identical to CVC4)
 blanchet parents: 
75299diff
changeset | 736 | only in oracle mode. | 
| 60758 | 737 | \<close> | 
| 58360 | 738 | |
| 75806 
2b106aae897c
added support for cvc5 (whose interface is almost identical to CVC4)
 blanchet parents: 
75299diff
changeset | 739 | declare [[cvc_extensions = false]] | 
| 58360 | 740 | |
| 60758 | 741 | text \<open> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 742 | Enable the following option to use built-in support for div/mod, datatypes, | 
| 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: 
57246diff
changeset | 743 | and records in Z3. Currently, this is implemented only in oracle mode. | 
| 60758 | 744 | \<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 745 | |
| 58061 | 746 | declare [[z3_extensions = false]] | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 747 | |
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 748 | |
| 60758 | 749 | subsection \<open>Certificates\<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 750 | |
| 60758 | 751 | text \<open> | 
| 61799 | 752 | By setting the option \<open>smt_certificates\<close> to the name of a file, | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 753 | all following applications of an SMT solver a cached in that file. | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 754 | Any further application of the same SMT solver (using the very same | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 755 | configuration) re-uses the cached certificate instead of invoking the | 
| 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: 
57246diff
changeset | 756 | solver. An empty string disables caching certificates. | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 757 | |
| 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: 
57246diff
changeset | 758 | The filename should be given as an explicit path. It is good | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 759 | practice to use the name of the current theory (with ending | 
| 61799 | 760 | \<open>.certs\<close> instead of \<open>.thy\<close>) as the certificates file. | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 761 | Certificate files should be used at most once in a certain theory context, | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 762 | to avoid race conditions with other concurrent accesses. | 
| 60758 | 763 | \<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 764 | |
| 58061 | 765 | declare [[smt_certificates = ""]] | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 766 | |
| 60758 | 767 | text \<open> | 
| 61799 | 768 | The option \<open>smt_read_only_certificates\<close> controls whether only | 
| 74740 | 769 | stored certificates should be used or invocation of an SMT solver | 
| 61799 | 770 | is allowed. When set to \<open>true\<close>, no SMT solver will ever be | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 771 | invoked and only the existing certificates found in the configured | 
| 61799 | 772 | cache are used; when set to \<open>false\<close> and there is no cached | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 773 | certificate for some proposition, then the configured SMT solver is | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 774 | invoked. | 
| 60758 | 775 | \<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 776 | |
| 58061 | 777 | declare [[smt_read_only_certificates = false]] | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 778 | |
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 779 | |
| 60758 | 780 | subsection \<open>Tracing\<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 781 | |
| 60758 | 782 | text \<open> | 
| 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: 
57246diff
changeset | 783 | The SMT method, when applied, traces important information. To | 
| 61799 | 784 | make it entirely silent, set the following option to \<open>false\<close>. | 
| 60758 | 785 | \<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 786 | |
| 58061 | 787 | declare [[smt_verbose = true]] | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 788 | |
| 60758 | 789 | text \<open> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 790 | For tracing the generated problem file given to the SMT solver as | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 791 | well as the returned result of the solver, the option | 
| 61799 | 792 | \<open>smt_trace\<close> should be set to \<open>true\<close>. | 
| 60758 | 793 | \<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 794 | |
| 58061 | 795 | declare [[smt_trace = false]] | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 796 | |
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 797 | |
| 60758 | 798 | subsection \<open>Schematic rules for Z3 proof reconstruction\<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 799 | |
| 60758 | 800 | text \<open> | 
| 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: 
57246diff
changeset | 801 | Several prof rules of Z3 are not very well documented. There are two | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 802 | lemma groups which can turn failing Z3 proof reconstruction attempts | 
| 61799 | 803 | into succeeding ones: the facts in \<open>z3_rule\<close> are tried prior to | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 804 | any implemented reconstruction procedure for all uncertain Z3 proof | 
| 61799 | 805 | rules; the facts in \<open>z3_simp\<close> are only fed to invocations of | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 806 | the simplifier when reconstructing theory-specific proof steps. | 
| 60758 | 807 | \<close> | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 808 | |
| 58061 | 809 | lemmas [z3_rule] = | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 810 | refl eq_commute conj_commute disj_commute simp_thms nnf_simps | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 811 | ring_distribs field_simps times_divide_eq_right times_divide_eq_left | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 812 | if_True if_False not_not | 
| 58776 
95e58e04e534
use NO_MATCH-simproc for distribution rules in field_simps, otherwise field_simps on '(a / (c + d)) * (e + f)' can be non-terminating
 hoelzl parents: 
58598diff
changeset | 813 | NO_MATCH_def | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 814 | |
| 58061 | 815 | lemma [z3_rule]: | 
| 57169 | 816 | "(P \<and> Q) = (\<not> (\<not> P \<or> \<not> Q))" | 
| 817 | "(P \<and> Q) = (\<not> (\<not> Q \<or> \<not> P))" | |
| 818 | "(\<not> P \<and> Q) = (\<not> (P \<or> \<not> Q))" | |
| 819 | "(\<not> P \<and> Q) = (\<not> (\<not> Q \<or> P))" | |
| 820 | "(P \<and> \<not> Q) = (\<not> (\<not> P \<or> Q))" | |
| 821 | "(P \<and> \<not> Q) = (\<not> (Q \<or> \<not> P))" | |
| 822 | "(\<not> P \<and> \<not> Q) = (\<not> (P \<or> Q))" | |
| 823 | "(\<not> P \<and> \<not> Q) = (\<not> (Q \<or> P))" | |
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 824 | by auto | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 825 | |
| 58061 | 826 | lemma [z3_rule]: | 
| 57169 | 827 | "(P \<longrightarrow> Q) = (Q \<or> \<not> P)" | 
| 828 | "(\<not> P \<longrightarrow> Q) = (P \<or> Q)" | |
| 829 | "(\<not> P \<longrightarrow> Q) = (Q \<or> P)" | |
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 830 | "(True \<longrightarrow> P) = P" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 831 | "(P \<longrightarrow> True) = True" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 832 | "(False \<longrightarrow> P) = True" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 833 | "(P \<longrightarrow> P) = True" | 
| 59037 
650dcf624729
added Z3 reconstruction rule suggested by F. Maric
 blanchet parents: 
59036diff
changeset | 834 | "(\<not> (A \<longleftrightarrow> \<not> B)) \<longleftrightarrow> (A \<longleftrightarrow> B)" | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 835 | by auto | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 836 | |
| 58061 | 837 | lemma [z3_rule]: | 
| 67091 | 838 | "((P = Q) \<longrightarrow> R) = (R \<or> (Q = (\<not> P)))" | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 839 | by auto | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 840 | |
| 58061 | 841 | lemma [z3_rule]: | 
| 57169 | 842 | "(\<not> True) = False" | 
| 843 | "(\<not> False) = True" | |
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 844 | "(x = x) = True" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 845 | "(P = True) = P" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 846 | "(True = P) = P" | 
| 57169 | 847 | "(P = False) = (\<not> P)" | 
| 848 | "(False = P) = (\<not> P)" | |
| 849 | "((\<not> P) = P) = False" | |
| 850 | "(P = (\<not> P)) = False" | |
| 851 | "((\<not> P) = (\<not> Q)) = (P = Q)" | |
| 852 | "\<not> (P = (\<not> Q)) = (P = Q)" | |
| 853 | "\<not> ((\<not> P) = Q) = (P = Q)" | |
| 854 | "(P \<noteq> Q) = (Q = (\<not> P))" | |
| 855 | "(P = Q) = ((\<not> P \<or> Q) \<and> (P \<or> \<not> Q))" | |
| 856 | "(P \<noteq> Q) = ((\<not> P \<or> \<not> Q) \<and> (P \<or> Q))" | |
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 857 | by auto | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 858 | |
| 58061 | 859 | lemma [z3_rule]: | 
| 57169 | 860 | "(if P then P else \<not> P) = True" | 
| 861 | "(if \<not> P then \<not> P else P) = True" | |
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 862 | "(if P then True else False) = P" | 
| 57169 | 863 | "(if P then False else True) = (\<not> P)" | 
| 864 | "(if P then Q else True) = ((\<not> P) \<or> Q)" | |
| 865 | "(if P then Q else True) = (Q \<or> (\<not> P))" | |
| 866 | "(if P then Q else \<not> Q) = (P = Q)" | |
| 867 | "(if P then Q else \<not> Q) = (Q = P)" | |
| 868 | "(if P then \<not> Q else Q) = (P = (\<not> Q))" | |
| 869 | "(if P then \<not> Q else Q) = ((\<not> Q) = P)" | |
| 870 | "(if \<not> P then x else y) = (if P then y else x)" | |
| 871 | "(if P then (if Q then x else y) else x) = (if P \<and> (\<not> Q) then y else x)" | |
| 872 | "(if P then (if Q then x else y) else x) = (if (\<not> Q) \<and> P then y else x)" | |
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 873 | "(if P then (if Q then x else y) else y) = (if P \<and> Q then x else y)" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 874 | "(if P then (if Q then x else y) else y) = (if Q \<and> P then x else y)" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 875 | "(if P then x else if P then y else z) = (if P then x else z)" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 876 | "(if P then x else if Q then x else y) = (if P \<or> Q then x else y)" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 877 | "(if P then x else if Q then x else y) = (if Q \<or> P then x else y)" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 878 | "(if P then x = y else x = z) = (x = (if P then y else z))" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 879 | "(if P then x = y else y = z) = (y = (if P then x else z))" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 880 | "(if P then x = y else z = y) = (y = (if P then x else z))" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 881 | by auto | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 882 | |
| 58061 | 883 | lemma [z3_rule]: | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 884 | "0 + (x::int) = x" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 885 | "x + 0 = x" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 886 | "x + x = 2 * x" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 887 | "0 * x = 0" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 888 | "1 * x = x" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 889 | "x + y = y + x" | 
| 72458 
b44e894796d5
add reconstruction for the SMT solver veriT
 Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> parents: 
72343diff
changeset | 890 | by auto | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 891 | |
| 58061 | 892 | lemma [z3_rule]: (* for def-axiom *) | 
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 893 | "P = Q \<or> P \<or> Q" | 
| 57169 | 894 | "P = Q \<or> \<not> P \<or> \<not> Q" | 
| 895 | "(\<not> P) = Q \<or> \<not> P \<or> Q" | |
| 896 | "(\<not> P) = Q \<or> P \<or> \<not> Q" | |
| 897 | "P = (\<not> Q) \<or> \<not> P \<or> Q" | |
| 898 | "P = (\<not> Q) \<or> P \<or> \<not> Q" | |
| 899 | "P \<noteq> Q \<or> P \<or> \<not> Q" | |
| 900 | "P \<noteq> Q \<or> \<not> P \<or> Q" | |
| 901 | "P \<noteq> (\<not> Q) \<or> P \<or> Q" | |
| 902 | "(\<not> P) \<noteq> Q \<or> P \<or> Q" | |
| 903 | "P \<or> Q \<or> P \<noteq> (\<not> Q)" | |
| 904 | "P \<or> Q \<or> (\<not> P) \<noteq> Q" | |
| 905 | "P \<or> \<not> Q \<or> P \<noteq> Q" | |
| 906 | "\<not> P \<or> Q \<or> P \<noteq> Q" | |
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 907 | "P \<or> y = (if P then x else y)" | 
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 908 | "P \<or> (if P then x else y) = y" | 
| 57169 | 909 | "\<not> P \<or> x = (if P then x else y)" | 
| 910 | "\<not> P \<or> (if P then x else y) = x" | |
| 911 | "P \<or> R \<or> \<not> (if P then Q else R)" | |
| 912 | "\<not> P \<or> Q \<or> \<not> (if P then Q else R)" | |
| 913 | "\<not> (if P then Q else R) \<or> \<not> P \<or> Q" | |
| 914 | "\<not> (if P then Q else R) \<or> P \<or> R" | |
| 915 | "(if P then Q else R) \<or> \<not> P \<or> \<not> Q" | |
| 916 | "(if P then Q else R) \<or> P \<or> \<not> R" | |
| 917 | "(if P then \<not> Q else R) \<or> \<not> P \<or> Q" | |
| 918 | "(if P then Q else \<not> R) \<or> P \<or> R" | |
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 919 | by auto | 
| 75806 
2b106aae897c
added support for cvc5 (whose interface is almost identical to CVC4)
 blanchet parents: 
75299diff
changeset | 920 | |
| 57230 | 921 | hide_type (open) symb_list pattern | 
| 922 | hide_const (open) Symb_Nil Symb_Cons trigger pat nopat fun_app z3div z3mod | |
| 56078 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 923 | |
| 
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
 blanchet parents: diff
changeset | 924 | end |