ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
semiring::Which Class Reference

Which-provenance (lineage) semiring. More...

#include "Which.h"

Inheritance diagram for semiring::Which:
Collaboration diagram for semiring::Which:

Public Member Functions

value_type zero () const override
 Return the additive identity \(\mathbb{0}\).
value_type one () const override
 Return the multiplicative identity \(\mathbb{1}\).
value_type plus (const std::vector< value_type > &vec) const override
 Apply the additive operation to a list of values.
value_type times (const std::vector< value_type > &vec) const override
 Apply the multiplicative operation to a list of values.
value_type monus (value_type x, value_type y) const override
 Apply the monus (m-semiring difference) operation.
value_type delta (value_type x) const override
 Apply the \(\delta\) operator.
bool idempotent () const override
 Which-provenance is idempotent: \(\oplus\) is set union.
virtual bool compatibleWithBooleanRewrite () const override
 No semiring homomorphism BoolFunc(Y) →+* Which exists, so the safe-query Boolean rewrite is unsound under which-provenance.
value_type parse_leaf (const char *v) const
 Parse a leaf value into a which-provenance set.
std::string to_text (const value_type &prov) const
Public Member Functions inherited from semiring::Semiring< which_provenance_t >
virtual value_type cmp (value_type s1, ComparisonOperator op, value_type s2) const
 Evaluate a comparison gate.
virtual value_type semimod (value_type x, value_type s) const
 Apply a semimodule scalar multiplication.
virtual value_type agg (AggregationOperator op, const std::vector< value_type > &s)
 Evaluate an aggregation gate.
virtual value_type value (const std::string &s) const
 Interpret a literal string as a semiring value.
virtual value_type unmapped_input (const std::string &uuid) const
 Value of a variable leaf (gate_input / gate_mulinput) that the provenance mapping does not name.
virtual value_type rv (const std::string &spec, const std::vector< value_type > &params) const
 Evaluate a continuous random-variable leaf (gate_rv).
virtual value_type arith (ArithmeticOperator op, const std::vector< value_type > &children, const std::string &extra) const
 Evaluate an arithmetic gate over scalar children (gate_arith).
virtual value_type mixture (value_type p, value_type x, value_type y) const
 Evaluate a Bernoulli mixture (gate_mixture, three wires).
virtual value_type categorical (value_type key, const std::vector< double > &probs, const std::vector< std::string > &outcomes) const
 Evaluate a categorical mixture (gate_mixture over gate_mulinput outcomes).
virtual value_type guarded_case (const std::vector< value_type > &children) const
 Evaluate a guarded selection (gate_case).
virtual value_type observe (value_type child, const std::string &datum) const
 Evaluate a latent-variable observation (gate_observe).
virtual value_type conditioned (const std::vector< value_type > &children) const
 Evaluate a conditioning marker (gate_conditioned).
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 mul_sub_left_distributive () const
 Return true if \(\otimes\) distributes over the monus on the left: \(a \otimes (b \ominus c) = (a \otimes b) \ominus (a \otimes c)\) for all \(a, b, c\).
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< which_provenance_t >
typedef which_provenance_t value_type
 The carrier type of this semiring.

Detailed Description

Which-provenance (lineage) semiring.

Each gate evaluates to a which_provenance_t (set of contributing labels, or \(\bot\)).

Definition at line 58 of file Which.h.

Member Function Documentation

◆ compatibleWithBooleanRewrite()

virtual bool semiring::Which::compatibleWithBooleanRewrite ( ) const
inlineoverridevirtual

No semiring homomorphism BoolFunc(Y) →+* Which exists, so the safe-query Boolean rewrite is unsound under which-provenance.

(Lineage tracks the union of contributing labels per derivation; the read-once rewrite collapses alternative derivations to a single shared label set, which is not in general the union produced by the original circuit.) Inherits the false default from Semiring; this override exists for documentation.

Lean: Provenance.Semirings.Which.no_hom_from_BoolFunc (provenance-lean/Provenance/Semirings/Which.lean).

Reimplemented from semiring::Semiring< which_provenance_t >.

Definition at line 135 of file Which.h.

◆ delta()

value_type semiring::Which::delta ( value_type x) const
inlineoverridevirtual

Apply the \(\delta\) operator.

Parameters
xInput value.
Returns
\(\delta(x)\).

Implements semiring::Semiring< which_provenance_t >.

Definition at line 109 of file Which.h.

Here is the call graph for this function:

◆ idempotent()

bool semiring::Which::idempotent ( ) const
inlineoverridevirtual

Which-provenance is idempotent: \(\oplus\) is set union.

Lean: Provenance.Semirings.Which.idempotent.

Reimplemented from semiring::Semiring< which_provenance_t >.

Definition at line 118 of file Which.h.

◆ monus()

value_type semiring::Which::monus ( value_type x,
value_type y ) const
inlineoverridevirtual

Apply the monus (m-semiring difference) operation.

Parameters
xMinuend.
ySubtrahend.
Returns
\(x \ominus y\).

Implements semiring::Semiring< which_provenance_t >.

Definition at line 93 of file Which.h.

◆ one()

value_type semiring::Which::one ( ) const
inlineoverridevirtual

Return the multiplicative identity \(\mathbb{1}\).

Returns
The one element of the semiring.

Implements semiring::Semiring< which_provenance_t >.

Definition at line 64 of file Which.h.

Here is the caller graph for this function:

◆ parse_leaf()

value_type semiring::Which::parse_leaf ( const char * v) const
inline

Parse a leaf value into a which-provenance set.

Accepted input formats (round-trip with to_text):

  • "⊥" → zero (no derivation)
  • Bare label (no leading '{'): "Alice"{Alice}
  • Empty set: "{}" → one (a derivation requiring no witnesses)
  • Full set: "{a,b,c}"{a,b,c}

Labels may contain any character except ',', '{', '}'.

Definition at line 150 of file Which.h.

◆ plus()

value_type semiring::Which::plus ( const std::vector< value_type > & v) const
inlineoverridevirtual

Apply the additive operation to a list of values.

Parameters
vOrdered list of operands (empty list should return zero()).
Returns
\(v_0 \oplus v_1 \oplus \cdots\).

Implements semiring::Semiring< which_provenance_t >.

Definition at line 68 of file Which.h.

◆ times()

value_type semiring::Which::times ( const std::vector< value_type > & v) const
inlineoverridevirtual

Apply the multiplicative operation to a list of values.

Parameters
vOrdered list of operands (empty list should return one()).
Returns
\(v_0 \otimes v_1 \otimes \cdots\).

Implements semiring::Semiring< which_provenance_t >.

Definition at line 80 of file Which.h.

Here is the call graph for this function:

◆ to_text()

std::string semiring::Which::to_text ( const value_type & prov) const
inline

Definition at line 186 of file Which.h.

◆ zero()

value_type semiring::Which::zero ( ) const
inlineoverridevirtual

Return the additive identity \(\mathbb{0}\).

Returns
The zero element of the semiring.

Implements semiring::Semiring< which_provenance_t >.

Definition at line 60 of file Which.h.

Here is the caller graph for this function:

The documentation for this class was generated from the following file:
  • /home/pierre/git/software/provsql/src/semiring/Which.h