-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Benjamin Pierce
committed
Jun 16, 2024
1 parent
8fa18b9
commit fb2cfe1
Showing
6 changed files
with
118 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/*@ | ||
lemma tl_snoc (pointer front, pointer back, datatype seq before, i32 popped) | ||
requires | ||
take T = Owned<struct int_queueCell>(back); | ||
is_null(T.next); | ||
take Q = IntQueueAux(front, back); | ||
let after = snoc(Q, T.first); | ||
before == snoc (Seq_Cons{head: popped, tail: Q}, T.first); | ||
ensures | ||
take T2 = Owned<struct int_queueCell>(back); | ||
T == T2; | ||
is_null(T.next); | ||
take Q2 = IntQueueAux(front, back); | ||
Q == Q2; | ||
after == tl(before); | ||
popped == hd(before); | ||
@*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "queue_headers.h" | ||
|
||
int IntQueue_pop (struct int_queue *q) | ||
{ | ||
struct int_queueCell* h = q->front; | ||
struct int_queueCell* t = q->back; | ||
if (h == t) { | ||
int x = h->first; | ||
freeIntQueueCell(h); | ||
q->front = 0; | ||
q->back = 0; | ||
return x; | ||
} else { | ||
int x = h->first; | ||
struct int_queueCell* n = h->next; | ||
q->front = n; | ||
freeIntQueueCell(h); | ||
return x; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/*@ | ||
lemma aux_induction(pointer front, pointer prev, pointer back, | ||
datatype seq before, i32 prev_pushed) | ||
requires | ||
take Prev = Owned<struct int_queueCell>(prev); | ||
take Q = IntQueueAux(front, prev); | ||
ptr_eq(Prev.next, back); // sanity check | ||
Prev.first == prev_pushed; // sanity check | ||
snoc(Q, prev_pushed) == before; // sanity check | ||
ensures | ||
take Q2 = IntQueueAux(front, back); | ||
before == Q2; | ||
@*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters