Skip to content

Commit

Permalink
queues still in progress, but one step ahead
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Pierce committed Jun 5, 2024
1 parent 4787f37 commit 4c9cdb1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/examples/queue.broken.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* queue.c */

#include "list.h"
#include "list_snoc_spec.h"
#include "list_snoc_spec.h"

struct int_queue {
struct int_queueCell* head;
Expand All @@ -15,7 +15,7 @@ struct int_queueCell {

// take V = Owned<t>(p) === p |-t-> V

// Why is the argument type just "pointer" with no info about what
// Why is the argument type just "pointer" with no info about what
// type it points to?

/*@
Expand Down Expand Up @@ -107,27 +107,27 @@ struct int_queue* IntQueue_empty ()
}

/*@
lemma snac_nil (i32 foo)
lemma snoc_nil (i32 foo)
requires true;
ensures snoc (Seq_Nil{}, foo) == Seq_Cons {head: foo, tail: Seq_Nil{}};
@*/

// should return void!
struct int_queue* IntQueue_push (int x, struct int_queue *q)
void IntQueue_push (int x, struct int_queue *q)
/*@ requires take l = IntQueue(q);
ensures take ret = IntQueue(return);
ensures take ret = IntQueue(q);
ret == snoc (l, x);
@*/
{
struct int_queueCell *c = mallocIntQueueCell();
c->first = x;
c->next = 0;
if (q->tail == 0) {
/*@ split_case (*q).head == NULL; @*/
/*@ apply snoc_nil(x); @*/
q->head = c;
q->tail = c;
} else {
q->tail->next = c;
q->tail = c;
}
return q;
}

0 comments on commit 4c9cdb1

Please sign in to comment.