![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
Symbolic provenance representation over std::string.
More...
#include "Formula.h"


Public Member Functions | |
| virtual value_type | zero () const override |
| Return the additive identity \(\mathbb{0}\). | |
| virtual value_type | one () const override |
| Return the multiplicative identity \(\mathbb{1}\). | |
| virtual value_type | plus (const std::vector< value_type > &v) const override |
| Apply the additive operation to a list of values. | |
| virtual value_type | times (const std::vector< value_type > &v) const override |
| Apply the multiplicative operation to a list of values. | |
| virtual value_type | monus (value_type x, value_type y) const override |
| Apply the monus (m-semiring difference) operation. | |
| virtual value_type | delta (value_type x) const override |
| Apply the \(\delta\) operator. | |
| virtual value_type | cmp (value_type s1, ComparisonOperator op, value_type s2) const override |
| Evaluate a comparison gate. | |
| virtual value_type | semimod (value_type x, value_type s) const override |
| Apply a semimodule scalar multiplication. | |
| virtual value_type | agg (AggregationOperator op, const std::vector< std::string > &s) override |
| Evaluate an aggregation gate. | |
| virtual value_type | value (const std::string &s) const override |
| Interpret a literal string as a semiring value. | |
| virtual value_type | rv (const std::string &spec, const std::vector< value_type > ¶ms) const override |
| Render a random-variable leaf from its on-disk encoding. | |
| virtual value_type | arith (ArithmeticOperator op, const std::vector< value_type > &v, const std::string &extra) const override |
| Render an arithmetic gate in ordinary arithmetic notation. | |
| virtual value_type | mixture (value_type p, value_type x, value_type y) const override |
| Render a Bernoulli mixture as a conditional expression. | |
| virtual value_type | categorical (value_type key, const std::vector< double > &probs, const std::vector< std::string > &outcomes) const override |
| Render a categorical mixture as its list of weighted outcomes, prefixed by the key that ties them to a single draw (two categoricals sharing a key share the draw). | |
| virtual value_type | guarded_case (const std::vector< value_type > &v) const override |
| Render a guarded selection, first-match order preserved. | |
| virtual value_type | observe (value_type child, const std::string &datum) const override |
| Render a likelihood-weighting observation. | |
| virtual value_type | conditioned (const std::vector< value_type > &v) const override |
Render a conditioning marker as "(target | evidence)". | |
| virtual value_type | unmapped_input (const std::string &uuid) const override |
| Identify a variable leaf the provenance mapping does not name by an abbreviated form of its UUID. | |
| value_type | parse_leaf (const char *v) const |
| virtual bool | compatibleWithBooleanRewrite () const override |
Special case: Formula serialises the circuit structure as a string rather than computing a semantic value, so a safe-query-rewritten circuit renders to its (rewritten) structural formula and remains a faithful description. | |
| std::string | to_text (const value_type &s) const |
| Serialise a Formula evaluation as text. | |
| Public Member Functions inherited from semiring::Semiring< std::string > | |
| virtual | ~Semiring ()=default |
| virtual bool | absorptive () const |
Return true if this semiring is absorptive ( \(\mathbb{1} \oplus a = \mathbb{1}\) for all \(a\)). | |
| virtual bool | certifying () const |
| Whether this semiring builds certified exclusive enumerations (see the three hooks below). | |
| virtual bool | independent_literal (const value_type &) const |
Whether v is an independent literal for certification purposes: a base Bernoulli variable (or a constant), so that distinct literals have disjoint supports and an AND over them is decomposable. | |
| virtual value_type | certified_world_term (const std::vector< value_type > &, const std::vector< value_type > &) const |
Build one complete world term: the conjunction of the present literals and the negations of the missing literals, certified decomposable. | |
| virtual value_type | certified_exclusive_plus (const std::vector< value_type > &) const |
Build the disjunction of pairwise-exclusive disjuncts, certified deterministic. | |
Additional Inherited Members | |
| Public Types inherited from semiring::Semiring< std::string > | |
| typedef std::string | value_type |
| The carrier type of this semiring. | |
Symbolic provenance representation over std::string.
Evaluates circuits to human-readable Unicode formulas. Supports all optional operations (cmp, semimod, agg, value) in addition to the mandatory ones.
|
inlineoverridevirtual |
Evaluate an aggregation gate.
| op | The aggregation function (COUNT, SUM, MIN…). |
| s | List of child semiring values to aggregate. |
| SemiringException | if not overridden. |
Reimplemented from semiring::Semiring< std::string >.
|
inlineoverridevirtual |
Render an arithmetic gate in ordinary arithmetic notation.
Deliberately ASCII (+, *, -, /, ^) so that arithmetic over scalar children stays visually distinct from the semiring's \(\oplus\) / \(\otimes\) / \(\ominus\). An operand count that does not match the operator's arity falls back to a functional rendering rather than misrepresenting the circuit.
Reimplemented from semiring::Semiring< std::string >.
Definition at line 345 of file Formula.h.

|
inlineoverridevirtual |
Render a categorical mixture as its list of weighted outcomes, prefixed by the key that ties them to a single draw (two categoricals sharing a key share the draw).
Reimplemented from semiring::Semiring< std::string >.
Definition at line 401 of file Formula.h.

|
inlineoverridevirtual |
Evaluate a comparison gate.
| s1 | Left operand. |
| op | Comparison operator. |
| s2 | Right operand. |
| SemiringException | if not overridden. |
Reimplemented from semiring::Semiring< std::string >.
|
inlineoverridevirtual |
Special case: Formula serialises the circuit structure as a string rather than computing a semantic value, so a safe-query-rewritten circuit renders to its (rewritten) structural formula and remains a faithful description.
The homomorphism question does not arise.
Reimplemented from semiring::Semiring< std::string >.
|
inlineoverridevirtual |
Render a conditioning marker as "(target | evidence)".
A three-wire (Boolean-event) conditioned gate also carries the materialised joint times(target, evidence) as its third wire; it is redundant with the first two and left out of the rendering.
Reimplemented from semiring::Semiring< std::string >.
Definition at line 434 of file Formula.h.

|
inlineoverridevirtual |
Apply the \(\delta\) operator.
| x | Input value. |
Implements semiring::Semiring< std::string >.
|
inlineoverridevirtual |
Render a guarded selection, first-match order preserved.
Reimplemented from semiring::Semiring< std::string >.
Definition at line 411 of file Formula.h.

|
inlineoverridevirtual |
Render a Bernoulli mixture as a conditional expression.
Reimplemented from semiring::Semiring< std::string >.
|
inlineoverridevirtual |
Apply the monus (m-semiring difference) operation.
| x | Minuend. |
| y | Subtrahend. |
Implements semiring::Semiring< std::string >.
|
inlineoverridevirtual |
Render a likelihood-weighting observation.
Reimplemented from semiring::Semiring< std::string >.
|
inlineoverridevirtual |
Return the multiplicative identity \(\mathbb{1}\).
Implements semiring::Semiring< std::string >.
Definition at line 145 of file Formula.h.

|
inline |
|
inlineoverridevirtual |
Apply the additive operation to a list of values.
| v | Ordered list of operands (empty list should return zero()). |
Implements semiring::Semiring< std::string >.
Definition at line 148 of file Formula.h.

|
inlineoverridevirtual |
Render a random-variable leaf from its on-disk encoding.
"normal:2.5,0.5" becomes "normal(2.5, 0.5)"; a wired parameter (written "$i", making the leaf a compound / latent one) is replaced by the rendering of the corresponding wire. Parsing here is deliberately textual: the rendering must survive any family the distribution registry gains, including one this build does not know.
Reimplemented from semiring::Semiring< std::string >.
Definition at line 307 of file Formula.h.

|
inlineoverridevirtual |
Apply a semimodule scalar multiplication.
| x | Provenance value. |
| s | Scalar value. |
| SemiringException | if not overridden. |
Reimplemented from semiring::Semiring< std::string >.
|
inlineoverridevirtual |
Apply the multiplicative operation to a list of values.
| v | Ordered list of operands (empty list should return one()). |
Implements semiring::Semiring< std::string >.
Definition at line 163 of file Formula.h.

|
inline |
|
inlineoverridevirtual |
Identify a variable leaf the provenance mapping does not name by an abbreviated form of its UUID.
Formula serialises the circuit, so the base class's \(\mathbb{1}\) would be doubly wrong here: it makes every unnamed leaf look alike, and – being the multiplicative identity – it is dropped by the enclosing times(), collapsing a whole join to "𝟙". An abbreviated UUID keeps the structure and stays recognisable against what ProvSQL Studio prints on the circuit's nodes. The first UUID group is kept: 32 bits, enough to tell the leaves of one circuit apart at a glance, with the full value one get_children / Studio click away.
Reimplemented from semiring::Semiring< std::string >.
|
inlineoverridevirtual |
Interpret a literal string as a semiring value.
Used for gate_value gates whose payload is a string.
| s | Literal string. |
| SemiringException | if not overridden. |
Reimplemented from semiring::Semiring< std::string >.
|
inlineoverridevirtual |
Return the additive identity \(\mathbb{0}\).
Implements semiring::Semiring< std::string >.
Definition at line 142 of file Formula.h.
