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

Cleans up and addresses some comments in Symex #63

Merged
merged 1 commit into from
Sep 16, 2024
Merged
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
41 changes: 2 additions & 39 deletions src/main/scala/lazabs/horn/symex/Symex.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,17 @@ abstract class Symex[CC](iClauses: Iterable[CC])(
if (theories.nonEmpty)
printInfo("Theories: " + (theories mkString ", ") + "\n")

val preds: Set[Predicate] =
val preds: Seq[Predicate] =
(for (c <- iClauses.iterator;
lit <- (Iterator single c.head) ++ c.body.iterator;
p = lit.predicate)
yield p).toSet
yield p).toSeq.distinct

// We keep a prover initialized with all the symbols running, which we will
// use to check the satisfiability of constraints.
// Note that the prover must be manually shut down for clean-up.
implicit val prover: SimpleAPI = SimpleAPI.spawn
prover.addTheories(theories)

// TODO: keeping preds as a set is problematic, it will introduced
// non-determinism. Turn the preds field into a Seq[Predicate]?
prover.addRelations(preds)

// Keeps track of all the terms and adds new symbols to the prover
Expand All @@ -108,12 +105,6 @@ abstract class Symex[CC](iClauses: Iterable[CC])(
).toSeq

val normClauseToCC: Map[NormClause, CC] = normClauses.toMap
//
//private val originalLocalSymbols = new MHashSet[ConstantTerm]
//private val rewrittenSymbols = new UnionFind[ConstantTerm]
//
//for ((normClause, _) <- normClauses)
// originalLocalSymbols ++= normClause.localSymbols

val clausesWithRelationInBody: Map[RelationSymbol, Seq[NormClause]] =
(for (rel <- relationSymbols.values) yield {
Expand All @@ -126,15 +117,6 @@ abstract class Symex[CC](iClauses: Iterable[CC])(
(rel, normClauses.filter(_._1.head._1 == rel).map(_._1))
}).toMap

// TODO: this block will not have any effect?
for (pred <- preds) {

normClauses.filter(
clause =>
clause._1.head._1.pred == pred ||
clause._1.body.exists(_._1.pred == pred))
}

val predicatesAndMaxOccurrences: Map[Predicate, Int] = {
val maxOccs = new MHashMap[Predicate, Int]
for (pred <- preds)
Expand Down Expand Up @@ -347,7 +329,6 @@ abstract class Symex[CC](iClauses: Iterable[CC])(

val backtranslatedPredSolution =
ConstantSubstVisitor(prover.asIFormula(predSolution), argSubst)
//ConstantSubst(predSolution, argSubst ++ constSubst)

(pred, backtranslatedPredSolution)
}
Expand Down Expand Up @@ -387,25 +368,8 @@ abstract class Symex[CC](iClauses: Iterable[CC])(
}
}
val subDags: Seq[Dag[(IAtom, CC)]] = {
//if (electrons.length == childrenAtoms.length) {
for ((electron, atom) <- electrons zip childrenAtoms)
yield computeAtoms(atom, electron)
//} else if (electrons.isEmpty) {
// // this might happen in clauses with literals in body that were
// // not derived, e.g., a single assertion clause
// //for ((childAtom, lit) <- childrenAtoms zip nucleus.body) yield {
// // // create a dag with artificial clauses to present the atoms in the cex
// // DagNode(
// // (childAtom,
// // normClauseToCC(NormClause(Conjunction.TRUE, Nil, lit))),
// // Nil,
// // DagEmpty)
// //}
//} else {
// throw new UnsupportedOperationException(
// "Cannot compute the" +
// "counterexample using: " + headAtom + " and\n" + cuc)
//}
}

val nextDag: Dag[(IAtom, CC)] =
Expand Down Expand Up @@ -524,5 +488,4 @@ abstract class Symex[CC](iClauses: Iterable[CC])(
unitClause
}
}

}
Loading