InutitionTC  0.30
vars_set.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (C) 2016 by University of Warsaw *
3  * *
4  * This file is part of IntuitionTC. *
5  * *
6  ****************************************************************************/
12 #ifndef _VARS_SET_H
13 #define _VARS_SET_H 1
14 
15 #include <string.h>
16 #include "checker.h"
17 
18 #define INITIAL_SIZE 1024
19 //@ logic size_t L_INITIAL_SIZE = (size_t)1024;
20 
26 typedef struct nameSet {
29  int size;
32 } nameSet;
33 
34 
35 /*@ predicate positive_size{L}(nameSet* s) = s->size > 0; @*/
36 /*@ predicate valid_vals{L}(nameSet* s) = s->size>=0 ==> is_allocated_size((char*)(s->vals),(size_t)s->size); @*/
37 /*@ predicate vals_unique{L}(nameSet* s) = \forall integer i,j;
38  @ 0 <= i < j < s->size && s->vals != \null &&
39  @ s->vals[i]!=\null && s->vals[j]!=\null ==>
40  @ strcmp(s->vals[i],s->vals[j])!=0;
41  @*/
42 
43 /*@ predicate valid_vals_valid{L}(nameSet* s) = \forall integer i;
44  @ 0 <= i < s->size && s->vals[i] != \null ==>
45  @ (is_allocated_size(s->vals[i],(size_t)\block_length(s->vals[i])) &&
46  @ 0 <= \block_length(s->vals[i]) <= UINT32_MAX &&
47  @ valid_string(s->vals[i]));
48  @*/
49 
50 /*@ predicate well_separated{L}(nameSet* s) =
51  @ \separated(s, s->vals+(0..s->size-1)) &&
52  @ \separated(s, { s->vals[i] |
53  @ integer i; 0 <= i < s->size && s->vals[i]!=0 }) &&
54  @ \separated(s->vals, { (s->vals)[i] |
55  @ integer i; 0 <= i < s->size && s->vals[i]!=0 }) &&
56  @ \separated(s, __allocated+(0..MAX_ALLOCS)) &&
57  @ \separated(s->vals+(0..s->size-1), __allocated+(0..MAX_ALLOCS)) &&
58  @ \forall integer i; 0 <= i < s->size && s->vals[i] != \null ==>
59  @ \separated(__allocated+(0..MAX_ALLOCS),
60  @ s->vals[i]+(0..\block_length(s->vals[i])-1));
61  @*/
62 
63 /*@ predicate valid_nameSet{L}(nameSet* s) = \valid(s) &&
64  @ is_allocated((char*)s) &&
65  @ positive_size(s) && valid_vals(s) && vals_unique(s) &&
66  @ valid_vals_valid(s) && well_separated(s);
67  @*/
68 
69 /*@ predicate fresh_Set{L}(nameSet* s) = \valid(s) && is_allocated((char*)s) &&
70  @ positive_size(s) && valid_vals(s) && vals_unique(s) &&
71  @ valid_vals_valid(s) && well_separated(s);
72  @*/
73 
74 
75 
76 nameSet* unionSet(nameSet* s1, nameSet* s2);
77 
78 /* union set and call freeSetShallow on operands */
79 nameSet* unionSetFreeShallow(nameSet* s1, nameSet* s2);
80 Name minusSet(nameSet* s, Name elem);
81 /* s is modified! */
82 nameSet* addSet(nameSet* s, Name elem);
83 nameSet* createSet();
84 nameSet* singletonSet(Name elem);
85 void freeSetShallow(nameSet* s);
86 void freeSetDeep(nameSet* s);
87 /* returns index or -1 */
88 int isIn(nameSet* s, Name elem);
89 
90 
91 #endif
The representation of the set that holds strings.
Definition: vars_set.h:26
int size
The size of the allocated area in which set elements can be stored.
Definition: vars_set.h:29
Definitions of the base structures that represent the formulas and proofs.
Name * vals
The array in which the elements of the set can be stored.
Definition: vars_set.h:31
char * Name
The type to structurally represent identifier names.
Definition: checker.h:46
struct nameSet nameSet
The representation of the set that holds strings.