32std::size_t count_reachable(
const GenericCircuit &gc,
gate_t r)
34 std::set<gate_t> seen;
35 std::stack<gate_t> stk;
37 while (!stk.empty()) {
38 gate_t g = stk.top(); stk.pop();
39 if (!seen.insert(g).second)
continue;
47 bool simplify,
bool decompose)
70 const std::size_t gates_before = count_reachable(gc, root);
81 unsigned count_cmp = 0, minmax = 0, sum = 0, agg_marginal = 0;
93 const unsigned total =
94 analytic + count_cmp + minmax + sum + agg_marginal + always_true;
96 const std::size_t gates_after = count_reachable(gc, root);
97 std::vector<std::string> parts;
98 if (analytic > 0) parts.push_back(std::to_string(analytic) +
" analytic");
99 if (count_cmp > 0) parts.push_back(std::to_string(count_cmp) +
" Poisson-binomial");
100 if (minmax > 0) parts.push_back(std::to_string(minmax) +
" min/max");
101 if (sum > 0) parts.push_back(std::to_string(sum) +
" weighted-sum");
102 if (agg_marginal > 0) parts.push_back(std::to_string(agg_marginal) +
" safe-join aggregate");
103 if (always_true > 0) parts.push_back(std::to_string(always_true) +
" always-true");
104 std::string breakdown;
105 for (std::size_t i = 0; i < parts.size(); ++i) {
106 if (i > 0) breakdown +=
" + ";
107 breakdown += parts[i];
110 "gate_cmp expression was shortcut by probability-side pre-pass "
111 "(%s): provenance circuit reduced from %zu to %zu gates",
112 breakdown.c_str(), gates_before, gates_after);
Exact closed-form HAVING COUNT(*) op C probability over safe-join lineage – the recursive marginal-ve...
Closed-form CDF resolution for trivial gate_cmp shapes.
gate_t
Strongly-typed gate identifier.
The single comparator-resolution pipeline and the single Boolean-subcircuit probability entry point,...
Closed-form Poisson-binomial CDF resolution for HAVING COUNT(*) op C gate_cmps.
Peephole simplifier for continuous gate_arith sub-circuits.
Closed-form probability resolution for HAVING MIN(a) op C and MAX(a) op C gate_cmps.
Support-based bound check for continuous-RV comparators.
Closed-form probability resolution for HAVING SUM(a) op C gate_cmps via a weighted-sum DP.
std::vector< gate_t > & getWires(gate_t g)
Return a mutable reference to the child-wire list of gate g.
In-memory provenance circuit with semiring-generic evaluation.
unsigned runAggMarginalEvaluator(GenericCircuit &gc)
Run the safe-join aggregate marginal-vector pre-pass over gc.
unsigned runCountCmpEvaluator(GenericCircuit &gc)
Run the Poisson-binomial pre-pass over gc.
unsigned runRangeCheck(GenericCircuit &gc)
Run the support-based pruning pass over gc.
unsigned runHybridSimplifier(GenericCircuit &gc)
Run the peephole simplifier over gc.
unsigned runMinMaxCmpEvaluator(GenericCircuit &gc)
Run the MIN / MAX closed-form pre-pass over gc.
unsigned runSumCmpEvaluator(GenericCircuit &gc)
Run the weighted-sum DP pre-pass over gc.
unsigned runHybridDecomposer(GenericCircuit &gc, unsigned samples)
Marginalise unresolved continuous-island gate_cmp gates into Bernoulli gate_input leaves.
unsigned runAnalyticEvaluator(GenericCircuit &gc)
Run the closed-form CDF resolution pass over gc.
unsigned runHavingAlwaysTrueRewriter(GenericCircuit &gc)
Probability-side pre-pass: rewrite HAVING-style gate_cmp gates that are provably TRUE on the agg's va...
void resolveComparators(GenericCircuit &gc, gate_t root, bool simplify, bool decompose)
Run the comparator-resolution pipeline on gc, rewriting every gate_cmp (RV comparison,...
int provsql_verbose
Verbosity level; controlled by the provsql.verbose_level GUC.
int provsql_rv_mc_samples
Default sample count for analytical-evaluator MC fallbacks; 0 disables fallback (callers raise instea...
bool provsql_cmp_probability_evaluation
Run closed-form / analytic probability evaluators for gate_cmps inside probability_evaluate (currentl...
bool provsql_hybrid_evaluation
Run the hybrid-evaluator simplifier inside probability_evaluate; controlled by the provsql....
Uniform error-reporting macros for ProvSQL.
#define provsql_notice(fmt,...)
Emit a ProvSQL informational notice (execution continues).
Core types, constants, and utilities shared across ProvSQL.