34#include <unordered_set>
57 return std::hash<typename std::underlying_type<gate_t>::type>()(
58 static_cast<typename std::underlying_type<gate_t>::type
>(g));
82std::unordered_map<gate_t, std::vector<double> >
shapley_delta()
const;
109std::vector<gate_t>
topological_order(
const std::vector<std::vector<gate_t> > &reversedWires)
const;
Boolean provenance circuit with support for knowledge compilation.
BooleanGate
Gate types for a Boolean provenance circuit.
gate_t
Strongly-typed gate identifier.
Boolean circuit for provenance formula evaluation.
dDNNF compilation(gate_t g, std::string compiler) const
Compile the sub-circuit rooted at g to a dDNNF via an external tool.
Builds a d-DNNF from a Boolean circuit using a tree decomposition.
A d-DNNF circuit supporting exact probabilistic and game-theoretic evaluation.
dDNNF conditionAndSimplify(gate_t var, bool value) const
Condition on variable var having value value and simplify.
gate_t root
The root gate of the d-DNNF.
dDNNF condition(gate_t var, bool value) const
Condition on variable var having value value (no simplification).
double banzhaf_internal() const
Compute the unnormalised Banzhaf value for the whole circuit.
double probabilityEvaluation() const
Compute the exact probability of the d-DNNF being true.
void setRoot(gate_t g)
Set the root gate.
void simplify()
Simplify the d-DNNF by removing redundant constants.
void makeSmooth()
Make the d-DNNF smooth.
void makeGatesBinary(BooleanGate type)
Rewrite all n-ary AND/OR gates into binary trees.
std::vector< std::vector< double > > shapley_alpha() const
Compute the α table used in the Shapley algorithm.
double shapley(gate_t var) const
Compute the Shapley value of input gate var.
double banzhaf(gate_t var) const
Compute the Banzhaf power index of input gate var.
std::vector< gate_t > topological_order(const std::vector< std::vector< gate_t > > &reversedWires) const
Compute a topological ordering of the circuit.
friend dDNNFTreeDecompositionBuilder
Allowed to construct and populate this d-DNNF.
std::unordered_set< gate_t > vars(gate_t root) const
Return the set of all variable (IN) gates reachable from root.
std::unordered_map< gate_t, double, hash_gate_t > probability_cache
Memoisation cache mapping gates to their probability values.
gate_t getRoot() const
Return the root gate of this d-DNNF.
std::unordered_map< gate_t, std::vector< double > > shapley_delta() const
Compute the δ table used in the Shapley algorithm.
std::hash functor for gate_t.
size_t operator()(gate_t g) const
Compute the hash of a gate identifier.