@@ -903,19 +903,19 @@ object quantifiedChunkSupporter extends QuantifiedChunkSupport {
903903 val interpreter = new QuantifiedPropertyInterpreter
904904 resourceDescription.instanceProperties.foreach (property => {
905905 v.decider.prover.comment(property.description)
906- v.decider.assume( interpreter.buildPathConditionForChunk(
906+ val pcsForChunk = interpreter.buildPathConditionForChunk(
907907 chunk = ch,
908908 property = property,
909909 qvars = effectiveTriggersQVars,
910910 args = tArgs,
911911 perms = gain,
912912 condition = tCond,
913913 triggers = effectiveTriggers,
914- qidPrefix = qid)
914+ qidPrefix = qid
915915 )
916+ v.decider.assume(pcsForChunk)
916917 })
917-
918- val h1 = s.h + ch
918+ val (fr1, h1) = v.stateConsolidator(s).merge(s.functionRecorder, s.h, Heap (Seq (ch)), v)
919919
920920 val resourceIdentifier = resource match {
921921 case wand : ast.MagicWand => MagicWandIdentifier (wand, s.program)
@@ -947,7 +947,7 @@ object quantifiedChunkSupporter extends QuantifiedChunkSupport {
947947 }
948948 val s1 =
949949 s.copy(h = h1,
950- functionRecorder = s.functionRecorder .recordFieldInv(inv),
950+ functionRecorder = fr1 .recordFieldInv(inv),
951951 conservedPcs = conservedPcs,
952952 smCache = smCache1)
953953 Q (s1, v)
@@ -976,7 +976,7 @@ object quantifiedChunkSupporter extends QuantifiedChunkSupport {
976976 if (s.recordPcs) (s.conservedPcs.head :+ v.decider.pcs.after(definitionalAxiomMark)) +: s.conservedPcs.tail
977977 else s.conservedPcs
978978 val ch = quantifiedChunkSupporter.createSingletonQuantifiedChunk(formalQVars, resource, tArgs, tPerm, sm, s.program)
979- val h1 = s.h + ch
979+ val (fr1, h1) = v.stateConsolidator(s).merge(s.functionRecorder, s.h, Heap ( Seq (ch)), v)
980980
981981 val interpreter = new NonQuantifiedPropertyInterpreter (h1.values, v)
982982 val resourceDescription = Resources .resourceDescriptions(ch.resourceID)
@@ -1003,7 +1003,7 @@ object quantifiedChunkSupporter extends QuantifiedChunkSupport {
10031003 val smDef2 = SnapshotMapDefinition (resource, sm, Seq (smValueDef), Seq ())
10041004 val s1 = s.copy(h = h1,
10051005 conservedPcs = conservedPcs,
1006- functionRecorder = s.functionRecorder .recordFvfAndDomain(smDef2),
1006+ functionRecorder = fr1 .recordFvfAndDomain(smDef2),
10071007 smCache = smCache1)
10081008 Q (s1, v)
10091009 }
@@ -1429,8 +1429,14 @@ object quantifiedChunkSupporter extends QuantifiedChunkSupport {
14291429 val chunkDepleted = v.decider.check(depletedCheck, Verifier .config.splitTimeout())
14301430
14311431 if (! chunkDepleted) {
1432- remainingChunks =
1433- remainingChunks :+ ithChunk.withPerm(PermMinus (ithChunk.perm, ithPTaken))
1432+ val unusedCheck = Forall (codomainQVars, ithPTaken === NoPerm , Nil )
1433+ val chunkUnused = v.decider.check(unusedCheck, Verifier .config.checkTimeout())
1434+ if (chunkUnused) {
1435+ remainingChunks = remainingChunks :+ ithChunk
1436+ } else {
1437+ remainingChunks =
1438+ remainingChunks :+ ithChunk.withPerm(PermMinus (ithChunk.perm, ithPTaken))
1439+ }
14341440 }
14351441 }
14361442
0 commit comments