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

Symbolic provenance formula semiring over std::string. More...

#include "Formula.h"

Inheritance diagram for semiring::Formula:
Collaboration diagram for semiring::Formula:

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.
 
- Public Member Functions inherited from semiring::Semiring< std::string >
virtual ~Semiring ()=default
 
virtual bool absorptive () const
 Return true if this semiring is absorptive ( \(a \oplus a = a\)).
 

Additional Inherited Members

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

Detailed Description

Symbolic provenance formula semiring over std::string.

Evaluates circuits to human-readable Unicode provenance formulas. Supports all optional operations (cmp, semimod, agg, value) in addition to the mandatory ones.

Definition at line 69 of file Formula.h.

Member Function Documentation

◆ agg()

virtual value_type semiring::Formula::agg ( AggregationOperator  op,
const std::vector< std::string > &  s 
)
inlineoverridevirtual

Evaluate an aggregation gate.

Parameters
opThe aggregation function (COUNT, SUM, MIN, …).
sList of child semiring values to aggregate.
Returns
The aggregated value.
Exceptions
SemiringExceptionif not overridden.

Reimplemented from semiring::Semiring< std::string >.

Definition at line 132 of file Formula.h.

◆ cmp()

virtual value_type semiring::Formula::cmp ( value_type  s1,
ComparisonOperator  op,
value_type  s2 
) const
inlineoverridevirtual

Evaluate a comparison gate.

Parameters
s1Left operand.
opComparison operator.
s2Right operand.
Returns
Result of the comparison in this semiring.
Exceptions
SemiringExceptionif not overridden.

Reimplemented from semiring::Semiring< std::string >.

Definition at line 105 of file Formula.h.

◆ delta()

virtual value_type semiring::Formula::delta ( value_type  x) const
inlineoverridevirtual

Apply the \(\delta\) operator.

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

Implements semiring::Semiring< std::string >.

Definition at line 98 of file Formula.h.

◆ monus()

virtual value_type semiring::Formula::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< std::string >.

Definition at line 94 of file Formula.h.

◆ one()

virtual value_type semiring::Formula::one ( ) const
inlineoverridevirtual

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

Returns
The one element of the semiring.

Implements semiring::Semiring< std::string >.

Definition at line 75 of file Formula.h.

Here is the caller graph for this function:

◆ plus()

virtual value_type semiring::Formula::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< std::string >.

Definition at line 78 of file Formula.h.

Here is the call graph for this function:

◆ semimod()

virtual value_type semiring::Formula::semimod ( value_type  x,
value_type  s 
) const
inlineoverridevirtual

Apply a semimodule scalar multiplication.

Parameters
xProvenance value.
sScalar value.
Returns
\(x * s\) in the semimodule.
Exceptions
SemiringExceptionif not overridden.

Reimplemented from semiring::Semiring< std::string >.

Definition at line 129 of file Formula.h.

◆ times()

virtual value_type semiring::Formula::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< std::string >.

Definition at line 86 of file Formula.h.

Here is the call graph for this function:

◆ value()

virtual value_type semiring::Formula::value ( const std::string &  s) const
inlineoverridevirtual

Interpret a literal string as a semiring value.

Used for gate_value gates whose payload is a string.

Parameters
sLiteral string.
Returns
The corresponding semiring value.
Exceptions
SemiringExceptionif not overridden.

Reimplemented from semiring::Semiring< std::string >.

Definition at line 215 of file Formula.h.

◆ zero()

virtual value_type semiring::Formula::zero ( ) const
inlineoverridevirtual

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

Returns
The zero element of the semiring.

Implements semiring::Semiring< std::string >.

Definition at line 72 of file Formula.h.

Here is the caller graph for this function:

The documentation for this class was generated from the following file: