![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
Top-down structured-d-DNNF builder over a query-derived variable order. More...
#include "StructuredDNNF.h"

Classes | |
| struct | InputKey |
| Structured per-input order key carried by the planner's markers. More... | |
| struct | CacheKey |
| struct | CacheKeyHash |
Public Member Functions | |
| StructuredDNNFBuilder (const BooleanCircuit &bc, gate_t root, const std::map< gate_t, int > &input_rank, std::size_t max_nodes=0) | |
| const dDNNF & | dnnf () const |
| The constructed d-DNNF (root set, simplified). | |
| gate_t | rootGate () const |
| Root gate of the constructed d-DNNF (current after simplify). | |
| double | probability () const |
| Probability that the function is true (independent inputs). | |
| std::size_t | size () const |
| d-DNNF gates reachable from the root. | |
Static Public Attributes | |
| static constexpr int | GUARD_FACTOR = -1 |
Private Types | |
| using | Var = int |
Variable rank in [0,ninputs). | |
| using | Term = std::vector<Var> |
| A product: sorted, duplicate-free vars. | |
| using | DNF = std::vector<Term> |
| A sum of products: canonicalised. | |
Private Member Functions | |
| DNF | extract (const BooleanCircuit &bc, gate_t g, const std::map< gate_t, int > &rank, std::map< gate_t, DNF > &memo) const |
| std::vector< DNF > | orDecompose (const DNF &d) const |
| std::vector< DNF > | andDecompose (const DNF &d) const |
| gate_t | mkAnd (const std::vector< gate_t > &children) |
| gate_t | mkLit (Var v) |
| shared positive literal IN | |
| gate_t | mkNeg (Var v) |
| shared negative literal NOT(IN) | |
| gate_t | newGate (BooleanGate type) |
| setGate + size guard | |
| gate_t | build (const DNF &d, gate_t false_sink) |
Static Private Member Functions | |
| static DNF | canonical (DNF d) |
| sort, dedup, drop supersets | |
| static DNF | condition (const DNF &d, Var v, bool value) |
Private Attributes | |
| dDNNF | dd_ |
| gate_t | root_ |
| std::size_t | max_nodes_ |
| std::vector< double > | prob_ |
| prob_[rank] = P(variable) | |
| std::vector< std::string > | uuid_ |
| rank -> source input UUID (for labels) | |
| std::vector< gate_t > | in_gate_ |
| rank -> shared dDNNF IN gate | |
| std::vector< gate_t > | not_gate_ |
| rank -> shared dDNNF NOT(IN) gate (lazy) | |
| gate_t | true_gate_ |
| gate_t | false_gate_ |
| empty AND / empty OR terminals | |
| std::unordered_map< CacheKey, gate_t, CacheKeyHash > | cache_ |
Top-down structured-d-DNNF builder over a query-derived variable order.
This is the §4 construction of the inversion-free plan: rather than the bottom-up apply of StructuredDNNF (kept above as a reference oracle), it compiles the monotone lineage top-down into a genuine ProvSQL dDNNF with two node kinds, placed by structure:
AND and recurse per factor. Decomposability (children share no variable) holds by construction and is the structural win an OBDD cannot express.OR(AND(v,hi),AND(¬v,lo)). Determinism (children mutually exclusive) holds because both branches come from a decision on the same variable.A component cache (keyed on the canonical residual) shares equal sub-d-DNNFs, which is what keeps the result linear in the lineage under the Prop. 4.5 order (and bounds the work). The function is taken as a monotone DNF expanded from the BooleanCircuit (AND distributes, OR unions, IN is a single literal; NOT and multivalued inputs are rejected, out of scope for the TID inversion-free path).
Output is a finished dDNNF (root set, simplify() applied) ready for dDNNF::probabilityEvaluation(). Pure C++ so it builds in the extension and the standalone -DTDKC harness.
Definition at line 59 of file StructuredDNNF.h.
|
private |
A sum of products: canonicalised.
Definition at line 109 of file StructuredDNNF.h.
|
private |
A product: sorted, duplicate-free vars.
Definition at line 108 of file StructuredDNNF.h.
|
private |
Variable rank in [0,ninputs).
Definition at line 107 of file StructuredDNNF.h.
| StructuredDNNFBuilder::StructuredDNNFBuilder | ( | const BooleanCircuit & | bc, |
| gate_t | root, | ||
| const std::map< gate_t, int > & | input_rank, | ||
| std::size_t | max_nodes = 0 ) |
| bc | Boolean circuit (monotone AND/OR/IN, no multivalued inputs, no NOT). |
| root | Root gate of the function to compile. |
| input_rank | Maps every IN gate reachable from root to a distinct rank in [0,ninputs). Lower rank = decided earlier (a Prop. 4.5-consistent order, derived by the caller). |
| max_nodes | Size guard: throw CircuitException once this many d-DNNF gates have been created (0 = no guard). |
| CircuitException | on multivalued/NOT/unsupported gates, a reachable input without a rank, or the size guard tripping. |
Definition at line 412 of file StructuredDNNF.cpp.

|
private |
Definition at line 131 of file StructuredDNNF.cpp.


Definition at line 354 of file StructuredDNNF.cpp.


|
staticprivate |
sort, dedup, drop supersets
Definition at line 68 of file StructuredDNNF.cpp.


|
staticprivate |
Definition at line 111 of file StructuredDNNF.cpp.


|
inline |
The constructed d-DNNF (root set, simplified).
Definition at line 95 of file StructuredDNNF.h.

|
private |
Definition at line 216 of file StructuredDNNF.cpp.


Definition at line 298 of file StructuredDNNF.cpp.


shared positive literal IN
Definition at line 279 of file StructuredDNNF.cpp.

shared negative literal NOT(IN)
Definition at line 288 of file StructuredDNNF.cpp.


|
private |
setGate + size guard
Definition at line 271 of file StructuredDNNF.cpp.

|
private |
|
inline |
Probability that the function is true (independent inputs).
Definition at line 101 of file StructuredDNNF.h.

|
inline |
Root gate of the constructed d-DNNF (current after simplify).
Definition at line 98 of file StructuredDNNF.h.
| std::size_t StructuredDNNFBuilder::size | ( | ) | const |
d-DNNF gates reachable from the root.
Definition at line 449 of file StructuredDNNF.cpp.

|
private |
Definition at line 127 of file StructuredDNNF.h.
|
private |
Definition at line 111 of file StructuredDNNF.h.
|
private |
empty AND / empty OR terminals
Definition at line 119 of file StructuredDNNF.h.
|
staticconstexpr |
Definition at line 92 of file StructuredDNNF.h.
|
private |
rank -> shared dDNNF IN gate
Definition at line 117 of file StructuredDNNF.h.
|
private |
Definition at line 113 of file StructuredDNNF.h.
|
private |
rank -> shared dDNNF NOT(IN) gate (lazy)
Definition at line 118 of file StructuredDNNF.h.
|
private |
prob_[rank] = P(variable)
Definition at line 115 of file StructuredDNNF.h.
|
private |
Definition at line 112 of file StructuredDNNF.h.
|
private |
Definition at line 119 of file StructuredDNNF.h.
|
private |
rank -> source input UUID (for labels)
Definition at line 116 of file StructuredDNNF.h.