28#include "utils/uuid.h"
33#include <unordered_map>
62 const std::unordered_map<gate_t, gate_t> *gc_to_bc,
63 std::unordered_map<gate_t, bool> &memo)
65 auto it = memo.find(g);
99 z = !w.empty() &&
provably_zero(gc, w[0], bc, gc_to_bc, memo);
106 z = !w.empty() &&
provably_zero(gc, w[0], bc, gc_to_bc, memo);
111 z = !w.empty() &&
provably_zero(gc, w[0], bc, gc_to_bc, memo);
122 auto jt = gc_to_bc->find(g);
123 if(jt != gc_to_bc->end() &&
144 PG_RETURN_BOOL(
true);
148 pg_uuid_t token = *DatumGetUUIDP(PG_GETARG_DATUM(0));
156 bool has_cmp =
false;
160 bool have_bc =
false;
162 std::unordered_map<gate_t, gate_t> gc_to_bc;
168 }
catch(
const std::exception &) {
173 std::unordered_map<gate_t, bool> memo;
175 have_bc ? &bc :
nullptr,
176 have_bc ? &gc_to_bc :
nullptr,
178 PG_RETURN_BOOL(!zero);
179 }
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.
The SIGINT handler installed for the lifetime of the object, the previous one restored as it ends (a ...
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.
void provsql_cancel_if_interrupted(void)
Raise PG's cancel if the evaluation stopped for one; nothing otherwise.
Cancellation of the long C++ evaluation loops.
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.