Documentation

CslibFrontier.Logics.Propositional.CNF.ModelCount.DenseRelabel

Dense variable numbering for CNF formulas #

CNF.denseRelabel φ renames each variable of a CNF formula φ by its index in φ.distinctVars. Unlike CNF.compact (which uses first positions in φ.vars and can leave gaps when variables repeat), CNF.denseRelabel φ maps the occurring variables bijectively onto 0, …, φ.numVars - 1 in order of first occurrence (a library adaptation to the declared-variable model of [OAI26k]).

The renaming preserves clause lengths, clause count, numVars, Satisfiable, modelCount, and gives φ.denseRelabel.modelCountOn (Finset.range φ.numVars) = φ.modelCount. It is computable in polynomial time for any variable encoding, both into unary variable indices and into binary natural-number indices (encCNF).

Main definitions #

Main results #

References #

Rename each variable of φ by its index in φ.distinctVars, producing dense variable indices 0, …, φ.numVars - 1.

@[simp]

Dense relabeling preserves all clause lengths in order.

@[simp]

Dense relabeling preserves the number of clauses.

theorem Cslib.Logic.PL.CNF.all_length_le_denseRelabel {V : Type u_1} [DecidableEq V] {k : ℕ} (φ : CNF V) :
(∀ c ∈ φ.denseRelabel, List.length c ≤ k) ↔ ∀ c ∈ φ, List.length c ≤ k

Dense relabeling preserves any uniform upper bound on clause lengths.

@[simp]

The occurring variables of φ.denseRelabel are Finset.range φ.numVars.

theorem Cslib.Logic.PL.CNF.mem_vars_denseRelabel_lt {V : Type u_1} [DecidableEq V] (φ : CNF V) {v : ℕ} (hv : v ∈ φ.denseRelabel.vars) :
v < φ.numVars

Every variable occurring in φ.denseRelabel is strictly below φ.numVars.

@[simp]

Dense relabeling preserves the number of distinct occurring variables.

@[simp]

The distinct variables of φ.denseRelabel in order of first occurrence are 0, …, φ.numVars - 1.

Dense variable relabeling preserves the exact literal-occurrence count of every occurring variable.

theorem Cslib.Logic.PL.CNF.count_vars_denseRelabel_le {V : Type u_1} [DecidableEq V] (φ : CNF V) {B : ℕ} (h : ∀ (v : V), List.count v φ.vars ≤ B) (i : ℕ) :

Any upper bound on original literal-occurrence counts is preserved by CNF.denseRelabel.

theorem Cslib.Logic.PL.CNF.eval_denseRelabel {V : Type u_1} [DecidableEq V] (φ : CNF V) (σ : V → Bool) :
eval (fun (i : ℕ) => φ.distinctVars[i]?.elim false σ) φ.denseRelabel = eval σ φ

Reading original variable values at their distinctVars indices recovers the evaluation of φ.

@[simp]

Dense relabeling preserves satisfiability.

@[simp]

Dense relabeling preserves the occurring-variable model count.

Dense relabeling preserves the declared-variable model count on Finset.range φ.numVars.