![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
Builds a d-DNNF from a Boolean circuit using a tree decomposition. More...
#include "dDNNFTreeDecompositionBuilder.h"

Classes | |
| struct | dDNNFGate |
| Intermediate representation of a partially built d-DNNF gate. More... | |
Public Types | |
| template<class T> | |
| using | small_vector = boost::container::static_vector<T, TreeDecomposition::MAX_TREEWIDTH+1> |
| Stack-allocated vector bounded by the maximum treewidth + 1. | |
| using | valuation_t = flat_map<gate_t, bool, small_vector> |
| Partial assignment of truth values to the gates of a bag. | |
| using | suspicious_t = flat_set<gate_t, small_vector> |
| Set of gates whose truth-value assignments are not yet confirmed. | |
| template<class T> | |
| using | gate_vector_t = std::vector<T> |
| Generic bounded-capacity vector for intermediate d-DNNF gates. | |
| using | gates_to_or_t |
| Dynamic-programming table: (valuation, suspicious) → list of children. | |
Public Member Functions | |
| dDNNFTreeDecompositionBuilder (const BooleanCircuit &circuit, gate_t gate, TreeDecomposition &tree_decomposition) | |
| Construct the builder for a specific circuit and tree decomposition. | |
| dDNNF && | build () && |
| Execute the compilation and return the resulting d-DNNF. | |
Private Member Functions | |
| 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_vector_t< dDNNFGate > | builddDNNFLeaf (bag_t bag) |
| Build the d-DNNF contributions for a leaf bag. | |
| gate_vector_t< dDNNFGate > | builddDNNF () |
| Main recursive procedure: build the d-DNNF bottom-up. | |
| bool | circuitHasWire (gate_t u, gate_t v) const |
Return true if there is a wire from gate u to gate v. | |
| 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. | |
Private Attributes | |
| const BooleanCircuit & | c |
| Source circuit. | |
| gate_t | root_id |
| Root gate of the source circuit. | |
| TreeDecomposition & | td |
| Tree decomposition of the circuit's primal graph. | |
| dDNNF | d |
| The d-DNNF being constructed. | |
| std::unordered_map< gate_t, bag_t > | responsible_bag |
| Maps each gate to its "responsible" bag. | |
| std::unordered_map< gate_t, gate_t > | input_gate |
| Maps original IN gates to d-DNNF IN gates. | |
| std::unordered_map< gate_t, gate_t > | negated_input_gate |
| Maps original IN gates to their negations. | |
| std::set< std::pair< gate_t, gate_t > > | wiresSet |
| Set of all wires in the source circuit. | |
Friends | |
| std::ostream & | operator<< (std::ostream &o, const dDNNFGate &g) |
Debug output for a dDNNFTreeDecompositionBuilder::dDNNFGate. | |
Builds a d-DNNF from a Boolean circuit using a tree decomposition.
This class is a one-shot builder: construct it, call build(), and the object is consumed (move-only).
Definition at line 56 of file dDNNFTreeDecompositionBuilder.h.
| using dDNNFTreeDecompositionBuilder::gate_vector_t = std::vector<T> |
Generic bounded-capacity vector for intermediate d-DNNF gates.
Definition at line 71 of file dDNNFTreeDecompositionBuilder.h.
Dynamic-programming table: (valuation, suspicious) → list of children.
Definition at line 74 of file dDNNFTreeDecompositionBuilder.h.
| using dDNNFTreeDecompositionBuilder::small_vector = boost::container::static_vector<T, TreeDecomposition::MAX_TREEWIDTH+1> |
Stack-allocated vector bounded by the maximum treewidth + 1.
Definition at line 61 of file dDNNFTreeDecompositionBuilder.h.
Set of gates whose truth-value assignments are not yet confirmed.
Definition at line 67 of file dDNNFTreeDecompositionBuilder.h.
| using dDNNFTreeDecompositionBuilder::valuation_t = flat_map<gate_t, bool, small_vector> |
Partial assignment of truth values to the gates of a bag.
Definition at line 64 of file dDNNFTreeDecompositionBuilder.h.
|
inline |
Construct the builder for a specific circuit and tree decomposition.
Pre-computes the wire set for fast circuitHasWire() queries.
| circuit | Source Boolean circuit. |
| gate | Root gate of circuit to compile. |
| tree_decomposition | Tree decomposition of circuit's primal graph. |
Definition at line 188 of file dDNNFTreeDecompositionBuilder.h.
|
nodiscard |
Execute the compilation and return the resulting d-DNNF.
This is a move-only operation: the builder object is consumed.
dDNNF (as an rvalue). Definition at line 50 of file dDNNFTreeDecompositionBuilder.cpp.


|
nodiscardprivate |
Main recursive procedure: build the d-DNNF bottom-up.
dDNNFGate entries at the root bag. Definition at line 408 of file dDNNFTreeDecompositionBuilder.cpp.


|
nodiscardprivate |
Build the d-DNNF contributions for a leaf bag.
Enumerates all consistent valuations for the gates in the leaf bag and creates the corresponding d-DNNF AND gates.
| bag | The leaf bag to process. |
dDNNFGate entries, one per consistent valuation. Definition at line 138 of file dDNNFTreeDecompositionBuilder.cpp.


Return true if there is a wire from gate u to gate v.
| u | Source gate. |
| v | Target gate. |
true if a wire from u to v exists in the source circuit. Definition at line 535 of file dDNNFTreeDecompositionBuilder.cpp.

|
nodiscardprivate |
Group a list of dDNNFGate entries by (valuation, suspicious) pairs.
Used when processing a bag's children to identify which sub-results can be OR'd together.
| bag | Current bag being processed. |
| gates | List of d-DNNF gates from child bags. |
| partial | Partially accumulated DP table from previous children. |
Definition at line 301 of file dDNNFTreeDecompositionBuilder.cpp.


|
nodiscardprivate |
Compute the subset of innocent that remains innocent.
Returns the gates in innocent whose suspicious status is not overridden by valuation.
| valuation | Current bag's valuation. |
| innocent | Candidate innocent set. |
Definition at line 220 of file dDNNFTreeDecompositionBuilder.cpp.


|
nodiscardprivate |
Return true if valuation is a "almost valuation".
A valuation is "almost" if every gate in it that must have its value confirmed by the current bag has indeed been assigned a value.
| valuation | The valuation to test. |
true if the valuation is consistent with circuit constraints. Definition at line 189 of file dDNNFTreeDecompositionBuilder.cpp.


|
friend |
Debug output for a dDNNFTreeDecompositionBuilder::dDNNFGate.
| o | Output stream. |
| g | Gate to display. |
o. Definition at line 512 of file dDNNFTreeDecompositionBuilder.cpp.
|
private |
Source circuit.
Definition at line 78 of file dDNNFTreeDecompositionBuilder.h.
|
private |
The d-DNNF being constructed.
Definition at line 81 of file dDNNFTreeDecompositionBuilder.h.
Maps original IN gates to d-DNNF IN gates.
Definition at line 83 of file dDNNFTreeDecompositionBuilder.h.
Maps original IN gates to their negations.
Definition at line 84 of file dDNNFTreeDecompositionBuilder.h.
Maps each gate to its "responsible" bag.
Definition at line 82 of file dDNNFTreeDecompositionBuilder.h.
|
private |
Root gate of the source circuit.
Definition at line 79 of file dDNNFTreeDecompositionBuilder.h.
|
private |
Tree decomposition of the circuit's primal graph.
Definition at line 80 of file dDNNFTreeDecompositionBuilder.h.
Set of all wires in the source circuit.
Definition at line 85 of file dDNNFTreeDecompositionBuilder.h.