Skip to content

Commit a6cbd14

Browse files
committed
simplified assert translation by adding pure action Assert
1 parent 8fa70b1 commit a6cbd14

File tree

12 files changed

+25
-59
lines changed

12 files changed

+25
-59
lines changed

Source/Concurrency/YieldingProcDuplicator.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,7 @@ public override Cmd VisitAssertCmd(AssertCmd node)
173173
assertCmd.Expr = Expr.True;
174174
return assertCmd;
175175
}
176-
if (layerNum != enclosingYieldingProc.Layer)
177-
{
178-
return assertCmd;
179-
}
180-
bool insideLoopInvariantOfYieldingLoop = enclosingYieldingProc.IsYieldingLoopHeaderAtProcedureLayer(enclosingBlock) && inPredicatePhase;
181-
if (insideLoopInvariantOfYieldingLoop)
182-
{
183-
return doRefinementCheck ? new AssumeCmd(node.tok, assertCmd.Expr, node.Attributes) : assertCmd;
184-
}
185-
else
186-
{
187-
return doRefinementCheck ? assertCmd : new AssumeCmd(node.tok, assertCmd.Expr, node.Attributes);
188-
}
176+
return doRefinementCheck ? new AssumeCmd(node.tok, assertCmd.Expr, node.Attributes) : assertCmd;
189177
}
190178

191179
public override Cmd VisitCallCmd(CallCmd call)

Source/Core/base.bpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,8 @@ datatype Unit { Unit() }
338338
function {:inline} UnitSet(): Set Unit {
339339
Set_Add(Set_Empty(), Unit())
340340
}
341+
342+
pure action Assert(b: bool)
343+
{
344+
assert b;
345+
}

