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

The one-best-derivation semiring over best_path_t. More...

#include "BestPath.h"

Inheritance diagram for semiring::BestPath:
Collaboration diagram for semiring::BestPath:

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 bool absorptive () const override
 \(\mathbb{1}\) is the best value, on both sides of a product.
virtual bool selective () const override
 The sum is the better of two values.
virtual bool commutative () const override
 Concatenation does not commute.
virtual bool mul_sub_left_distributive () const override
 \(\otimes\) distributes over \(\ominus\), on both sides.
virtual value_type star (const value_type &) const override
 Every star is \(\mathbb{1}\), by absorption.
Public Member Functions inherited from semiring::Semiring< best_path_t >
virtual value_type plus_of (const std::vector< const value_type * > &v) const
 plus over the values v points to, read in place.
virtual value_type times_of (const std::vector< const value_type * > &v) const
 times over the values v points to, read in place (see plus_of).
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 idempotent () const
 Return true if this semiring is idempotent ( \(a \oplus a = a\) for all \(a\)).
virtual bool has_star () const
 Return true if star computes \(a^* = \mathbb{1} \oplus a \oplus a^2 \oplus \cdots\).
virtual bool symbolic () const
 Return true if the semiring can name an unknown and record an equation over it (symbolic_unknown, define).
virtual value_type symbolic_unknown (std::size_t position) const
 A fresh unknown, as a value.
virtual void define (const value_type &unknown, const value_type &rhs) const
 Record the equation unknown = rhs.
virtual bool equal (const value_type &a, const value_type &b) const
 Equality of the semiring elements two values denote.
virtual bool exact_equality () const
 Return true if equal decides equality of semiring elements.
virtual bool exclusive () const
 Return true if the semiring is exclusive: \(a \otimes (\mathbb{1} \ominus a) = \mathbb{0}\).
virtual bool mul_idempotent () const
 Return true if \(\otimes\) is idempotent: \(a \otimes a = a\).
bool product_is_joint () const
 Whether the product of the predicate provenances of two conditions over one family of occurrences is the provenance of their conjunction (and their sum that of their disjunction).
virtual bool compatibleWithBooleanRewrite () const
 Return true if a semiring homomorphism BoolFunc(X) →+* S exists, so the safe-query (Boolean-rewrite) optimisation produces circuits that are semantically faithful when evaluated under this semiring.
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.

Static Public Member Functions

static bool better (const best_path_t &a, const best_path_t &b)
 Whether a is strictly better than b.
static best_path_t leaf (double cost, const std::string *label)
 The value of an input of cost cost and label label, no label being the empty word, and an infinite cost \(\mathbb{0}\).

Additional Inherited Members

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

Detailed Description

The one-best-derivation semiring over best_path_t.

Its leaves combine two mappings, costs and labels (see sr_best_path), so they are built by the caller with leaf.

Definition at line 77 of file BestPath.h.

Member Function Documentation

◆ absorptive()

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

\(\mathbb{1}\) is the best value, on both sides of a product.

Reimplemented from semiring::Semiring< best_path_t >.

Definition at line 138 of file BestPath.h.

◆ better()

bool semiring::BestPath::better ( const best_path_t & a,
const best_path_t & b )
inlinestatic

Whether a is strictly better than b.

Definition at line 81 of file BestPath.h.

Here is the caller graph for this function:

◆ commutative()

virtual bool semiring::BestPath::commutative ( ) const
inlineoverridevirtual

Concatenation does not commute.

Reimplemented from semiring::Semiring< best_path_t >.

Definition at line 146 of file BestPath.h.

◆ delta()

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

Apply the \(\delta\) operator.

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

Implements semiring::Semiring< best_path_t >.

Definition at line 133 of file BestPath.h.

Here is the call graph for this function:

◆ leaf()

best_path_t semiring::BestPath::leaf ( double cost,
const std::string * label )
inlinestatic

The value of an input of cost cost and label label, no label being the empty word, and an infinite cost \(\mathbb{0}\).

Definition at line 91 of file BestPath.h.

Here is the caller graph for this function:

◆ monus()

virtual value_type semiring::BestPath::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< best_path_t >.

Definition at line 130 of file BestPath.h.

Here is the call graph for this function:

◆ mul_sub_left_distributive()

virtual bool semiring::BestPath::mul_sub_left_distributive ( ) const
inlineoverridevirtual

\(\otimes\) distributes over \(\ominus\), on both sides.

Read only by the HAVING evaluation, which refuses a non-commutative semiring for now.

Lean: Provenance.Semirings.BestPath.mul_sub_left_distributive_of.

Reimplemented from semiring::Semiring< best_path_t >.

Definition at line 157 of file BestPath.h.

◆ one()

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

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

Returns
The one element of the semiring.

Implements semiring::Semiring< best_path_t >.

Definition at line 110 of file BestPath.h.

Here is the caller graph for this function:

◆ plus()

virtual value_type semiring::BestPath::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< best_path_t >.

Definition at line 113 of file BestPath.h.

Here is the call graph for this function:

◆ selective()

virtual bool semiring::BestPath::selective ( ) const
inlineoverridevirtual

The sum is the better of two values.

Reimplemented from semiring::Semiring< best_path_t >.

Definition at line 142 of file BestPath.h.

◆ star()

virtual value_type semiring::BestPath::star ( const value_type & ) const
inlineoverridevirtual

Every star is \(\mathbb{1}\), by absorption.

Reimplemented from semiring::Semiring< best_path_t >.

Definition at line 161 of file BestPath.h.

Here is the call graph for this function:

◆ times()

virtual value_type semiring::BestPath::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< best_path_t >.

Definition at line 120 of file BestPath.h.

Here is the call graph for this function:

◆ zero()

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

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

Returns
The zero element of the semiring.

Implements semiring::Semiring< best_path_t >.

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