Changes between Version 19 and Version 20 of C Interface
- Timestamp:
- 09/15/10 10:47:11 (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
C Interface
v19 v20 21 21 22 22 {{{ 23 #pragma TASS assume N>0 23 #pragma TASS input {N>0} int 24 #define N 25 24 25 }}} 26 27 (Note: the "25" will be ignored by TASS.) 25 28 26 29 == Non-deterministic select statement == … … 35 38 36 39 {{{ 37 #pragma TASS assert forall {int i | i>=0 && i<N} a[i]>=040 #pragma TASS assert NAME forall {int i | i>=0 && i<N} a[i]>=0; 38 41 }}} 39 40 41 == Loop (joint) invariants ==42 43 Question: how are these expressed in the source code?44 45 Answer: These are also expressed as pragmas:46 {{{47 #pragma TASS jointinvariant skew(2:1) i == spec.j && k == spec.s + 148 }}}49 or something like that.50 42 51 43 == Library calls == … … 104 96 int more = fscanf(fp, "%lf", &tmp); 105 97 106 #pragma TASS assume tmp>=0.0 98 #pragma TASS assume tmp>=0.0; 107 99 if (more == EOF) break; 108 100 i++; … … 127 119 Question: what are all the pragmas we will need, and what will be there exact syntax and semantics: 128 120 129 Answer: Here is a proposed list:121 Here is the general pragma grammar for assertion/invariants: 130 122 131 * `#pragma TASS assert <TASS expression>` 132 * verify that the expression is true; report an error if it is not 133 * {{{#pragma TASS assume <TASS expression>}}} 123 {{{ 124 #pragma TASS [collective|joint]? [assert|invariant] IDENT <expression> [skew <expression>]? ; 125 }}} 126 127 128 Other pragmas: 129 * `#pragma TASS assume <TASS expression>` 134 130 * assume the expression is true, i.e., add the value of this expression to the current path condition 135 * {{{#pragma TASS invariant <TASS expression>}}} 136 * this is an (ordinary) loop invariant. Check that it really is an invariant, and use that fact to compute the state after the loop exit 137 * {{{#pragma TASS jointinvariant <TASS expression>}}} 138 * this is a joint loop invariant relating this loop to a loop in the specification program. Use to check functional equivalence. 139 * {{{#pragma TASS ignore}}} 131 * `#pragma TASS ignore` 140 132 * ignore the next statement (typically used for I/O statements that are not relevant) 141 * {{{#pragma TASS input <type> <variable>}}}142 * treat the next element as an input variable. Could be a preprocessor directory defining an object-type macro. 133 * `#pragma TASS input ['{' assumption-expression '}']? <type> <variable>?` 134 * treat the next element as an input variable. Could be a preprocessor directory defining an object-type macro. If preceding a preprocessor object macro, leave out the variable. The assumption expression is optional and can be used to add an assumption to the initial state. 143 135 * `#pragma TASS system` 144 136 * declares the following function to be "system-level" 145 137 * `#pragma TASS abstract` 146 138 * declares the following function to be abstract (a pure mathematical side-effect free function, like sin(x)) 147 148 To combine an input with assumption:149 {{{150 #pragma TASS input { N>0 && N*N<M }151 int N;152 }}}153 139 154 140 Grammar of TASS expressions: … … 158 144 * {{{forall {<type> <ident> | expr} expr}}} 159 145 * ditto with {{{exists}}} in place of {{{forall}}} 146 * `PROC[expr].IDENT` 147 * reference to a process-global variable in another process (with pid obtained by evaluating expr) 148 * `PROC[expr]@f.IDENT` 149 * like above, but referring to a local variable in function f in the other process 160 150 161 151
