ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
CertifiedDDMaterialize.h
Go to the documentation of this file.
1/**
2 * @file CertifiedDDMaterialize.h
3 * @brief Content-addressed materialisation of a certified d-D into the
4 * mmap provenance store.
5 *
6 * A decomposition-aligned compiler (the reachability compiler, the
7 * joint-width UCQ compiler) builds a circuit that is **deterministic and
8 * decomposable by construction** -- a certified d-D. Rather than reading
9 * the probability off that circuit in C++, the certified d-D can be
10 * *materialised* as ordinary provenance gates (@c plus / @c times /
11 * @c monus, carrying the @c DNNF_CERT_INFO mark), so that the answer --
12 * probability, Shapley, expectation, any provenance-store evaluation --
13 * is obtained through the **single** standard entry point
14 * @c probability_evaluate() (etc.) on the materialised token. This keeps
15 * one evaluation path for the whole system and exploits the certificate
16 * (linear-time @c independentEvaluation / @c interpretAsDD).
17 *
18 * Gate UUIDs are content-addressed with the standard v5 recipes, so
19 * identical sub-circuits dedup in the store and re-materialising the same
20 * circuit is a no-op.
21 */
22#ifndef CERTIFIED_DD_MATERIALIZE_H
23#define CERTIFIED_DD_MATERIALIZE_H
24
25extern "C" {
26#include "postgres.h"
27#include "utils/uuid.h"
28}
29
30#include "dDNNF.h"
31
32#include <unordered_map>
33#include <vector>
34
35/**
36 * @brief RFC 4122 version-5 UUID in the ProvSQL namespace.
37 *
38 * Same value as the SQL @c uuid_generate_v5(uuid_ns_provsql(), name), so
39 * gates content-address identically to those the query rewriter mints.
40 *
41 * @param name Name within the namespace.
42 * @return The version-5 UUID.
43 */
44pg_uuid_t provsqlUuidV5(const std::string &name);
45
46/**
47 * @brief Materialise (the reachable part of) a certified d-D into the
48 * mmap store.
49 *
50 * Bottom-up over the gates reachable from @p roots: input gates keep
51 * their existing tokens (the leaf provenance, not touched), @c NOT @c x
52 * is stored as @c monus(one, x), AND as @c times, OR as @c plus. Gates
53 * carrying the d-D certificate get it persisted.
54 *
55 * @param dd The certified circuit.
56 * @param roots Gates whose closure to materialise.
57 * @return Map from @p dd gates to their store UUIDs.
58 */
59std::unordered_map<gate_t, pg_uuid_t, hash_gate_t> materializeCertifiedDD(
60 const dDNNF &dd, const std::vector<gate_t> &roots);
61
62/**
63 * @brief Wrap a materialised root in the @c 'absorptive' assumption
64 * marker and return the wrapper's UUID.
65 *
66 * Used by the reachability route, whose compiled circuit is the
67 * absorptive quotient of a genuinely infinite recursive provenance. The
68 * joint-width UCQ compiler does NOT use this: its d-D is the exact
69 * Boolean provenance of the (non-recursive) UCQ, sound for every
70 * absorptive-or-not probability evaluation.
71 *
72 * @param child UUID of the materialised root to wrap.
73 * @return UUID of the @c gate_assumed wrapper.
74 */
76
77#endif /* CERTIFIED_DD_MATERIALIZE_H */
std::unordered_map< gate_t, pg_uuid_t, hash_gate_t > materializeCertifiedDD(const dDNNF &dd, const std::vector< gate_t > &roots)
Materialise (the reachable part of) a certified d-D into the mmap store.
pg_uuid_t wrapAssumedAbsorptive(const pg_uuid_t &child)
Wrap a materialised root in the 'absorptive' assumption marker and return the wrapper's UUID.
pg_uuid_t provsqlUuidV5(const std::string &name)
RFC 4122 version-5 UUID in the ProvSQL namespace.
A d-DNNF circuit supporting exact probabilistic and game-theoretic evaluation.
Definition dDNNF.h:71
Decomposable Deterministic Negation Normal Form circuit.
UUID structure.