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

Min-max / max-min m-semiring with Datum carrier over a PostgreSQL enum type. More...

#include "MinMax.h"

Inheritance diagram for semiring::MinMax:
Collaboration diagram for semiring::MinMax:

Public Member Functions

 MinMax (Oid enum_type_oid, bool reverse_)
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 bool absorptive () const override
 Return true if this semiring is absorptive ( \(\mathbb{1} \oplus a = \mathbb{1}\) for all \(a\)).
virtual bool compatibleWithBooleanRewrite () const override
 No semiring homomorphism BoolFunc(Y) →+* MinMax exists (the enum-min / enum-max structure cannot model the Boolean-functions semiring), so the safe-query Boolean rewrite is unsound under MinMax / MaxMin.
Datum parse_leaf (const char *str) const
 Parse an enum text literal to a Datum.
Public Member Functions inherited from semiring::Semiring< Datum >
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

Static Private Member Functions

static int enum_cmp_datum (Datum a, Datum b)

Private Attributes

Oid enum_oid
bool reverse
Datum bottom_datum
Datum top_datum
Oid in_func
Oid typioparam

Additional Inherited Members

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

Detailed Description

Min-max / max-min m-semiring with Datum carrier over a PostgreSQL enum type.

A single class covers both the MinMax (reverse = false, the security shape) and the MaxMin (reverse = true, the fuzzy / trust shape) instantiations: the two are related by order reversal on the same carrier. Bottom and top of the carrier enum are looked up once in the constructor and cached as bottom_datum / top_datum.

Definition at line 76 of file MinMax.h.

Constructor & Destructor Documentation

◆ MinMax()

semiring::MinMax::MinMax ( Oid enum_type_oid,
bool reverse_ )
inlineexplicit

Definition at line 90 of file MinMax.h.

Member Function Documentation

◆ absorptive()

virtual bool semiring::MinMax::absorptive ( ) const
inlineoverridevirtual

Return true if this semiring is absorptive ( \(\mathbb{1} \oplus a = \mathbb{1}\) for all \(a\)).

When true, the circuit evaluator and HAVING-semantics machinery may exploit the resulting idempotency ( \(a \oplus a = a\), implied by absorptivity) to deduplicate children of plus gates and to short-circuit over the multiplicative identity.

Returns
false by default; override to return true.

Reimplemented from semiring::Semiring< Datum >.

Definition at line 165 of file MinMax.h.

◆ compatibleWithBooleanRewrite()

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

No semiring homomorphism BoolFunc(Y) →+* MinMax exists (the enum-min / enum-max structure cannot model the Boolean-functions semiring), so the safe-query Boolean rewrite is unsound under MinMax / MaxMin.

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

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

Reimplemented from semiring::Semiring< Datum >.

Definition at line 179 of file MinMax.h.

◆ delta()

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

Apply the \(\delta\) operator.

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

Implements semiring::Semiring< Datum >.

Definition at line 161 of file MinMax.h.

◆ enum_cmp_datum()

int semiring::MinMax::enum_cmp_datum ( Datum a,
Datum b )
inlinestaticprivate

Definition at line 85 of file MinMax.h.

Here is the caller graph for this function:

◆ monus()

virtual value_type semiring::MinMax::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< Datum >.

Definition at line 151 of file MinMax.h.

Here is the call graph for this function:

◆ one()

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

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

Returns
The one element of the semiring.

Implements semiring::Semiring< Datum >.

Definition at line 128 of file MinMax.h.

Here is the caller graph for this function:

◆ parse_leaf()

Datum semiring::MinMax::parse_leaf ( const char * str) const
inline

Parse an enum text literal to a Datum.

Used by pec_anyenum() to build the input mapping; exposed here so the parser can share the cached in_func / typioparam.

Definition at line 189 of file MinMax.h.

◆ plus()

virtual value_type semiring::MinMax::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< Datum >.

Definition at line 131 of file MinMax.h.

Here is the call graph for this function:

◆ times()

virtual value_type semiring::MinMax::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< Datum >.

Definition at line 141 of file MinMax.h.

Here is the call graph for this function:

◆ zero()

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

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

Returns
The zero element of the semiring.

Implements semiring::Semiring< Datum >.

Definition at line 125 of file MinMax.h.

Here is the caller graph for this function:

Member Data Documentation

◆ bottom_datum

Datum semiring::MinMax::bottom_datum
private

Definition at line 80 of file MinMax.h.

◆ enum_oid

Oid semiring::MinMax::enum_oid
private

Definition at line 78 of file MinMax.h.

◆ in_func

Oid semiring::MinMax::in_func
private

Definition at line 82 of file MinMax.h.

◆ reverse

bool semiring::MinMax::reverse
private

Definition at line 79 of file MinMax.h.

◆ top_datum

Datum semiring::MinMax::top_datum
private

Definition at line 81 of file MinMax.h.

◆ typioparam

Oid semiring::MinMax::typioparam
private

Definition at line 83 of file MinMax.h.


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