33#ifndef dDNNF_TREE_DECOMPOSITION_BUILDER_H
34#define dDNNF_TREE_DECOMPOSITION_BUILDER_H
37#include <unordered_map>
40#include <boost/container/static_vector.hpp>
59using small_vector = boost::container::static_vector<T, TreeDecomposition::MAX_TREEWIDTH+1>;
73 std::unordered_map<valuation_t, std::map<suspicious_t, gate_vector_t<gate_t> > >;
121 const gate_vector_t<dDNNFGate> &gates,
140[[nodiscard]] gate_vector_t<dDNNFGate>
builddDNNF();
207friend std::ostream &
operator<<(std::ostream &o,
const dDNNFGate &g);
Boolean provenance circuit with support for knowledge compilation.
gate_t
Strongly-typed gate identifier.
static MMappedCircuit * circuit
Singleton pointer to the process-wide mmap-backed provenance circuit.
Tree decomposition of a Boolean circuit for knowledge compilation.
bag_t
Strongly-typed bag identifier for a tree decomposition.
Boolean circuit for provenance formula evaluation.
std::vector< gate_t > & getWires(gate_t g)
Return a mutable reference to the child-wire list of gate g.
std::vector< gate_t >::size_type getNbGates() const
Return the total number of gates in the circuit.
Tree decomposition of a Boolean circuit's primal graph.
Builds a d-DNNF from a Boolean circuit using a tree decomposition.
std::unordered_map< gate_t, bag_t > responsible_bag
Maps each gate to its "responsible" bag.
bool circuitHasWire(gate_t u, gate_t v) const
Return true if there is a wire from gate u to gate v.
std::vector< T > gate_vector_t
Generic bounded-capacity vector for intermediate d-DNNF gates.
gate_vector_t< dDNNFGate > builddDNNF()
Main recursive procedure: build the d-DNNF bottom-up.
std::set< std::pair< gate_t, gate_t > > wiresSet
Set of all wires in the source circuit.
std::unordered_map< valuation_t, std::map< suspicious_t, gate_vector_t< gate_t > > > gates_to_or_t
Dynamic-programming table: (valuation, suspicious) → list of children.
flat_map< gate_t, bool, small_vector > valuation_t
Partial assignment of truth values to the gates of a bag.
std::unordered_map< gate_t, gate_t > negated_input_gate
Maps original IN gates to their negations.
dDNNF && build() &&
Execute the compilation and return the resulting d-DNNF.
flat_set< gate_t, small_vector > suspicious_t
Set of gates whose truth-value assignments are not yet confirmed.
std::unordered_map< gate_t, gate_t > input_gate
Maps original IN gates to d-DNNF IN gates.
gates_to_or_t collectGatesToOr(bag_t bag, const gate_vector_t< dDNNFGate > &gates, const gates_to_or_t &partial)
Group a list of dDNNFGate entries by (valuation, suspicious) pairs.
gate_t root_id
Root gate of the source circuit.
boost::container::static_vector< T, TreeDecomposition::MAX_TREEWIDTH+1 > small_vector
Stack-allocated vector bounded by the maximum treewidth + 1.
dDNNF d
The d-DNNF being constructed.
const BooleanCircuit & c
Source circuit.
friend std::ostream & operator<<(std::ostream &o, const dDNNFGate &g)
Debug output for a dDNNFTreeDecompositionBuilder::dDNNFGate.
dDNNFTreeDecompositionBuilder(const BooleanCircuit &circuit, gate_t gate, TreeDecomposition &tree_decomposition)
Construct the builder for a specific circuit and tree decomposition.
TreeDecomposition & td
Tree decomposition of the circuit's primal graph.
bool isAlmostValuation(const valuation_t &valuation) const
Return true if valuation is a "almost valuation".
suspicious_t getInnocent(const valuation_t &valuation, const suspicious_t &innocent) const
Compute the subset of innocent that remains innocent.
gate_vector_t< dDNNFGate > builddDNNFLeaf(bag_t bag)
Build the d-DNNF contributions for a leaf bag.
A d-DNNF circuit supporting exact probabilistic and game-theoretic evaluation.
std::ostream & operator<<(std::ostream &o, const dDNNFTreeDecompositionBuilder::dDNNFGate &g)
Debug output for a dDNNFTreeDecompositionBuilder::dDNNFGate.
Decomposable Deterministic Negation Normal Form circuit.
Flat (unsorted, contiguous-storage) associative map template.
Flat (unsorted, contiguous-storage) set template.
Intermediate representation of a partially built d-DNNF gate.
suspicious_t suspicious
Gates whose assignments are unconfirmed.
valuation_t valuation
Current bag's truth-value assignment.
gate_t id
Gate ID in the target d-DNNF.
dDNNFGate(gate_t i, valuation_t v, suspicious_t s)
Construct a dDNNFGate.