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.aggregation_evaluate (UUID token, REGCLASS token2value, REGPROC agg_function_final, REGPROC agg_function, REGPROC semimod_function, ANYELEMENT element_one, REGTYPE value_type, REGPROC plus_function, REGPROC times_function, REGPROC monus_function, REGPROC delta_function)
 Evaluate aggregate 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)
 
ANYELEMENT provsql.aggregation_evaluate (UUID token, REGCLASS token2value, REGPROC agg_function_final, REGPROC agg_function, REGPROC semimod_function, ANYELEMENT element_one, REGPROC plus_function, REGPROC times_function, REGPROC monus_function=NULL, REGPROC delta_function=NULL)
 Evaluate aggregate 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

◆ aggregation_evaluate() [1/2]

ANYELEMENT provsql.aggregation_evaluate ( UUID  token,
REGCLASS  token2value,
REGPROC  agg_function_final,
REGPROC  agg_function,
REGPROC  semimod_function,
ANYELEMENT  element_one,
REGPROC  plus_function,
REGPROC  times_function,
REGPROC  monus_function = NULL,
REGPROC  delta_function = NULL 
)

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

Source code
provsql.sql line 748

◆ aggregation_evaluate() [2/2]

ANYELEMENT provsql.aggregation_evaluate ( UUID  token,
REGCLASS  token2value,
REGPROC  agg_function_final,
REGPROC  agg_function,
REGPROC  semimod_function,
ANYELEMENT  element_one,
REGTYPE  value_type,
REGPROC  plus_function,
REGPROC  times_function,
REGPROC  monus_function,
REGPROC  delta_function 
)

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

Handles agg and semimod gates produced by GROUP BY queries.

Parameters
tokenprovenance token to evaluate
token2valuemapping table from tokens to semiring values
agg_function_finalfinalization function for the aggregate
agg_functionaggregate combination function
semimod_functionsemimodule scalar multiplication function
element_oneidentity element of the semiring
value_typeOID of the semiring value type
plus_functionsemiring addition
times_functionsemiring multiplication
monus_functionsemiring monus, or NULL
delta_functionδ-semiring operator, or NULL
Source code
provsql.sql line 748

◆ 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 618

◆ 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 618

◆ 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 593