Counting assignments on a declared set of variables #
CNF.modelCountOn counts assignments of a supplied finite set, extending them by false outside
that set. When the set contains all occurring variables, each unused variable contributes a free
Boolean choice. The original occurring-variable CNF.modelCount is unchanged and is recovered by
declaring exactly the occurring variables.
Renaming by positions in distinctVars gives dense natural labels below numVars. This differs
from the existing compact, whose first literal-occurrence positions can have gaps. The dense
renaming preserves literal order, clause lengths and the occurring-variable count.
These are elementary semantic transport facts for the declared-variable convention of the native counting development in #1226. They do not implement a counting algorithm or assert a runtime bound.
Main definitions #
Cslib.Logic.PL.CNF.modelCountOn: count assignments on a declared finite set.Cslib.Logic.PL.CNF.validDeclaredInput: guard for clause widths≤ kand variables< N.Cslib.Logic.PL.CNF.normalizeDeclaredLeaf: right-shift a declared count by unused variables.
Main results #
Cslib.Logic.PL.CNF.modelCountOn_vars: recover the original occurring-variable count.Cslib.Logic.PL.CNF.modelCountOn_eq_mul_modelCount: unused variables give independent choices.Cslib.Logic.PL.CNF.vars_dense_relabel: dense renaming has exactly the expected variable range.Cslib.Logic.PL.CNF.modelCountOn_dense_relabel: dense renaming preserves the declared count.Cslib.Logic.PL.CNF.validDeclaredInput_eq_true_iff: width andFinset.range Nequivalence.Cslib.Logic.PL.CNF.normalizeDeclaredLeaf_eq_div,normalizeDeclaredLeaf_eq_modelCount,normalizeDeclaredLeaf_le_two_pow_numVars: division form,modelCount, and2 ^ numVarsbound.
Count assignments of declared that satisfy the existing CNF evaluation, extending by false
outside declared. To interpret this as a declared-variable formula, require that every occurring
variable belongs to declared. No inhabitedness of the variable type is needed.
Instances For
Declaring exactly the occurring variables recovers the existing model count.
Every declared variable is free in an empty formula, including when the declared set is empty.
An empty clause rules out every assignment, regardless of the declared variables.
If the declared set contains all occurring variables, its unused variables independently
contribute two choices each. The containment premise is essential because assignments outside the
declared set are extended by false.
Renaming by the duplicate-free variable list uses every index below numVars, without gaps.
The original clause and literal order is retained.
Dense natural relabeling preserves the occurring-variable model count.
Dense natural relabeling gives the original count on exactly numVars declared variables.
This includes the empty formula without requiring a total map from V into Fin 0.
When ψ's variables lie in Finset.range (NOf p) and h (p, ψ) equals the declared-range
count ψ.modelCountOn (Finset.range (NOf p)), normalizeDeclaredLeaf recovers ψ.modelCount.
When ψ's variables lie in Finset.range (NOf p) and h (p, ψ) ≤ 2 ^ NOf p,
normalizeDeclaredLeaf NOf h (p, ψ) is at most 2 ^ ψ.numVars.