Documentation

CslibFrontier.Logics.Propositional.PseudoBoolean

Pseudo-Boolean constraints #

A pseudo-Boolean constraint ∑ᵢ aᵢ ℓᵢ ≥ d has natural coefficients aᵢ on literals ℓᵢ and a natural degree d; a literal counts 1 when true and 0 when false (Cslib.Logic.PL.PBConstr). This is the normalized form in which the VeriPB proof checker Bogaerts, Gocht, McCreesh and Nordström stores constraints. The definitions here are computable and written with structural recursion on lists, so that the kernel can evaluate them.

A constraint is normalized (Cslib.Logic.PL.PBConstr.normalize) through its linear form: the literal ¬x is 1 - x, so the constraint is ∑ᵥ cᵥ xᵥ ≥ D with integer cᵥ and D (Cslib.Logic.PL.PBConstr.toLinear); terms on the same variable are merged and terms with coefficient 0 dropped, and the result is turned back into literals with positive coefficients, the degree rising by the coefficients of the negative literals and clamped at 0. Normalization changes no satisfying assignment (Cslib.Logic.PL.PBConstr.holds_normalize) and introduces no variable (Cslib.Logic.PL.PBConstr.mem_vars_of_mem_vars_normalize).

The rules of the cutting-planes fragment of VeriPB Gocht and Nordström are sound (Cslib.Logic.PL.PBConstr.Holds.add, …): addition, multiplication by a natural, division by a positive natural with every coefficient and the degree rounded up, saturation of every coefficient at the degree, weakening (dropping a variable and lowering the degree by its coefficients), and the literal axioms ℓ ≥ 0. The negation of ∑ aᵢ ℓᵢ ≥ d is ∑ aᵢ ¬ℓᵢ ≥ ∑ aᵢ - d + 1 (Cslib.Logic.PL.PBConstr.holds_negate).

Main definitions #

References #

A pseudo-Boolean constraint ∑ᵢ aᵢ ℓᵢ ≥ d over the variables ℕ: a list of terms, each a natural coefficient and a literal, and a natural degree.

