Documentation

CslibFrontier.Logics.Propositional.CNF.UnitPropagation

Unit propagation for CNF formulas #

This module formalizes unit-clause detection and unit propagation over Cslib.Logic.PL.CNF, built on Cslib.Logic.PL.CNF.restrict and Cslib.Logic.PL.CNF.restrictList.

Iterated propagation uses structural recursion on a clause-count fuel bound φ.length (unitPropagateWithTrailAux), ensuring kernel reducibility while terminating cleanly on every formula because each unit step removes at least the unit clause [l].

Because propagating [l] drops [l] itself from φ.restrict l.1 l.2, evaluation equivalence carries an explicit side condition that every propagated unit literal holds under σ (CNF.eval_unitPropagate_iff). Satisfiability (CNF.satisfiable_unitPropagate_iff) and model counts (CNF.modelCountOn_unitPropagate, CNF.modelCount_unitPropagate) are conserved exactly.

Main definitions #

Main results #

Unit-clause recognition #

Extract the literal of a singleton clause [l], returning none otherwise.

theorem Cslib.Logic.PL.Clause.unit?_eq_some_iff {V : Type u_1} {c : Clause V} {l : Literal V} :
c.unit? = some l ↔ c = [l]

c.unit? = some l holds if and only if c = [l].

c.unit? = none holds if and only if c.length ≠ 1.

def Cslib.Logic.PL.CNF.findUnit? {V : Type u_1} (φ : CNF V) :

Find the literal of the first unit clause in φ, if any.

theorem Cslib.Logic.PL.CNF.mem_of_findUnit?_eq_some {V : Type u_1} {φ : CNF V} {l : Literal V} (h : φ.findUnit? = some l) :
[l] ∈ φ

If φ.findUnit? = some l, then the unit clause [l] belongs to φ.

theorem Cslib.Logic.PL.CNF.mem_vars_of_findUnit?_eq_some {V : Type u_1} {φ : CNF V} {l : Literal V} (h : φ.findUnit? = some l) :
l.1 ∈ φ.vars

If φ.findUnit? = some l, then l.1 occurs in φ.

theorem Cslib.Logic.PL.CNF.findUnit?_eq_none_iff {V : Type u_1} {φ : CNF V} :
φ.findUnit? = none ↔ ∀ c ∈ φ, List.length c ≠ 1

φ.findUnit? = none holds iff φ contains no unit clauses.

Single-unit forcing and model-count conservation #

theorem Cslib.Logic.PL.CNF.eval_eq_of_mem_singleton {V : Type u_1} {φ : CNF V} {l : Literal V} (hl : [l] ∈ φ) {σ : V → Bool} (hσ : eval σ φ = true) :
σ l.1 = l.2

Any model of a formula containing the unit clause [l] sets l.1 to l.2.

theorem Cslib.Logic.PL.CNF.eval_restrict_of_mem_singleton {V : Type u_1} [DecidableEq V] {φ : CNF V} {l : Literal V} (hl : [l] ∈ φ) (σ : V → Bool) :
eval σ φ = true ↔ σ l.1 = l.2 ∧ eval σ (φ.restrict l.1 l.2) = true

For a unit clause [l] ∈ φ, φ holds under σ iff σ l.1 = l.2 and φ.restrict l.1 l.2 holds under σ.

Propagating a unit clause [l] ∈ φ preserves satisfiability.

theorem Cslib.Logic.PL.CNF.modelCountOn_restrict_of_mem_singleton {V : Type u_1} [DecidableEq V] {φ : CNF V} {l : Literal V} (hl : [l] ∈ φ) {declared : Finset V} (hv : l.1 ∈ declared) :
φ.modelCountOn declared = (φ.restrict l.1 l.2).modelCountOn (declared.erase l.1)

Propagating a unit clause [l] ∈ φ on l.1 ∈ declared preserves CNF.modelCountOn on declared.erase l.1.

theorem Cslib.Logic.PL.CNF.modelCount_restrict_of_mem_singleton {V : Type u_1} [DecidableEq V] {φ : CNF V} {l : Literal V} (hl : [l] ∈ φ) :
φ.modelCount = 2 ^ (φ.numVars - 1 - (φ.restrict l.1 l.2).numVars) * (φ.restrict l.1 l.2).modelCount

Propagating a unit clause [l] ∈ φ preserves occurring-variable CNF.modelCount up to the factor 2 for each variable other than l.1 dropped alongside [l].

Single-step and iterated unit propagation #

Perform a single unit-propagation step on φ, returning φ unchanged if no unit clause exists.

One step of unit propagation preserves satisfiability.

One step of unit propagation does not increase clause count.

Structural fuel helper for iterated unit propagation.

Repeatedly propagate unit clauses to a unit-free formula, returning (trail, reduced) with the list of propagated unit literals and the resulting unit-free CNF.

The unit-free CNF produced by iterated unit propagation on φ.

The list of unit literals forced during iterated unit propagation on φ.

theorem Cslib.Logic.PL.CNF.unitPropagate_ind {V : Type u_1} [DecidableEq V] {motive : CNF V → Prop} (base : ∀ (φ : CNF V), φ.findUnit? = none → motive φ) (step : ∀ (φ : CNF V) (l : Literal V), φ.findUnit? = some l → motive (φ.restrict l.1 l.2) → motive φ) (φ : CNF V) :
motive φ

Induction principle matching iterated unit propagation: either φ has no unit clauses, or some unit literal l is propagated via φ.restrict l.1 l.2 with strictly fewer variables.

Iterated unit propagation equals sequential restriction along φ.unitTrail.

theorem Cslib.Logic.PL.CNF.eval_unitPropagate_iff {V : Type u_1} [DecidableEq V] (φ : CNF V) (σ : V → Bool) :
(∀ l ∈ φ.unitTrail, σ l.1 = l.2) ∧ eval σ φ.unitPropagate = true ↔ eval σ φ = true

Exact evaluation equivalence for iterated unit propagation together with the forced unit trail.

Iterated unit propagation preserves satisfiability.

A unit-propagation conflict (deriving the empty clause) certifies unsatisfiability.

theorem Cslib.Logic.PL.CNF.mem_vars_of_mem_unitTrail {V : Type u_1} [DecidableEq V] (φ : CNF V) {l : Literal V} (hl : l ∈ φ.unitTrail) :
l.1 ∈ φ.vars

Every variable in φ.unitTrail occurs in φ.

φ.unitTrail never repeats a variable.

Every clause remaining in φ.unitPropagate has length distinct from 1.

theorem Cslib.Logic.PL.CNF.modelCountOn_unitPropagate {V : Type u_1} [DecidableEq V] (φ : CNF V) (declared : Finset V) (htrail : ∀ l ∈ φ.unitTrail, l.1 ∈ declared) :

Declared-universe model counting is conserved across iterated unit propagation, removing the forced trail variables from declared.

theorem Cslib.Logic.PL.CNF.modelCountOn_unitPropagate_of_vars_subset {V : Type u_1} [DecidableEq V] (φ : CNF V) {declared : Finset V} (hvars : φ.vars.toFinset ⊆ declared) :

When declared contains all occurring variables of φ, φ.modelCountOn declared equals φ.unitPropagate.modelCountOn on the unpropagated declared variables.

Occurring-variable CNF.modelCount under iterated unit propagation, accounting for any variables eliminated alongside forced unit clauses.

Iterated unit propagation does not increase clause count.

Remaining variables after iterated unit propagation belong to φ outside the trail.

Iterated unit propagation does not increase variable occurrences.

Any variable forced in φ.unitTrail has zero remaining occurrences in φ.unitPropagate.