SMT-RAT
24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
ExpressionPool.cpp
Go to the documentation of this file.
1
/*
2
#include "ExpressionPool.h"
3
4
#include "ExpressionContent.h"
5
#include "simplifier/Simplifier.h"
6
7
namespace smtrat {
8
namespace expression {
9
10
const ExpressionContent* ExpressionPool::add(ExpressionContent* _ec) {
11
std::cout << "Current pool: " << mPool << std::endl;
12
std::cout << "Adding " << *_ec << std::endl;
13
simplifier::Simplifier s;
14
const ExpressionContent* simplified = s(_ec);
15
if (simplified != nullptr) return simplified;
16
auto it = mPool.find(_ec);
17
if (it != mPool.end()) {
18
if (*it != _ec) delete _ec;
19
return *it;
20
}
21
ExpressionContent* res = *mPool.insert(_ec).first;
22
res->id = mNextID++;
23
24
assert(!Expression(_ec).isUnary() || Expression(_ec).getUnary().type != NOT);
25
ExpressionContent* negation = new ExpressionContent(UnaryExpression(NOT, Expression(_ec)));
26
std::cout << "Negation: " << negation << std::endl;
27
assert(mPool.find(negation) == mPool.end());
28
mPool.insert(negation);
29
negation->id = mNextID++;
30
negation->negation = res;
31
res->negation = negation;
32
33
std::cout << "Current pool now: " << mPool << std::endl;
34
35
return res;
36
}
37
38
const ExpressionContent* ExpressionPool::create(carl::Variable::Arg var)
39
{
40
return add(new ExpressionContent(var));
41
}
42
const ExpressionContent* ExpressionPool::create(ITEType _type, Expression&& _if, Expression&& _then, Expression&& _else)
43
{
44
return add(new ExpressionContent(ITEExpression(_type, std::move(_if), std::move(_then), std::move(_else))));
45
}
46
const ExpressionContent* ExpressionPool::create(QuantifierType _type, std::vector<carl::Variable>&& _variables, Expression&& _expression)
47
{
48
return add(new ExpressionContent(QuantifierExpression(_type, std::move(_variables), std::move(_expression))));
49
}
50
const ExpressionContent* ExpressionPool::create(UnaryType _type, Expression&& _expression)
51
{
52
return add(new ExpressionContent(UnaryExpression(_type, std::move(_expression))));
53
}
54
const ExpressionContent* ExpressionPool::create(BinaryType _type, Expression&& _lhs, Expression&& _rhs)
55
{
56
return add(new ExpressionContent(BinaryExpression(_type, std::move(_lhs), std::move(_rhs))));
57
}
58
const ExpressionContent* ExpressionPool::create(NaryType _type, Expressions&& _expressions)
59
{
60
return add(new ExpressionContent(NaryExpression(_type, std::move(_expressions))));
61
}
62
const ExpressionContent* ExpressionPool::create(NaryType _type, const std::initializer_list<Expression>& _expressions)
63
{
64
return add(new ExpressionContent(NaryExpression(_type, _expressions)));
65
}
66
}
67
}
68
*/
smtrat-expressions
ExpressionPool.cpp
Generated by
1.9.1