Instances For
    @[instance_reducible]

    Semantics #

    The variable of a term.

    The sign of the literal of a term: true for x, false for ¬x.

    @[simp]
    @[simp]

    The value of a term: its coefficient if its literal is true, and 0 otherwise.

    The value ∑ᵢ aᵢ ℓᵢ of a list of terms.

    σ satisfies the constraint.

    Instances For
      @[instance_reducible]

      The sum of the coefficients.

      @[simp]
      theorem Cslib.Logic.PL.PBConstr.lhs_nil (σ : ℕ → Bool) :
      lhs σ [] = 0
      @[simp]
      theorem Cslib.Logic.PL.PBConstr.lhs_cons (σ : ℕ → Bool) (t : ℕ × Literal ℕ) (ts : List (ℕ × Literal ℕ)) :
      lhs σ (t :: ts) = termVal σ t + lhs σ ts
      @[simp]
      theorem Cslib.Logic.PL.PBConstr.lhs_append (σ : ℕ → Bool) (ts us : List (ℕ × Literal ℕ)) :
      lhs σ (ts ++ us) = lhs σ ts + lhs σ us
      theorem Cslib.Logic.PL.PBConstr.holds_congr {σ τ : ℕ → Bool} {c : PBConstr} (h : ∀ t ∈ c.terms, σ (termVar t) = τ (termVar t)) :
      Holds σ c ↔ Holds τ c

      A constraint holds at σ exactly when it holds at an assignment agreeing with σ on the variables of its terms.

      A term and the term of the negated literal sum to the coefficient.

      The linear form #

      The signed coefficient of a term on its variable: a for x, -a for ¬x.

      The coefficients of the negative literals, whose 1s move to the right-hand side.

      Add a to the coefficient of v in a list of variables and integer coefficients.

      The linear form ∑ᵥ cᵥ xᵥ of a list of terms, one entry per variable.

      The value ∑ᵥ cᵥ xᵥ of a linear form.

      The sum of the magnitudes of the negative coefficients of a linear form.

      @[simp]
      theorem Cslib.Logic.PL.PBConstr.linVal_cons (σ : ℕ → Bool) (e : ℕ × ℤ) (L : List (ℕ × ℤ)) :
      linVal σ (e :: L) = e.2 * ↑(σ e.1).toNat + linVal σ L
      theorem Cslib.Logic.PL.PBConstr.linVal_map_neg (σ : ℕ → Bool) (L : List (ℕ × ℤ)) :
      linVal σ (List.map (fun (e : ℕ × ℤ) => (e.1, -e.2)) L) = -linVal σ L

      Negating every coefficient negates the value.

      theorem Cslib.Logic.PL.PBConstr.linVal_congr {σ τ : ℕ → Bool} {L : List (ℕ × ℤ)} (h : ∀ e ∈ L, σ e.1 = τ e.1) :
      linVal σ L = linVal τ L

      A linear form has the same value at assignments agreeing on its variables.

      theorem Cslib.Logic.PL.PBConstr.linVal_insertCoeff (σ : ℕ → Bool) (v : ℕ) (a : ℤ) (L : List (ℕ × ℤ)) :
      linVal σ (insertCoeff v a L) = a * ↑(σ v).toNat + linVal σ L
      theorem Cslib.Logic.PL.PBConstr.insertCoeff_of_not_mem {v : ℕ} {a : ℤ} {L : List (ℕ × ℤ)} (h : v ∉ List.map Prod.fst L) :
      insertCoeff v a L = L ++ [(v, a)]

      Adding a coefficient for a variable not in the linear form appends it.

      The linear form of terms has one entry per variable.

      The linear form of terms has no variable other than theirs.

      theorem Cslib.Logic.PL.PBConstr.termVal_eq (σ : ℕ → Bool) (t : ℕ × Literal ℕ) :
      ↑(termVal σ t) = termCoeff t * ↑(σ (termVar t)).toNat + if termPos t = true then 0 else ↑t.1

      The value of a term is its signed coefficient times its variable, plus its coefficient if its literal is negative.

      theorem Cslib.Logic.PL.PBConstr.lhs_eq_linVal (σ : ℕ → Bool) (ts : List (ℕ × Literal ℕ)) :
      ↑(lhs σ ts) = linVal σ (toLinear ts) + ↑(negSum ts)

      The linear form: ∑ aᵢ ℓᵢ = ∑ᵥ cᵥ xᵥ + ∑_{ℓᵢ negative} aᵢ.

      The term of a linear-form entry: c x for c > 0, |c| ¬x for c < 0, none for 0.

      The constraint ∑ᵥ cᵥ xᵥ ≥ D of a linear form, with positive coefficients on literals.

      theorem Cslib.Logic.PL.PBConstr.lhs_entryTerm (σ : ℕ → Bool) (e : ℕ × ℤ) :
      ↑(lhs σ (entryTerm e).toList) = e.2 * ↑(σ e.1).toNat + ↑(-e.2).toNat
      theorem Cslib.Logic.PL.PBConstr.lhs_fromLinear (σ : ℕ → Bool) (L : List (ℕ × ℤ)) (D : ℤ) :
      ↑(lhs σ (fromLinear L D).terms) = linVal σ L + ↑(negMass L)

      Normalization #

      The normal form: merge the terms on each variable, drop zero coefficients, and move the constants of negative literals into the degree, clamped at 0.

      @[simp]

      Normalization changes no satisfying assignment.

      The variables of the terms of a constraint.

      The constraint of a linear form has only variables of the form.

      Normalization introduces no variable.

      The rules #

      Addition: the sum of two constraints, normalized.

      Multiplication by a natural k, normalized.

      ⌈a / k⌉, and 0 for k = 0.

      Division by k: normalize, then round every coefficient and the degree up.

      Saturation: normalize, then cap every coefficient at the degree.

      Weakening on the variable v: normalize, drop the terms on v, and lower the degree by their coefficients.

      The literal axiom ℓ ≥ 0.

      The negation of the normal form of ∑ aᵢ ℓᵢ ≥ d: ∑ aᵢ ¬ℓᵢ ≥ ∑ aᵢ - d + 1.

      A constraint whose coefficients sum to less than its degree: no assignment satisfies it.

      Instances For

        Soundness of the rules #

        theorem Cslib.Logic.PL.PBConstr.lhs_map_mul (σ : ℕ → Bool) (k : ℕ) (ts : List (ℕ × Literal ℕ)) :
        lhs σ (List.map (fun (t : ℕ × Literal ℕ) => (k * t.1, t.2)) ts) = k * lhs σ ts
        theorem Cslib.Logic.PL.PBConstr.Holds.add {σ : ℕ → Bool} {c d : PBConstr} (hc : Holds σ c) (hd : Holds σ d) :
        Holds σ (c.add d)
        theorem Cslib.Logic.PL.PBConstr.Holds.mul {σ : ℕ → Bool} {c : PBConstr} (hc : Holds σ c) (k : ℕ) :
        theorem Cslib.Logic.PL.PBConstr.le_mul_ceilDiv (a : ℕ) {k : ℕ} (hk : 0 < k) :
        a ≤ k * ceilDiv a k
        theorem Cslib.Logic.PL.PBConstr.ceilDiv_le_of_le_mul {a k x : ℕ} (hk : 0 < k) (h : a ≤ k * x) :
        ceilDiv a k ≤ x
        theorem Cslib.Logic.PL.PBConstr.lhs_le_mul_lhs_ceilDiv (σ : ℕ → Bool) {k : ℕ} (hk : 0 < k) (ts : List (ℕ × Literal ℕ)) :
        lhs σ ts ≤ k * lhs σ (List.map (fun (t : ℕ × Literal ℕ) => (ceilDiv t.1 k, t.2)) ts)
        theorem Cslib.Logic.PL.PBConstr.Holds.div {σ : ℕ → Bool} {c : PBConstr} (hc : Holds σ c) (k : ℕ) :
        theorem Cslib.Logic.PL.PBConstr.lhs_le_filter (σ : ℕ → Bool) (v : ℕ) (ts : List (ℕ × Literal ℕ)) :
        lhs σ ts ≤ lhs σ (List.filter (fun (x : ℕ × Literal ℕ) => termVar x != v) ts) + coeffSum (List.filter (fun (x : ℕ × Literal ℕ) => termVar x == v) ts)
        theorem Cslib.Logic.PL.PBConstr.Holds.weaken {σ : ℕ → Bool} {c : PBConstr} (hc : Holds σ c) (v : ℕ) :

        The negation is exact.

        Clauses #

        A clause as the constraint ∑ ℓ ≥ 1 over its distinct literals.