Skip to content

Commit 802460d

Browse files
authored
Add proof elaboration for MACRO_BOOL_BV_INVERT_SOLVE (cvc5#11701)
1 parent 8288af5 commit 802460d

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

src/rewriter/basic_rewrite_rcons.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ void BasicRewriteRCons::ensureProofForTheoryRewrite(CDProof* cdp,
195195
handledMacro = true;
196196
}
197197
break;
198+
case ProofRewriteRule::MACRO_BOOL_BV_INVERT_SOLVE:
199+
if (ensureProofMacroBoolBvInvertSolve(cdp, eq))
200+
{
201+
handledMacro = true;
202+
}
203+
break;
198204
case ProofRewriteRule::MACRO_ARITH_INT_EQ_CONFLICT:
199205
case ProofRewriteRule::MACRO_ARITH_INT_GEQ_TIGHTEN:
200206
if (ensureProofMacroArithIntRelation(cdp, eq))
@@ -370,6 +376,22 @@ bool BasicRewriteRCons::ensureProofMacroBoolNnfNorm(CDProof* cdp,
370376
return true;
371377
}
372378

379+
bool BasicRewriteRCons::ensureProofMacroBoolBvInvertSolve(CDProof* cdp,
380+
const Node& eq)
381+
{
382+
Trace("brc-macro") << "Expand Bool BV invert solve " << eq[0]
383+
<< " == " << eq[1] << std::endl;
384+
Assert(eq[0].getKind() == Kind::EQUAL);
385+
Assert(eq[0][0].getKind() == Kind::EQUAL
386+
&& eq[0][1].getKind() == Kind::EQUAL);
387+
std::unordered_set<Kind> disallowedKinds;
388+
theory::booleans::TheoryBoolRewriter::getBvInvertSolve(
389+
nodeManager(), eq[0][0], eq[0][1][0], disallowedKinds, cdp);
390+
// finish proof
391+
cdp->addStep(eq, ProofRule::TRUE_INTRO, {eq[0]}, {});
392+
return true;
393+
}
394+
373395
bool BasicRewriteRCons::ensureProofMacroArithIntRelation(CDProof* cdp,
374396
const Node& eq)
375397
{

src/rewriter/basic_rewrite_rcons.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ class BasicRewriteRCons : protected EnvObj
130130
* @return true if added a closed proof of eq to cdp.
131131
*/
132132
bool ensureProofMacroBoolNnfNorm(CDProof* cdp, const Node& eq);
133+
/**
134+
* Elaborate a rewrite eq that was proven by
135+
* ProofRewriteRule::MACRO_BOOL_BV_INVERT_SOLVE.
136+
*
137+
* @param cdp The proof to add to.
138+
* @param eq The rewrite proven by
139+
* ProofRewriteRule::MACRO_BOOL_BV_INVERT_SOLVE.
140+
* @return true if added a closed proof of eq to cdp.
141+
*/
142+
bool ensureProofMacroBoolBvInvertSolve(CDProof* cdp, const Node& eq);
133143
/**
134144
* Elaborate a rewrite eq that was proven by
135145
* ProofRewriteRule::MACRO_ARITH_INT_EQ_CONFLICT or

src/theory/booleans/theory_bool_rewriter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ Node TheoryBoolRewriter::getBvInvertSolve(
316316
{
317317
quantifiers::BvInverter binv;
318318
// solve for the variable on this path using the inverter
319-
std::vector<unsigned> path;
319+
std::vector<uint32_t> path;
320320
Node slit = binv.getPathToPv(lit, var, path);
321321
// check if the path had a kind that does not preserve equivalence of the
322322
// overall literal
@@ -331,7 +331,7 @@ Node TheoryBoolRewriter::getBvInvertSolve(
331331
slit = Node::null();
332332
break;
333333
}
334-
unsigned p = path[npath - i - 1];
334+
uint32_t p = path[npath - i - 1];
335335
curr = curr[p];
336336
}
337337
Assert(slit.isNull() || curr == var);
@@ -346,7 +346,7 @@ Node TheoryBoolRewriter::getBvInvertSolve(
346346
Node curr = lit;
347347
for (size_t i = 0, npath = path.size(); i < npath; i++)
348348
{
349-
unsigned p = path[npath - i - 1];
349+
uint32_t p = path[npath - i - 1];
350350
curr = curr[p];
351351
ts.push_back(curr);
352352
}

0 commit comments

Comments
 (0)