Skip to content

Commit

Permalink
print lemmas and instantiations as implications
Browse files Browse the repository at this point in the history
  • Loading branch information
HanielB committed Mar 22, 2024
1 parent f7740c9 commit d2acf40
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/parser/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2137,13 +2137,18 @@ void GetHintsCommand::printResult(cvc5::Solver* solver, std::ostream& out) const
// - lemmas
// - instantiation
// - (rewrite rule + instances)*
bool first = true;
for (size_t i = 0, size = d_result.size(); i < size; ++i)
{
out << (i == 0 ? "Preprocess:"
: i == 1 ? "Theory lemmas:"
: i == 2 ? "Instantiations:"
: "rewrites:")
out << (i == 0
? "Preprocess:"
: i == 1 ? "\nTheory lemmas:"
: i == 2 ? "\nInstantiations:"
: (first ? "\nRewrites (rules and their usages "
"in quantifier-free terms):"
: "Rewrites:"))
<< "\n";
first = i <= 2;
for (const auto& l : d_result[i])
{
out << "\t" << l << "\n";
Expand Down
26 changes: 25 additions & 1 deletion src/smt/solver_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1790,6 +1790,30 @@ std::vector<Node> SolverEngine::getHints()
r = SkolemManager::getOriginalForm(r);
Trace("hints") << "\t" << r << "\n";
Trace("hints-proofs") << "\t\t" << *p.get() << "\n";
// r will be a disjunction. If there is a positive atom and all others
// negatives, turn it into an implication
if (r.getKind() == Kind::OR)
{
std::vector<Node> negLits;
std::copy_if(r.begin(), r.end(), std::back_inserter(negLits), [](Node n) {
return n.getKind() == Kind::NOT;
});
if (negLits.size() == r.getNumChildren() - 1)
{
Node conc;
for (const Node& rc : r)
{
if (std::find(negLits.begin(), negLits.end(), rc) == negLits.end())
{
conc = rc;
break;
}
}
Assert(!conc.isNull());
currResults.push_back(nm->mkNode(Kind::IMPLIES, nm->mkAnd(negLits), conc));
continue;
}
}
currResults.push_back(r);
}
result.push_back(nm->mkNode(Kind::SEXPR, currResults));
Expand All @@ -1806,7 +1830,7 @@ std::vector<Node> SolverEngine::getHints()
r = SkolemManager::getOriginalForm(r);
Trace("hints") << "\t" << r << "\n";
Trace("hints-proofs") << "\t\t" << *p.get() << "\n";
currResults.push_back(r);
currResults.push_back(nm->mkNode(Kind::IMPLIES, r[0][0], r[1]));
}
}
result.push_back(nm->mkNode(Kind::SEXPR, currResults));
Expand Down

0 comments on commit d2acf40

Please sign in to comment.