Skip to content

Commit

Permalink
Merge pull request #712 from viperproject/meilers_simplifier_equality
Browse files Browse the repository at this point in the history
Disable simplification of equalities
  • Loading branch information
marcoeilers authored Jun 30, 2023
2 parents 0e92e92 + 11fc379 commit 86d3ab9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/scala/viper/silver/ast/utility/Simplifier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ object Simplifier {
FalseLit()(root.pos, root.info)
case Implies(TrueLit(), consequent) => consequent

case root @ EqCmp(left, right) if left == right => TrueLit()(root.pos, root.info)
// ME: Disabled since it is not equivalent in case the expression is not well-defined.
// TODO: Consider checking if Expressions.proofObligations(left) is empty (requires adding the program as parameter).
// case root @ EqCmp(left, right) if left == right => TrueLit()(root.pos, root.info)
case root @ EqCmp(BoolLit(left), BoolLit(right)) =>
BoolLit(left == right)(root.pos, root.info)
case root @ EqCmp(FalseLit(), right) => Not(right)(root.pos, root.info)
Expand Down
6 changes: 6 additions & 0 deletions src/test/scala/SimplifierTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,11 @@ class SimplifierTests extends AnyFunSuite with Matchers {
simplify(Mod(-3, -8)()) should be (5: IntLit)
}

test("equality") {
val seqAcc = SeqIndex(EmptySeq(Int)(), 0: IntLit)()
// Do not simplify away definedness issues.
simplify(EqCmp(seqAcc, seqAcc)()) should be(EqCmp(seqAcc, seqAcc)())
}

implicit def int2IntLit(i: Int): IntLit = IntLit(i)()
}

0 comments on commit 86d3ab9

Please sign in to comment.