Theory SMT
section ‹Bindings to Satisfiability Modulo Theories (SMT) solvers based on SMT-LIB 2›
theory SMT
imports Numeral_Simprocs
ATP
keywords
"smt_status" :: diag
begin
subsection ‹A skolemization tactic and proof method›
lemma ex_iff_push: "(∃y. P ⟷ Q y) ⟷ (P ⟶ (∃y. Q y)) ∧ ((∀y. Q y) ⟶ P)"
by metis
ML ‹
fun moura_tac ctxt =
TRY o Atomize_Elim.atomize_elim_tac ctxt THEN'
REPEAT o EqSubst.eqsubst_tac ctxt [0]
@{thms choice_iff[symmetric] bchoice_iff[symmetric]} THEN'
TRY o Simplifier.asm_full_simp_tac
(Simplifier.clear_simpset ctxt |> Simplifier.add_simps @{thms all_simps ex_simps ex_iff_push}) THEN_ALL_NEW
Metis_Tactic.metis_tac (take 1 ATP_Proof_Reconstruct.partial_type_encs)
ATP_Proof_Reconstruct.default_metis_lam_trans ctxt []
›
method_setup moura = ‹
Scan.succeed (SIMPLE_METHOD' o moura_tac)
› "solve skolemization goals, especially those arising from Z3 proofs"
hide_fact (open) ex_iff_push
subsection ‹Triggers for quantifier instantiation›
text ‹
Some SMT solvers support patterns as a quantifier instantiation
heuristics. Patterns may either be positive terms (tagged by "pat")
triggering quantifier instantiations -- when the solver finds a
term matching a positive pattern, it instantiates the corresponding
quantifier accordingly -- or negative terms (tagged by "nopat")
inhibiting quantifier instantiations. A list of patterns
of the same kind is called a multipattern, and all patterns in a
multipattern are considered conjunctively for quantifier instantiation.
A list of multipatterns is called a trigger, and their multipatterns
act disjunctively during quantifier instantiation. Each multipattern
should mention at least all quantified variables of the preceding
quantifier block.
›
typedecl 'a symb_list
consts
Symb_Nil :: "'a symb_list"
Symb_Cons :: "'a ⇒ 'a symb_list ⇒ 'a symb_list"
typedecl pattern
consts
pat :: "'a ⇒ pattern"
nopat :: "'a ⇒ pattern"
definition trigger :: "pattern symb_list symb_list ⇒ bool ⇒ bool" where
"trigger _ P = P"
subsection ‹Higher-order encoding›
text ‹
Application is made explicit for constants occurring with varying
numbers of arguments. This is achieved by the introduction of the
following constant.
›
definition fun_app :: "'a ⇒ 'a" where "fun_app f = f"
text ‹
Some solvers support a theory of arrays which can be used to encode
higher-order functions. The following set of lemmas specifies the
properties of such (extensional) arrays.
›
lemmas array_rules = ext fun_upd_apply fun_upd_same fun_upd_other fun_upd_upd fun_app_def
subsection ‹Normalization›
lemma case_bool_if[abs_def]: "case_bool x y P = (if P then x else y)"
by simp
lemmas Ex1_def_raw = Ex1_def[abs_def]
lemmas Ball_def_raw = Ball_def[abs_def]
lemmas Bex_def_raw = Bex_def[abs_def]
lemmas abs_if_raw = abs_if[abs_def]
lemmas min_def_raw = min_def[abs_def]
lemmas max_def_raw = max_def[abs_def]
definition pow_2 where "pow_2 y = power (2::int) (nat y)"
lemma pow_2_raw'': "power (2::nat) ≡ (λb. nat (pow_2 (int b)))"
unfolding pow_2_def
apply (rule eq_reflection)
apply standard+
using nat_eq_iff2 by force
lemma nat_zero_as_int:
"0 = nat 0"
by simp
lemma nat_one_as_int:
"1 = nat 1"
by simp
lemma nat_numeral_as_int: "numeral = (λi. nat (numeral i))" by simp
lemma nat_less_as_int: "(<) = (λa b. int a < int b)" by simp
lemma nat_leq_as_int: "(≤) = (λa b. int a ≤ int b)" by simp
lemma Suc_as_int: "Suc = (λa. nat (int a + 1))" by (rule ext) simp
lemma nat_plus_as_int: "(+) = (λa b. nat (int a + int b))" by (rule ext)+ simp
lemma nat_minus_as_int: "(-) = (λa b. nat (int a - int b))" by (rule ext)+ simp
lemma nat_times_as_int: "(*) = (λa b. nat (int a * int b))" by (simp add: nat_mult_distrib)
lemma nat_div_as_int: "(div) = (λa b. nat (int a div int b))" by (simp add: nat_div_distrib)
lemma nat_mod_as_int: "(mod) = (λa b. nat (int a mod int b))" by (simp add: nat_mod_distrib)
lemma int_Suc: "int (Suc n) = int n + 1" by simp
lemma int_plus: "int (n + m) = int n + int m" by (rule of_nat_add)
lemma int_minus: "int (n - m) = int (nat (int n - int m))" by auto
lemma nat_int_comparison:
fixes a b :: nat
shows "(a = b) = (int a = int b)"
and "(a < b) = (int a < int b)"
and "(a ≤ b) = (int a ≤ int b)"
by simp_all
named_theorems int_ops ‹Used when embedding natural numbers into integers›
named_theorems nat_embedding_ops ‹Used when embedding natural numbers into integers›
lemma [int_ops]:
fixes a b :: nat
shows "int 0 = 0"
and "int 1 = 1"
and "int (numeral n) = numeral n"
and "int (Suc a) = int a + 1"
and "int (a + b) = int a + int b"
and "int (a - b) = (if int a < int b then 0 else int a - int b)"
and "int (a * b) = int a * int b"
and "int (a div b) = int a div int b"
and "int (a mod b) = int a mod int b"
by (auto intro: zdiv_int zmod_int)
lemma [int_ops]:
"int (nat (pow_2 x)) = pow_2 x"
unfolding pow_2_def
by simp
lemma int_if:
fixes a b :: nat
shows "int (if P then a else b) = (if P then int a else int b)"
by simp
named_theorems pow_2_word ‹power on words should be translated natively›
subsection ‹Integer division and modulo for Z3›
text ‹
The following Z3-inspired definitions are overspecified for the case where ‹l = 0›. This
Schönheitsfehler is corrected in the ‹div_as_z3div› and ‹mod_as_z3mod› theorems.
›
definition z3div :: "int ⇒ int ⇒ int" where
"z3div k l = (if l ≥ 0 then k div l else - (k div - l))"
definition z3mod :: "int ⇒ int ⇒ int" where
"z3mod k l = k mod (if l ≥ 0 then l else - l)"
lemma div_as_z3div:
"∀k l. k div l = (if l = 0 then 0 else if l > 0 then z3div k l else z3div (- k) (- l))"
by (simp add: z3div_def)
lemma mod_as_z3mod:
"∀k l. k mod l = (if l = 0 then k else if l > 0 then z3mod k l else - z3mod (- k) (- l))"
by (simp add: z3mod_def)
subsection ‹Extra theorems for Alethe reconstruction›
lemma alethe_sko_forall[no_atp]: ‹(∀x. P x) ⟷ P (SOME x. ¬P x)›
using someI[of ‹λx. ¬P x›]
by auto
lemma alethe_sko_forall'[no_atp]: ‹P (SOME x. ¬P x) = A ⟹ (∀x. P x) = A›
by (subst alethe_sko_forall)
lemma alethe_sko_forall'': ‹B = A ⟹ (SOME x. P x) = A ≡ (SOME x. P x) = B›
by auto
lemma alethe_sko_forall_indirect[no_atp]: ‹x = (SOME x. ¬P x) ⟹ (∀x. P x) ⟷ P x›
using someI[of ‹λx. ¬P x›]
by auto
lemma alethe_sko_forall_indirect2[no_atp]:
‹x = (SOME x. ¬P x) ⟹ (⋀x :: 'a. (P x = P' x)) ⟹ (∀x. P' x) ⟷ P x›
using someI[of ‹λx. ¬P x›]
by auto
lemma alethe_sko_ex[no_atp]: ‹(∃x. P x) ⟷ P (SOME x. P x)›
using someI[of ‹λx. P x›]
by auto
lemma alethe_sko_ex'[no_atp]: ‹P (SOME x. P x) = A ⟹ (∃x. P x) = A›
by (subst alethe_sko_ex)
lemma alethe_sko_ex_indirect[no_atp]: ‹x = (SOME x. P x) ⟹ (∃x. P x) ⟷ P x›
using someI[of ‹λx. P x›]
by auto
lemma alethe_sko_ex_indirect2[no_atp]: ‹x = (SOME x. P x) ⟹ (⋀x. P x = P' x) ⟹ (∃x. P' x) ⟷ P x›
using someI[of ‹λx. P x›]
by auto
lemma alethe_Pure_trans[no_atp]:
‹P ≡ Q ⟹ Q ⟹ P›
by auto
lemma alethe_if_cong[no_atp]:
assumes ‹b ≡ c›
and ‹c ⟹ x ≡ u›
and ‹¬ c ⟹ y ≡ v›
shows ‹(if b then x else y) ≡ (if c then u else v)›
using assms if_cong[of b c x u] by auto
lemma alethe_if_weak_cong'[no_atp]:
‹b ≡ c ⟹ (if b then x else y) ≡ (if c then x else y)›
by auto
lemma alethe_or_neg[no_atp]:
‹(A ⟹ B) ⟹ B ∨ ¬A›
by auto
lemma alethe_implies_pos[no_atp]: ‹¬(A ⟶ B) ∨ ¬A ∨ B›
by auto
lemma alethe_subst_bool[no_atp]: ‹P ⟹ f True ⟹ f P›
by auto
lemma alethe_and_pos[no_atp]:
‹(a ⟹ ¬(b ∧ c) ∨ A) ⟹ ¬(a ∧ b ∧ c) ∨ A›
‹(a ⟹ b ⟹ A) ⟹ ¬(a ∧ b) ∨ A›
by blast+
lemma alethe_and_pos0[no_atp]:
‹(¬(b ∧ c) ∨ A) ⟹ ¬(a ∧ b ∧ c) ∨ A›
‹(¬b ∨ A) ⟹ ¬(a ∧ b) ∨ A›
‹A ⟹ ¬a ∨ A›
by blast+
lemma alethe_farkas[no_atp]:
‹(a ⟹ A) ⟹ ¬a ∨ A›
‹(¬a ⟹ A) ⟹ a ∨ A›
by blast+
lemma alethe_or_pos[no_atp]:
‹A ∧ A' ⟹ (c ∧ A) ∨ (¬c ∧ A')›
‹A ∧ A' ⟹ (¬c ∧ A) ∨ (c ∧ A')›
by blast+
lemma alethe_distinct_elim_two_clauses[no_atp]:
"((x::bool) ≠ y ∧ x ≠ z ∧ y ≠ z) = False"
apply (cases "x")
apply (cases "y")
by simp_all
lemma alethe_distinct_elim_0[no_atp]:
‹(x ⟹ ¬y ⟹ ¬z ⟹ ((x ≠ a) ∧ A) = False)
⟹ (¬x ⟹ y ⟹ z ⟹ ((x ≠ a) ∧ A) = False)
⟹ (((x ≠ y) ∧ (x ≠ z) ∧ (x ≠ a) ∧ A) = False)›
by (cases x; cases y; cases z; simp)
lemma alethe_distinct_elim_1[no_atp]:
‹((x ≠ b) ∧ A) = False ⟹ ((x ≠ a) ∧ (x ≠ b) ∧ A) = False›
‹ A = False ⟹ ((x ≠ a) ∧ A) = False›
‹(x = a) ⟹ ((x ≠ a) ∧ A) = False›
by blast+
lemma alethe_distinct_elim_2[no_atp]:
‹¬ y ⟹ ¬ z ⟹ y = z›
‹y ⟹ z ⟹ y = z›
by blast+
lemma alethe_shuffle_and1[no_atp]:
‹ A = B ⟹ (a ∧ A) = (a ∧ B)›
by blast
lemma alethe_shuffle_and2[no_atp]:
‹(¬a ⟶ ¬B) ⟹ (a ⟹ A = (b ∧ B)) ⟹ (a ∧ A) = (b ∧ B)›
‹(¬a ⟶ ¬(b ∧ B)) ⟹ (a ⟹ (b ∧ B)) ⟹ a = (b ∧ B)›
by (cases a) auto
lemma alethe_shuffle_and3[no_atp]:
‹b = A ⟹ (a ⟹ b = (a ∧ A))›
apply (cases a)
by simp_all
lemma alethe_shuffle_and4[no_atp]:
‹A ⟹ (a = (a ∧ A))›
apply (cases a)
by simp_all
lemma alethe_shuffle_or_split[no_atp]:
"(a ⟶ (b ∨ B)) ⟹ (¬a ⟹ A = (b ∨ B)) ⟹ (a ∨ A) = (b ∨ B)"
"(a ⟶ (b ∨ B)) ⟹ (¬a ⟹ ¬(b ∨ B)) ⟹ a = (b ∨ B)"
by auto
lemma alethe_shuffle_or_resolve[no_atp]:
"a ⟶ (a ∨ A)"
"a ⟶ A ⟹ a ⟶ (b ∨ A)"
by auto
lemma alethe_shuffle_or1a[no_atp]: "(A = B) ⟹ (a ∨ A) = (a ∨ B)" by auto
lemma alethe_shuffle_or1b[no_atp]: "¬B ⟹ a = (a ∨ B)" by auto
lemma alethe_shuffle_or4a[no_atp]: "a ⟶ (a ∨ B)" by auto
lemma alethe_shuffle_or4b[no_atp]: "(a ⟶ B) ⟹ (a ⟶ (b ∨ B))" by auto
lemma alethe_shuffle_or2b[no_atp]: "(b ⟹ A) ⟹ (¬b ⟹ A = B) ⟹ A = (b ∨ B)"
by auto
lemma alethe_shuffle_or3[no_atp]: "(a ⟹ A) ⟹ (¬a ⟹ A) ⟹ (a ∨ A)"
by auto
lemma alethe_shuffle_or5[no_atp]: "(a ⟹ A) ⟹ (¬a ⟹ ¬A) ⟹ (a = A)"
by auto
lemma alethe_shuffle_or6[no_atp]: "¬A ⟹ (¬a ⟹ (a = A))"
by auto
lemma alethe_la_generic[no_atp]:
‹(a::int) ≤ x ∨ a = x ∨ a ≥ x›
by linarith
lemma alethe_bfun_elim[no_atp]:
‹(if b then P True else P False) = P b›
‹(∀b. P' b) = (P' False ∧ P' True)›
‹(∃b. P' b) = (P' False ∨ P' True)›
by (cases b) (auto simp: all_bool_eq ex_bool_eq)
lemma alethe_eq_true_simplify[no_atp]:
‹(P = True) ≡ P›
by auto
lemma alethe_and_neg[no_atp]:
‹(a ⟹ ¬b ∨ A) ⟹ ¬(a ∧ b) ∨ A›
‹(a ⟹ A) ⟹ ¬a ∨ A›
‹(¬a ⟹ A) ⟹ a ∨ A›
by blast+
lemma alethe_forall_inst[no_atp]:
‹A ⟷ B ⟹ ¬A ∨ B›
‹¬A ⟷ B ⟹ A ∨ B›
‹A ⟷ B ⟹ ¬B ∨ A›
‹A ⟷ ¬B ⟹ B ∨ A›
‹A ⟶ B ⟹ ¬A ∨ B›
‹¬A ⟶ B ⟹ A ∨ B›
by blast+
lemma alethe_eq_transitive[no_atp]:
‹A = B ⟹ B = C ⟹ A = C›
‹A = B ⟹ C = B ⟹ A = C›
‹B = A ⟹ B = C ⟹ A = C›
‹B = A ⟹ C = B ⟹ A = C›
by auto
lemma alethe_bool_simplify[no_atp]:
‹¬(P ⟶ Q) ⟷ P ∧ ¬Q›
‹¬(P ∨ Q) ⟷ ¬P ∧ ¬Q›
‹¬(P ∧ Q) ⟷ ¬P ∨ ¬Q›
‹(P ⟶ (Q ⟶ R)) ⟷ ((P ∧ Q) ⟶ R)›
‹((P ⟶ Q) ⟶ Q) ⟷ P ∨ Q›
‹(Q ⟷ (P ∨ Q)) ⟷ (P ⟶ Q)›
‹P ∧ (P ⟶ Q) ⟷ P ∧ Q›
‹(P ⟶ Q) ∧ P ⟷ P ∧ Q›
unfolding not_imp imp_conjL
by auto
lemma alethe_connective_def[no_atp]:
‹(A ≠ B) = ((¬A ∧ B) ∨ (A ∧ ¬B))›
‹(A = B) = ((A ⟶ B) ∧ (B ⟶ A))›
‹(If A B C) = ((A ⟶ B) ∧ (¬A ⟶ C))›
apply (case_tac [!] A)
by simp_all
lemma alethe_connective_def_forall[no_atp]:
assumes "⋀x::'a. (P x = (Q x))"
shows "(∀x. P x) = (∀x. Q x )"
using assms
unfolding All_def
by (iprover intro: ext eqTrueI assms)
lemma alethe_connective_def_forall2[no_atp]:
assumes "(P = Q)"
shows "(∀x. P x) = (∀x. Q x)"
unfolding assms ..
lemma alethe_ite_simplify[no_atp]:
‹(If True B C) = B›
‹(If False B C) = C›
‹(If A' B B) = B›
‹(If (¬A') B C) = (If A' C B)›
‹(If c (If c A B) C) = (If c A C)›
‹(If c C (If c A B)) = (If c C B)›
‹(If A' True False) = A'›
‹(If A' False True) ⟷ ¬A'›
‹(If A' True B') ⟷ A' ∨ B'›
‹(If A' B' False) ⟷ A' ∧ B'›
‹(If A' False B') ⟷ ¬A' ∧ B'›
‹(If A' B' True) ⟷ ¬A' ∨ B'›
‹x ∧ True ⟷ x›
‹x ∨ False ⟷ x›
‹x ∨ True ⟷ True›
‹x ∧ False ⟷ False›
‹True ∧ x ⟷ x›
‹False ∨ x ⟷ x›
‹True ∨ x ⟷ True›
‹False ∧ x ⟷ False›
for B C :: 'a and A' B' C' :: bool
by auto
lemma alethe_and_simplify1[no_atp]:
‹True ∧ b ⟷ b› ‹b ∧ True ⟷ b›
‹False ∧ b ⟷ False› ‹b ∧ False ⟷ False›
‹(c ∧ ¬c) ⟷ False› ‹(¬c ∧ c) ⟷ False›
‹¬¬a = a›
by auto
lemmas alethe_and_simplify [no_atp] = conj_ac de_Morgan_conj disj_not1
lemma alethe_or_simplify_1[no_atp]:
‹False ∨ b ⟷ b› ‹b ∨ False ⟷ b›
‹b ∨ ¬b›
‹¬b ∨ b›
by auto
lemmas alethe_or_simplify [no_atp] = disj_ac
lemma alethe_not_simplify [no_atp]:
‹¬ ¬b ⟷ b› ‹¬True ⟷ False› ‹¬False ⟷ True›
by auto
lemma alethe_implies_simplify[no_atp]:
‹(¬a ⟶ ¬b) ⟷ (b ⟶ a)›
‹(False ⟶ a) ⟷ True›
‹(a ⟶ True) ⟷ True›
‹(True ⟶ a) ⟷ a›
‹(a ⟶ False) ⟷ ¬a›
‹(a ⟶ a) ⟷ True›
‹(¬a ⟶ a) ⟷ a›
‹(a ⟶ ¬a) ⟷ ¬a›
‹((a ⟶ b) ⟶ b) ⟷ a ∨ b›
‹(¬True) ⟷ False›
‹(¬False) ⟷ True›
by auto
lemma alethe_equiv_simplify[no_atp]:
‹((¬a) = (¬b)) ⟷ (a = b)›
‹(a = a) ⟷ True›
‹(a = (¬a)) ⟷ False›
‹((¬a) = a) ⟷ False›
‹(True = a) ⟷ a›
‹(a = True) ⟷ a›
‹(False = a) ⟷ ¬a›
‹(a = False) ⟷ ¬a›
‹¬¬a ⟷ a›
‹(¬ False) = True›
for a b :: bool
by auto
lemmas alethe_eq_simplify[no_atp] =
eq_refl num.simps neg_equal_zero equal_neg_zero neg_equal_iff_equal Num.rel_simps
lemma alethe_minus_simplify[no_atp]:
‹(a :: 'a :: cancel_comm_monoid_add) - a = 0›
‹(a :: 'a :: cancel_comm_monoid_add) - 0 = a›
‹0 - (b :: 'b :: {group_add}) = -b›
‹- (- (b :: 'b :: group_add)) = b›
by auto
lemma alethe_sum_simplify[no_atp]:
‹(a :: 'a :: cancel_comm_monoid_add) + 0 = a›
by auto
lemmas alethe_prod_simplify[no_atp] =
mult_1
mult_1_right
lemmas alethe_div_simplify[no_atp] =
divide_self div_minus_minus div_by_1
divide_numeral_1 one_plus_numeral
divmod_steps less_irrefl divmod_trivial divmod_cancel
numeral_div_numeral prod.case mult.right_neutral
divmod_step_def euclidean_size_int_def comp_def of_bool_eq
nat_numeral fst_conv snd_conv if_False if_True
minus_numeral_div_numeral Parity.adjust_div_eq
order_refl
num.simps numerals eq_neg_numeral_simps eq_numeral_simps
old.nat.distinct
mult_numeral_left_semiring_numeral le_numeral_Suc pred_numeral_simps Suc_le_mono le_zero_eq
le_num_simps less_num_simps euclidean_size_numeral le_numeral_simps numeral_plus_one
mult.left_neutral numeral_div_minus_numeral
nat_1 nat_0
lemma alethe_comp_simplify1[no_atp]:
‹(a :: 'a ::order) < a ⟷ False›
‹a ≤ a›
‹¬(b' ≤ a') ⟷ (a' :: 'b :: linorder) < b'›
by auto
lemmas alethe_comp_simplify[no_atp] =
alethe_comp_simplify1
zero_less_one
zero_le_one
rel_simps
lemma alethe_la_disequality[no_atp]:
‹(a :: 'a ::linorder) = b ∨ ¬a ≤ b ∨ ¬b ≤ a›
by auto
lemma alethe_la_mult_pos_less[no_atp]:
‹(0 :: 'a :: linordered_idom) < m ∧ (a < b) ⟶ m*a < m*b›
by simp
lemma alethe_la_mult_pos[no_atp]:
‹c = (0 :: 'a :: linordered_idom) ⟹ c < m ∧ (a < b) ⟶ m*a < m*b›
‹c = (0 :: 'a :: linordered_idom) ⟹ c < m ∧ (a ≤ b) ⟶ m*a ≤ m*b›
‹c = (0 :: 'a :: linordered_idom) ⟹ c < m ∧ (a = b) ⟶ m*a = m*b›
‹c = (0 :: 'a :: linordered_idom) ⟹ c < m ∧ ¬(a = b) ⟶ ¬(m*a = m*b)›
‹c = (0 :: 'a :: linordered_idom) ⟹ c < m ∧ (a ≥ b) ⟶ m*a ≥ m*b›
‹c = (0 :: 'a :: linordered_idom) ⟹ c < m ∧ (a > b) ⟶ m*a > m*b›
by simp_all
lemma alethe_la_mult_neg[no_atp]:
‹c = (0 :: 'a :: linordered_idom) ⟹ m < c ∧ (a < b) ⟶ m*a > m*b›
‹c = (0 :: 'a :: linordered_idom) ⟹ m < c ∧ (a ≤ b) ⟶ m*a ≥ m*b›
‹c = (0 :: 'a :: linordered_idom) ⟹ m < c ∧ (a = b) ⟶ m*a = m*b›
‹c = (0 :: 'a :: linordered_idom) ⟹ m < c ∧ ¬(a = b) ⟶ ¬(m*a = m*b)›
‹c = (0 :: 'a :: linordered_idom) ⟹ m < c ∧ (a > b) ⟶ m*a < m*b›
‹c = (0 :: 'a :: linordered_idom) ⟹ m < c ∧ (a ≥ b) ⟶ m*a ≤ m*b›
by simp_all
context
begin
text ‹For the reconstruction, we need to keep the order of the arguments.›
named_theorems smt_arith_multiplication ‹Theorems to reconstruct arithmetic theorems.›
named_theorems smt_arith_combine ‹Theorems to reconstruct arithmetic theorems.›
named_theorems smt_arith_simplify ‹Theorems to combine theorems in the LA procedure›
named_theorems smt_rewrite_lemma_simplify ‹Theorems to simplify instantiate lemma during rewrite reconstruction›
named_theorems arith_simp_cvc5 ‹Might be temp and integrated into smt_arith_simplify›
named_theorems arith_mult_poly_norm_cvc5 ‹Extra rules for reconstruction of poly-norm.›
lemmas [arith_mult_poly_norm_cvc5] =
Groups.monoid_mult_class.mult_1_right Nat.mult_Suc_right
Nat.mult_0_right Nat.add_Suc_right Groups.monoid_add_class.add.right_neutral
Num.numeral_2_eq_2 Nat.One_nat_def Num.numeral_2_eq_2 Nat.One_nat_def
Nat.Suc_less_eq Nat.zero_less_Suc minus_nat.diff_0 Nat.diff_Suc_Suc Nat.le0
prod.case numeral_plus_one divmod_step_def order.refl le_zero_eq
le_numeral_simps less_numeral_simps mult.right_neutral divides_aux_eq
mult_nonneg_nonneg dvd_imp_mod_0 dvd_add zero_less_one mod_mult_self4 numeral_mod_numeral
divmod_trivial prod.sel mult.left_neutral div_pos_pos_trivial arith_simps div_add div_mult_self1
add_le_cancel_left add_le_same_cancel2 not_one_le_zero le_numeral_simps add_le_same_cancel1
zero_neq_one zero_le_one le_num_simps add_Suc mod_div_trivial nat.distinct mult_minus_right
add.inverse_inverse distrib_left_numeral mult_num_simps numeral_times_numeral add_num_simps
divmod_steps rel_simps if_True if_False numeral_div_numeral divmod_cancel prod.case
add_num_simps one_plus_numeral fst_conv arith_simps sub_num_simps dbl_inc_simps
dbl_simps mult_1 add_le_cancel_right left_diff_distrib_numeral add_uminus_conv_diff zero_neq_one
zero_le_one One_nat_def add_Suc mod_div_trivial nat.distinct of_int_1 numerals numeral_One
of_int_numeral add_uminus_conv_diff zle_diff1_eq add_less_same_cancel2 minus_add_distrib
add_uminus_conv_diff mult.left_neutral semiring_class.distrib_right
add_diff_cancel_left' ring_distribs mult_minus_left minus_diff_eq
lemmas [smt_arith_simplify] =
Groups.monoid_mult_class.mult_1_right Nat.mult_Suc_right
Nat.mult_0_right Nat.add_Suc_right Groups.monoid_add_class.add.right_neutral
Num.numeral_2_eq_2 Nat.One_nat_def
Nat.Suc_less_eq Nat.zero_less_Suc minus_nat.diff_0 Nat.diff_Suc_Suc Nat.le0
prod.case numeral_plus_one divmod_step_def order.refl le_zero_eq
mult.right_neutral divides_aux_eq
mult_nonneg_nonneg dvd_imp_mod_0 dvd_add zero_less_one mod_mult_self4 numeral_mod_numeral
divmod_trivial prod.sel mult.left_neutral div_pos_pos_trivial arith_simps div_add div_mult_self1
add_le_cancel_left add_le_same_cancel2 not_one_le_zero add_le_same_cancel1
zero_neq_one zero_le_one add_Suc mod_div_trivial nat.distinct mult_minus_right
add.inverse_inverse distrib_left_numeral
divmod_steps rel_simps if_True if_False numeral_div_numeral divmod_cancel
one_plus_numeral fst_conv
mult_1 add_le_cancel_right left_diff_distrib_numeral add_uminus_conv_diff
of_int_1 numerals numeral_One
of_int_numeral zle_diff1_eq add_less_same_cancel2 minus_add_distrib
semiring_class.distrib_right
add_diff_cancel_left' add_diff_eq ring_distribs mult_minus_left minus_diff_eq
mod_mult_self2_is_0
less_irrefl
lemmas [arith_simp_cvc5] =
smt_arith_simplify
ab_semigroup_mult_class.mult.commute
lemma [arith_simp_cvc5,arith_mult_poly_norm_cvc5,smt_arith_simplify]:
‹¬ (a' :: 'a :: linorder) < b' ⟷ b' ≤ a'›
‹¬ (a' :: 'a :: linorder) ≤ b' ⟷ b' < a'›
‹(c::int) mod Numeral1 = 0›
‹(a::nat) mod Numeral1 = 0›
‹(c::int) div Numeral1 = c›
‹a div Numeral1 = a›
‹(c::int) mod 1 = 0›
‹a mod 1 = 0›
‹(c::int) div 1 = c›
‹a div 1 = a›
‹¬(a' ≠ b') ⟷ a' = b'›
by auto
lemma [arith_simp_cvc5,arith_mult_poly_norm_cvc5]:
‹NO_MATCH 0 (b:: int) ⟹ NO_MATCH 0 (a:: int) ⟹ a < b ⟷ b - a > 0›
‹NO_MATCH 0 b ⟹ NO_MATCH 0 a ⟹ a ≤ b ⟷ b - a ≥ 0›
‹NO_MATCH 0 b ⟹ NO_MATCH 0 a ⟹ a = b ⟷ b - a = 0›
by auto
lemmas [arith_simp_cvc5,arith_mult_poly_norm_cvc5,smt_arith_simplify] = divide_eq_eq_numeral1
uminus_add_conv_diff divide_less_eq_numeral1
diff_gt_0_iff_gt times_divide_eq_left
lemma div_mod_decomp: "A = (A div n) * n + (A mod n)" for A :: nat
by auto
lemma div_less_mono:
fixes A B :: nat
assumes "A < B" "0 < n" and
mod: "A mod n = 0""B mod n = 0"
shows "(A div n) < (B div n)"
using assms(1)
by (subst (asm) div_mod_decomp[of "A" n], subst (asm) div_mod_decomp[of "B" n],
unfold mod, use assms(2,3) in ‹auto simp: ac_simps›)
lemma alethe_le_mono_div[no_atp]:
fixes A B :: nat
assumes "A < B" "0 < n"
shows "(A div n) + (if B mod n = 0 then 1 else 0) ≤ (B div n)"
by (auto simp: ac_simps Suc_leI assms less_mult_imp_div_less div_le_mono less_imp_le_nat)
lemmas [smt_arith_multiplication] =
alethe_le_mono_div[THEN mult_le_mono1, unfolded add_mult_distrib]
div_le_mono[THEN mult_le_mono2, unfolded add_mult_distrib]
lemma div_mod_decomp_int: "A = (A div n) * n + (A mod n)" for A :: int
by auto
lemma zdiv_mono_strict:
fixes A B :: int
assumes "A < B" "0 < n" and
mod: "A mod n = 0""B mod n = 0"
shows "(A div n) < (B div n)"
proof -
show ?thesis
using assms(1)
apply (subst (asm) div_mod_decomp_int[of A n])
apply (subst (asm) div_mod_decomp_int[of B n])
unfolding mod
by (use assms(2,3) in ‹auto simp: ac_simps›)
qed
lemma alethe_le_mono_div_int[no_atp]:
‹A div n + (if B mod n = 0 then 1 else 0) ≤ B div n›
if ‹A < B› ‹0 < n›
for A B n :: int
proof -
from ‹A < B› ‹0 < n› have ‹A div n ≤ B div n›
by (auto intro: zdiv_mono1)
show ?thesis
proof (cases ‹n dvd B›)
case False
with ‹A div n ≤ B div n› show ?thesis
by auto
next
case True
then obtain C where ‹B = n * C› ..
then have ‹B div n = C›
using ‹0 < n› by simp
from ‹0 < n› have ‹A mod n ≥ 0›
by simp
have ‹A div n < C›
proof (rule ccontr)
assume ‹¬ A div n < C›
then have ‹C ≤ A div n›
by simp
with ‹B div n = C› ‹A div n ≤ B div n›
have ‹A div n = C›
by simp
moreover from ‹A < B› have ‹n * (A div n) + A mod n < B›
by simp
ultimately have ‹n * C + A mod n < n * C›
using ‹B = n * C› by simp
moreover have ‹A mod n ≥ 0›
using ‹0 < n› by simp
ultimately show False
by simp
qed
with ‹n dvd B› ‹B div n = C› show ?thesis
by simp
qed
qed
lemma alethe_less_mono_div_int2[no_atp]:
fixes A B :: int
assumes "A ≤ B" "0 < -n"
shows "(A div n) ≥ (B div n)"
using assms(1) assms(2) zdiv_mono1_neg by auto
lemmas [smt_arith_multiplication] =
alethe_le_mono_div_int[THEN mult_left_mono, unfolded int_distrib]
zdiv_mono1[THEN mult_left_mono, unfolded int_distrib]
lemma [smt_arith_multiplication]:
"(x::nat) = y ⟹ x div n * p = y div n * p"
"(x'::int) = y' ⟹ x' div n' * p' = y' div n' * p'"
by simp_all
lemma [smt_arith_combine]:
"a < b ⟹ c < d ⟹ a + c + 2 ≤ b + d"
"a < b ⟹ c ≤ d ⟹ a + c + 1 ≤ b + d"
"a ≤ b ⟹ c < d ⟹ a + c + 1 ≤ b + d" for a b c :: int
by auto
lemma [smt_arith_combine]:
"a < b ⟹ c < d ⟹ a + c + 2 ≤ b + d"
"a < b ⟹ c ≤ d ⟹ a + c + 1 ≤ b + d"
"a ≤ b ⟹ c < d ⟹ a + c + 1 ≤ b + d" for a b c :: nat
by auto
lemmas [smt_arith_combine] =
add_strict_mono
add_less_le_mono
add_mono
add_le_less_mono
lemma [smt_arith_combine]:
‹m < n ⟹ c = d ⟹ m + c < n + d›
‹m ≤ n ⟹ c = d ⟹ m + c ≤ n + d›
‹c = d ⟹ m < n ⟹ m + c < n + d›
‹c = d ⟹ m ≤ n ⟹ m + c ≤ n + d›
for m :: ‹'a :: ordered_cancel_ab_semigroup_add›
by (auto intro: ordered_cancel_ab_semigroup_add_class.add_strict_right_mono
ordered_ab_semigroup_add_class.add_right_mono)
lemma [smt_arith_combine]:
"c = d ⟹ e = f ⟹ c + e = d + f"
by simp
lemma alethe_negate_coefficient[no_atp]:
‹a ≤ (b :: 'a :: {ordered_ab_group_add}) ⟹ -a ≥ -b›
‹a < b ⟹ -a > -b›
‹a = b ⟹ -a = -b›
by auto
lemma alethe_invert_farkas_equation[no_atp]:
‹a ≤ (b :: 'a :: {ordered_ab_group_add}) ⟹ -a ≥ -b›
‹a < b ⟹ -a > -b›
‹a = b ⟹ b = a›
by auto
end
lemma alethe_ite_intro[no_atp]:
‹(If p (a' = (If p a' b')) (b' = (If p a' b'))) ⟷ True›
‹(If p (a' = (If p a' b')) ((If p a' b') = b')) ⟷ True›
‹(If p ((If p a' b') = a') (b' = (If p a' b'))) ⟷ True›
‹(If p ((If p a' b') =a') ((If p a' b') = b')) ⟷ True›
‹(if a then P (if a then a' else b') else Q) ⟷ (if a then P a' else Q)›
‹(if a then P' else Q' (if a then a' else b')) ⟷ (if a then P' else Q' b')›
‹A = f (if a then R else S) ⟷ (if a then A = f R else A = f S)›
by auto
lemma alethe_ite_if_cong[no_atp]:
fixes x y :: bool
assumes "b = c"
and "c ≡ True ⟹ x = u"
and "c ≡ False ⟹ y = v"
shows "(if b then x else y) ≡ (if c then u else v)"
proof -
have H: "(if b then x else y) = (if c then u else v)"
using assms by (auto split: if_splits)
show "(if b then x else y) ≡ (if c then u else v)"
by (subst H) auto
qed
lemma alethe_miniscope_distribute[no_atp]:
‹(∀X. (F1 X ∧ A X)) = ((∀X. F1 X) ∧ (∀X. A X))›
‹(∃X. (F1 X ∨ A X)) = ((∃X. F1 X) ∨ (∃X. A X))›
by (simp_all only: all_conj_distrib ex_disj_distrib)
lemma alethe_miniscope_split[no_atp]:
‹((∀x. F1 x) ∨ (∀y. A y)) = (∀x y. (F1 x ∨ A y))›
‹((∀x. F1 x) ∨ B) = (∀x. (F1 x ∨ B))›
‹(B ∨ (∀x. F1 x)) = (∀x. (B ∨ F1 x))›
‹((∃x. F1 x) ∧ (∃y. A y)) = (∃x y. (F1 x ∧ A y))›
‹((∃x. F1 x) ∧ B) = (∃x. (F1 x ∧ B))›
‹(B ∧ (∃x. F1 x)) = (∃x. (B ∧ F1 x))›
by simp_all
lemma alethe_miniscope_ITE[no_atp]:
‹(∀x Y. (if C then F1 x else A Y)) = (if C then (∀x. F1 x) else (∀Y. A Y))›
‹(∀x. (if C then F1 x else B)) = (if C then (∀x. F1 x) else (∀Y. B))›
‹(∀Y. (if C then F2 else A Y)) = (if C then F2 else (∀Y. A Y))›
by simp_all
named_theorems alethe_poly_simp_rel ‹Theorems required to replay poly_simp_rel›
lemma [alethe_poly_simp_rel]:
fixes x1::"int" and x2 y1 y2 cx cy
shows "cx ≠ 0 ⟹ cy ≠ 0 ⟹
((cx * (x1 - x2)) = (cy * (y1 - y2))) ⟶ ((x1 = x2) = (y1 = y2))"
by force
lemma [alethe_poly_simp_rel]:
fixes x1::"int" and x2 y1 y2 cx cy
shows "((cx > 0) = (cy > 0)) ⟹ cx ≠ 0 ⟹ cy ≠ 0 ⟹
((cx * (x1 - x2)) = (cy * (y1 - y2))) ⟶ ((x1 < x2) = (y1 < y2))"
by (metis less_iff_diff_less_0 mult_less_0_iff not_less_iff_gr_or_eq zero_less_mult_iff)
lemma [alethe_poly_simp_rel]:
fixes x1::"int" and x2 y1 y2 cx cy
shows "((cx > 0) = (cy > 0)) ⟹ cx ≠ 0 ⟹ cy ≠ 0 ⟹
((cx * (x1 - x2)) = (cy * (y1 - y2))) ⟶ ((x1 ≤ x2) = (y1 ≤ y2))"
by (metis diff_gt_0_iff_gt linorder_not_le mult_less_0_iff not_less_iff_gr_or_eq zero_less_mult_iff)
lemma [alethe_poly_simp_rel]:
fixes x1::"int" and x2 y1 y2 cx cy
shows "((cx > 0) = (cy > 0)) ⟹ cx ≠ 0 ⟹ cy ≠ 0 ⟹
((cx * (x1 - x2)) = (cy * (y1 - y2))) ⟶ ((x1 > x2) = (y1 > y2))"
by (metis le_iff_diff_le_0 linorder_not_le mult_less_0_iff nless_le zero_less_mult_iff)
lemma [alethe_poly_simp_rel]:
fixes x1::"int" and x2 y1 y2 cx cy
shows "((cx > 0) = (cy > 0)) ⟹ cx ≠ 0 ⟹ cy ≠ 0 ⟹
((cx * (x1 - x2)) = (cy * (y1 - y2))) ⟶ ((x1 ≥ x2) = (y1 ≥ y2))"
by (metis diff_ge_0_iff_ge linorder_not_le mult_less_0_iff not_less_iff_gr_or_eq zero_less_mult_iff)
lemma alethe_nat_embedding[no_atp]:
"∃x. x ≥ 0 ∧ (y::nat) = nat (x::int)"
using int_eq_iff by blast
lemma alethe_nat_embedding2[no_atp]:
"int (nat (Num.numeral_class.numeral n)) ≡ numeral n"
by simp
lemma alethe_nat_embedding_all[no_atp]:
"(∀(x::nat). P x) = (∀(x::int). x ≥ 0 ⟶ P (nat x))"
using all_nat by simp_all
lemma alethe_nat_embedding_ex[no_atp]:
"(∃(x::nat). P x) = (∃(x::int). x ≥ 0 ∧ P (nat x))"
using ex_nat by simp
lemma int_nat_embedding_preproc_all[no_atp]:
"(∀(x::nat) . P x) ≡ (∀(x::int). x ≥ 0 ⟶ P (nat x))"
using all_nat by simp
lemma int_nat_embedding_preproc_ex[no_atp]:
"(∃(x::nat). P x) ≡ (∃(x::int). x ≥ 0 ∧ P (nat x))"
using ex_nat by auto
context
begin
qualified definition lift_The :: "(int ⇒ bool) ⇒ int" where
"lift_The Q = int (The (λn::nat. Q (int n)))"
lemma int_nat_embedding_preproc_the[no_atp]:
"(The (P::nat ⇒ bool)) ≡ nat (lift_The (λz::int. 0 ≤ z ∧ P (nat z)))"
by (simp add: lift_The_def)
lemma alethe_nat_embedding_all_new[no_atp]:
"(∀x . (∃x'. (((x::nat) = nat (x'::int) ∧ 0 ≤ x' ) ∧ P x = P' x')))
⟹ (∀x::nat. P x) = (∀x'::int. x' ≥ 0 ⟶ P' x')"
apply simp
apply standard+
subgoal using eq_nat_nat_iff by blast
by blast
lemma alethe_nat_embedding_all2[no_atp]:
"(∀(x::int) ≥ 0. int (nat x) = x)"
using all_nat by simp
lemma alethe_nat_embedding_ex2[no_atp]:
"(∃(x::int). x ≥ 0 ∧ int (nat x) = x)"
using ex_nat by auto
lemma alethe_nat_embedding_all3[no_atp]:
"P (int (nat x)) ⟹ x ≥ 0 ⟹ P x"
using all_nat by simp
lemma smt_lift_int_nat[no_atp]:
"int (nat 0) ≡ 0"
"int (nat 1) ≡ 1"
by simp_all
lemma smt_natasint_lift_nat_embedding[no_atp]:
‹x ≥ 0 ⟹ int (nat x) = x›
by simp
lemma smt_natasint_lift_nat_embedding'[no_atp]:
‹x ≥ 0 ⟹ int (nat x) ≡ x›
by simp
lemma smt_natasint_lift_nat_eq[no_atp]:
fixes a b :: int
shows ‹0 ≤ a ⟹ 0 ≤ b ⟹ nat a = nat b ≡ a = b›
by (simp add: nat_eq_iff)
lemma alethe_onepoint[no_atp]:
‹(⋀a. P a = Q a) ⟹ (∀a. P a) = (∀a. Q a)›
‹(⋀a. P' a = Q') ⟹ (∀a. P' a) = Q'›
‹(⋀a. P a = Q a) ⟹ (∃a. P a) = (∃a. Q a)›
‹(⋀a. P' a = Q') ⟹ (∃a. P' a) = Q'›
by auto
lemma alethe_onepoint_simp[no_atp]:
‹(∀x. a = b ∧ P x ⟶ Q x) ⟷ (a = b ⟶ (∀x. P x ⟶ Q x))›
by auto
lemma alethe_rewrite_in_imp[no_atp]:
‹((a::'a) = (b::'a) ≡ P') ⟹ (P' ⟹ P = Q) ⟹ (a = b ⟶ P) ≡ (P' ⟶ Q)›
by auto
lemma alethe_imp_commute[no_atp]: ‹(a ⟶ b ⟶ q) = (b ⟶ a ⟶ q)›
by auto
end
named_theorems nat_normalized_input ‹Theorems required to replay nat operators embedded into lifted int versions›
named_theorems cvc5_normalized_input ‹Theorems required to replay
our more complicated translations›
named_theorems cvc5_holes_simp ‹Simplification theorems for holes›
named_theorems cvc5_holes_pre ‹Theorems applied for holes›
named_theorems simplify_translation ‹Lemmas to normalize the assertions before translation. When an operator (such as a constant) appears the simplifier is called and uses this set›
lemmas [simplify_translation] = arith_simps more_arith_simps
named_theorems alethe_poly_norm ‹Extra theorems for poly norm.›
lemmas [alethe_poly_norm] = mult_1_right mult_1_left
named_theorems alethe_aci_simp ‹Extra theorems for aci simp›
lemma alethe_onepoint2_all[no_atp]:
assumes ‹⋀x. x = t ⟹ P t = Q› ‹⋀x. P x = (x = t ⟶ P x)›
shows ‹(∀x. P x) = Q›
by (use assms in metis)+
lemma alethe_onepoint2_ex[no_atp]:
assumes ‹⋀x. x = t ⟹ P t = Q› ‹⋀x. P x = (x = t ∧ P x)›
shows ‹(∃x. P x) = Q›
by (use assms in metis)+
lemmas alethe_poly_simp_rel_simps[no_atp] =
less_divide_eq_numeral1
less_numeral_simps alethe_div_simplify zero_less_one
not_one_less_zero neg_0_less_iff_less
Parity.semiring_parity_class.odd_numeral
Parity.semiring_parity_class.odd_one
named_theorems alethe_poly_simp_rel_bv_simps ‹Extra theorems for poly simp rel for bv›
lemma alethe_arg_cong0[no_atp]: ‹f = g ⟹ f a = f a›
by (rule arg_cong)
lemma alethe_arg_cong[no_atp]: ‹f = g ⟹ a = b ⟹ f a = g b›
by (auto)
context
begin
qualified definition alethe_Box :: ‹bool ⇒ bool› where
‹alethe_Box P = P›
qualified lemma alethe_Box[no_atp]:
‹P ≡ alethe_Box P›
unfolding alethe_Box_def
by auto
qualified lemma alethe_Box_def2[no_atp]:
‹alethe_Box P ≡ P›
unfolding alethe_Box_def
by auto
qualified definition alethe_id :: ‹'a ⇒ 'a› where
‹alethe_id x = x›
end
named_theorems rare_simplify_temp ‹Theorems to reconstruct bitvector theorems concerning list
functions, e.g. take.›
named_theorems cvc_evaluate ‹Theorems to reconstruct evaluate steps in cvc5 proofs›
named_theorems cvc_evaluate_bv ‹Theorems to reconstruct bit-vector evaluate steps in cvc5 proofs›
lemmas cvc_arith_rewrite_defs = SMT.z3div_def linorder_not_le alethe_comp_simplify1
add1_zle_eq
subsection ‹Setup›
ML_file ‹Tools/SMT/smt_util.ML›
ML_file ‹Tools/SMT/smt_failure.ML›
ML_file ‹Tools/SMT/smt_config.ML›
ML_file ‹Tools/SMT/smt_builtin.ML›
ML_file ‹Tools/SMT/smt_datatypes.ML›
ML_file ‹Tools/SMT/smt_normalize.ML›
ML_file ‹Tools/SMT/smt_translate.ML›
ML_file ‹Tools/SMT/smt_parser_util.ML›
ML_file ‹Tools/SMT/smtlib.ML›
ML_file ‹Tools/SMT/smtlib_interface.ML›
ML_file ‹Tools/SMT/smtlib_proof.ML›
ML_file ‹Tools/SMT/smtlib_isar.ML›
ML_file ‹Tools/SMT/smt_solver.ML›
ML_file ‹Tools/SMT/z3/z3_proof.ML›
ML_file ‹Tools/SMT/z3/z3_isar.ML›
ML_file ‹Tools/SMT/alethe/alethe_node.ML›
ML_file ‹Tools/SMT/alethe/alethe_proof.ML›
ML_file ‹Tools/SMT/alethe/alethe_smt_problem.ML›
ML_file ‹Tools/SMT/alethe/alethe_isar.ML›
ML_file ‹Tools/SMT/alethe/alethe_proof_parse.ML›
ML_file ‹Tools/SMT/alethe/cvc_interface.ML›
ML_file ‹Tools/SMT/alethe/cvc_proof_parse.ML›
ML_file ‹Tools/SMT/conj_disj_perm.ML›
ML_file ‹Tools/SMT/smt_replay_methods.ML›
ML_file ‹Tools/SMT/smt_replay.ML›
ML_file ‹Tools/SMT/smt_replay_arith.ML›
ML_file ‹Tools/SMT/z3/z3_interface.ML›
ML_file ‹Tools/SMT/z3/z3_replay_rules.ML›
ML_file ‹Tools/SMT/z3/z3_replay_methods.ML›
ML_file ‹Tools/SMT/z3/z3_replay.ML›
ML_file ‹Tools/SMT/alethe/alethe_replay_methods.ML›
ML_file ‹Tools/SMT/alethe/cvc5_replay_methods.ML›
ML_file ‹Tools/SMT/alethe/verit_replay_methods.ML›
ML_file ‹Tools/SMT/alethe/alethe_strategies.ML›
ML_file ‹Tools/SMT/alethe/alethe_replay.ML›
ML_file ‹Tools/SMT/alethe/verit_replay.ML›
ML_file ‹Tools/SMT/alethe/cvc5_replay.ML›
ML_file ‹Tools/SMT/smt_systems.ML›
subsection ‹Configuration›
text ‹
The current configuration can be printed by the command
‹smt_status›, which shows the values of most options.
›
subsection ‹General configuration options›
text ‹
The option ‹smt_solver› can be used to change the target SMT
solver. The possible values can be obtained from the ‹smt_status›
command.
›
declare [[smt_solver = z3]]
text ‹
Since SMT solvers are potentially nonterminating, there is a timeout
(given in seconds) to restrict their runtime.
›
declare [[smt_timeout = 0]]
text ‹
SMT solvers apply randomized heuristics. In case a problem is not
solvable by an SMT solver, changing the following option might help.
›
declare [[smt_random_seed = 1]]
text ‹
In general, the binding to SMT solvers runs as an oracle, i.e, the SMT
solvers are fully trusted without additional checks. The following
option can cause the SMT solver to run in proof-producing mode, giving
a checkable certificate. This is currently implemented only for veriT and
Z3.
›
declare [[smt_oracle = false]]
text ‹
Each SMT solver provides several command-line options to tweak its
behaviour. They can be passed to the solver by setting the following
options.
›
declare [[cvc4_options = ""]]
declare [[cvc5_options = "--proof-alethe-define-skolems --proof-elim-subtypes --enum-inst"]]
declare [[cvc5_proof_options = "--proof-format-mode=alethe --proof-granularity=dsl-rewrite
--proof-mode=full-proof-strict --enum-inst"]]
declare [[verit_options = "--proof-with-sharing"]]
declare [[z3_options = ""]]
text ‹
The SMT method provides an inference mechanism to detect simple triggers
in quantified formulas, which might increase the number of problems
solvable by SMT solvers (note: triggers guide quantifier instantiations
in the SMT solver). To turn it on, set the following option.
›
declare [[smt_infer_triggers = false]]
text ‹
Enable the following options to use built-in support for datatypes and codatatypes.›
declare [[smt_native_datatypes = false]]
declare [[smt_native_codatatypes = false]]
text ‹
Enable the following option to use built-in support for div/mod, datatypes,
and records in Z3. Currently, this is implemented only in oracle mode.
›
declare [[z3_extensions = false]]
subsection ‹Certificates›
text ‹
By setting the option ‹smt_certificates› to the name of a file,
all following applications of an SMT solver are cached in that file.
Any further application of the same SMT solver (using the very same
configuration) re-uses the cached certificate instead of invoking the
solver. An empty string disables caching certificates.
The filename should be given as an explicit path. It is good
practice to use the name of the current theory (with ending
‹.certs› instead of ‹.thy›) as the certificates file.
Certificate files should be used at most once in a certain theory context,
to avoid race conditions with other concurrent accesses.
›
declare [[smt_certificates = ""]]
text ‹
The option ‹smt_read_only_certificates› controls whether only
stored certificates should be used or invocation of an SMT solver
is allowed. When set to ‹true›, no SMT solver will ever be
invoked and only the existing certificates found in the configured
cache are used; when set to ‹false› and there is no cached
certificate for some proposition, then the configured SMT solver is
invoked.
›
declare [[smt_read_only_certificates = false]]
subsection ‹Tracing›
text ‹
The SMT method, when applied, traces important information. To
make it entirely silent, set the following option to ‹false›.
›
declare [[smt_verbose = true]]
text ‹
For tracing the generated problem file given to the SMT solver as
well as the returned result of the solver, the option
‹smt_trace› should be set to ‹true›.
›
declare [[smt_trace = false]]
subsection ‹Schematic rules for Z3 proof reconstruction›
text ‹
Several prof rules of Z3 are not very well documented. There are two
lemma groups which can turn failing Z3 proof reconstruction attempts
into succeeding ones: the facts in ‹z3_rule› are tried prior to
any implemented reconstruction procedure for all uncertain Z3 proof
rules; the facts in ‹z3_simp› are only fed to invocations of
the simplifier when reconstructing theory-specific proof steps.
›
lemmas [z3_rule] =
refl eq_commute conj_commute disj_commute simp_thms nnf_simps
ring_distribs field_simps times_divide_eq_right times_divide_eq_left
if_True if_False not_not
NO_MATCH_def
lemma [z3_rule]:
"(P ∧ Q) = (¬ (¬ P ∨ ¬ Q))"
"(P ∧ Q) = (¬ (¬ Q ∨ ¬ P))"
"(¬ P ∧ Q) = (¬ (P ∨ ¬ Q))"
"(¬ P ∧ Q) = (¬ (¬ Q ∨ P))"
"(P ∧ ¬ Q) = (¬ (¬ P ∨ Q))"
"(P ∧ ¬ Q) = (¬ (Q ∨ ¬ P))"
"(¬ P ∧ ¬ Q) = (¬ (P ∨ Q))"
"(¬ P ∧ ¬ Q) = (¬ (Q ∨ P))"
by auto
lemma [z3_rule]:
"(P ⟶ Q) = (Q ∨ ¬ P)"
"(¬ P ⟶ Q) = (P ∨ Q)"
"(¬ P ⟶ Q) = (Q ∨ P)"
"(True ⟶ P) = P"
"(P ⟶ True) = True"
"(False ⟶ P) = True"
"(P ⟶ P) = True"
"(¬ (A ⟷ ¬ B)) ⟷ (A ⟷ B)"
by auto
lemma [z3_rule]:
"((P = Q) ⟶ R) = (R ∨ (Q = (¬ P)))"
by auto
lemma [z3_rule]:
"(¬ True) = False"
"(¬ False) = True"
"(x = x) = True"
"(P = True) = P"
"(True = P) = P"
"(P = False) = (¬ P)"
"(False = P) = (¬ P)"
"((¬ P) = P) = False"
"(P = (¬ P)) = False"
"((¬ P) = (¬ Q)) = (P = Q)"
"¬ (P = (¬ Q)) = (P = Q)"
"¬ ((¬ P) = Q) = (P = Q)"
"(P ≠ Q) = (Q = (¬ P))"
"(P = Q) = ((¬ P ∨ Q) ∧ (P ∨ ¬ Q))"
"(P ≠ Q) = ((¬ P ∨ ¬ Q) ∧ (P ∨ Q))"
by auto
lemma [z3_rule]:
"(if P then P else ¬ P) = True"
"(if ¬ P then ¬ P else P) = True"
"(if P then True else False) = P"
"(if P then False else True) = (¬ P)"
"(if P then Q else True) = ((¬ P) ∨ Q)"
"(if P then Q else True) = (Q ∨ (¬ P))"
"(if P then Q else ¬ Q) = (P = Q)"
"(if P then Q else ¬ Q) = (Q = P)"
"(if P then ¬ Q else Q) = (P = (¬ Q))"
"(if P then ¬ Q else Q) = ((¬ Q) = P)"
"(if ¬ P then x else y) = (if P then y else x)"
"(if P then (if Q then x else y) else x) = (if P ∧ (¬ Q) then y else x)"
"(if P then (if Q then x else y) else x) = (if (¬ Q) ∧ P then y else x)"
"(if P then (if Q then x else y) else y) = (if P ∧ Q then x else y)"
"(if P then (if Q then x else y) else y) = (if Q ∧ P then x else y)"
"(if P then x else if P then y else z) = (if P then x else z)"
"(if P then x else if Q then x else y) = (if P ∨ Q then x else y)"
"(if P then x else if Q then x else y) = (if Q ∨ P then x else y)"
"(if P then x = y else x = z) = (x = (if P then y else z))"
"(if P then x = y else y = z) = (y = (if P then x else z))"
"(if P then x = y else z = y) = (y = (if P then x else z))"
by auto
lemma [z3_rule]:
"0 + (x::int) = x"
"x + 0 = x"
"x + x = 2 * x"
"0 * x = 0"
"1 * x = x"
"x + y = y + x"
by auto
lemma [z3_rule]:
"P = Q ∨ P ∨ Q"
"P = Q ∨ ¬ P ∨ ¬ Q"
"(¬ P) = Q ∨ ¬ P ∨ Q"
"(¬ P) = Q ∨ P ∨ ¬ Q"
"P = (¬ Q) ∨ ¬ P ∨ Q"
"P = (¬ Q) ∨ P ∨ ¬ Q"
"P ≠ Q ∨ P ∨ ¬ Q"
"P ≠ Q ∨ ¬ P ∨ Q"
"P ≠ (¬ Q) ∨ P ∨ Q"
"(¬ P) ≠ Q ∨ P ∨ Q"
"P ∨ Q ∨ P ≠ (¬ Q)"
"P ∨ Q ∨ (¬ P) ≠ Q"
"P ∨ ¬ Q ∨ P ≠ Q"
"¬ P ∨ Q ∨ P ≠ Q"
"P ∨ y = (if P then x else y)"
"P ∨ (if P then x else y) = y"
"¬ P ∨ x = (if P then x else y)"
"¬ P ∨ (if P then x else y) = x"
"P ∨ R ∨ ¬ (if P then Q else R)"
"¬ P ∨ Q ∨ ¬ (if P then Q else R)"
"¬ (if P then Q else R) ∨ ¬ P ∨ Q"
"¬ (if P then Q else R) ∨ P ∨ R"
"(if P then Q else R) ∨ ¬ P ∨ ¬ Q"
"(if P then Q else R) ∨ P ∨ ¬ R"
"(if P then ¬ Q else R) ∨ ¬ P ∨ Q"
"(if P then Q else ¬ R) ∨ P ∨ R"
by auto
hide_type (open) symb_list pattern
hide_const (open) Symb_Nil Symb_Cons trigger pat nopat fun_app z3div z3mod
declare[[smt_cvc_alethe = true]]
end