Documentation

CslibFrontier.Logics.Propositional.CSP.ToCNF.Count

Exact violation counts for forbidden-pattern CNF compilation #

Each violated Boolean constraint contributes exactly one falsified clause to the existing forbidden-pattern compiler, even when its scope repeats variables. The unique falsified clause forbids the local pattern induced by the assignment. Thus compilation preserves the number of violated constraints, although the total number of clauses can grow. The exact-count formulation is an original library lemma about the existing compiler.

Main results #

theorem Cslib.Logic.PL.Constraint.countUnsat_toCNF {Rel : Type u_1} {V : Type u_2} (sem : Rel → List Bool → Bool) (c : Constraint Rel V) (σ : V → Bool) :
CNF.countUnsat σ (toCNF sem c) = if eval sem σ c = true then 0 else 1

Exactly one forbidden-pattern clause is false when the constraint is violated; otherwise all its clauses are true. No distinctness assumption on the scope is needed.

theorem Cslib.Logic.PL.CSP.countUnsat_toCNF {Rel : Type u_1} {V : Type u_2} (sem : Rel → List Bool → Bool) (F : CSP Rel V) (σ : V → Bool) :
CNF.countUnsat σ (toCNF sem F) = List.countP (fun (c : Constraint Rel V) => !Constraint.eval sem σ c) F

Forbidden-pattern compilation preserves the number of violated constraints, counted with multiplicity.

theorem Cslib.Logic.PL.CSP.countUnsat_toCNFBounded {Rel : Type u_1} {V : Type u_2} {k : ℕ} (sem : Rel → List Bool → Bool) {F : CSP Rel V} (hF : ∀ c ∈ F, c.scope.length ≤ k) (σ : V → Bool) :
CNF.countUnsat σ (toCNFBounded k sem F) = List.countP (fun (c : Constraint Rel V) => !Constraint.eval sem σ c) F

The width-guarded compiler preserves violation counts when every scope satisfies its width bound.