AFTD Auto-Formalizing Theoretical Domains

thr_res_soundness

theoremverifiedformalization

Soundness of Threshold Resolution: for any CNF formula F : List (List (CnfLit V)), multiset of literals f : Multiset (CnfLit V), and integer s : ℤ, if ThrResDerivable F f s holds, then for every Boolean assignment α : V → Bool satisfying F (meaning that for every clause C ∈ F there is some literal l ∈ C such that eval_cnf_lit α l = true), the threshold condition holds: s ≤ (eval_thr_lits α f : ℤ).

Statement

theorem thr_res_soundness {V : Type*} (F : List (List (CnfLit V))) (f : Multiset (CnfLit V)) (s : ℤ) (hderiv : ThrResDerivable F f s) (α : V → Bool) (hα : ∀ C ∈ F, ∃ l ∈ C, eval_cnf_lit α l = true) : s ≤ (eval_thr_lits α f : ℤ)
Formalizes
arXiv:2611.24548 Theorem 2.18
Verified
20 Nov 2026
Axioms
Quot.soundpropext
Built on 7
  • ThrResDerivableInductive derivation relation ThrResDerivable F f s for a CNF formula F : List (List (CnfLit V)) (a list of clauses, each a list of…
  • eval_thr_litsThe count of literals in a multiset f that evaluate to true under the truth assignment α.
  • eval_cnf_litEvaluation of a CNF literal under a truth assignment: a positive literal pos v evaluates to α v, and a negative literal neg v evaluates to…
  • LinearOrder.toTotalPreorderEvery LinearOrder is a TotalPreorder.
  • CnfLitA CNF literal over a variable type V is either a positive variable or a negated variable.
  • cnf_lit_complThe complement of a literal, negating its polarity.
  • TotalPreorderA total preorder: a preorder where ≤ is total (complete). This is weaker than LinearOrder — it does NOT require antisymmetry or…
Used by 1
  • thr_res_unsat_of_refutationIf a Threshold Resolution refutation of a CNF formula F : List (List (CnfLit V)) exists (namely ThrResDerivable F 0 1), then F is…

Read back from the Lean

For any type $V$, any formula $F$ represented as a list of clauses (each clause being a list of literals over $V$, where a literal is either a positive or negative variable from $V$), any multiset of literals $f$ over $V$, and any integer $s$: if the threshold clause $(f, s)$ is derivable from $F$ via the threshold resolution system ThrResDerivable, then for every truth assignment $\alpha : V \to \mathrm{Bool}$ that satisfies $F$ (in the sense that for every clause $C \in F$, there exists a literal $l \in C$ such that $l$ evaluates to true under $\alpha$), the threshold integer $s$ is less than or equal to the number of literals in $f$ (counted with multiplicity) that evaluate to true under $\alpha$ (cast to an integer).

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

The proof, explained

The proof proceeds by induction on the derivation of `ThrResDerivable F f s`. The base case holds because the empty multiset and threshold 0 satisfy `0 ≤ 0`. For the clause rule, the assumption that α satisfies F ensures each axiom clause has at least one true literal (evaluating to ≥ 1), incrementing the threshold by 1. For resolution on variable x, case analysis on α(x) shows that one branch's resolved literal evaluates to 0, directly reducing that branch's induction hypothesis to the desired bound. Weakening, introduction, and simplification follow from the additivity of literal evaluation and the fact that complementary literal pairs {l, ¬l} always evaluate to 1.

  1. Threshold literal evaluation is additive over multiset sum: `eval_thr_lits α (f₁ + f₂) = eval_thr_lits α f₁ + eval_thr_lits α f₂`.

    By definition, `eval_thr_lits` counts the literals satisfied by α by filtering the multiset and taking its cardinality. Filtering distributes over multiset addition by `Multiset.filter_add`, and the cardinality of a sum of multisets is the sum of their cardinalities by `Multiset.card_add`.

    lines 1–7

    uses Multiset.filter_add, Multiset.card_add

    theorem thr_res_soundness_eval_add {V : Type*} (α : V → Bool) (f₁ f₂ : Multiset (CnfLit V)) :
        eval_thr_lits α (f₁ + f₂) = eval_thr_lits α f₁ + eval_thr_lits α f₂ := by
      change (Multiset.filter (fun l => eval_cnf_lit α l = true) (f₁ + f₂)).card =
        (Multiset.filter (fun l => eval_cnf_lit α l = true) f₁).card +
        (Multiset.filter (fun l => eval_cnf_lit α l = true) f₂).card
      rw [Multiset.filter_add, Multiset.card_add]
    
  2. Threshold evaluation on the empty multiset is zero: `eval_thr_lits α 0 = 0`.

    Filtering the empty multiset yields the empty multiset, whose cardinality is 0.

    lines 8–12

    theorem thr_res_soundness_eval_zero {V : Type*} (α : V → Bool) :
        eval_thr_lits α 0 = 0 := by
      change (Multiset.filter (fun l => eval_cnf_lit α l = true) 0).card = 0
      simp
    
  3. A literal's complement evaluates to the Boolean negation of the literal: `eval_cnf_lit α (cnf_lit_compl l) = !eval_cnf_lit α l`.

    By case analysis on whether the literal `l` is positive or negative, expanding the definitions of `eval_cnf_lit` and `cnf_lit_compl` directly verifies the equality.

    lines 13–16

    theorem thr_res_soundness_eval_cnf_lit_compl {V : Type*} (α : V → Bool) (l : CnfLit V) :
        eval_cnf_lit α (cnf_lit_compl l) = !eval_cnf_lit α l := by
      cases l <;> simp [eval_cnf_lit, cnf_lit_compl]
    
  4. Evaluating a prepended literal satisfies `eval_thr_lits α (l ::ₘ f) = (if eval_cnf_lit α l = true then 1 else 0) + eval_thr_lits α f`.

    By `Multiset.filter_cons`, filtering `l ::ₘ f` produces a singleton `{l}` if `l` evaluates to true (with cardinality 1) or the empty multiset if false (cardinality 0), plus the filtered tail `f`. Splitting on the condition completes the equality.

    lines 17–25

    uses Multiset.filter_cons, Multiset.card_add

    theorem thr_res_soundness_eval_cons {V : Type*} (α : V → Bool) (l : CnfLit V) (f : Multiset (CnfLit V)) :
        eval_thr_lits α (l ::ₘ f) = (if eval_cnf_lit α l = true then 1 else 0) + eval_thr_lits α f := by
      change (Multiset.filter (fun x => eval_cnf_lit α x = true) (l ::ₘ f)).card =
        (if eval_cnf_lit α l = true then 1 else 0) + (Multiset.filter (fun x => eval_cnf_lit α x = true) f).card
      rw [Multiset.filter_cons, Multiset.card_add]
      split_ifs with h
      · simp
      · simp
    
  5. A complementary pair of literals `{l, ¬l}` evaluates to exactly 1 under any assignment: `eval_thr_lits α (l ::ₘ cnf_lit_compl l ::ₘ 0) = 1`.

    Rewriting with `thr_res_soundness_eval_cons`, `thr_res_soundness_eval_zero`, and `thr_res_soundness_eval_cnf_lit_compl` expresses the evaluation as the sum of truth values for `l` and `!l`. A case split on `eval_cnf_lit α l` confirms that exactly one is true, summing to 1.

    lines 26–30

    uses thr_res_soundness_eval_cons, thr_res_soundness_eval_zero, thr_res_soundness_eval_cnf_lit_compl

    theorem thr_res_soundness_eval_compl_pair {V : Type*} (α : V → Bool) (l : CnfLit V) :
        eval_thr_lits α (l ::ₘ cnf_lit_compl l ::ₘ 0) = 1 := by
      rw [thr_res_soundness_eval_cons, thr_res_soundness_eval_cons, thr_res_soundness_eval_zero, thr_res_soundness_eval_cnf_lit_compl]
      cases eval_cnf_lit α l <;> rfl
    
  6. If an assignment satisfies a clause `C`, the multiset of its literals has evaluation at least 1: `1 ≤ eval_thr_lits α (↑C)`.

    Since `C` contains a literal `l` satisfied by α, `l` belongs to the filtered multiset of true literals in `C` by `Multiset.mem_filter` and list-to-multiset inclusion (`Multiset.mem_coe.mpr`). As this filtered multiset is non-empty, its cardinality is strictly positive (`Multiset.card_pos_iff_exists_mem.mpr`), so it is at least 1.

    lines 31–42

    uses Multiset.mem_filter, Multiset.mem_coe.mpr, Multiset.card_pos_iff_exists_mem.mpr

    theorem thr_res_soundness_eval_coe_list_pos {V : Type*} (α : V → Bool) (C : List (CnfLit V))
        (hl : ∃ l ∈ C, eval_cnf_lit α l = true) :
        1 ≤ eval_thr_lits α (↑C : Multiset (CnfLit V)) := by
      rcases hl with ⟨l, hin, heval⟩
      change 1 ≤ (Multiset.filter (fun x => eval_cnf_lit α x = true) (↑C : Multiset (CnfLit V))).card
      have hmem : l ∈ Multiset.filter (fun x => eval_cnf_lit α x = true) (↑C : Multiset (CnfLit V)) := by
        rw [Multiset.mem_filter]
        exact ⟨Multiset.mem_coe.mpr hin, heval⟩
      have hpos : 0 < (Multiset.filter (fun x => eval_cnf_lit α x = true) (↑C : Multiset (CnfLit V))).card :=
        Multiset.card_pos_iff_exists_mem.mpr ⟨l, hmem⟩
      omega
    
  7. If variable `x` is false under α, the singleton `{x}` evaluates to 0: `eval_thr_lits α {CnfLit.pos x} = 0`.

    Representing `{CnfLit.pos x}` as `CnfLit.pos x ::ₘ 0`, rewriting with `thr_res_soundness_eval_cons`, `thr_res_soundness_eval_zero`, and `add_zero`, and substituting `α x = false` reduces the evaluation to 0.

    lines 43–48

    uses thr_res_soundness_eval_cons, thr_res_soundness_eval_zero, add_zero

    theorem thr_res_soundness_eval_pos_of_false {V : Type*} (α : V → Bool) (x : V) (h : α x = false) :
        eval_thr_lits α {CnfLit.pos x} = 0 := by
      have : ({CnfLit.pos x} : Multiset (CnfLit V)) = CnfLit.pos x ::ₘ 0 := rfl
      rw [this, thr_res_soundness_eval_cons, thr_res_soundness_eval_zero, add_zero]
      simp [eval_cnf_lit, h]
    
  8. If variable `x` is true under α, the singleton `{¬x}` evaluates to 0: `eval_thr_lits α {CnfLit.neg x} = 0`.

    Representing `{CnfLit.neg x}` as `CnfLit.neg x ::ₘ 0`, rewriting with `thr_res_soundness_eval_cons`, `thr_res_soundness_eval_zero`, and `add_zero`, and substituting `α x = true` reduces the evaluation of the negated literal to 0.

    lines 49–54

    uses thr_res_soundness_eval_cons, thr_res_soundness_eval_zero, add_zero

    theorem thr_res_soundness_eval_neg_of_true {V : Type*} (α : V → Bool) (x : V) (h : α x = true) :
        eval_thr_lits α {CnfLit.neg x} = 0 := by
      have : ({CnfLit.neg x} : Multiset (CnfLit V)) = CnfLit.neg x ::ₘ 0 := rfl
      rw [this, thr_res_soundness_eval_cons, thr_res_soundness_eval_zero, add_zero]
      simp [eval_cnf_lit, h]
    
  9. Induction setup for `thr_res_soundness` and base case: for the derivation rule `source`, `0 ≤ eval_thr_lits α 0`.

    We proceed by induction on the derivation `ThrResDerivable F f s`. In the base case `source`, the multiset is `0` and the threshold is `0`. Applying `thr_res_soundness_eval_zero` simplifies the goal to `0 ≤ 0`, which holds reflexively.

    lines 55–60

    uses thr_res_soundness_eval_zero

    /-- Theorem 2.18 (Soundness): Every line of a Thr-Res derivation is satisfied by every assignment satisfying the CNF. -/
    theorem thr_res_soundness {V : Type*} (F : List (List (CnfLit V))) (f : Multiset (CnfLit V)) (s : ℤ) (hderiv : ThrResDerivable F f s) (α : V → Bool) (hα : ∀ C ∈ F, ∃ l ∈ C, eval_cnf_lit α l = true) : s ≤ (eval_thr_lits α f : ℤ) := by
      induction hderiv with
      | source =>
        rw [thr_res_soundness_eval_zero]
        rfl
  10. Axiom clause rule: if `s ≤ eval_thr_lits α f` and `C ∈ F`, then `s + 1 ≤ eval_thr_lits α (f + ↑C)`.

    By `thr_res_soundness_eval_add`, the evaluation of `f + ↑C` is `eval_thr_lits α f + eval_thr_lits α ↑C`. Since α satisfies `F`, clause `C` has at least one true literal, so `1 ≤ eval_thr_lits α ↑C` by `thr_res_soundness_eval_coe_list_pos`. Combining this with the induction hypothesis `s ≤ eval_thr_lits α f` establishes `s + 1 ≤ eval_thr_lits α (f + ↑C)` by linear arithmetic (`omega`).

    lines 61–65

    uses thr_res_soundness_eval_add, thr_res_soundness_eval_coe_list_pos

      | @clause f s C h hin ih =>
        rw [thr_res_soundness_eval_add]
        push_cast
        have hc := thr_res_soundness_eval_coe_list_pos α C (hα C hin)
        omega
  11. Resolution rule: if `s ≤ eval_thr_lits α (f + {x})` and `s ≤ eval_thr_lits α (f + {¬x})`, then `s ≤ eval_thr_lits α f`.

    We split into cases on `α x`. If `α x = true`, then `{¬x}` evaluates to 0 by `thr_res_soundness_eval_neg_of_true`, so the second induction hypothesis simplifies via `thr_res_soundness_eval_add` and `add_zero` directly to `s ≤ eval_thr_lits α f`. If `α x = false`, then `{x}` evaluates to 0 by `thr_res_soundness_eval_pos_of_false`, and the first induction hypothesis similarly yields `s ≤ eval_thr_lits α f`.

    lines 66–73

    uses add_zero, thr_res_soundness_eval_add, thr_res_soundness_eval_neg_of_true, thr_res_soundness_eval_pos_of_false

      | @resolution f s x h1 h2 ih1 ih2 =>
        cases hx : α x with
        | true =>
          rw [thr_res_soundness_eval_add, thr_res_soundness_eval_neg_of_true α x hx, add_zero] at ih2
          exact ih2
        | false =>
          rw [thr_res_soundness_eval_add, thr_res_soundness_eval_pos_of_false α x hx, add_zero] at ih1
          exact ih1
  12. Weakening rule: if `s ≤ eval_thr_lits α f`, then `s ≤ eval_thr_lits α (f + {l})`.

    By `thr_res_soundness_eval_add`, `eval_thr_lits α (f + {l}) = eval_thr_lits α f + eval_thr_lits α {l}`. Since literal counts are non-negative, the result follows immediately from the induction hypothesis `s ≤ eval_thr_lits α f` via `omega`.

    lines 74–77

    uses thr_res_soundness_eval_add

      | weak h ih =>
        rw [thr_res_soundness_eval_add]
        push_cast
        omega
  13. Introduction rule: if `s ≤ eval_thr_lits α f`, then `s + 1 ≤ eval_thr_lits α (f + {l, ¬l})`.

    By additivity (`thr_res_soundness_eval_add`) and `thr_res_soundness_eval_compl_pair`, the evaluation of `f + {l, ¬l}` is `eval_thr_lits α f + 1`. Adding 1 to both sides of the induction hypothesis `s ≤ eval_thr_lits α f` completes the step by `omega`.

    lines 78–81

    uses thr_res_soundness_eval_add, thr_res_soundness_eval_compl_pair

      | introduce h ih =>
        rw [thr_res_soundness_eval_add, thr_res_soundness_eval_compl_pair]
        push_cast
        omega
  14. Simplification rule: if `s ≤ eval_thr_lits α (f + {l, ¬l})`, then `s - 1 ≤ eval_thr_lits α f`.

    Rewriting the induction hypothesis with `thr_res_soundness_eval_add` and `thr_res_soundness_eval_compl_pair` gives `s ≤ eval_thr_lits α f + 1`. Subtracting 1 from both sides yields `s - 1 ≤ eval_thr_lits α f` by linear integer arithmetic (`omega`).

    lines 82–85

    uses thr_res_soundness_eval_add, thr_res_soundness_eval_compl_pair

      | simplify h ih =>
        rw [thr_res_soundness_eval_add, thr_res_soundness_eval_compl_pair] at ih
        push_cast at ih
        omega
Multiset.filter_add
Filtering a sum of multisets by a predicate distributes over the sum.
Multiset.card_add
The cardinality of the sum of two multisets is the sum of their cardinalities.
Multiset.filter_cons
Filtering an element prepended to a multiset yields a singleton if the element satisfies the predicate (or empty otherwise) plus the filtered tail.
thr_res_soundness_eval_cons
The number of satisfied literals in `l ::ₘ f` is 1 (if `l` is satisfied) or 0 (if not), plus the satisfied count of `f`.
thr_res_soundness_eval_zero
The empty multiset of literals has zero satisfied literals under any assignment.
thr_res_soundness_eval_cnf_lit_compl
The truth value of the complement of a literal is the Boolean negation of the literal's truth value.
Multiset.mem_filter
An element belongs to a filtered multiset if and only if it belongs to the multiset and satisfies the predicate.
Multiset.mem_coe.mpr
An element belonging to a list also belongs to its multiset coercion.
Multiset.card_pos_iff_exists_mem.mpr
If a multiset contains at least one element, its cardinality is strictly positive.
add_zero
Adding zero to an element leaves it unchanged.
thr_res_soundness_eval_add
The count of satisfied literals distributes additively over multiset addition.
thr_res_soundness_eval_coe_list_pos
If a clause contains at least one literal evaluated to true by an assignment, the multiset of its literals has threshold evaluation at least 1.
thr_res_soundness_eval_pos_of_false
A positive literal of a variable assigned false contributes 0 to the threshold evaluation.
thr_res_soundness_eval_neg_of_true
A negative literal of a variable assigned true contributes 0 to the threshold evaluation.
thr_res_soundness_eval_compl_pair
A pair consisting of a literal and its complement evaluates to exactly 1 under any assignment.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

theorem thr_res_soundness_eval_add {V : Type*} (α : V → Bool) (f₁ f₂ : Multiset (CnfLit V)) :    eval_thr_lits α (f₁ + f₂) = eval_thr_lits α f₁ + eval_thr_lits α f₂ := by  change (Multiset.filter (fun l => eval_cnf_lit α l = true) (f₁ + f₂)).card =    (Multiset.filter (fun l => eval_cnf_lit α l = true) f₁).card +    (Multiset.filter (fun l => eval_cnf_lit α l = true) f₂).card  rw [Multiset.filter_add, Multiset.card_add]theorem thr_res_soundness_eval_zero {V : Type*} (α : V → Bool) :    eval_thr_lits α 0 = 0 := by  change (Multiset.filter (fun l => eval_cnf_lit α l = true) 0).card = 0  simptheorem thr_res_soundness_eval_cnf_lit_compl {V : Type*} (α : V → Bool) (l : CnfLit V) :    eval_cnf_lit α (cnf_lit_compl l) = !eval_cnf_lit α l := by  cases l <;> simp [eval_cnf_lit, cnf_lit_compl]theorem thr_res_soundness_eval_cons {V : Type*} (α : V → Bool) (l : CnfLit V) (f : Multiset (CnfLit V)) :    eval_thr_lits α (l ::ₘ f) = (if eval_cnf_lit α l = true then 1 else 0) + eval_thr_lits α f := by  change (Multiset.filter (fun x => eval_cnf_lit α x = true) (l ::ₘ f)).card =    (if eval_cnf_lit α l = true then 1 else 0) + (Multiset.filter (fun x => eval_cnf_lit α x = true) f).card  rw [Multiset.filter_cons, Multiset.card_add]  split_ifs with h  · simp  · simptheorem thr_res_soundness_eval_compl_pair {V : Type*} (α : V → Bool) (l : CnfLit V) :    eval_thr_lits α (l ::ₘ cnf_lit_compl l ::ₘ 0) = 1 := by  rw [thr_res_soundness_eval_cons, thr_res_soundness_eval_cons, thr_res_soundness_eval_zero, thr_res_soundness_eval_cnf_lit_compl]  cases eval_cnf_lit α l <;> rfltheorem thr_res_soundness_eval_coe_list_pos {V : Type*} (α : V → Bool) (C : List (CnfLit V))    (hl : ∃ l ∈ C, eval_cnf_lit α l = true) :    1 ≤ eval_thr_lits α (↑C : Multiset (CnfLit V)) := by  rcases hl with ⟨l, hin, heval⟩  change 1 ≤ (Multiset.filter (fun x => eval_cnf_lit α x = true) (↑C : Multiset (CnfLit V))).card  have hmem : l ∈ Multiset.filter (fun x => eval_cnf_lit α x = true) (↑C : Multiset (CnfLit V)) := by    rw [Multiset.mem_filter]    exact ⟨Multiset.mem_coe.mpr hin, heval⟩  have hpos : 0 < (Multiset.filter (fun x => eval_cnf_lit α x = true) (↑C : Multiset (CnfLit V))).card :=    Multiset.card_pos_iff_exists_mem.mpr ⟨l, hmem⟩  omegatheorem thr_res_soundness_eval_pos_of_false {V : Type*} (α : V → Bool) (x : V) (h : α x = false) :    eval_thr_lits α {CnfLit.pos x} = 0 := by  have : ({CnfLit.pos x} : Multiset (CnfLit V)) = CnfLit.pos x ::ₘ 0 := rfl  rw [this, thr_res_soundness_eval_cons, thr_res_soundness_eval_zero, add_zero]  simp [eval_cnf_lit, h]theorem thr_res_soundness_eval_neg_of_true {V : Type*} (α : V → Bool) (x : V) (h : α x = true) :    eval_thr_lits α {CnfLit.neg x} = 0 := by  have : ({CnfLit.neg x} : Multiset (CnfLit V)) = CnfLit.neg x ::ₘ 0 := rfl  rw [this, thr_res_soundness_eval_cons, thr_res_soundness_eval_zero, add_zero]  simp [eval_cnf_lit, h]/-- Theorem 2.18 (Soundness): Every line of a Thr-Res derivation is satisfied by every assignment satisfying the CNF. -/theorem thr_res_soundness {V : Type*} (F : List (List (CnfLit V))) (f : Multiset (CnfLit V)) (s : ℤ) (hderiv : ThrResDerivable F f s) (α : V → Bool) (hα : ∀ C ∈ F, ∃ l ∈ C, eval_cnf_lit α l = true) : s ≤ (eval_thr_lits α f : ℤ) := by  induction hderiv with  | source =>    rw [thr_res_soundness_eval_zero]    rfl  | @clause f s C h hin ih =>    rw [thr_res_soundness_eval_add]    push_cast    have hc := thr_res_soundness_eval_coe_list_pos α C (hα C hin)    omega  | @resolution f s x h1 h2 ih1 ih2 =>    cases hx : α x with    | true =>      rw [thr_res_soundness_eval_add, thr_res_soundness_eval_neg_of_true α x hx, add_zero] at ih2      exact ih2    | false =>      rw [thr_res_soundness_eval_add, thr_res_soundness_eval_pos_of_false α x hx, add_zero] at ih1      exact ih1  | weak h ih =>    rw [thr_res_soundness_eval_add]    push_cast    omega  | introduce h ih =>    rw [thr_res_soundness_eval_add, thr_res_soundness_eval_compl_pair]    push_cast    omega  | simplify h ih =>    rw [thr_res_soundness_eval_add, thr_res_soundness_eval_compl_pair] at ih    push_cast at ih    omega
See it in the graphDiscuss this resultChallenge it