Skip to content

Commit 8851a19

Browse files
authored
Merge branch 'master' into meilers_record_merge_var_constraints
2 parents 6454055 + a5bd224 commit 8851a19

18 files changed

Lines changed: 448 additions & 245 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(declare-fun MWSF_apply ($MWSF $Snap) $Snap)

src/main/scala/Utils.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ package object utils {
222222
case class ViperEmbedding(embeddedSort: Sort) extends silver.ast.ExtensionType {
223223
def substitute(typVarsMap: Predef.Map[silver.ast.TypeVar, silver.ast.Type]): silver.ast.Type = this
224224
def isConcrete: Boolean = true
225+
override def toString: String = s"ViperEmbedding(sorts.$embeddedSort)"
225226
}
226227
}
227228

src/main/scala/decider/TermToSMTLib2Converter.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class TermToSMTLib2Converter
6161

6262
case sorts.FieldPermFunction() => text("$FPM")
6363
case sorts.PredicatePermFunction() => text("$PPM")
64+
65+
case sorts.MagicWandSnapFunction => text("$MWSF")
6466
}
6567

6668
def convert(d: Decl): String = {
@@ -263,7 +265,7 @@ class TermToSMTLib2Converter
263265

264266
case Lookup(field, fvf, at) => //fvf.sort match {
265267
// case _: sorts.PartialFieldValueFunction =>
266-
parens(text("$FVF.lookup_") <> field <+> render(fvf) <+> render(at))
268+
parens(text("$FVF.lookup_") <> field <+> render(fvf) <+> render(at))
267269
// case _: sorts.TotalFieldValueFunction =>
268270
// render(Apply(fvf, Seq(at)))
269271
// parens("$FVF.lookup_" <> field <+> render(fvf) <+> render(at))
@@ -313,6 +315,9 @@ class TermToSMTLib2Converter
313315
val docBindings = ssep((bindings.toSeq map (p => parens(render(p._1) <+> render(p._2)))).to(collection.immutable.Seq), space)
314316
parens(text("let") <+> parens(docBindings) <+> render(body))
315317

318+
case MagicWandSnapshot(mwsf) => render(mwsf)
319+
case MWSFLookup(mwsf, snap) => renderApp("MWSF_apply", Seq(mwsf, snap), sorts.Snap)
320+
316321
case _: MagicWandChunkTerm
317322
| _: Quantification =>
318323
sys.error(s"Unexpected term $term cannot be translated to SMTLib code")

src/main/scala/decider/TermToZ3APIConverter.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,8 @@ class TermToZ3APIConverter
445445
case Let(bindings, body) =>
446446
convert(body.replace(bindings))
447447

448+
case MWSFLookup(mwsf, snap) => createApp("MWSF_apply", Seq(mwsf, snap), sorts.Snap)
449+
448450
case _: MagicWandChunkTerm
449451
| _: Quantification =>
450452
sys.error(s"Unexpected term $term cannot be translated to SMTLib code")

src/main/scala/rules/HavocSupporter.scala

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,17 @@ object havocSupporter extends SymbolicExecutionRules {
181181
val id = ChunkIdentifier(resource, s.program)
182182
val (relevantChunks, otherChunks) = chunkSupporter.splitHeap[NonQuantifiedChunk](s.h, id)
183183

184-
val newChunks = relevantChunks.map { ch =>
185-
val havockedSnap = freshSnap(ch.snap.sort, v)
186-
val cond = replacementCond(lhs, ch.args, condInfo)
187-
ch.withSnap(Ite(cond, havockedSnap, ch.snap))
184+
val newChunks = relevantChunks.map {
185+
case ch: MagicWandChunk =>
186+
val havockedSnap = v.decider.fresh("mwsf", sorts.MagicWandSnapFunction)
187+
val cond = replacementCond(lhs, ch.args, condInfo)
188+
val magicWandSnapshot = MagicWandSnapshot(Ite(cond, havockedSnap, ch.snap.mwsf))
189+
ch.withSnap(magicWandSnapshot)
190+
191+
case ch =>
192+
val havockedSnap = freshSnap(ch.snap.sort, v)
193+
val cond = replacementCond(lhs, ch.args, condInfo)
194+
ch.withSnap(Ite(cond, havockedSnap, ch.snap))
188195
}
189196
otherChunks ++ newChunks
190197
}

src/main/scala/rules/MagicWandSupporter.scala

Lines changed: 201 additions & 132 deletions
Large diffs are not rendered by default.

src/main/scala/rules/MoreCompleteExhaleSupporter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ object moreCompleteExhaleSupporter extends SymbolicExecutionRules {
5555
resource match {
5656
case f: ast.Field => v.symbolConverter.toSort(f.typ)
5757
case _: ast.Predicate => sorts.Snap
58-
case _: ast.MagicWand => sorts.Snap
58+
case _: ast.MagicWand => sorts.MagicWandSnapFunction
5959
}
6060

6161
val `?s` = Var(Identifier("?s"), sort, false)

src/main/scala/rules/Producer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ object producer extends ProductionRules {
397397
Q(s2, v1)})
398398

399399
case wand: ast.MagicWand =>
400-
val snap = sf(sorts.Snap, v)
400+
val snap = sf(sorts.MagicWandSnapFunction, v)
401401
magicWandSupporter.createChunk(s, wand, MagicWandSnapshot(snap), pve, v)((s1, chWand, v1) =>
402402
chunkSupporter.produce(s1, s1.h, chWand, v1)((s2, h2, v2) =>
403403
Q(s2.copy(h = h2), v2)))

src/main/scala/rules/QuantifiedChunkSupport.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,6 @@ object quantifiedChunkSupporter extends QuantifiedChunkSupport {
637637

638638
/* Snapshots */
639639

640-
/** @inheritdoc */
641640
def singletonSnapshotMap(s: State,
642641
resource: ast.Resource,
643642
arguments: Seq[Term],
@@ -1287,7 +1286,7 @@ object quantifiedChunkSupporter extends QuantifiedChunkSupport {
12871286
codomainQVars,
12881287
relevantChunks,
12891288
v1,
1290-
optSmDomainDefinitionCondition = if (s2.smDomainNeeded) Some(True) else None,
1289+
optSmDomainDefinitionCondition = None,
12911290
optQVarsInstantiations = Some(arguments))
12921291
val permsTaken = result match {
12931292
case Complete() => rPerm
@@ -1332,7 +1331,7 @@ object quantifiedChunkSupporter extends QuantifiedChunkSupport {
13321331
resource = resource,
13331332
codomainQVars = codomainQVars,
13341333
relevantChunks = relevantChunks,
1335-
optSmDomainDefinitionCondition = if (s1.smDomainNeeded) Some(True) else None,
1334+
optSmDomainDefinitionCondition = None,
13361335
optQVarsInstantiations = Some(arguments),
13371336
v = v)
13381337
val s2 = s1.copy(functionRecorder = s1.functionRecorder.recordFvfAndDomain(smDef1),

0 commit comments

Comments
 (0)