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

Examples for test generation #96

Draft
wants to merge 153 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
153 commits
Select commit Hold shift + click to select a range
a178c8e
Fix queue pop lemma example
dc-mak Jun 19, 2024
4660b01
timeout-broken example no-longer timing out
cp526 Jun 20, 2024
adb8131
... and move back again. Apparently different OCaml/z3 versions behave
cp526 Jun 20, 2024
8850178
Update README.md
dc-mak Jun 24, 2024
0bbfe64
fix https://github.com/rems-project/cerberus/issues/350
cp526 Jun 25, 2024
1ab8504
Add a few more small examples and error cases (#29)
septract Jul 4, 2024
f5adb3d
recategorise files with different timeout behaviour due to switch to
cp526 Jul 4, 2024
204c330
Make the build script fail correctly on build errors
septract Jul 5, 2024
3340e3b
Add negative examples in directory `should-fail` (#28)
septract Jul 5, 2024
a8d390c
Add a workflow to run CN on examples
septract Jul 5, 2024
507b76b
Properly thread through CN tool name and args
septract Jul 5, 2024
b6f95eb
record that one example was broken by a recent Cerberus change
cp526 Jul 9, 2024
20e598f
Add `make check` target (#14)
thatplguy Jul 10, 2024
e22b93c
move previously-broken example back, in preparation for Kayvan's fix
cp526 Jul 10, 2024
69a7a75
Add README with how to build coq lemmas
scuellar May 28, 2024
12f6e66
Add examples
scuellar May 28, 2024
db0b916
Add build files
scuellar May 28, 2024
a7d0950
Add and reorder examples
scuellar Jun 10, 2024
9ea5766
Add examples and ignore automatically generated files
scuellar Jun 10, 2024
14457db
Ignore more automatic coq files
scuellar Jun 10, 2024
f71b240
adding examples
scuellar Jun 19, 2024
1cfbca2
Clarity
scuellar Jun 24, 2024
93a6f25
Typos
scuellar Jul 9, 2024
1c88cfd
Clarify examples
scuellar Jul 9, 2024
d99d111
Add new script for checking coq extraction
scuellar Jul 10, 2024
4dbd8b7
add the script for checking coq extraction
scuellar Jul 10, 2024
f50f637
Explain the new organization, including Coq lemmas.
scuellar Jul 10, 2024
f85a420
Generalize process_files and use it to check Coq extraction
scuellar Jul 10, 2024
b5b722d
Ignore the build files
scuellar Jul 10, 2024
b7e3ca0
Ignore coq files, except the proofs. This affects only the example-ar…
scuellar Jul 10, 2024
35deed9
Add the proofs
scuellar Jul 10, 2024
55e525f
Move examples that fail to build/incomplete proofs.
scuellar Jul 10, 2024
a2a431a
Fix the popd bug and add titles to the two sections.
scuellar Jul 10, 2024
32b2a8c
Move the build folder prototype to the parent directory to be used by…
scuellar Jul 10, 2024
be83fa4
Foolproof build
scuellar Jul 10, 2024
6913e1e
README details
scuellar Jul 10, 2024
f9d179f
remove old build folder
scuellar Jul 10, 2024
7f8d632
clean up
scuellar Jul 10, 2024
be21ea3
Fix Typos
scuellar Jul 11, 2024
60eb895
Add clarity
scuellar Jul 11, 2024
08667b8
Tidy up typos and some script things
septract Jul 11, 2024
47a0d5c
Readme tweaks
septract Jul 11, 2024
ad166c5
Deactivate CI for Coq to make the merge easier
septract Jul 11, 2024
2ffc2cf
increase timeout, for handling https://github.com/rems-project/cerber…
cp526 Jul 17, 2024
bc3314a
recategorise that test
cp526 Jul 17, 2024
4e3d3dd
add constructors and begin (broken) push function
elaustell Jun 20, 2024
fbe03c2
add snoc to linked list file
elaustell Jun 20, 2024
021b902
add predicates that traverse backwards
elaustell Jun 20, 2024
3f99051
begin implementing append (broken)
elaustell Jun 20, 2024
b0ec83e
create todo list
elaustell Jun 20, 2024
4d19bcd
add constructors that go out from middle node
elaustell Jun 24, 2024
15a97a2
add malloc and free
elaustell Jun 24, 2024
f65f80d
add singleton constructor
elaustell Jun 24, 2024
0297948
add remove function
elaustell Jun 24, 2024
73c6519
include that the rest of the list is unchanged in remove function
elaustell Jun 24, 2024
ae7611f
implement hacky add function
elaustell Jun 24, 2024
92fb603
add correctness check to add_between
elaustell Jun 24, 2024
17229f0
try to implement add
elaustell Jun 24, 2024
62172cf
add comments for clarification
elaustell Jun 24, 2024
680a158
Delete src/examples/Linked_List/WIPlinklist2.c
elaustell Jun 26, 2024
7e66c47
add new way of reasoning about linked lists
elaustell Jun 26, 2024
cc2a8cd
rework everything with opts and seqs
elaustell Jun 27, 2024
c84ccd2
add simple functions with new dblList and dblListOption types
elaustell Jun 28, 2024
b22410c
another attempt at add_between function
elaustell Jun 28, 2024
4b4e445
more work
elaustell Jul 1, 2024
9a6b400
add remove function (working)
elaustell Jul 1, 2024
4dc56cf
work on add functions
elaustell Jul 2, 2024
12953f1
more changes
elaustell Jul 9, 2024
8e2e261
Update WIPlinklist.c
elaustell Jul 9, 2024
92e0b14
make add work
elaustell Jul 9, 2024
66b0572
add remove function
elaustell Jul 10, 2024
7407333
Add correctness check for remove
elaustell Jul 11, 2024
afdf2e5
add correctness checks to add function
elaustell Jul 11, 2024
1b0971e
add find head and tail functions
elaustell Jul 11, 2024
17a8cd1
convert to more systematic naming conventions
elaustell Jul 15, 2024
fddfcfc
organize into folders and add explanations of specs
elaustell Jul 15, 2024
1991e83
Change Dll datatype to only use seqs
elaustell Jul 15, 2024
9a60e3a
fix remove spec to be more concise
elaustell Jul 16, 2024
1028401
rename for clarity
elaustell Jul 16, 2024
e7984ff
change Linked_List to Dbl_Linked_list
elaustell Jul 16, 2024
16b7594
make add spec more concise
elaustell Jul 16, 2024
3dd4f71
change spec identifiers to Before and After
elaustell Jul 16, 2024
2431d5c
add doubly linked list to tutorial
elaustell Jul 16, 2024
5419725
gitignore ./check
cp526 Jul 17, 2024
f159166
Update tutorial and examples for Owned disjoint
dc-mak Jul 16, 2024
24d5748
Temporarily delete division crash files
dc-mak Jul 18, 2024
e5e80ea
Re-add division files
dc-mak Jul 18, 2024
e01ed1a
add runway example to tutorial
elaustell Jul 16, 2024
7781ee6
Removed hard-coded repo name in CI script (#48)
septract Jul 20, 2024
9983c50
Create example of reading a zero-initialized array (#49)
samcowger Jul 20, 2024
88a8a15
Fix #55 - Use cn verify
dc-mak Jul 22, 2024
3b57729
Remove redundant instantiate, add stronger post to write_5 example
septract Jul 20, 2024
625aaea
ci: install pygments gem during web deployment
samcowger Jul 22, 2024
2ba6b4a
Move wrongly located examples
septract Jul 20, 2024
8b24fdd
Remove old annotated tutorial versions
septract Jul 20, 2024
36a8c52
Modify examples to use a->b syntax
septract Jul 23, 2024
8570786
Temporarily remove crashing bitwise tests
dc-mak Jul 23, 2024
2297bf3
make asciidoc produce table of contents
cp526 Jul 23, 2024
8039cb4
Re-add bitwise complement examples (now working)
dc-mak Jul 23, 2024
386b599
fix makefile to use `cn verify`
cp526 Jul 25, 2024
0562b8d
Quick fixes for broken build
Jul 25, 2024
aee33ca
Temporarily remove crashing modulo test
dc-mak Jul 29, 2024
c9f3b4f
recategorise now-working examples
cp526 Jul 29, 2024
7018bb7
Add broken proof example from Cerberus repo here
dc-mak Jul 30, 2024
8e9c148
Update tests for PR #459 in the Cerberus repo
yav Aug 2, 2024
7529616
put in authors, funding ack, and reference for CN paper
cp526 Aug 6, 2024
91198d2
Tidy
Aug 6, 2024
58faff9
recategorise some tests following Kayvan's https://github.com/cp526/c…
cp526 Aug 12, 2024
596be8b
Temporarily remove crashing pointer dec tests
dc-mak Aug 13, 2024
18bf66c
Re-add pointer dec tests
dc-mak Aug 13, 2024
f11f32f
use cn verify in check.sh
dsainati1 Aug 14, 2024
0350aa9
bump up timeout another time
cp526 Aug 15, 2024
19dc407
update to use `boolean` kw, fix build script issues
septract Aug 17, 2024
3fa9acd
Fix more `bool` cases, fix Makefile
septract Aug 17, 2024
35bedb2
One more instance of `bool`
septract Aug 17, 2024
d78811b
Build script tweak
septract Aug 17, 2024
4282590
Typo
septract Aug 17, 2024
1d2bde1
Fix Makefile issue
septract Aug 17, 2024
6445df4
Log SMT output from recently changed files
septract Jul 18, 2024
9860682
Tidy up script, add comments
septract Jul 18, 2024
f0b262c
Tweak log generator for use in CI
septract Jul 20, 2024
3e1592e
Revise script per dialog with CVC5 team
septract Aug 19, 2024
d3b44c1
Fix IntListSeg predicate
dc-mak Aug 20, 2024
b7bda5d
Work-around Z3 bug
dc-mak Aug 26, 2024
ff994f9
Revert "Work-around Z3 bug"
dc-mak Aug 26, 2024
c98d4ac
use == instead of ptr_eq to compare u32 values (#83)
dsainati1 Aug 28, 2024
24057b8
bump timeout again
cp526 Sep 11, 2024
3d5cb82
recategorise that test
cp526 Sep 29, 2024
f003208
Temporarily remove test (#87)
dc-mak Sep 30, 2024
3e1d0eb
Temporarily remove test
dc-mak Sep 30, 2024
a551d3f
Re-add removed broken-crash test as broken-proof
dc-mak Sep 30, 2024
f284ac2
Add support for VIP
dc-mak Sep 30, 2024
7c0a52c
Adds style guide and naming conventions (#93)
thatplguy Oct 9, 2024
97366ef
Checkpoint: working on a binary search tree specificaion
yav Oct 15, 2024
c1858fb
Make `traverse` preserve the tree.
yav Oct 15, 2024
47aca9f
Checkpoint: lookup with lots of duplication
yav Oct 16, 2024
b47b8f8
Modify "lookup" to work in combination with "member"
yav Oct 17, 2024
19ede1c
Some examples of using CN to generate tests
yav Oct 23, 2024
4de597e
Merge branch 'main' into bst
yav Nov 4, 2024
7c46185
Fix up some examples, and add sorted lists, which doesn't work at the…
yav Nov 4, 2024
fe2a505
Implement a simple vector type, no CN specs yet
yav Nov 5, 2024
5f8334a
Insertion in a sorted list
yav Nov 5, 2024
9bb2a8d
Use `char` as elements, and show various issues with testing.
yav Nov 5, 2024
b556cbd
Add specifications to the vector type
yav Nov 6, 2024
3456417
A script to remove Etna mutants
yav Nov 6, 2024
4f09ded
Testable vector and bst
yav Nov 7, 2024
f80fa49
Rename to caml case
yav Nov 7, 2024
c6985f5
Delete from BST
yav Nov 7, 2024
6d25b99
Add a couple of mutants
yav Nov 7, 2024
2c8f00f
Generate a coverage report
yav Nov 11, 2024
89971ed
A BST formulation that separates memory layout and the invariant
yav Nov 11, 2024
045a2d7
Fix implementation and spec for deletion, and add specs for other ope…
yav Nov 12, 2024
76168d5
Fix deletion
yav Nov 12, 2024
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
238 changes: 238 additions & 0 deletions src/examples/bst/bst_map.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@

#include "bst_map.h"
#include "bst_map_cn.h"


#if 0
/* Allocate a new singleton node */
struct MapNode *newNode(KEY key, VALUE value)
/*@
requires
true;
ensures
take node = Owned<struct MapNode>(return);
node.key == key;
node.value == value;
is_null(node.smaller);
is_null(node.larger);
@*/
{
struct MapNode *node = malloc_MapNode();
node->key = key;
node->value = value;
node->smaller = NULL;
node->larger = NULL;
return node;
}
#endif



#if 0
// A no-op function, just shows hows to traverse a tree with a loop.
void traverse(struct MapNode *node)
/*@
requires
take start = BST(node);
ensures
take end = BST(node);
start == end;
@*/
{
struct MapNode *cur = node;

/*@ split_case is_null(cur); @*/
/*@ unfold setKey(fromBSTNode(start).data.key, Leaf {}, start); @*/
while (cur)
/*@
inv
{node} unchanged;
take focus = BSTFocus(node,cur);
start == unfocus(focus);
let cur_prev = cur;
@*/
{
cur = cur->smaller;
/*@ apply FocusedGo(node,cur_prev,true); @*/
}
}
#endif


#if 0
struct MapNode *findLeast(struct MapNode *p)
/*@
requires
take tree = BST(p);
ensures
take final_tree = BST(p);
tree == final_tree;
@*/
{
struct MapNode *parent = 0;
struct MapNode *cur = p;
/*@ split_case is_null(cur); @*/
/*@ unfold setKey(fromBSTNode(tree).data.key, Leaf {}, tree); @*/
while(cur)
/*@
inv
{p} unchanged;
take front = BSTFocus(p,cur);
tree == unfocus(front);
let cur_prev = cur;
@*/
{
parent = cur;
cur = cur->smaller;
/*@ apply FocusedGoSmaller(p,cur_prev); @*/
}
return parent;
}
#endif

#if 1
/* Look for a node and its parent */
struct MapNode *findNode(struct MapNode *root, KEY key)
/*@
requires
take tree = BST(root);
ensures
take focus = BSTFocus(root, return);
unfocus(focus) == tree;
match focus {
AtLeaf { tree: _ } => { !member(key,tree) }
AtNode { done: _, node: node, smaller: _, larger: _ } => {
node.key == key
}
};
@*/
{
struct MapNode *cur = root;
/*@ split_case is_null(cur); @*/
/*@ unfold setKey(fromBSTNode(tree).data.key, Leaf {}, tree); @*/
/*@ unfold member(key, Leaf {}); @*/
while (cur)
/*@ inv
{root} unchanged;
{key} unchanged;
take focus = BSTFocus(root,cur);
unfocus(focus) == tree;
!member(key, focusDone(focus));
let cur_prev = cur;
@*/
{
KEY k = cur->key;
if (k == key) return cur;
cur = k < key? cur->larger : cur->smaller;
/*@ apply FocusedGoKey(root, cur_prev, k > key, key); @*/
}
return 0;
}
#endif


/*@
predicate BSTFocus FindParentFocus(pointer tree_ptr, pointer cur_ptr, pointer parent_ptr, KEY key) {
if (is_null(cur_ptr)) {
take focus = BSTFocus(tree_ptr, parent_ptr);
let tree_after = unfocus(focus);
assert(!member(key,tree_after)); // More?
return focus;
} else {
// Found in tree
take focus = BSTFocus(tree_ptr, cur_ptr);
let at_node = fromBSTFocusNode(focus);
assert(at_node.node.key == key);
return focus;
}
}
@*/


#if 0
/* Look for a node and its parent */
struct MapNode *findParent(struct MapNode **node, KEY key)
/*@
requires
take tree_ptr = Owned<struct MapNode*>(node);
take tree = BST(tree_ptr);
ensures
take cur_ptr = Owned<struct MapNode*>(node);
let parent_ptr = return;
take focus = FindParentFocus(tree_ptr, parent_ptr, cur_ptr, key);
let tree_after = unfocus(focus);
tree == tree_after;
@*/
{
struct MapNode *parent = 0;
struct MapNode *cur = *node;
/*@ split_case is_null(cur); @*/
while (cur)
/*@ inv
{node} unchanged;
{key} unchanged;
take node_ptr = Owned<struct MapNode*>(node);
ptr_eq(node_ptr,tree_ptr);
take focus = BSTFocus(tree_ptr, cur);
let cur_prev = cur;
@*/
{
KEY k = cur->key;
if (k == key) {
*node = cur;
/*@ split_case is_null(cur); @*/
return parent;
}
parent = cur;
cur = k < key? cur->larger : cur->smaller;
/*@ apply FocusedGo(tree_ptr, cur_prev, k > key); @*/
}
*node = cur;
return parent;
}
#endif


#if 0
/* Create an empty set */
struct Map map_empty()
/*@ @*/
{
return (struct Map) { .root = NULL };
}
#endif

#if 0
/* Lookup a value in a map */
bool map_lookup(struct Map map, KEY key, VALUE *value) {
struct MapNode *search = map.root;
findParent(&search, key);
if (search == NULL) { return false; }
*value = search->value;
return true;
}
#endif

#if 0
/* Insert an element into a map. Overwrites previous if already present. */
void map_insert(struct Map *map, KEY key, VALUE value) {
struct MapNode *search = map->root;
struct MapNode *parent = findParent(&search, key);
if (search != NULL) {
search->value = value;
return;
}

if (parent == NULL) {
map->root = newNode(key,value);
return;
}

struct MapNode *new_node = newNode(key,value);
if (parent->key < key) {
parent->larger = new_node;
} else {
parent->smaller = new_node;
}
}
#endif
29 changes: 29 additions & 0 deletions src/examples/bst/bst_map.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef SET_H
#define SET_H
/* A set defined as binary search tree */

#include <stdbool.h>

#define KEY int
#define VALUE long

struct MapNode {
KEY key;
int ignore;
VALUE value;
struct MapNode *smaller;
struct MapNode *larger;
};

struct MapNode* malloc_MapNode();


struct Map {
struct MapNode *root;
};

struct Map map_empty();
bool map_lookup(struct Map map, KEY key, VALUE *value);


#endif // SET_H
10 changes: 10 additions & 0 deletions src/examples/bst/bst_map_cn.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <stdlib.h>
#include <assert.h>

#include "bst_map_cn.h"

struct MapNode *malloc_MapNode() {
struct MapNode *result = malloc(sizeof(struct MapNode));
assert(result != NULL);
return result;
}
Loading
Loading