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 (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) ›
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"
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. ›
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
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_if: fixes a b :: nat shows "int (if P then a else b) = (if P then int a else int b)" by simp
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 veriT reconstruction›
lemma verit_sko_forall: ‹(∀x. P x) ⟷ P (SOME x. ¬P x)› using someI[of ‹λx. ¬P x›] by auto
lemma verit_sko_forall': ‹P (SOME x. ¬P x) = A ==> (∀x. P x) = A› by (subst verit_sko_forall)
lemma verit_sko_forall'': ‹B = A ==> (SOME x. P x) = A ≡ (SOME x. P x) = B› by auto
lemma verit_sko_forall_indirect: ‹x = (SOME x. ¬P x) ==> (∀x. P x) ⟷ P x› using someI[of ‹λx. ¬P x›] by auto
lemma verit_sko_forall_indirect2: ‹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 verit_sko_ex: ‹(∃x. P x) ⟷ P (SOME x. P x)› using someI[of ‹λx. P x›] by auto
lemma verit_sko_ex': ‹P (SOME x. P x) = A ==> (∃x. P x) = A› by (subst verit_sko_ex)
lemma verit_sko_ex_indirect: ‹x = (SOME x. P x) ==> (∃x. P x) ⟷ P x› using someI[of ‹λx. P x›] by auto
lemma verit_sko_ex_indirect2: ‹x = (SOME x. P x) ==> (∧x. P x = P' x) ==> (∃x. P' x) ⟷ P x› using someI[of ‹λx. P x›] by auto
lemma verit_Pure_trans: ‹P ≡ Q ==> Q ==> P› by auto
lemma verit_if_cong: 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 verit_if_weak_cong': ‹b ≡ c ==> (if b then x else y) ≡ (if c then x else y)› by auto
lemma verit_or_neg: ‹(A ==> B) ==> B ∨¬A› ‹(¬A ==> B) ==> B ∨ A› by auto
lemma verit_subst_bool: ‹P ==> f True ==> f P› by auto
lemma verit_and_pos: ‹(a ==>¬(b ∧ c) ∨ A) ==>¬(a ∧ b ∧ c) ∨ A› ‹(a ==> b ==> A) ==>¬(a ∧ b) ∨ A› by blast+
lemma verit_farkas: ‹(a ==> A) ==>¬a ∨ A› ‹(¬a ==> A) ==> a ∨ A› by blast+
lemma verit_or_pos: ‹A ∧ A' ==> (c ∧ A) ∨ (¬c ∧ A')› ‹A ∧ A' ==> (¬c ∧ A) ∨ (c ∧ A')› by blast+
lemma verit_la_generic: ‹(a::int) ≤ x ∨ a = x ∨ a ≥ x› by linarith
lemma verit_bfun_elim: ‹(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 verit_eq_true_simplify: ‹(P = True) ≡ P› by auto
lemma verit_and_neg: ‹(a ==>¬b ∨ A) ==>¬(a ∧ b) ∨ A› ‹(a ==> A) ==>¬a ∨ A› ‹(¬a ==> A) ==> a ∨ A› by blast+
lemma verit_forall_inst: ‹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 verit_eq_transitive: ‹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
text ‹We need the last equation for 🍋‹¬(∀a b. ¬P a b)›\ lemma verit_connective_def: 🍋‹the definition of XOR is missing as the operator is not generated by Isabelle› ‹(A = B) ⟷ ((A ⟶ B) ∧ (B ⟶ A))› ‹(If A B C) = ((A ⟶ B) ∧ (¬A ⟶ C))› ‹(∃x. P x) ⟷¬(∀x. ¬P x)› ‹¬(∃x. P x) ⟷ (∀x. ¬P x)› by auto lemma verit_ite_simplify: ‹(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› for B C :: 'a and A' B' C' :: bool by auto lemma verit_and_simplify1: ‹True ∧ b ⟷ b›‹b ∧ True ⟷ b› ‹False ∧ b ⟷ False›‹b ∧ False ⟷ False› ‹(c ∧¬c) ⟷ False›‹(¬c ∧ c) ⟷ False› ‹¬¬a = a› by auto lemmas verit_and_simplify = conj_ac de_Morgan_conj disj_not1 lemma verit_or_simplify_1: ‹False ∨ b ⟷ b›‹b ∨ False ⟷ b› ‹b ∨¬b› ‹¬b ∨ b› by auto lemmas verit_or_simplify = disj_ac lemma verit_not_simplify: ‹¬¬b ⟷ b›‹¬True ⟷ False›‹¬False ⟷ True› by auto lemma verit_implies_simplify: ‹(¬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› by auto lemma verit_equiv_simplify: ‹((¬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 verit_eq_simplify = semiring_char_0_class.eq_numeral_simps eq_refl zero_neq_one num.simps neg_equal_zero equal_neg_zero one_neq_zero neg_equal_iff_equal lemma verit_minus_simplify: ‹(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 verit_sum_simplify: ‹(a :: 'a :: cancel_comm_monoid_add) + 0 = a› by auto lemmas verit_prod_simplify = (* already included: mult_zero_class.mult_zero_right mult_zero_class.mult_zero_left *) mult_1 mult_1_right
lemma verit_comp_simplify1: ‹(a :: 'a ::order) < a ⟷ False› ‹a ≤ a› ‹¬(b' ≤ a') ⟷ (a' :: 'b :: linorder) < b'› by auto
lemma [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 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)" proof - show ?thesis using assms(1) apply (subst (asm) div_mod_decomp[of "A" n]) apply (subst (asm) div_mod_decomp[of "B" n]) unfolding mod by (use assms(2,3) in ‹auto simp: ac_simps›) qed
lemma verit_le_mono_div: 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)
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 verit_le_mono_div_int: ‹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 verit_less_mono_div_int2: 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] = arg_cong[of _ _ ‹λa :: nat. a div n * p› for n p :: nat, THEN sym] arg_cong[of _ _ ‹λa :: int. a div n * p› for n p :: int, THEN sym]
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
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 verit_negate_coefficient: ‹a ≤ (b :: 'a :: {ordered_ab_group_add}) ==> -a ≥ -b› ‹a < b ==> -a > -b› ‹a = b ==> -a = -b› by auto
end
lemma verit_ite_intro: ‹(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 verit_ite_if_cong: 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
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. ›
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 option to use built-in support for datatypes, codatatypes, and records in CVC4 and cvc5. Currently, this is implemented only in oracle mode. ›
declare [[cvc_extensions = 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. ›
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]: (* for def-axiom *) "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
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.