Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Symex] Only generate counterexample when the user asks for it #67

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/scala/lazabs/horn/HornWrapper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ class SymexHornWrapper(unsimplifiedClauses : Seq[Clause],
HornWrapper.verifySolution(fullSol, unsimplifiedClauses)
fullSol
} else {
// only keep relation symbols that were also part of the orginal problem
// only keep relation symbols that were also part of the original problem
res filterKeys allPredicates(unsimplifiedClauses)
}
}
Expand Down
16 changes: 14 additions & 2 deletions src/main/scala/lazabs/horn/symex/Symex.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import ap.terfor._
import ap.terfor.conjunctions.Conjunction
import ap.terfor.substitutions.ConstantSubst
import ap.theories.{Theory, TheoryCollector}
import lazabs.GlobalParameters
import lazabs.horn.bottomup.{HornClauses, NormClause, RelationSymbol}
import lazabs.horn.bottomup.HornClauses.ConstraintClause
import lazabs.horn.Util.{Dag, DagEmpty, DagNode}
Expand All @@ -56,6 +57,7 @@ abstract class Symex[CC](iClauses: Iterable[CC])(
import Symex._

var printInfo = false

def printInfo(s : String, newLine : Boolean = true) : Unit = {
if (printInfo)
print(s + (if (newLine) "\n" else ""))
Expand Down Expand Up @@ -227,7 +229,12 @@ abstract class Symex[CC](iClauses: Iterable[CC])(
val proverStatus = checkFeasibility(newElectron.constraint)
if (hasContradiction(newElectron, proverStatus)) { // false :- true
unitClauseDB.add(newElectron, (nucleus, electrons))
result = Right(buildCounterExample(newElectron))
if (GlobalParameters.get.needFullCEX || lazabs.GlobalParameters.get.simplifiedCEX) {
// Only generate a counterexample when it is asked for
result = Right(buildCounterExample(newElectron))
} else {
result = Right(DagEmpty)
}
} else if (constraintIsFalse(newElectron, proverStatus)) {
printInfo("")
handleFalseConstraint(nucleus, electrons)
Expand Down Expand Up @@ -277,7 +284,12 @@ abstract class Symex[CC](iClauses: Iterable[CC])(
} else toUnitClause(clause)
unitClauseDB.add(cuc, (clause, Nil))
if (hasContradiction(cuc, checkFeasibility(cuc.constraint))) {
result = Right(buildCounterExample(cuc))
if (GlobalParameters.get.needFullCEX || lazabs.GlobalParameters.get.simplifiedCEX) {
// Only generate a counterexample when it is asked for
result = Right(buildCounterExample(cuc))
} else {
result = Right(DagEmpty)
}
}
}
if (result == null) { // none of the assertions failed, so this is SAT
Expand Down