ProvSQL SQL API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
Semiring evaluation

Functions for evaluating provenance circuits over semirings, both user-defined (via function references) and compiled (built-in). More...

Functions

ANYELEMENT provsql.provenance_evaluate_compiled (UUID token, REGCLASS token2value, TEXT semiring, ANYELEMENT element_one)
 Evaluate provenance using a compiled (built-in) semiring.
ANYELEMENT provsql.provenance_evaluate (UUID token, REGCLASS token2value, ANYELEMENT element_one, REGTYPE value_type, REGPROC plus_function, REGPROC times_function, REGPROC monus_function, REGPROC delta_function)
 Evaluate provenance over a user-defined semiring (PL/pgSQL version).
ANYELEMENT provsql.provenance_evaluate (UUID token, REGCLASS token2value, ANYELEMENT element_one, REGPROC plus_function, REGPROC times_function, REGPROC monus_function=NULL, REGPROC delta_function=NULL)
 Evaluate provenance over a user-defined semiring (C version).

Detailed Description

Functions for evaluating provenance circuits over semirings, both user-defined (via function references) and compiled (built-in).

Function Documentation

◆ provenance_evaluate() [1/2]

ANYELEMENT provsql.provenance_evaluate ( UUID token,
REGCLASS token2value,
ANYELEMENT element_one,
REGPROC plus_function,
REGPROC times_function,
REGPROC monus_function = NULL,
REGPROC delta_function = NULL )

Evaluate provenance over a user-defined semiring (C version).

Optimized C implementation of provenance_evaluate. Infers the value type from element_one. Monus and delta functions are optional.

Parameters
tokenprovenance token to evaluate
token2valuemapping table from tokens to semiring values
element_oneidentity element of the semiring
plus_functionsemiring addition (aggregate)
times_functionsemiring multiplication (aggregate)
monus_functionsemiring monus, or NULL if not needed
delta_functionδ-semiring operator, or NULL if not needed
Source code
provsql.sql line 1697

◆ provenance_evaluate() [2/2]

ANYELEMENT provsql.provenance_evaluate ( UUID token,
REGCLASS token2value,
ANYELEMENT element_one,
REGTYPE value_type,
REGPROC plus_function,
REGPROC times_function,
REGPROC monus_function,
REGPROC delta_function )

Evaluate provenance over a user-defined semiring (PL/pgSQL version).

Recursively walks the provenance circuit and evaluates each gate using the provided semiring operations. This is the generic version that accepts semiring operations as function references.

Parameters
tokenprovenance token to evaluate
token2valuemapping table from tokens to semiring values
element_oneidentity element of the semiring
value_typeOID of the semiring value type
plus_functionsemiring addition (aggregate)
times_functionsemiring multiplication (aggregate)
monus_functionsemiring monus (binary), or NULL
delta_functionδ-semiring operator, or NULL
Source code
provsql.sql line 1697

◆ provenance_evaluate_compiled()

ANYELEMENT provsql.provenance_evaluate_compiled ( UUID token,
REGCLASS token2value,
TEXT semiring,
ANYELEMENT element_one )

Evaluate provenance using a compiled (built-in) semiring.

This C function handles semiring evaluation entirely in C++ for better performance. The semiring is specified by name.

Parameters
tokenprovenance token to evaluate
token2valuemapping table from tokens to semiring values
semiringname of the compiled semiring (e.g., "formula", "counting")
element_oneidentity element of the semiring
Source code
provsql.sql line 1672