Skip to content

Commit 9185b2a

Browse files
authored
Merge pull request #825 from viperproject/meilers_fix_mce_wildcard_incompleteness
Recording missing constraint about MCE wildcards in FunctionRecorder
2 parents 50f8adf + c475ee5 commit 9185b2a

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

src/main/scala/rules/MoreCompleteExhaleSupporter.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,12 +369,15 @@ object moreCompleteExhaleSupporter extends SymbolicExecutionRules {
369369
ch.withPerm(PermMinus(ch.perm, permTaken))
370370
})
371371

372-
v.decider.assume(
372+
val totalTakenBounds =
373373
Implies(
374374
totalPermSum !== NoPerm,
375375
And(
376376
PermLess(NoPerm, totalPermTaken),
377-
PermLess(totalPermTaken, totalPermSum))))
377+
PermLess(totalPermTaken, totalPermSum)))
378+
v.decider.assume(totalTakenBounds)
379+
380+
newFr = newFr.recordConstraint(totalTakenBounds)
378381

379382
val s1 = s.copy(functionRecorder = newFr)
380383

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class FunctionData(val programFunction: ast.Function,
9494
private[this] var freshFvfsAndDomains: InsertionOrderedSet[SnapshotMapDefinition] = InsertionOrderedSet.empty
9595
private[this] var freshFieldInvs: InsertionOrderedSet[InverseFunctions] = InsertionOrderedSet.empty
9696
private[this] var freshArps: InsertionOrderedSet[(Var, Term)] = InsertionOrderedSet.empty
97+
private[this] var freshConstraints: InsertionOrderedSet[Term] = InsertionOrderedSet.empty
9798
private[this] var freshSnapshots: InsertionOrderedSet[Function] = InsertionOrderedSet.empty
9899
private[this] var freshPathSymbols: InsertionOrderedSet[Function] = InsertionOrderedSet.empty
99100
private[this] var freshMacros: InsertionOrderedSet[MacroDecl] = InsertionOrderedSet.empty
@@ -117,6 +118,7 @@ class FunctionData(val programFunction: ast.Function,
117118
freshFvfsAndDomains = mergedFunctionRecorder.freshFvfsAndDomains
118119
freshFieldInvs = mergedFunctionRecorder.freshFieldInvs
119120
freshArps = mergedFunctionRecorder.freshArps
121+
freshConstraints = mergedFunctionRecorder.freshConstraints
120122
freshSnapshots = mergedFunctionRecorder.freshSnapshots
121123
freshPathSymbols = mergedFunctionRecorder.freshPathSymbols
122124
freshMacros = mergedFunctionRecorder.freshMacros
@@ -143,7 +145,8 @@ class FunctionData(val programFunction: ast.Function,
143145
val nested = (
144146
freshFieldInvs.flatMap(_.definitionalAxioms)
145147
++ freshFvfsAndDomains.flatMap (fvfDef => fvfDef.domainDefinitions ++ fvfDef.valueDefinitions)
146-
++ freshArps.map(_._2))
148+
++ freshArps.map(_._2)
149+
++ freshConstraints)
147150

148151
// Filter out nested definitions that contain free variables.
149152
// This should not happen, but currently can, due to bugs in the function axiomatisation code.

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ trait FunctionRecorder extends Mergeable[FunctionRecorder] {
2626
def freshFvfsAndDomains: InsertionOrderedSet[SnapshotMapDefinition]
2727
def freshFieldInvs: InsertionOrderedSet[InverseFunctions]
2828
def freshArps: InsertionOrderedSet[(Var, Term)]
29+
def freshConstraints: InsertionOrderedSet[Term]
2930
def freshSnapshots: InsertionOrderedSet[Function]
3031
def freshPathSymbols: InsertionOrderedSet[Function]
3132
def freshMacros: InsertionOrderedSet[MacroDecl]
@@ -34,6 +35,7 @@ trait FunctionRecorder extends Mergeable[FunctionRecorder] {
3435
def recordFvfAndDomain(fvfDef: SnapshotMapDefinition): FunctionRecorder
3536
def recordFieldInv(inv: InverseFunctions): FunctionRecorder
3637
def recordArp(arp: Var, constraint: Term): FunctionRecorder
38+
def recordConstraint(constraint: Term): FunctionRecorder
3739
def recordFreshSnapshot(snap: Function): FunctionRecorder
3840
def recordPathSymbol(symbol: Function): FunctionRecorder
3941
def recordFreshMacro(decl: MacroDecl): FunctionRecorder
@@ -47,6 +49,7 @@ case class ActualFunctionRecorder(private val _data: FunctionData,
4749
freshFvfsAndDomains: InsertionOrderedSet[SnapshotMapDefinition] = InsertionOrderedSet(),
4850
freshFieldInvs: InsertionOrderedSet[InverseFunctions] = InsertionOrderedSet(),
4951
freshArps: InsertionOrderedSet[(Var, Term)] = InsertionOrderedSet(),
52+
freshConstraints: InsertionOrderedSet[Term] = InsertionOrderedSet(),
5053
freshSnapshots: InsertionOrderedSet[Function] = InsertionOrderedSet(),
5154
freshPathSymbols: InsertionOrderedSet[Function] = InsertionOrderedSet(),
5255
freshMacros: InsertionOrderedSet[MacroDecl] = InsertionOrderedSet(),
@@ -190,6 +193,10 @@ case class ActualFunctionRecorder(private val _data: FunctionData,
190193
if (depth <= 2) copy(freshArps = freshArps + ((arp, constraint)))
191194
else this
192195

196+
def recordConstraint(constraint: Term): ActualFunctionRecorder =
197+
if (depth <= 2) copy(freshConstraints = freshConstraints + constraint)
198+
else this
199+
193200
def recordFreshSnapshot(snap: Function): ActualFunctionRecorder =
194201
if (depth <= 1) copy(freshSnapshots = freshSnapshots + snap)
195202
else this
@@ -231,6 +238,7 @@ case class ActualFunctionRecorder(private val _data: FunctionData,
231238
val fvfs = freshFvfsAndDomains ++ other.freshFvfsAndDomains
232239
val fieldInvs = freshFieldInvs ++ other.freshFieldInvs
233240
val arps = freshArps ++ other.freshArps
241+
val constraints = freshConstraints ++ other.freshConstraints
234242
val snaps = freshSnapshots ++ other.freshSnapshots
235243
val symbols = freshPathSymbols ++ other.freshPathSymbols
236244
val macros = freshMacros ++ other.freshMacros
@@ -240,6 +248,7 @@ case class ActualFunctionRecorder(private val _data: FunctionData,
240248
freshFvfsAndDomains = fvfs,
241249
freshFieldInvs = fieldInvs,
242250
freshArps = arps,
251+
freshConstraints = constraints,
243252
freshSnapshots = snaps,
244253
freshPathSymbols = symbols,
245254
freshMacros = macros)
@@ -269,6 +278,7 @@ case object NoopFunctionRecorder extends FunctionRecorder {
269278
val freshFvfsAndDomains: InsertionOrderedSet[SnapshotMapDefinition] = InsertionOrderedSet.empty
270279
val freshFieldInvs: InsertionOrderedSet[InverseFunctions] = InsertionOrderedSet.empty
271280
val freshArps: InsertionOrderedSet[(Var, Term)] = InsertionOrderedSet.empty
281+
val freshConstraints: InsertionOrderedSet[Term] = InsertionOrderedSet.empty
272282
val freshSnapshots: InsertionOrderedSet[Function] = InsertionOrderedSet.empty
273283
val freshPathSymbols: InsertionOrderedSet[Function] = InsertionOrderedSet.empty
274284
val freshMacros: InsertionOrderedSet[MacroDecl] = InsertionOrderedSet.empty
@@ -285,6 +295,7 @@ case object NoopFunctionRecorder extends FunctionRecorder {
285295
def recordFieldInv(inv: InverseFunctions): NoopFunctionRecorder.type = this
286296
def recordSnapshot(fapp: ast.FuncApp, guards: Stack[Term], snap: Term): NoopFunctionRecorder.type = this
287297
def recordArp(arp: Var, constraint: Term): NoopFunctionRecorder.type = this
298+
def recordConstraint(constraint: Term): NoopFunctionRecorder.type = this
288299
def recordFreshSnapshot(snap: Function): NoopFunctionRecorder.type = this
289300
def recordPathSymbol(symbol: Function): NoopFunctionRecorder.type = this
290301
def recordFreshMacro(decl: MacroDecl): NoopFunctionRecorder.type = this

0 commit comments

Comments
 (0)