69virtual char const *
what() const noexcept {
163 std::vector<value_type> c;
165 for(
const auto *x : v)
178 std::vector<value_type> c;
180 for(
const auto *x : v)
283 const std::vector<value_type> ¶ms)
const {
285 "This semiring does not support rv gates: a continuous "
286 "distribution is not a semiring value. Query a "
287 "random-variable token through the measure surface "
288 "(expected / variance / quantile / support / sample), or use "
289 "the formula pseudo-semiring for a symbolic rendering.");
304 const std::vector<value_type> &children,
305 const std::string &extra)
const {
307 "This semiring does not support arith gates: arithmetic over "
308 "scalar (random-variable) children is not a semiring "
309 "operation. Query such a token through the measure surface "
310 "(expected / variance / quantile / support / sample), or use "
311 "the formula pseudo-semiring for a symbolic rendering.");
324 "This semiring does not support mixture gates: a probabilistic "
325 "mixture is not a semiring operation. Query such a token "
326 "through the measure surface (expected / variance / quantile / "
327 "support / sample), or use the formula pseudo-semiring for a "
328 "symbolic rendering.");
341 const std::vector<double> &probs,
342 const std::vector<std::string> &outcomes)
const {
344 "This semiring does not support categorical mixture gates: a "
345 "distribution over outcomes is not a semiring value. Query "
346 "such a token through the measure surface (expected / "
347 "variance / quantile / support / sample), or use the formula "
348 "pseudo-semiring for a symbolic rendering.");
361 "The requested semiring does not support a CASE / guarded "
362 "selection over random variables (gate_case): it is evaluable "
363 "only through the random-variable / measure surface "
364 "(expected / variance / support / probability / sample).");
376 "This semiring does not support observe gates: the density "
377 "factor of a likelihood-weighting observation is not a "
378 "semiring value. Such a token is evaluated by the "
379 "importance-sampling surface, or rendered symbolically by the "
380 "formula pseudo-semiring.");
394 "The requested semiring does not support conditioning: "
395 "P(·|C) = P(·∧C)/P(C) needs a normalising division "
396 "no general semiring provides. A conditioned token is "
397 "evaluable only in the measure interpretation "
398 "(probability_evaluate, or the random-variable / agg_token "
399 "distribution evaluators).");
520 for(
int k = 0; k < 1000000; ++k) {
733 const std::vector<value_type> &,
734 const std::vector<value_type> &)
const {
745 const std::vector<value_type> &)
const {
Typed aggregation value, operator, and aggregator abstractions.
AggregationOperator
SQL aggregation functions tracked by ProvSQL.
ComparisonOperator
SQL comparison operators used in gate_cmp circuit gates.
ArithmeticOperator
Arithmetic operations carried by gate_arith circuit gates.
Exception thrown when a semiring operation is not supported.
std::string message
Human-readable description of the error.
virtual char const * what() const noexcept
Return the error message as a C-string.
SemiringException(const std::string &m)
Construct with a descriptive error message.
A gate kind this semiring does not interpret (a comparison, a semimodule multiplication,...
SemiringGateException(const std::string &m)
Construct with a descriptive error message.
Abstract base class for (m-)semirings.
V value_type
The carrier type of this semiring.
virtual value_type semimod(value_type x, value_type s) const
Apply a semimodule scalar multiplication.
virtual bool commutative() const
Return true if is commutative ( for all ).
virtual value_type plus(const std::vector< value_type > &v) const =0
Apply the additive operation to a list of values.
virtual value_type mixture(value_type p, value_type x, value_type y) const
Evaluate a Bernoulli mixture (gate_mixture, three wires).
virtual bool idempotent() const
Return true if this semiring is idempotent ( for all ).
virtual bool mul_idempotent() const
Return true if is idempotent: .
virtual bool absorptive() const
Return true if this semiring is absorptive ( for all ).
virtual void define(const value_type &unknown, const value_type &rhs) const
Record the equation unknown = rhs.
virtual bool certifying() const
Whether this semiring builds certified exclusive enumerations (see the three hooks below).
virtual ~Semiring()=default
virtual bool has_star() const
Return true if star computes .
virtual bool compatibleWithBooleanRewrite() const
Return true if a semiring homomorphism BoolFunc(X) →+* S exists, so the safe-query (Boolean-rewrite) ...
virtual value_type zero() const =0
Return the additive identity .
bool product_is_joint() const
Whether the product of the predicate provenances of two conditions over one family of occurrences is ...
virtual value_type guarded_case(const std::vector< value_type > &children) const
Evaluate a guarded selection (gate_case).
virtual value_type cmp(value_type s1, ComparisonOperator op, value_type s2) const
Evaluate a comparison gate.
virtual bool exclusive() const
Return true if the semiring is exclusive: .
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 agg(AggregationOperator op, const std::vector< value_type > &s)
Evaluate an aggregation gate.
virtual value_type conditioned(const std::vector< value_type > &children) const
Evaluate a conditioning marker (gate_conditioned).
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 bool symbolic() const
Return true if the semiring can name an unknown and record an equation over it (symbolic_unknown,...
virtual bool selective() const
Return true if is selective (for all , ).
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 missi...
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 unmapped_input(const std::string &uuid) const
Value of a variable leaf (gate_input / gate_mulinput) that the provenance mapping does not name.
virtual bool mul_sub_left_distributive() const
Return true if distributes over the monus on the left: for all .
virtual value_type one() const =0
Return the multiplicative identity .
virtual bool equal(const value_type &a, const value_type &b) const
Equality of the semiring elements two values denote.
virtual value_type monus(value_type x, value_type y) const =0
Apply the monus (m-semiring difference) operation.
virtual value_type rv(const std::string &spec, const std::vector< value_type > ¶ms) const
Evaluate a continuous random-variable leaf (gate_rv).
virtual value_type certified_exclusive_plus(const std::vector< value_type > &) const
Build the disjunction of pairwise-exclusive disjuncts, certified deterministic.
virtual value_type delta(value_type x) const =0
Apply the operator.
virtual value_type symbolic_unknown(std::size_t position) const
A fresh unknown, as a value.
virtual value_type times(const std::vector< value_type > &v) const =0
Apply the multiplicative operation to a list of values.
virtual value_type star(const value_type &a) const
, the sum of the powers of a.
virtual value_type observe(value_type child, const std::string &datum) const
Evaluate a latent-variable observation (gate_observe).
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 bool independent_literal(const value_type &) const
Whether v is an independent literal for certification purposes: a base Bernoulli variable (or a const...
virtual bool exact_equality() const
Return true if equal decides equality of semiring elements.
virtual value_type value(const std::string &s) const
Interpret a literal string as a semiring value.