Skip to content

Commit

Permalink
Fixed order of solver add()
Browse files Browse the repository at this point in the history
  • Loading branch information
leventeBajczi committed Feb 7, 2024
1 parent af0fe24 commit b87b5f5
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class BoundedChecker<S : ExprState, A : StmtAction> @JvmOverloads constructor(
bmcSolver.push()
bmcSolver.add(unfoldedInitExpr)
bmcSolver.add(exprs)
bmcSolver.add(Not(unfoldedPropExpr(indices.last())))

if (lfPathOnly()) { // indices contains currIndex as last()
for (indexing in indices) {
Expand All @@ -106,8 +105,16 @@ class BoundedChecker<S : ExprState, A : StmtAction> @JvmOverloads constructor(
bmcSolver.add(Not(allVarsSame))
}
}

if (bmcSolver.check().isUnsat) {
bmcSolver.pop()
logger.write(Logger.Level.MAINSTEP, "Safety proven in BMC step\n")
return SafetyResult.safe<S, A>()
}
}

bmcSolver.add(Not(unfoldedPropExpr(indices.last())))

val ret = if (bmcSolver.check().isSat) {
val trace = getTrace(bmcSolver.model)
logger.write(Logger.Level.MAINSTEP, "CeX found in BMC step (length ${trace.length()})\n")
Expand Down Expand Up @@ -151,6 +158,27 @@ class BoundedChecker<S : ExprState, A : StmtAction> @JvmOverloads constructor(
itpSolver.add(a, unfoldedInitExpr)
itpSolver.add(a, exprs[0])
itpSolver.add(b, exprs.subList(1, exprs.size))

if (lfPathOnly()) { // indices contains currIndex as last()
itpSolver.push()
for (indexing in indices) {
if (indexing != indices.last()) {
val allVarsSame = And(vars.map {
Eq(PathUtils.unfold(it.ref, indexing), PathUtils.unfold(it.ref, indices.last()))
})
itpSolver.add(a, Not(allVarsSame))
}
}

if (itpSolver.check().isUnsat) {
itpSolver.pop()
itpSolver.pop()
logger.write(Logger.Level.MAINSTEP, "Safety proven in IMC/BMC step\n")
return SafetyResult.safe()
}
itpSolver.pop()
}

itpSolver.add(b, Not(unfoldedPropExpr(indices.last())))

val status = itpSolver.check()
Expand Down

0 comments on commit b87b5f5

Please sign in to comment.