Test/civl/large-samples/GC.bpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ preserves call Yield_Iso();
301301
preserves call Yield_Lock();
302302
requires {:layer 95, 96, 99} tid->i == i;
303303
{
304-
assert {:layer 100} mutatorTidWhole(tid) && rootAddr(x) && tidOwns(tid, x) && fieldAddr(f) && rootAddr(y) && tidOwns(tid, y) && memAddrAbs(rootAbs[x]);
304+
call {:layer 100} Assert(mutatorTidWhole(tid) && rootAddr(x) && tidOwns(tid, x) && fieldAddr(f) && rootAddr(y) && tidOwns(tid, y) && memAddrAbs(rootAbs[x]));
305305
call WriteBarrier(tid, i, y);
306306
call Yield_Iso() | Yield_WriteField(tid, x, y);
307307
call WriteFieldRaw(tid, x, f, y) | Yield_Lock();
@@ -1936,7 +1936,8 @@ refines AtomicLockAcquire;
19361936
preserves call Yield_Lock();
19371937
{
19381938
var status:bool;
1939-
assert {:layer 95} tid->i != 0;
1939+
1940+
call {:layer 95} Assert(tid->i != 0);
19401941
while (true)
19411942
invariant {:yields} true;
19421943
invariant call Yield_Lock();

Test/civl/large-samples/cache-coherence.bpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ refines atomic action {:layer 2} _ {
357357
call Set_Put(cachePermissions, drp);
358358
}
359359
{
360-
assert {:layer 1} Set_Contains(drp, One(CachePermission(i, Hash(ma))));
360+
call {:layer 1} Assert(Set_Contains(drp, One(CachePermission(i, Hash(ma)))));
361361
call cache_evict_resp#0(i, ma);
362362
call {:layer 1} Set_Put(cachePermissions, drp);
363363
}
@@ -397,7 +397,7 @@ refines left action {:layer 2} _ {
397397
call Set_Put(cachePermissions, drp);
398398
}
399399
{
400-
assert {:layer 1} Set_Contains(drp, One(CachePermission(i, Hash(ma))));
400+
call {:layer 1} Assert(Set_Contains(drp, One(CachePermission(i, Hash(ma)))));
401401
call cache_read_resp#0(i, ma, v, s);
402402
call {:layer 1} Set_Put(cachePermissions, drp);
403403
}
@@ -722,7 +722,7 @@ refines left action {:layer 2} _ {
722722
call Set_Put(dirPermissions, dp);
723723
}
724724
{
725-
assert {:layer 1} dp == WholeDirPermission(ma);
725+
call {:layer 1} Assert(dp == WholeDirPermission(ma));
726726
call dir_req_end#0(ma, dirState);
727727
call {:layer 1} Set_Put(dirPermissions, dp);
728728
}

Test/civl/large-samples/shared-vector.bpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ preserves call Yield(loc_iv);
157157
return;
158158
}
159159

160-
assert {:layer 2} Map_Contains(IntArrayPool, One(loc_iv));
161-
assert {:layer 2} (var vec := Map_At(IntArrayPool, One(loc_iv)); Vec_Contains(vec, i) && Vec_Contains(vec, j));
160+
call {:layer 2} Assert(Map_Contains(IntArrayPool, One(loc_iv)));
161+
call {:layer 2} Assert((var vec := Map_At(IntArrayPool, One(loc_iv)); Vec_Contains(vec, i) && Vec_Contains(vec, j)));
162162

163163
// deadlock avoidance
164164
if (i < j) {

Test/civl/paxos/PaxosImpl.bpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ refines left action {:layer 2} _ {
178178
status[r] := Proposed(v);
179179
}
180180
{
181-
assert {:layer 1} voteInfo[r] == MapConst(false);
181+
call {:layer 1} Assert(voteInfo[r] == MapConst(false));
182182
call {:layer 1} status := Copy(status[r := Proposed(v)]);
183183
}
184184

@@ -296,7 +296,7 @@ refines left action {:layer 2} _ {
296296
status[r] := Decided(v);
297297
}
298298
{
299-
assert {:layer 1} status[r] == Proposed(v);
299+
call {:layer 1} Assert(status[r] == Proposed(v));
300300
call {:layer 1} status := Copy(status[r := Decided(v)]);
301301
}
302302

@@ -363,8 +363,8 @@ requires call YieldInv();
363363
{
364364
var voteResponse: VoteResponse;
365365

366-
assert {:layer 1} IsActive(status[r], v);
367-
assert {:layer 1} !voteInfo[r][n];
366+
call {:layer 1} Assert(IsActive(status[r], v));
367+
call {:layer 1} Assert(!voteInfo[r][n]);
368368
call voteResponse := VoteUpdate(r, n, v);
369369
call SendVoteResponse(r, voteResponse);
370370
if (voteResponse is VoteAccept) {

Test/civl/regression-tests/Pure2.bpl

Lines changed: 0 additions & 20 deletions
This file was deleted.

Test/civl/regression-tests/Pure2.bpl.expect

Lines changed: 0 additions & 8 deletions
This file was deleted.

Test/civl/samples/MutexOverFutex.bpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ preserves call YieldInv();
6666
preserves call YieldWait(tid);
6767
{
6868
var oldValue: int;
69-
assert {:layer 1} mutex == Some(tid->val);
69+
call {:layer 1} Assert(mutex == Some(tid->val));
7070
call oldValue := FetchSub(1);
7171
if (oldValue == 1) {
7272
call {:layer 1} mutex := Copy(None());

Test/civl/samples/StoreBuffer.bpl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ requires {:layer 1} mutatorOrGcTid(tid->val);
7575
preserves call YieldLock();
7676
preserves call YieldStoreBufferLockAddrAbsent(tid);
7777
{
78-
assert {:layer 1} mutatorOrGcTid(tid->val);
79-
assert {:layer 1} lock == tid->val;
78+
call {:layer 1} Assert(lock == tid->val);
8079
call LockZero(tid->val);
8180
call YieldLock() | YieldStoreBufferLockAddrPresent(tid);
8281
call FlushStoreBufferEntryForLock(tid->val);
@@ -114,9 +113,8 @@ refines AtomicSetCollectorPhase;
114113
requires {:layer 1} mutatorOrGcTid(tid->val);
115114
preserves call YieldLock();
116115
{
117-
assert {:layer 1} mutatorOrGcTid(tid->val);
118-
assert {:layer 1} lock == tid->val;
119-
assert {:layer 1} collectorPhase == collectorPhaseDelayed;
116+
call {:layer 1} Assert(lock == tid->val);
117+
call {:layer 1} Assert(collectorPhase == collectorPhaseDelayed);
120118
call PrimitiveSetCollectorPhase(tid->val, phase);
121119
}
122120

0 commit comments

Comments
 (0)