mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Multi-argument and and or.
This commit is contained in:
parent
f940e1f9e7
commit
91f32a7beb
@ -113,6 +113,7 @@ void BooleanLPSolver::addAssertion(Expression const& _expr)
|
|||||||
}
|
}
|
||||||
else if (_expr.name == "=")
|
else if (_expr.name == "=")
|
||||||
{
|
{
|
||||||
|
solAssert(_expr.arguments.size() == 2);
|
||||||
solAssert(_expr.arguments.at(0).sort->kind == _expr.arguments.at(1).sort->kind);
|
solAssert(_expr.arguments.at(0).sort->kind == _expr.arguments.at(1).sort->kind);
|
||||||
if (_expr.arguments.at(0).sort->kind == Kind::Bool)
|
if (_expr.arguments.at(0).sort->kind == Kind::Bool)
|
||||||
{
|
{
|
||||||
@ -150,28 +151,19 @@ void BooleanLPSolver::addAssertion(Expression const& _expr)
|
|||||||
solAssert(false);
|
solAssert(false);
|
||||||
}
|
}
|
||||||
else if (_expr.name == "and")
|
else if (_expr.name == "and")
|
||||||
{
|
for (auto const& arg: _expr.arguments)
|
||||||
addAssertion(_expr.arguments.at(0));
|
addAssertion(arg);
|
||||||
addAssertion(_expr.arguments.at(1));
|
|
||||||
}
|
|
||||||
else if (_expr.name == "or")
|
else if (_expr.name == "or")
|
||||||
{
|
{
|
||||||
// We could try to parse a full clause here.
|
vector<Literal> literals;
|
||||||
Literal left = parseLiteralOrReturnEqualBoolean(_expr.arguments.at(0));
|
// We could try to parse a full clause here instead.
|
||||||
Literal right = parseLiteralOrReturnEqualBoolean(_expr.arguments.at(1));
|
for (auto const& arg: _expr.arguments)
|
||||||
/*
|
literals.emplace_back(parseLiteralOrReturnEqualBoolean(arg));
|
||||||
if (isConditionalConstraint(left.variable) && isConditionalConstraint(right.variable))
|
state().clauses.emplace_back(Clause{move(literals)});
|
||||||
{
|
|
||||||
// We cannot have more than one constraint per clause.
|
|
||||||
// TODO Why?
|
|
||||||
right = *parseLiteral(declareInternalVariable(true));
|
|
||||||
addBooleanEquality(right, _expr.arguments.at(1));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
state().clauses.emplace_back(Clause{vector<Literal>{left, right}});
|
|
||||||
}
|
}
|
||||||
else if (_expr.name == "not")
|
else if (_expr.name == "not")
|
||||||
{
|
{
|
||||||
|
solAssert(_expr.arguments.size() == 1);
|
||||||
// TODO can we still try to add a fixed constraint?
|
// TODO can we still try to add a fixed constraint?
|
||||||
Literal l = negate(parseLiteralOrReturnEqualBoolean(_expr.arguments.at(0)));
|
Literal l = negate(parseLiteralOrReturnEqualBoolean(_expr.arguments.at(0)));
|
||||||
state().clauses.emplace_back(Clause{vector<Literal>{l}});
|
state().clauses.emplace_back(Clause{vector<Literal>{l}});
|
||||||
|
Loading…
Reference in New Issue
Block a user