Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Civl] Simplify and generalize invariants for ticket protocol #834

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions Test/civl/samples/ticket.bpl
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// RUN: %parallel-boogie "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

function RightOpen (n: int) : [int]bool;
function RightClosed (n: int) : [int]bool;
axiom (forall x: int, y: int :: RightOpen(x)[y] <==> y < x);
axiom (forall x: int, y: int :: RightClosed(x)[y] <==> y <= x);

type Tid;

var {:layer 0,1} t: int; // next ticket to issue
Expand All @@ -18,13 +13,12 @@ var {:layer 1,2} T: [int]bool; // set of issued tickets

function {:inline} Inv1 (tickets: [int]bool, ticket: int): (bool)
{
tickets == RightOpen(ticket)
(forall i: int :: tickets[i] <==> i < ticket)
}

function {:inline} Inv2 (tickets: [int]bool, ticket: int, lock: Option Tid): (bool)
{
if (lock is None) then tickets == RightOpen(ticket)
else tickets == RightClosed(ticket)
lock is None || tickets[ticket]
}

// ###########################################################################
Expand Down
Loading