![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
Abstract base class for (m-)semirings. More...
#include "Semiring.h"
Public Types | |
| typedef V | value_type |
| The carrier type of this semiring. | |
Public Member Functions | |
| virtual value_type | zero () const =0 |
| Return the additive identity \(\mathbb{0}\). | |
| virtual value_type | one () const =0 |
| Return the multiplicative identity \(\mathbb{1}\). | |
| virtual value_type | plus (const std::vector< value_type > &v) const =0 |
| Apply the additive operation to a list of values. | |
| virtual value_type | times (const std::vector< value_type > &v) const =0 |
| Apply the multiplicative operation to a list of values. | |
| virtual value_type | monus (value_type x, value_type y) const =0 |
| Apply the monus (m-semiring difference) operation. | |
| virtual value_type | delta (value_type x) const =0 |
| Apply the \(\delta\) operator. | |
| 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 ( \(a \oplus a = a\)). | |
Abstract base class for (m-)semirings.
| V | The carrier type (e.g. bool, unsigned, std::string). |
All pure-virtual methods must be implemented by concrete subclasses.
cmp(), semimod(), agg(), and value() have default implementations that throw SemiringException. Override them in subclasses that support these circuit gate types.
A semiring is absorptive (i.e., \(a \oplus a = a\) for all \(a\)) iff absorptive() returns true. This allows the circuit evaluator to deduplicate children of plus gates for efficiency.
Definition at line 83 of file Semiring.h.
| typedef V semiring::Semiring< V >::value_type |
The carrier type of this semiring.
Definition at line 87 of file Semiring.h.
|
virtualdefault |
|
inlinevirtual |
Return true if this semiring is absorptive ( \(a \oplus a = a\)).
When true, the circuit evaluator may deduplicate the children of plus gates, which can improve performance significantly for semirings such as Boolean and Why-provenance.
false by default; override to return true. Reimplemented in semiring::Boolean, and semiring::BoolExpr.
Definition at line 195 of file Semiring.h.
|
inlinevirtual |
Evaluate an aggregation gate.
| op | The aggregation function (COUNT, SUM, MIN, …). |
| s | List of child semiring values to aggregate. |
| SemiringException | if not overridden. |
Reimplemented in semiring::Formula.
Definition at line 167 of file Semiring.h.
|
inlinevirtual |
Evaluate a comparison gate.
| s1 | Left operand. |
| op | Comparison operator. |
| s2 | Right operand. |
| SemiringException | if not overridden. |
Reimplemented in semiring::Formula.
Definition at line 143 of file Semiring.h.
|
pure virtual |
Apply the \(\delta\) operator.
| x | Input value. |
Implemented in semiring::Boolean, semiring::BoolExpr, semiring::Counting, semiring::Formula, and semiring::Why.
|
pure virtual |
Apply the monus (m-semiring difference) operation.
| x | Minuend. |
| y | Subtrahend. |
Implemented in semiring::Boolean, semiring::BoolExpr, semiring::Counting, semiring::Formula, and semiring::Why.
|
pure virtual |
Return the multiplicative identity \(\mathbb{1}\).
Implemented in semiring::Boolean, semiring::BoolExpr, semiring::Counting, semiring::Formula, and semiring::Why.
|
pure virtual |
Apply the additive operation to a list of values.
| v | Ordered list of operands (empty list should return zero()). |
Implemented in semiring::Boolean, semiring::Counting, semiring::Formula, semiring::BoolExpr, and semiring::Why.
|
inlinevirtual |
Apply a semimodule scalar multiplication.
| x | Provenance value. |
| s | Scalar value. |
| SemiringException | if not overridden. |
Reimplemented in semiring::Formula.
Definition at line 155 of file Semiring.h.
|
pure virtual |
Apply the multiplicative operation to a list of values.
| v | Ordered list of operands (empty list should return one()). |
Implemented in semiring::Boolean, semiring::Counting, semiring::Formula, semiring::BoolExpr, and semiring::Why.
|
inlinevirtual |
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 in semiring::Formula.
Definition at line 180 of file Semiring.h.
|
pure virtual |
Return the additive identity \(\mathbb{0}\).
Implemented in semiring::Boolean, semiring::BoolExpr, semiring::Counting, semiring::Formula, and semiring::Why.