6#include "PredicateAbstractor.h"
12#include "dlinear/symbolic/LinearFormulaFlattener.h"
13#include "dlinear/util/Stats.h"
14#include "dlinear/util/Timer.h"
28Formula PredicateAbstractor::operator()(
const std::vector<Formula> &formulas) {
return Process(formulas); }
32 const bool is_negated = is_negation(flattened_f);
33 const Formula &unary_f = is_negated ? get_operand(flattened_f) : flattened_f;
39 return FormulaVisitor::VisitFormula(flattened_f);
49 const bool is_negated = is_negation(flattened_f);
50 const Formula &unary_f = is_negated ? get_operand(flattened_f) : flattened_f;
58 return is_negated ? !Formula{bvar} : Formula{bvar};
60 return is_negated ? !Formula{it->second} : Formula{it->second};
63Formula PredicateAbstractor::VisitEqualTo(
const Formula &f)
const {
return VisitAtomic(f); }
64Formula PredicateAbstractor::VisitNotEqualTo(
const Formula &f)
const {
return VisitAtomic(f); }
65Formula PredicateAbstractor::VisitLessThan(
const Formula &f)
const {
return VisitAtomic(f); }
66Formula PredicateAbstractor::VisitLessThanOrEqualTo(
const Formula &f)
const {
return VisitAtomic(f); }
67Formula PredicateAbstractor::VisitGreaterThan(
const Formula &f)
const {
return VisitAtomic(f); }
68Formula PredicateAbstractor::VisitGreaterThanOrEqualTo(
const Formula &f)
const {
return VisitAtomic(f); }
70Formula PredicateAbstractor::VisitNegation(
const Formula &f)
const {
return !
VisitFormula(get_operand(f)); }
71Formula PredicateAbstractor::VisitForall(
const Formula &f)
const {
return VisitAtomic(f); }
72Formula PredicateAbstractor::VisitConjunction(
const Formula &f)
const {
73 const std::set<Formula> operands{
74 map(get_operands(f), [
this](
const Formula &formula) {
return VisitFormula(formula); })};
77Formula PredicateAbstractor::VisitDisjunction(
const Formula &f)
const {
78 const std::set<Formula> operands{
79 map(get_operands(f), [
this](
const Formula &formula) {
return VisitFormula(formula); })};
void Increase()
Increase the iteration counter by one.
Formula Process(const Formula &f)
Convert a first-order logic formula f into a Boolean formula by predicate abstraction.
Formula VisitFormula(const Formula &f) const override
Visit an atomic formula.
std::unordered_map< Formula, Variable > formula_to_var_map_
Map from previously converted formula to Boolean variable.
std::unordered_map< Variable, Formula > var_to_formula_map_
Map from Boolean variable to previously converted formula.
LinearFormulaFlattener flattener_
Linear formula flattener.
Timer & m_timer()
Get read-write access to the timer of the stats.
bool enabled() const
Check whether the stats is enabled.
The TimeGuard wraps a timer object and pauses it when the guard object is destructed.
@ BOOLEAN
A BOOLEAN variable takes a bool value.
Global namespace for the dlinear library.
Formula make_conjunction(const std::vector< Formula > &formulas)
Make conjunction of formulas.
std::set< Formula > map(const std::set< Formula > &formulas, const std::function< Formula(const Formula &)> &func)
Given formulas = {fâ, ..., fâ} and a func : Formula â Formula, map(formulas, func) returns a set {fun...
Formula make_disjunction(const std::vector< Formula > &formulas)
Make disjunction of formulas.