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

The Viterbi (max-times) m-semiring over double. More...

#include "Viterbi.h"

Inheritance diagram for semiring::Viterbi:
Collaboration diagram for semiring::Viterbi:

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
 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) →+* Viterbi exists (real multiplication is not idempotent), so the safe-query Boolean rewrite is unsound under the Viterbi semiring.
value_type parse_leaf (const char *v) const
Public Member Functions inherited from semiring::Semiring< double >
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

Additional Inherited Members

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

Detailed Description

The Viterbi (max-times) m-semiring over double.

Each gate evaluates to the probability of the most likely derivation of the corresponding sub-formula.

Definition at line 49 of file Viterbi.h.

Member Function Documentation

◆ absorptive()

virtual bool semiring::Viterbi::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< double >.

Definition at line 73 of file Viterbi.h.

◆ compatibleWithBooleanRewrite()

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

No semiring homomorphism BoolFunc(Y) →+* Viterbi exists (real multiplication is not idempotent), so the safe-query Boolean rewrite is unsound under the Viterbi semiring.

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

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

Reimplemented from semiring::Semiring< double >.

Definition at line 86 of file Viterbi.h.

◆ delta()

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

Apply the \(\delta\) operator.

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

Implements semiring::Semiring< double >.

Definition at line 69 of file Viterbi.h.

Here is the call graph for this function:

◆ monus()

virtual value_type semiring::Viterbi::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< double >.

Definition at line 65 of file Viterbi.h.

Here is the call graph for this function:

◆ one()

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

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

Returns
The one element of the semiring.

Implements semiring::Semiring< double >.

Definition at line 55 of file Viterbi.h.

Here is the caller graph for this function:

◆ parse_leaf()

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

Definition at line 89 of file Viterbi.h.

◆ plus()

virtual value_type semiring::Viterbi::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< double >.

Definition at line 58 of file Viterbi.h.

Here is the call graph for this function:

◆ times()

virtual value_type semiring::Viterbi::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< double >.

Definition at line 62 of file Viterbi.h.

◆ zero()

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

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

Returns
The zero element of the semiring.

Implements semiring::Semiring< double >.

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