![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
SQL functions for Shapley and Banzhaf power-index computation. More...
#include "postgres.h"#include "fmgr.h"#include "catalog/pg_type.h"#include "utils/uuid.h"#include "executor/spi.h"#include "provsql_shmem.h"#include "provsql_utils.h"#include "c_cpp_compatibility.h"#include "BooleanCircuit.h"#include "Circuit.hpp"#include "provsql_utils_cpp.h"#include "dDNNFTreeDecompositionBuilder.h"#include "CircuitFromMMap.h"#include <fstream>
Go to the source code of this file.
Functions | |
| static double | shapley_internal (pg_uuid_t token, pg_uuid_t variable, const std::string &method, const std::string &args, bool banzhaf) |
| Core implementation for Shapley and Banzhaf index computation. | |
| Datum | shapley (PG_FUNCTION_ARGS) |
| PostgreSQL-callable wrapper for shapley() and banzhaf(). | |
| Datum | shapley_all_vars (PG_FUNCTION_ARGS) |
| PostgreSQL-callable wrapper for shapley_all_vars() set-returning function. | |
SQL functions for Shapley and Banzhaf power-index computation.
Implements two SQL-callable functions:
provsql.shapley(token, variable, method, args): Shapley value of a given input gate (tuple) in the provenance circuit rooted at token.provsql.shapley_all_vars(token, method, args): Shapley values for all input gates simultaneously (more efficient than calling shapley() once per variable).The method argument selects the computation algorithm:
"tree-decomposition": exact, polynomial if treewidth ≤ MAX_TREEWIDTH."monte-carlo": approximate via random sampling."d4", "c2d", etc.).Banzhaf power index computation is exposed via the same internal helper (shapley_internal with banzhaf=true), called by the provsql.banzhaf() SQL function defined in the SQL layer.
Definition in file shapley.cpp.
| Datum shapley | ( | PG_FUNCTION_ARGS | ) |
PostgreSQL-callable wrapper for shapley() and banzhaf().
Definition at line 81 of file shapley.cpp.

| Datum shapley_all_vars | ( | PG_FUNCTION_ARGS | ) |
PostgreSQL-callable wrapper for shapley_all_vars() set-returning function.
Definition at line 118 of file shapley.cpp.

|
static |
Core implementation for Shapley and Banzhaf index computation.
| token | UUID of the root provenance gate. |
| variable | UUID of the input gate whose index is to be computed. |
| method | d-DNNF compilation method. |
| args | Additional arguments for the compilation method. |
| banzhaf | If true, compute the Banzhaf index instead of Shapley. |
variable. Definition at line 53 of file shapley.cpp.

