Skip to content

Commit c4350bd

Browse files
authored
Merge pull request #852 from viperproject/meilers_record_merge_var_constraints
Recording constraints for newly-introduced variables during state consolidation
2 parents a5bd224 + 8851a19 commit c4350bd

5 files changed

Lines changed: 17 additions & 17 deletions

File tree

src/main/scala/rules/Evaluator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ object evaluator extends EvaluationRules {
185185
* term returned by eval, mark as constrainable on client-side (e.g. in consumer).
186186
*/
187187
val s1 =
188-
s.copy(functionRecorder = s.functionRecorder.recordArp(tVar, tConstraints))
188+
s.copy(functionRecorder = s.functionRecorder.recordConstrainedVar(tVar, tConstraints))
189189
.setConstrainable(Seq(tVar), true)
190190
Q(s1, tVar, v)
191191

src/main/scala/rules/MoreCompleteExhaleSupporter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ object moreCompleteExhaleSupporter extends SymbolicExecutionRules {
365365
)
366366

367367
v.decider.assume(constraint)
368-
newFr = newFr.recordArp(permTaken, constraint)
368+
newFr = newFr.recordConstrainedVar(permTaken, constraint)
369369

370370
ch.withPerm(PermMinus(ch.perm, permTaken))
371371
})

src/main/scala/rules/StateConsolidator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class DefaultStateConsolidator(protected val config: Config) extends StateConsol
216216
* to use t1 or t2 and constrain it.
217217
*/
218218
val t3 = v.decider.fresh(t1.sort)
219-
(fr.recordFreshSnapshot(t3), t3, And(Implies(b1, t3 === t1), Implies(b2, t3 === t2)))
219+
(fr.recordConstrainedVar(t3, And(Implies(b1, t3 === t1), Implies(b2, t3 === t2))), t3, And(Implies(b1, t3 === t1), Implies(b2, t3 === t2)))
220220
}
221221
}
222222

