projMC: A Projected Model Counter

projMC is a recursive algorithm for projected model counting, i.e., the problem consisting in determining the number of models ||∃X.Σ|| of a propositional CNF formula Σ after eliminating from it a given set X of variables. Based on a ”standard” model counter, our algorithm takes advantage of a disjunctive decomposition scheme of ∃X.Σ for computing ||∃X.Σ||. It also looks for disjoint components in its input for improving the computation.

For more details, see the paper:

J.-M. Lagniez and P. Marquis, "A Recursive Algorithm for Projected Model Counting". Proceedings of AAAI'19.

Ressources for the projected model counter projMC

How to use projMC:

Let name.cnf be the input CNF instance (it conforms to the standard DIMACS format).

Example of DIMACS CNF formula
p cnf 4 3
1 -2 3 0
-3 4 0
2 -3 0

Associated with it (in the same folder) can be a file name_nbvar.var which contains the list of variables occurring in name.cnf which must be kept (i.e., all the other variables of name.cnf must be forgotten). name_nbvar.var simply contains variable identifiers (positive integers) separated by commas. nbvar denotes an integer which gives the number of variables to be kept. If the option -fpv="name_nbvar.var" is not used, then projMC counts the number of models of name.cnf.

Example of var file
2,3

To launch projMC on name.cnf given the variables to be kept in name_nbvar.cnf, run ./projMC name.cnf -fpv=“name_nbvar.var"

Example of solver result
s 4

Some messages are then reported in the standard output. The first group of lines are about the benchmark itself (they make precise successively its number of variables, its number of clauses, and its size in number of literals). Integer mode is the default mode (used for unweighted model counting).

The second group recalls the default options used by the underlying model counter (D4).

Then some statistics are provided about the solving of the instance. A first group of lines synthesizes some data about the “standard” model counting task (number of calls to the model counter, number of decomposable AND nodes found, number of decision nodes generated). A second group of lines synthesizes some data which are specific to the projected model counting task (number of calls to the projected model counter, number of decomposable AND nodes found, number of UNSAT subproblems found, number of positive hits in the cache).

Finally, the time (in seconds) needed to count the number of models of name.cnf, once projected on the set of variables specified by name_nbvar.var is reported.

Here is an example of invocation of projMC, where the input CNF benchmark is stored in the file circ_30_1.cnf of the circuitBenchs subfolder. The 94 variables to be kept are reported in the file circ_30_1_94.var located in the same subfolder. The messages written in the standard output are:

Example of solver output
c Benchmark Information
c Number of variables: 99
c Number of clauses: 179
c Number of literals: 399
c Integer mode
c
c Option list
c Caching: 1
c Variable heuristic: VSADS
c Phase heuristic: TRUE
c Partitioning heuristic: YES + graph reduction + equivalence simplication
c
c
c Statistics
c Model Counter Information
c Number of recursive calls: 245
c Number of decomposable AND nodes: 206
c Number of decision nodes: 108
c
c Projected Model Counter Information
c Number of recursive calls: 43
c Number of decomposable AND nodes: 63
c Number of UNSAT subproblems: 11
c Number of positive hits: 45
c
c Final time: 0.029554
c
s 549957444

Thus the time needed by projMC to solve this instance is 0.029554s and the corresponding projected model count is 549957444 models.