Counting satisfying assignments #
CNF.modelCount φ is the number of satisfying assignments of a formula φ in conjunctive normal
form: the assignments of the variables occurring in φ (CNF.vars) that satisfy it. Variables
not occurring in φ are not counted, so the count does not depend on the type of variables.
Relabelling results are in CNF.ModelCount.Relabel. As a function of the formula this is the
counting problem #SAT Valiant.
The distinct variables of φ in order of their first occurrence are listed by CNF.distinctVars,
of length CNF.numVars (CNF.length_distinctVars), and the literal occurrences with their clause
and position indices are listed by occurrences. On any list of variables vs,
bitsAssignment vs i assigns to the variable at position j of vs the binary digit j of i,
so satisfiability of a formula whose variables lie in vs is a search over i < 2 ^ |vs|
(CNF.satisfiable_iff_exists_bitsAssignment).
Counts are usually computed through a map f from assignments to some finite type: if two
satisfying assignments have the same image exactly when they agree on the variables of φ, then
φ has as many satisfying assignments as there are images of satisfying assignments
(CNF.modelCount_eq_card_filter). A formula has a satisfying assignment exactly when its count
is positive (CNF.modelCount_pos_iff), and exactly one when every satisfying assignment agrees
with a given one on the variables of the formula (CNF.modelCount_eq_one_iff).
Main definitions #
Cslib.Logic.PL.CNF.numVars: the number of distinct variables of a formula.Cslib.Logic.PL.CNF.distinctVars: the distinct variables of a formula, in order of first occurrence.Cslib.Logic.PL.Occurrence,Cslib.Logic.PL.occurrences: the occurrences of literals in a formula.Cslib.Logic.PL.bitsAssignment: the assignment numbered byion a list of variables.Cslib.Logic.PL.CNF.extendAssignment: an assignment of the variables of a formula, extended byfalseto all variables.Cslib.Logic.PL.CNF.modelCount: the number of satisfying assignments.
Main results #
Cslib.Logic.PL.CNF.mem_distinctVars,Cslib.Logic.PL.CNF.nodup_distinctVars,Cslib.Logic.PL.CNF.distinctVars_toFinset,Cslib.Logic.PL.CNF.length_distinctVars:φ.distinctVarslists theφ.numVarsvariables ofφwithout repetition.Cslib.Logic.PL.mem_occurrences,Cslib.Logic.PL.map_occurrences,Cslib.Logic.PL.length_occurrences: the literal occurrences ofφand their variables.Cslib.Logic.PL.exists_lt_two_pow_bitsAssignment_eq,Cslib.Logic.PL.CNF.satisfiable_iff_exists_bitsAssignment: satisfiability is a search over2 ^ |vs|numbered assignments.Cslib.Logic.PL.CNF.modelCount_eq_card_filter: counting satisfying assignments through a map.Cslib.Logic.PL.CNF.modelCount_pos_iff,Cslib.Logic.PL.CNF.modelCount_eq_one_iff.
References #
An occurrence of a literal in a formula: its clause, its position in the clause, and the literal.
Instances For
The occurrences of literals in a formula.
Instances For
Membership in occurrences φ as valid clause and literal indices.
The variables of the occurrences, in order, are the variables of the formula.
A formula has one occurrence for each occurrence of a variable.
The number of distinct variables of a formula.
Instances For
A formula has at most as many distinct variables as occurrences of variables.
A formula with m clauses of at most k literals has at most k m variables.
The variables of φ without repetitions, in the order of their first occurrences.
Instances For
The distinct variables of φ are the variables of φ.
φ.distinctVars lists each variable once.
The finite set of distinct variables of φ is the finite set of variables of φ.
A formula has numVars distinct variables.
The assignment numbered by i on the list of variables vs: the variable at position j of
vs takes the binary digit j of i.
Instances For
Every assignment is numbered. The assignments of the variables of a duplicate-free list
vs are the numbered assignments bitsAssignment vs i for i < 2 ^ |vs|.
Satisfiability by exhaustive search. A formula whose variables are all in the list vs is
satisfiable exactly when it is satisfied by an assignment numbered by some i < 2 ^ |vs|.
The numbered assignment bitsAssignment vs i looks up the binary digit of i in i.bits at
the index of v in vs, defaulting to false.
The assignment of all variables extending an assignment τ of the variables of φ by
false.
Instances For
φ.extendAssignment τ agrees with τ on every variable occurring in φ.
The number of satisfying assignments of φ: the assignments of the variables occurring
in φ that satisfy it.
Instances For
An assignment of all variables satisfies φ exactly when its restriction to the variables of
φ, extended by false, does.
Counting satisfying assignments through a map. Let f send assignments to a finite type
so that two satisfying assignments have the same image exactly when they agree on the variables
of φ. Then the satisfying assignments of φ are as many as the images of satisfying
assignments, described by P.
A formula has a satisfying assignment exactly when its count is positive.
A formula has exactly one satisfying assignment when some assignment satisfies it and every satisfying assignment agrees with it on the variables of the formula.