mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
temp
This commit is contained in:
parent
22aba74176
commit
a3f999a13e
@ -207,7 +207,10 @@ pair<CheckResult, vector<string>> BooleanLPSolver::check(vector<Expression> cons
|
|||||||
cout << "--------------" << endl;
|
cout << "--------------" << endl;
|
||||||
|
|
||||||
if (state().infeasible)
|
if (state().infeasible)
|
||||||
|
{
|
||||||
|
cout << "----->>>>> unsatisfiable" << endl;
|
||||||
return make_pair(CheckResult::UNSATISFIABLE, vector<string>{});
|
return make_pair(CheckResult::UNSATISFIABLE, vector<string>{});
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> booleanVariables;
|
std::vector<std::string> booleanVariables;
|
||||||
std::vector<Clause> clauses = state().clauses;
|
std::vector<Clause> clauses = state().clauses;
|
||||||
@ -227,7 +230,10 @@ pair<CheckResult, vector<string>> BooleanLPSolver::check(vector<Expression> cons
|
|||||||
//cout << "Boolean variables:" << joinHumanReadable(booleanVariables) << endl;
|
//cout << "Boolean variables:" << joinHumanReadable(booleanVariables) << endl;
|
||||||
//cout << "Running LP solver on fixed constraints." << endl;
|
//cout << "Running LP solver on fixed constraints." << endl;
|
||||||
if (m_lpSolver.check(lpState).first == LPResult::Infeasible)
|
if (m_lpSolver.check(lpState).first == LPResult::Infeasible)
|
||||||
|
{
|
||||||
|
cout << "----->>>>> unsatisfiable" << endl;
|
||||||
return {CheckResult::UNSATISFIABLE, {}};
|
return {CheckResult::UNSATISFIABLE, {}};
|
||||||
|
}
|
||||||
|
|
||||||
auto theorySolver = [&](map<size_t, bool> const& _booleanAssignment) -> optional<Clause>
|
auto theorySolver = [&](map<size_t, bool> const& _booleanAssignment) -> optional<Clause>
|
||||||
{
|
{
|
||||||
@ -263,12 +269,12 @@ pair<CheckResult, vector<string>> BooleanLPSolver::check(vector<Expression> cons
|
|||||||
auto optionalModel = CDCL{move(booleanVariables), clauses, theorySolver}.solve();
|
auto optionalModel = CDCL{move(booleanVariables), clauses, theorySolver}.solve();
|
||||||
if (!optionalModel)
|
if (!optionalModel)
|
||||||
{
|
{
|
||||||
//cout << "==============> CDCL final result: unsatisfiable." << endl;
|
cout << "==============> CDCL final result: unsatisfiable." << endl;
|
||||||
return {CheckResult::UNSATISFIABLE, {}};
|
return {CheckResult::UNSATISFIABLE, {}};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//cout << "==============> CDCL final result: SATisfiable / UNKNOWN." << endl;
|
cout << "==============> CDCL final result: SATisfiable / UNKNOWN." << endl;
|
||||||
// TODO should be "unknown" later on
|
// TODO should be "unknown" later on
|
||||||
//return {CheckResult::SATISFIABLE, {}};
|
//return {CheckResult::SATISFIABLE, {}};
|
||||||
return {CheckResult::UNKNOWN, {}};
|
return {CheckResult::UNKNOWN, {}};
|
||||||
|
@ -69,8 +69,8 @@ optional<CDCL::Model> CDCL::solve()
|
|||||||
cancelUntil(backtrackLevel);
|
cancelUntil(backtrackLevel);
|
||||||
solAssert(!learntClause.empty());
|
solAssert(!learntClause.empty());
|
||||||
solAssert(!isAssigned(learntClause.front()));
|
solAssert(!isAssigned(learntClause.front()));
|
||||||
for (size_t i = 1; i < learntClause.size(); i++)
|
// for (size_t i = 1; i < learntClause.size(); i++)
|
||||||
solAssert(isAssignedFalse(learntClause.at(i)));
|
// solAssert(value(learntClause[i]) == TriState{false});
|
||||||
|
|
||||||
addClause(move(learntClause));
|
addClause(move(learntClause));
|
||||||
enqueue(m_clauses.back()->front(), &(*m_clauses.back()));
|
enqueue(m_clauses.back()->front(), &(*m_clauses.back()));
|
||||||
|
@ -85,6 +85,7 @@ void ReasoningBasedSimplifier::operator()(If& _if)
|
|||||||
{
|
{
|
||||||
cout << "Checking if condition can be true" << endl;
|
cout << "Checking if condition can be true" << endl;
|
||||||
m_solver->push();
|
m_solver->push();
|
||||||
|
// TODO change this to >= 1 for simplicity?
|
||||||
m_solver->addAssertion(condition != constantValue(0));
|
m_solver->addAssertion(condition != constantValue(0));
|
||||||
cout << " running check" << endl;
|
cout << " running check" << endl;
|
||||||
CheckResult result2 = m_solver->check({}).first;
|
CheckResult result2 = m_solver->check({}).first;
|
||||||
@ -99,6 +100,7 @@ void ReasoningBasedSimplifier::operator()(If& _if)
|
|||||||
// Nothing left to be done.
|
// Nothing left to be done.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
cout << " unknown :(" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_solver->push();
|
m_solver->push();
|
||||||
|
@ -344,6 +344,14 @@ BOOST_AUTO_TEST_CASE(pure_boolean)
|
|||||||
infeasible();
|
infeasible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(more_test)
|
||||||
|
{
|
||||||
|
Expression x = variable("x");
|
||||||
|
solver.addAssertion(x == 0);
|
||||||
|
solver.addAssertion(x != 0);
|
||||||
|
infeasible();
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user