mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
strict inequalities
This commit is contained in:
@@ -196,6 +196,9 @@ BOOST_AUTO_TEST_CASE(splittable)
|
||||
Expression w = variable("w");
|
||||
solver.addAssertion(x < y);
|
||||
solver.addAssertion(x < y - 2);
|
||||
solver.addAssertion(x >= 0);
|
||||
solver.addAssertion(y >= 0);
|
||||
solver.addAssertion(w >= 0);
|
||||
solver.addAssertion(z + w == 28);
|
||||
|
||||
solver.push();
|
||||
|
||||
+27
-3
@@ -55,12 +55,25 @@ public:
|
||||
{
|
||||
_lhs -= _rhs;
|
||||
_lhs[0] = -_lhs[0];
|
||||
m_solver.addConstraint({move(_lhs), false}, move(_reason));
|
||||
m_solver.addConstraint({move(_lhs), Constraint::LESS_OR_EQUAL}, move(_reason));
|
||||
}
|
||||
|
||||
void addLEConstraint(LinearExpression _lhs, rational _rhs)
|
||||
{
|
||||
addLEConstraint(move(_lhs), constant(_rhs));
|
||||
addLEConstraint(move(_lhs), LinearExpression::constant(move(_rhs)));
|
||||
}
|
||||
|
||||
/// Adds the constraint "_lhs < _rhs".
|
||||
void addLTConstraint(LinearExpression _lhs, LinearExpression _rhs, optional<size_t> _reason = {})
|
||||
{
|
||||
_lhs -= _rhs;
|
||||
_lhs[0] = -_lhs[0];
|
||||
m_solver.addConstraint({move(_lhs), Constraint::LESS_THAN}, move(_reason));
|
||||
}
|
||||
|
||||
void addLTConstraint(LinearExpression _lhs, rational _rhs)
|
||||
{
|
||||
addLTConstraint(move(_lhs), LinearExpression::constant(move(_rhs)));
|
||||
}
|
||||
|
||||
/// Adds the constraint "_lhs = _rhs".
|
||||
@@ -68,7 +81,7 @@ public:
|
||||
{
|
||||
_lhs -= _rhs;
|
||||
_lhs[0] = -_lhs[0];
|
||||
m_solver.addConstraint({move(_lhs), true}, move(_reason));
|
||||
m_solver.addConstraint({move(_lhs), Constraint::EQUAL}, move(_reason));
|
||||
}
|
||||
|
||||
void addLowerBound(string _variable, rational _value)
|
||||
@@ -425,6 +438,17 @@ BOOST_AUTO_TEST_CASE(reasons_joined)
|
||||
infeasible({0, 2, 3});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(less_than)
|
||||
{
|
||||
auto x = variable("x");
|
||||
addLTConstraint(2 * x, 10);
|
||||
feasible({{"x", 0}});
|
||||
addLowerBound("x", 4);
|
||||
feasible({{"x", 4}});
|
||||
addLowerBound("x", 5);
|
||||
infeasible();
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(fuzzer2)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user