src/main/scala/supporters/functions/FunctionData.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ class FunctionData(val programFunction: ast.Function,
9393
private[functions] var fappToSnap: Map[ast.FuncApp, Term] = Map.empty
9494
private[this] var freshFvfsAndDomains: InsertionOrderedSet[SnapshotMapDefinition] = InsertionOrderedSet.empty
9595
private[this] var freshFieldInvs: InsertionOrderedSet[InverseFunctions] = InsertionOrderedSet.empty
96-
private[this] var freshArps: InsertionOrderedSet[(Var, Term)] = InsertionOrderedSet.empty
96+
private[this] var freshConstrainedVars: InsertionOrderedSet[(Var, Term)] = InsertionOrderedSet.empty
9797
private[this] var freshConstraints: InsertionOrderedSet[Term] = InsertionOrderedSet.empty
9898
private[this] var freshSnapshots: InsertionOrderedSet[Function] = InsertionOrderedSet.empty
9999
private[this] var freshPathSymbols: InsertionOrderedSet[Function] = InsertionOrderedSet.empty
100100
private[this] var freshMacros: InsertionOrderedSet[MacroDecl] = InsertionOrderedSet.empty
101101
private[this] var freshSymbolsAcrossAllPhases: InsertionOrderedSet[Decl] = InsertionOrderedSet.empty
102102

103103
private[functions] def getFreshFieldInvs: InsertionOrderedSet[InverseFunctions] = freshFieldInvs
104-
private[functions] def getFreshArps: InsertionOrderedSet[Var] = freshArps.map(_._1)
104+
private[functions] def getFreshConstrainedVars: InsertionOrderedSet[Var] = freshConstrainedVars.map(_._1)
105105
private[functions] def getFreshSymbolsAcrossAllPhases: InsertionOrderedSet[Decl] = freshSymbolsAcrossAllPhases
106106

107107
private[functions] def advancePhase(recorders: Seq[FunctionRecorder]): Unit = {
@@ -117,14 +117,14 @@ class FunctionData(val programFunction: ast.Function,
117117
fappToSnap = mergedFunctionRecorder.fappToSnap
118118
freshFvfsAndDomains = mergedFunctionRecorder.freshFvfsAndDomains
119119
freshFieldInvs = mergedFunctionRecorder.freshFieldInvs
120-
freshArps = mergedFunctionRecorder.freshArps
120+
freshConstrainedVars = mergedFunctionRecorder.freshConstrainedVars
121121
freshConstraints = mergedFunctionRecorder.freshConstraints
122122
freshSnapshots = mergedFunctionRecorder.freshSnapshots
123123
freshPathSymbols = mergedFunctionRecorder.freshPathSymbols
124124
freshMacros = mergedFunctionRecorder.freshMacros
125125

126126
freshSymbolsAcrossAllPhases ++= freshPathSymbols map FunctionDecl
127-
freshSymbolsAcrossAllPhases ++= freshArps.map(pair => FunctionDecl(pair._1))
127+
freshSymbolsAcrossAllPhases ++= freshConstrainedVars.map(pair => FunctionDecl(pair._1))
128128
freshSymbolsAcrossAllPhases ++= freshSnapshots map FunctionDecl
129129
freshSymbolsAcrossAllPhases ++= freshFieldInvs.flatMap(i => (i.inverses ++ i.images) map FunctionDecl)
130130
freshSymbolsAcrossAllPhases ++= freshMacros
@@ -145,7 +145,7 @@ class FunctionData(val programFunction: ast.Function,
145145
val nested = (
146146
freshFieldInvs.flatMap(_.definitionalAxioms)
147147
++ freshFvfsAndDomains.flatMap (fvfDef => fvfDef.domainDefinitions ++ fvfDef.valueDefinitions)
148-
++ freshArps.map(_._2)
148+
++ freshConstrainedVars.map(_._2)
149149
++ freshConstraints)
150150

151151
// Filter out nested definitions that contain free variables.

src/main/scala/supporters/functions/FunctionRecorder.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ trait FunctionRecorder extends Mergeable[FunctionRecorder] {
2525
def fappToSnap: Map[ast.FuncApp, Term]
2626
def freshFvfsAndDomains: InsertionOrderedSet[SnapshotMapDefinition]
2727
def freshFieldInvs: InsertionOrderedSet[InverseFunctions]
28-
def freshArps: InsertionOrderedSet[(Var, Term)]
28+
def freshConstrainedVars: InsertionOrderedSet[(Var, Term)]
2929
def freshConstraints: InsertionOrderedSet[Term]
3030
def freshSnapshots: InsertionOrderedSet[Function]
3131
def freshPathSymbols: InsertionOrderedSet[Function]
@@ -34,7 +34,7 @@ trait FunctionRecorder extends Mergeable[FunctionRecorder] {
3434
def recordSnapshot(fapp: ast.FuncApp, guards: Stack[Term], snap: Term): FunctionRecorder
3535
def recordFvfAndDomain(fvfDef: SnapshotMapDefinition): FunctionRecorder
3636
def recordFieldInv(inv: InverseFunctions): FunctionRecorder
37-
def recordArp(arp: Var, constraint: Term): FunctionRecorder
37+
def recordConstrainedVar(v: Var, constraint: Term): FunctionRecorder
3838
def recordConstraint(constraint: Term): FunctionRecorder
3939
def recordFreshSnapshot(snap: Function): FunctionRecorder
4040
def recordPathSymbol(symbol: Function): FunctionRecorder
@@ -48,7 +48,7 @@ case class ActualFunctionRecorder(private val _data: FunctionData,
4848
private[functions] val fappToSnaps: Map[ast.FuncApp, InsertionOrderedSet[(Stack[Term], Term)]] = Map(),
4949
freshFvfsAndDomains: InsertionOrderedSet[SnapshotMapDefinition] = InsertionOrderedSet(),
5050
freshFieldInvs: InsertionOrderedSet[InverseFunctions] = InsertionOrderedSet(),
51-
freshArps: InsertionOrderedSet[(Var, Term)] = InsertionOrderedSet(),
51+
freshConstrainedVars: InsertionOrderedSet[(Var, Term)] = InsertionOrderedSet(),
5252
freshConstraints: InsertionOrderedSet[Term] = InsertionOrderedSet(),
5353
freshSnapshots: InsertionOrderedSet[Function] = InsertionOrderedSet(),
5454
freshPathSymbols: InsertionOrderedSet[Function] = InsertionOrderedSet(),
@@ -189,8 +189,8 @@ case class ActualFunctionRecorder(private val _data: FunctionData,
189189
if (depth <= 2) copy(freshFieldInvs = freshFieldInvs + inv)
190190
else this
191191

192-
def recordArp(arp: Var, constraint: Term): ActualFunctionRecorder =
193-
if (depth <= 2) copy(freshArps = freshArps + ((arp, constraint)))
192+
def recordConstrainedVar(arp: Var, constraint: Term): ActualFunctionRecorder =
193+
if (depth <= 2) copy(freshConstrainedVars = freshConstrainedVars + ((arp, constraint)))
194194
else this
195195

196196
def recordConstraint(constraint: Term): ActualFunctionRecorder =
@@ -237,7 +237,7 @@ case class ActualFunctionRecorder(private val _data: FunctionData,
237237

238238
val fvfs = freshFvfsAndDomains ++ other.freshFvfsAndDomains
239239
val fieldInvs = freshFieldInvs ++ other.freshFieldInvs
240-
val arps = freshArps ++ other.freshArps
240+
val arps = freshConstrainedVars ++ other.freshConstrainedVars
241241
val constraints = freshConstraints ++ other.freshConstraints
242242
val snaps = freshSnapshots ++ other.freshSnapshots
243243
val symbols = freshPathSymbols ++ other.freshPathSymbols
@@ -247,7 +247,7 @@ case class ActualFunctionRecorder(private val _data: FunctionData,
247247
fappToSnaps = fts,
248248
freshFvfsAndDomains = fvfs,
249249
freshFieldInvs = fieldInvs,
250-
freshArps = arps,
250+
freshConstrainedVars = arps,
251251
freshConstraints = constraints,
252252
freshSnapshots = snaps,
253253
freshPathSymbols = symbols,
@@ -277,7 +277,7 @@ case object NoopFunctionRecorder extends FunctionRecorder {
277277
val locToSnap: Map[ast.LocationAccess, Term] = Map.empty
278278
val freshFvfsAndDomains: InsertionOrderedSet[SnapshotMapDefinition] = InsertionOrderedSet.empty
279279
val freshFieldInvs: InsertionOrderedSet[InverseFunctions] = InsertionOrderedSet.empty
280-
val freshArps: InsertionOrderedSet[(Var, Term)] = InsertionOrderedSet.empty
280+
val freshConstrainedVars: InsertionOrderedSet[(Var, Term)] = InsertionOrderedSet.empty
281281
val freshConstraints: InsertionOrderedSet[Term] = InsertionOrderedSet.empty
282282
val freshSnapshots: InsertionOrderedSet[Function] = InsertionOrderedSet.empty
283283
val freshPathSymbols: InsertionOrderedSet[Function] = InsertionOrderedSet.empty
@@ -294,7 +294,7 @@ case object NoopFunctionRecorder extends FunctionRecorder {
294294
def recordFvfAndDomain(fvfDef: SnapshotMapDefinition): NoopFunctionRecorder.type = this
295295
def recordFieldInv(inv: InverseFunctions): NoopFunctionRecorder.type = this
296296
def recordSnapshot(fapp: ast.FuncApp, guards: Stack[Term], snap: Term): NoopFunctionRecorder.type = this
297-
def recordArp(arp: Var, constraint: Term): NoopFunctionRecorder.type = this
297+
def recordConstrainedVar(arp: Var, constraint: Term): NoopFunctionRecorder.type = this
298298
def recordConstraint(constraint: Term): NoopFunctionRecorder.type = this
299299
def recordFreshSnapshot(snap: Function): NoopFunctionRecorder.type = this
300300
def recordPathSymbol(symbol: Function): NoopFunctionRecorder.type = this

0 commit comments

Comments
 (0)