ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
Formula.h File Reference

Symbolic formula semiring producing readable provenance expressions. More...

#include <numeric>
#include <vector>
#include <string>
#include <sstream>
#include <iterator>
#include "Semiring.h"
Include dependency graph for Formula.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  semiring::Formula
 Symbolic provenance formula semiring over std::string. More...
 

Namespaces

namespace  semiring
 

Functions

template<typename Range , typename Value = typename Range::value_type>
static std::string join (Range const &elements, const char *const delimiter)
 Concatenate elements of a range with a delimiter.
 

Detailed Description

Symbolic formula semiring producing readable provenance expressions.

The Formula semiring (std::string, \(\oplus\), \(\otimes\), "𝟘", "𝟙") represents provenance as a human-readable symbolic expression using Unicode semiring symbols. It is primarily used for debugging and testing.

Each gate evaluates to a string:

  • zero() → "𝟘"
  • one() → "𝟙"
  • plus() → "(a ⊕ b ⊕ 
)" or just "a" for singletons
  • times() → "(a ⊗ b ⊗ 
)" or just "a" for singletons
  • monus() → "(a ⊖ b)"
  • delta() → "ÎŽ(a)" or "ÎŽa" if a starts with (
  • cmp() → "[s1 op s2]"
  • semimod()→ "x*s"
  • agg() → operator-specific notation (e.g., "min(a,b)")
  • value() → the literal string itself

Definition in file Formula.h.

Function Documentation

◆ join()

template<typename Range , typename Value = typename Range::value_type>
static std::string join ( Range const &  elements,
const char *const  delimiter 
)
static

Concatenate elements of a range with a delimiter.

Used internally by Formula::plus(), Formula::times(), and Formula::agg() to build operator-separated strings.

Template Parameters
RangeAny range type with a value_type typedef.
ValueElement type (defaults to Range::value_type).
Parameters
elementsThe range to join.
delimiterString to insert between adjacent elements.
Returns
All elements concatenated with delimiter between them.

Definition at line 46 of file Formula.h.

Here is the caller graph for this function: