Skip to content

Commit

Permalink
Merge pull request viperproject#771 from viperproject/meilers_let_tri…
Browse files Browse the repository at this point in the history
…ggers

Recording possible triggers from inside let-expressions properly
  • Loading branch information
marcoeilers authored Nov 10, 2023
2 parents da2f36f + 045d6f5 commit 829142e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/scala/rules/Evaluator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,17 @@ object evaluator extends EvaluationRules {
val t = v1.decider.appliedFresh("letvar", v1.symbolConverter.toSort(x.typ), s1.relevantQuantifiedVariables)
v1.decider.assumeDefinition(t === t0)
val newFuncRec = s1.functionRecorder.recordFreshSnapshot(t.applicable.asInstanceOf[Function])
eval(s1.copy(g = s1.g + (x.localVar, t0), functionRecorder = newFuncRec), e1, pve, v1)(Q)
val possibleTriggersBefore = if (s1.recordPossibleTriggers) s1.possibleTriggers else Map.empty
eval(s1.copy(g = s1.g + (x.localVar, t0), functionRecorder = newFuncRec), e1, pve, v1)((s2, t2, v2) => {
val newPossibleTriggers = if (s2.recordPossibleTriggers) {
val addedTriggers = s2.possibleTriggers -- possibleTriggersBefore.keys
val addedTriggersReplaced = addedTriggers.map(at => at._1.replace(x.localVar, e0) -> at._2)
s2.possibleTriggers ++ addedTriggersReplaced
} else {
s2.possibleTriggers
}
Q(s2.copy(possibleTriggers = newPossibleTriggers), t2, v2)
})
})

/* Strict evaluation of AND */
Expand Down Expand Up @@ -1130,7 +1140,7 @@ object evaluator extends EvaluationRules {
!possibleTriggersBefore.contains(t._1) || possibleTriggersBefore(t._1) != t._2)

def wrapInOld(e: ast.Exp) = {
if (label == "old") {
if (label == Verifier.PRE_STATE_LABEL) {
ast.Old(e)(e.pos, e.info, e.errT)
} else {
ast.LabelledOld(e, label)(e.pos, e.info, e.errT)
Expand Down

0 comments on commit 829142e

Please sign in to comment.