VeriFast

1 program Added 2026-02-10T19:13:01.197643Z Agent: claude-codeModel: sonnetWebSearch: disabled Evidence Report issue View issues
Aliases: —
Provenance: commit 80e4d2669a · authored 2026-02-10T20:13:22+01:00 · agent claude-code · model sonnet

Sources mentioning this language

1 source · not in taxonomy (canonical name didn't match any upstream)
LLM (this repo) · 1

Related languages

Verse (0.21)Verus (0.21)Verve (0.21)Veryl (0.21)Verona (0.20)

LLM-contributed programs

Verified Stack Implementation

Provenance: commit 80e4d2669a · authored 2026-02-10T20:13:22+01:00 · agent claude-code · model sonnet · WebSearch disabled
code.c · license: MIT · added: 2026-02-10T19:13:01.197643Z
#include "stdlib.h"

struct node {
    void *value;
    struct node *next;
};

struct stack {
    struct node *head;
};

/*@
predicate nodes(struct node *node, int count) =
    node == 0 ?
        count == 0
    :
        0 < count &*& node->value |-> _ &*& node->next |-> ?next &*& malloc_block_node(node) &*& nodes(next, count - 1);

predicate stack(struct stack *stack, int count) =
    stack->head |-> ?head &*& malloc_block_stack(stack) &*& 0 <= count &*& nodes(head, count);
@*/

struct stack *create_stack()
    //@ requires true;
    //@ ensures stack(result, 0);
{
    struct stack *stack = malloc(sizeof(struct stack));
    if (stack == 0) { abort(); }
    stack->head = 0;
    //@ close nodes(0, 0);
    //@ close stack(stack, 0);
    return stack;
}

void stack_push(struct stack *stack, void *value)
    //@ requires stack(stack, ?count);
    //@ ensures stack(stack, count + 1);
{
    //@ open stack(stack, count);
    struct node *n = malloc(sizeof(struct node));
    if (n == 0) { abort(); }
    n->next = stack->head;
    n->value = value;
    stack->head = n;
    //@ close nodes(n, count + 1);
    //@ close stack(stack, count + 1);
}

void *stack_pop(struct stack *stack)
    //@ requires stack(stack, ?count) &*& 0 < count;
    //@ ensures stack(stack, count - 1);
{
    //@ open stack(stack, count);
    struct node *head = stack->head;
    //@ open nodes(head, count);
    void *result = head->value;
    stack->head = head->next;
    free(head);
    //@ close stack(stack, count - 1);
    return result;
}

Contribute — propose a file extension

Tell us where to find evidence about VeriFast (mapped to pl/verifast). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/VeriFast/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← VeriBasic verifpal →