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

Boolean circuit implementation and evaluation algorithms. More...

#include "BooleanCircuit.h"
#include "Circuit.hpp"
#include <type_traits>
#include <unistd.h>
#include <math.h>
#include <cassert>
#include <string>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <stack>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include "dDNNFTreeDecompositionBuilder.h"
#include "provsql_utils.h"
#include "utils/elog.h"
#include "provsql_error.h"
Include dependency graph for BooleanCircuit.cpp:

Go to the source code of this file.

Functions

static constexpr bool almost_equals (double a, double b)
 Check whether two double values are approximately equal.
 

Detailed Description

Boolean circuit implementation and evaluation algorithms.

Implements the methods declared in BooleanCircuit.h, including:

  • Gate management (addGate, setGate, setInfo, setProb).
  • Probability evaluation algorithms: possible worlds, Monte Carlo, WeightMC, independent evaluation.
  • Knowledge compilation: compilation() (external tools), interpretAsDD() (direct from circuit structure), makeDD() (dispatcher).
  • rewriteMultivaluedGates(): replaces MULVAR/MULIN clusters with standard AND/OR/NOT circuits.
  • Tseytin(): DIMACS/weighted CNF generation for model counters.
  • exportCircuit(): serialisation in the tdkc text format.
  • toString(): human-readable gate description.

In the standalone tdkc build (when TDKC is defined) a lightweight elog() stub replaces the PostgreSQL error-reporting function.

Definition in file BooleanCircuit.cpp.

Function Documentation

◆ almost_equals()

static constexpr bool almost_equals ( double  a,
double  b 
)
staticconstexpr

Check whether two double values are approximately equal.

Parameters
aFirst value.
bSecond value.
Returns
true if a and b differ by less than 10× machine epsilon.

Definition at line 752 of file BooleanCircuit.cpp.

Here is the caller graph for this function: