28#include "utils/uuid.h"
33#include <unordered_map>
61 const std::unordered_map<gate_t, gate_t> *gc_to_bc,
62 std::unordered_map<gate_t, bool> &memo)
64 auto it = memo.find(g);
98 z = !w.empty() &&
provably_zero(gc, w[0], bc, gc_to_bc, memo);
105 z = !w.empty() &&
provably_zero(gc, w[0], bc, gc_to_bc, memo);
110 z = !w.empty() &&
provably_zero(gc, w[0], bc, gc_to_bc, memo);
121 auto jt = gc_to_bc->find(g);
122 if(jt != gc_to_bc->end() &&
143 PG_RETURN_BOOL(
true);
146 pg_uuid_t token = *DatumGetUUIDP(PG_GETARG_DATUM(0));
154 bool has_cmp =
false;
158 bool have_bc =
false;
160 std::unordered_map<gate_t, gate_t> gc_to_bc;
166 }
catch(
const std::exception &) {
171 std::unordered_map<gate_t, bool> memo;
173 have_bc ? &bc :
nullptr,
174 have_bc ? &gc_to_bc :
nullptr,
176 PG_RETURN_BOOL(!zero);
177 }
catch(
const std::exception &e) {
Boolean provenance circuit with support for knowledge compilation.
@ OR
Logical disjunction of child gates.
BooleanCircuit getBooleanCircuit(GenericCircuit &gc, pg_uuid_t token, gate_t &gate, std::unordered_map< gate_t, gate_t > &gc_to_bc)
Build a BooleanCircuit from an already-loaded GenericCircuit.
GenericCircuit getGenericCircuit(pg_uuid_t token)
Build a GenericCircuit from the mmap store rooted at token.
Build in-memory circuits from the mmap-backed persistent store.
gate_t
Strongly-typed gate identifier.
Semiring-agnostic in-memory provenance circuit.
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.
gateType getGateType(gate_t g) const
Return the type of gate g.
gate_t getGate(const uuid &u)
Return (or create) the gate associated with UUID u.
std::vector< gate_t >::size_type getNbGates() const
Return the total number of gates in the circuit.
In-memory provenance circuit with semiring-generic evaluation.
static bool provably_zero(const GenericCircuit &gc, gate_t g, const BooleanCircuit *bc, const std::unordered_map< gate_t, gate_t > *gc_to_bc, std::unordered_map< gate_t, bool > &memo)
Structural proof of universal zero-ness of g, memoized over the DAG.
Datum true_nonzero(PG_FUNCTION_ARGS)
PostgreSQL-callable wrapper: the default mode of provsql.nonzero().
#define provsql_error(fmt,...)
Report a fatal ProvSQL error and abort the current transaction.
Core types, constants, and utilities shared across ProvSQL.
@ gate_annotation
Transparent single-child wrapper carrying a query-level annotation in extra (inversion-free certifica...
@ gate_assumed
Structural marker over a single child whose sub-circuit was computed under a Boolean-provenance assum...
string uuid2string(pg_uuid_t uuid)
Format a pg_uuid_t as a std::string.
C++ utility functions for UUID manipulation.