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

How-provenance m-semiring over \(\mathbb{N}[X]\). More...

#include "How.h"

Inheritance diagram for semiring::How:
Collaboration diagram for semiring::How:

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.
virtual bool compatibleWithBooleanRewrite () const override
 No semiring homomorphism BoolFunc(Y) →+* ℕ[X] exists, so the safe-query Boolean rewrite is unsound under how-provenance (which is sensitive to derivation multiplicities and monomial structure that the read-once rewrite collapses).
value_type parse_leaf (const char *v) const
 Parse a leaf value into a how-provenance polynomial.
std::string to_text (const value_type &prov) const
Public Member Functions inherited from semiring::Semiring< how_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 ~Semiring ()=default
virtual bool absorptive () const
 Return true if this semiring is absorptive ( \(\mathbb{1} \oplus a = \mathbb{1}\) for all \(a\)).

Additional Inherited Members

Public Types inherited from semiring::Semiring< how_provenance_t >
typedef how_provenance_t value_type
 The carrier type of this semiring.

Detailed Description

How-provenance m-semiring over \(\mathbb{N}[X]\).

Each gate evaluates to a how_provenance_t, a polynomial in canonical sum-of-products form. Two semantically-equal polynomials compare equal under std::map's lexicographic equality, so this semiring supports provenance-aware query equivalence.

Definition at line 72 of file How.h.

Member Function Documentation

◆ compatibleWithBooleanRewrite()

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

No semiring homomorphism BoolFunc(Y) →+* ℕ[X] exists, so the safe-query Boolean rewrite is unsound under how-provenance (which is sensitive to derivation multiplicities and monomial structure that the read-once rewrite collapses).

Inherits the false default from Semiring; this override exists for documentation.

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

Reimplemented from semiring::Semiring< how_provenance_t >.

Definition at line 139 of file How.h.

◆ delta()

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

Apply the \(\delta\) operator.

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

Implements semiring::Semiring< how_provenance_t >.

Definition at line 124 of file How.h.

Here is the call graph for this function:

◆ monus()

value_type semiring::How::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< how_provenance_t >.

Definition at line 112 of file How.h.

◆ one()

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

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

Returns
The one element of the semiring.

Implements semiring::Semiring< how_provenance_t >.

Definition at line 78 of file How.h.

Here is the caller graph for this function:

◆ parse_leaf()

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

Parse a leaf value into a how-provenance polynomial.

Accepted input formats (round-trip with to_text):

  • "0" → zero polynomial
  • Bare label: "Alice"{Alice}
  • Constant: "5"5 (polynomial 5⋅1)
  • Monomial: "2⋅Alice⋅Bob^2"
  • Sum of monomials: "2⋅Alice⋅Bob^2 + 3⋅Charlie"

Variables may contain any character except '⋅', '+', '^'. The " + " separator must use ASCII spaces around the '+'.

Definition at line 156 of file How.h.

◆ plus()

value_type semiring::How::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< how_provenance_t >.

Definition at line 82 of file How.h.

◆ times()

value_type semiring::How::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< how_provenance_t >.

Definition at line 92 of file How.h.

Here is the call graph for this function:

◆ to_text()

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

Definition at line 237 of file How.h.

◆ zero()

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

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

Returns
The zero element of the semiring.

Implements semiring::Semiring< how_provenance_t >.

Definition at line 74 of file How.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/How.h