Skip to content

Commit

Permalink
improved fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pruemmer committed Mar 20, 2024
1 parent de1608a commit 8791c90
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions src/main/scala/lazabs/horn/symex/ConstraintSimplifier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ trait ConstraintSimplifierUsingConjunctEliminator extends ConstraintSimplifier {

protected def universalElimination(m: ModelElement): Unit = {}

override protected def addDivisibility(f: Conjunction) =
divJudgements = f :: divJudgements

var divJudgements: List[Conjunction] = List()
override protected def addDivisibility(f: Conjunction) = {}

override protected def isEliminationCandidate(t: Term): Boolean =
localSymbols contains t
Expand All @@ -83,30 +80,36 @@ trait ConstraintSimplifierUsingConjunctEliminator extends ConstraintSimplifier {
symex_sf.reducer(Conjunction.TRUE)(constraint)
else constraint

/**
* [[ConjunctEliminator]] does not seem to support formulas with
* disjunctions, so we remove constants appearing in disjuncts.
*/
val elimSymbols : Set[Term] =
localSymbols -- constraint.negatedConjs.constants
val simpConstraint1 : Conjunction = new LocalSymbolEliminator(reducedConstraint,
elimSymbols, symex_sf.order).eliminate(ComputationLogger.NonLogger)

/**
* If there were disjunctions, then try another method of simplification.
*/
if (constraint.negatedConjs.constants.nonEmpty) {
if (constraint.negatedConjs.isEmpty) {
/**
* If the constraint is a conjunction, we can use the
* [[ConjunctEliminator]] class for simplification.
*/
new LocalSymbolEliminator(reducedConstraint,
localSymbols,
symex_sf.order)
.eliminate(ComputationLogger.NonLogger)
} else {
/**
* If there are disjunctions, then try another method of
* simplification.
*/
// quantify local symbols
val sortedLocalSymbols =
symex_sf.order.sort(localSymbols.map(_.asInstanceOf[ConstantTerm]))
val quanF = Conjunction.quantify(ap.terfor.conjunctions.Quantifier.EX,
sortedLocalSymbols,
simpConstraint1, simpConstraint1.order)
sortedLocalSymbols,
constraint, constraint.order)

// try to eliminate the quantified vars
val reducedQuanF : Conjunction =
symex_sf.reducer(Conjunction.TRUE).apply(quanF)

// eliminate any remaining quantifiers by re-introducing local symbols
reducedQuanF.instantiate(sortedLocalSymbols)(reducedQuanF.order)
} else simpConstraint1
assert(sortedLocalSymbols.size >= reducedQuanF.quans.size)

reducedQuanF.instantiate(sortedLocalSymbols take reducedQuanF.quans.size)(
reducedQuanF.order)
}
}
}

0 comments on commit 8791c90

Please sign in to comment.