Skip to content

Commit

Permalink
examples: add create method for peterson
Browse files Browse the repository at this point in the history
  • Loading branch information
nisarg-certora committed Nov 10, 2024
1 parent 09e20ca commit d2ca70a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/comparison/peterson.rav
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,35 @@ module Peterson[R: LockResource]
(own(l, access, 2, 1.0) && resource(r))))
}

proc create(implicit ghost r: R)
returns (l: Ref)
requires resource(r)
ensures peterson_inv(l, r)
ensures own(l, active_left, false, 0.5)
ensures own(l, active_right, false, 0.5)
{
l := new(
turn: false,
wait_left: false,
wait_right: false,
active_left: false,
active_right: false,
access: 2
);

fold peterson_inv(l, r)[
wl := false,
wr := false,
t := false,
la := false,
ra := false,
or_l := false,
or_r := false,
or_tl := false,
or_tr := false
];
}

proc wait_acquire_l(l: Ref, implicit ghost r: R)
requires peterson_inv(l, r)
requires own(l, wait_left, true, 0.5)
Expand Down

0 comments on commit d2ca70a

Please sign in to comment.