Expand description
§decdnnf-rs: A Rust Library and CLI Tool for Decision-DNNF Manipulation
decdnnf-rs is a comprehensive Rust library for efficiently manipulating Decision-DNNF formulas, accompanied by a companion Command Line Interface (CLI) tool designed for practical interaction and testing.
Decision-DNNF (Decomposable Negation Normal Form) is a knowledge compilation formalism used in artificial intelligence and logic. It compiles propositional logic formulas into a tractable representation, enabling efficient inference tasks like model checking and counting. This project provides both a high-performance library for manipulating Decision-DNNF structures and a user-friendly CLI tool for interacting with these formulas.
The decdnnf-rs library and its CLI tool are designed to handle formulas produced by the d4 knowledge compiler.
Furthermore, the library enables crucial tasks such as model-counting (determining the number of satisfying assignments) and uniform sampling (generating random models according to the formula) directly on the compiled structure.
§Installation
§Installing the CLI tool
The tool is available on crates.io. You can install it using Cargo:
cargo install decdnnf_rs§Using as a dependency in a Rust project
Just type the following command in the root directory of your project to include the latest version of the library:
cargo add decdnnf_rs§Building from source
If you’d like to build from source:
git clone https://github.com/crillab/decdnnf_rs.git
cd decdnnf_rs
cargo build --releaseThe binary will be available at target/release/decdnnf_rs.
§Available commands
The decdnnf-rs application provides multiple commands, each of which is dedicated to a specific task.
To see the full list, invoke the program with the help flag.
decdnnf_rs -hSimilarly, you can obtain a list of the expected and optional arguments by adding the help flag after the subcommand.
decdnnf_rs model-counting -h§Common options
Some options are common to most commands, such as those dedicated to the input file and the logging level.
Another interesting option is the --n-vars option.
The output format of d4, the default input format of decdnnf_rs, does not provide the number of variables for the problems.
Therefore, if this number is more important than the highest variable index in use, it cannot be deduced.
Setting --n-vars overrides the number of variables returned by the parser, which is set to the highest variable index.
By default, decdnnf_rs performs a partial check of the input Decision-DNNF for correctness, focusing on the decomposability property of the disjunction and the determinism of the disjunction node.
However, these checks may take some time.
If you are confident that the formula is correct, you can skip these tests by adding the --do-not-check flag.
§Translate a d4 Decision-DNNF into a c2d Decision-DNNF
The c2d knowledge compiler’s output format was the standard format used to represent decision-DNNF for a long time.
The decdnnf-rs program provides a command to translate a d4 formula into a c2d formula:
decdnnf_rs translation -i instance.nnf§Check for a model under assumptions
The compute-model command checks for the existence of a model.
Assumptions can be provided using the -a option:
decdnnf_rs compute-model -i instance.nnf -a '1 2'As described above, use the -h flag to get more information on this command:
decdnnf_rs compute-model -h'§Count the models of a Decision-DNNF
Use the model-counting command:
decdnnf_rs model-counting -i instance.nnfThe -a (assumptions) and -h (help) options function similarly to those of the previous command.
§Enumerate the models of a Decision-DNNF
Use the model-enumeration command:
decdnnf_rs model-enumeration -i instance.nnfThis command has multiple options that affect both the algorithm used to enumerate solutions and the format used to output the model.
For more information on these algorithms and formats, see our research paper Leveraging Decision-DNNF Compilation for Enumerating Disjoint Partial Models and the command help (decdnnf_rs model-enumeration -h).
Again, the -a (assumptions) and -h (help) options function similarly to those of the previous command.
§Direct access to a model
Use the direct-access command:
decdnnf_rs direct-access --index 5 -i instance.nnfBy default, the order of the models is determined by the structure of the formula and may change with new versions of the tool.
Adding the --lexicographic-order flag prevents this from happening.
This flag instructs the tool to sort the models in lexicographic order. However, this approach results in longer processing times.
§Uniform sampling
Use the sampling command:
decdnnf_rs sampling -l 5 -i instance.nnfThe indices associated with these models function similarly to those for direct access and include the --lexicographic-order flag.
§Reduction w.r.t. equivalences
Use the reduce-formula command with an input Decision-DNNF and an equivalent DIMACS-formatted CNF formula:
decdnnf_rs reduce-formula -i instance.nnf -c instance.cnf§License
Decdnnf-rs is developed at CRIL (Univ. Artois & CNRS). It is made available under the terms of the GNU GPLv3 license.
§Acknowledgments
Parts of this work has benefited from the support of the AI Chair EXPEKCTATION (ANR-19-CHIA-0005-01) of the French National Research Agency, including the research papers Leveraging Decision-DNNF Compilation for Enumerating Disjoint Partial Models and Enhancing Query Efficiency for D-DNNF Representations Through Preprocessing.
Parts of this work has benefited from the support of the CERADOC project (ANR-25-CE23-3078) of the French National Research Agency, including the research papers [Efficient Minimization of Decision-DNNF Circuits via Semantic Hashing and Provenance Tracking](IJCAI-ECAI 2026, to appear) and [decdnnf_rs: A framework for Querying d-DNNF](SAT 2026, to appear).
Please use the SAT 2026 reference to cite decdnnf_rs.
Structs§
- Assumptions
- A structure that is used to handle literal assumptions.
- Binary
Reader - A structure used to read a Decision-DNNF encoded using its writer counterpart.
- Binary
Writer - A structure used to write a Decision-DNNF using a binary format.
- C2dWriter
- A structure used to write a Decision-DNNF in the c2d output format.
- CNFFormula
- A structure that handles a CNF formula.
- D4Reader
- A structure used to read the output of the d4 compiler.
- D4Writer
- A structure used for writing a decision-DNNF using the d4 output format.
- DecisionDNNF
- A Decision-DNNF formula.
- DecisionDNNF
Checker - An algorithm used for an algorithm that checks if a Decision-DNNF is correct.
- DimacsCNF
Reader - A reader for the DIMACS CNF format.
- Direct
Access Engine - An object that, given a complete order on the models of a
DecisionDNNFcomputed internally, allows the k-th model to be returned. - Edge
- An edge targets a node and propagates literals, in the spirit of recent d4 versions.
See
DecisionDNNFfor more information on the internal representation of such formulas. - Edge
Index - An index type dedicated to
Edgeobjects. - Equivalent
Nodes Merging - An object that detects node equivalences in
DecisionDNNFformulas. - Free
Variables - A structure used to computes the free variables, i.e. the variables that does not appear in some models.
- Literal
- A structure representing a literal.
- Model
Counter - A structure used to count the models of a
DecisionDNNF. - Model
Enumerator - A structure used to enumerate the models of a
DecisionDNNF. - Model
Finder - A structure used to find models in a
DecisionDNNF. - Model
Sampler - A structure used to sample the models of a
DecisionDNNF. - Node
Index - An index type dedicated to
Nodeobjects. - OrFree
Variables - A structure used to efficiently handle the free variables located at disjunction nodes.
- Ordered
Direct Access Engine - An object that, given a complete order on the models of a
DecisionDNNFcomputed internally, allows the k-th model to be returned. - Orphan
Finder - A structure that detects and removes orphan nodes and edges — that is, nodes and edges that have no ancestor, despite not being the root of the
DecisionDNNF. - Parallel
Model Enumerator - A structure used to enumerate the models of a
DecisionDNNFusing multiple threads. - Smart
Reader - A
DecisionDNNFReaderthat tries to load aDecisionDNNFby trying to read it with other readers.
Enums§
- Node
- A Decision-DNNF node.
Traits§
- DecisionDNNF
Reader - A trait for object that can read
DecisionDNNF - DecisionDNNF
Writer - A trait for object that can write
DecisionDNNF