mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add invariant to the solver results
This commit is contained in:
parent
fa48abf4f1
commit
9a87680d21
@ -87,7 +87,7 @@ void CHCSmtLib2Interface::addRule(Expression const& _expr, std::string const& /*
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pair<CheckResult, CHCSolverInterface::CexGraph> CHCSmtLib2Interface::query(Expression const& _block)
|
tuple<CheckResult, Expression, CHCSolverInterface::CexGraph> CHCSmtLib2Interface::query(Expression const& _block)
|
||||||
{
|
{
|
||||||
string accumulated{};
|
string accumulated{};
|
||||||
swap(m_accumulatedOutput, accumulated);
|
swap(m_accumulatedOutput, accumulated);
|
||||||
@ -118,8 +118,7 @@ pair<CheckResult, CHCSolverInterface::CexGraph> CHCSmtLib2Interface::query(Expre
|
|||||||
else
|
else
|
||||||
result = CheckResult::ERROR;
|
result = CheckResult::ERROR;
|
||||||
|
|
||||||
// TODO collect invariants or counterexamples.
|
return {result, Expression(true), {}};
|
||||||
return {result, {}};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHCSmtLib2Interface::declareVariable(string const& _name, SortPointer const& _sort)
|
void CHCSmtLib2Interface::declareVariable(string const& _name, SortPointer const& _sort)
|
||||||
|
@ -44,7 +44,9 @@ public:
|
|||||||
|
|
||||||
void addRule(Expression const& _expr, std::string const& _name) override;
|
void addRule(Expression const& _expr, std::string const& _name) override;
|
||||||
|
|
||||||
std::pair<CheckResult, CexGraph> query(Expression const& _expr) override;
|
/// Takes a function application _expr and checks for reachability.
|
||||||
|
/// @returns solving result, an invariant, and counterexample graph, if possible.
|
||||||
|
std::tuple<CheckResult, Expression, CexGraph> query(Expression const& _expr) override;
|
||||||
|
|
||||||
void declareVariable(std::string const& _name, SortPointer const& _sort) override;
|
void declareVariable(std::string const& _name, SortPointer const& _sort) override;
|
||||||
|
|
||||||
|
@ -54,8 +54,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Takes a function application _expr and checks for reachability.
|
/// Takes a function application _expr and checks for reachability.
|
||||||
/// @returns solving result and a counterexample graph, if possible.
|
/// @returns solving result, an invariant, and counterexample graph, if possible.
|
||||||
virtual std::pair<CheckResult, CexGraph> query(
|
virtual std::tuple<CheckResult, Expression, CexGraph> query(
|
||||||
Expression const& _expr
|
Expression const& _expr
|
||||||
) = 0;
|
) = 0;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ void Z3CHCInterface::addRule(Expression const& _expr, string const& _name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pair<CheckResult, CHCSolverInterface::CexGraph> Z3CHCInterface::query(Expression const& _expr)
|
tuple<CheckResult, Expression, CHCSolverInterface::CexGraph> Z3CHCInterface::query(Expression const& _expr)
|
||||||
{
|
{
|
||||||
CheckResult result;
|
CheckResult result;
|
||||||
try
|
try
|
||||||
@ -93,15 +93,15 @@ pair<CheckResult, CHCSolverInterface::CexGraph> Z3CHCInterface::query(Expression
|
|||||||
if (m_version >= tuple(4, 8, 8, 0))
|
if (m_version >= tuple(4, 8, 8, 0))
|
||||||
{
|
{
|
||||||
auto proof = m_solver.get_answer();
|
auto proof = m_solver.get_answer();
|
||||||
return {result, cexGraph(proof)};
|
return {result, Expression(true), cexGraph(proof)};
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case z3::check_result::unsat:
|
case z3::check_result::unsat:
|
||||||
{
|
{
|
||||||
result = CheckResult::UNSATISFIABLE;
|
result = CheckResult::UNSATISFIABLE;
|
||||||
// TODO retrieve invariants.
|
auto invariants = m_z3Interface->fromZ3Expr(m_solver.get_answer());
|
||||||
break;
|
return {result, move(invariants), {}};
|
||||||
}
|
}
|
||||||
case z3::check_result::unknown:
|
case z3::check_result::unknown:
|
||||||
{
|
{
|
||||||
@ -125,7 +125,7 @@ pair<CheckResult, CHCSolverInterface::CexGraph> Z3CHCInterface::query(Expression
|
|||||||
result = CheckResult::ERROR;
|
result = CheckResult::ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {result, {}};
|
return {result, Expression(true), {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Z3CHCInterface::setSpacerOptions(bool _preProcessing)
|
void Z3CHCInterface::setSpacerOptions(bool _preProcessing)
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
|
|
||||||
void addRule(Expression const& _expr, std::string const& _name) override;
|
void addRule(Expression const& _expr, std::string const& _name) override;
|
||||||
|
|
||||||
std::pair<CheckResult, CexGraph> query(Expression const& _expr) override;
|
std::tuple<CheckResult, Expression, CexGraph> query(Expression const& _expr) override;
|
||||||
|
|
||||||
Z3Interface* z3Interface() const { return m_z3Interface.get(); }
|
Z3Interface* z3Interface() const { return m_z3Interface.get(); }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user