Changes between Version 17 and Version 18 of VerificationWithContracts


Ignore:
Timestamp:
02/12/16 11:36:59 (10 years ago)
Author:
zmanchun
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • VerificationWithContracts

    v17 v18  
    1 == Verify programs with Contracts ==
     1== Verify Programs with Contracts ==
    22
    3 == Different kinds of contracts ==
    4 CIVL generally provides three kinds of contracts:
     3The CIVL contract system is based on ACSL (http://frama-c.com/acsl.html), and it contains four categories:
     4
    55* Contracts for sequential programs
    66* Contracts for MPI
    7 * Contracts for reduction (see [wiki:ContractReduction])
    8 All these contracts in CIVL are developed as extensions on ACSL language.
     7* Contracts for state space reduction (see [wiki:ContractReduction])
     8* Loop invariants
    99
    10 ==  Sequential contracts ==
     10Note that the first three are also called function contracts, while the last is called loop contract.
     11
     12Additional primitives that extend ACSL include:
     13* contract primitives for MPI
     14 * MPI collective contract
     15 * remote expressions
     16* contract primitives for dependency relation
     17  * `depends` clause: specify the dependency relation of the function, usually used for partial order reduction (POR) or other analysis
     18  * `\calls(fun, arg0, arg1, ...)`: a set of actions that invokes the function with the specified arguments
     19  * `\noact`: empty set of actions
     20  * `\anyact`: any action sets
     21  * set of memory actions: `\read(mu-list)`, `\write(mu-list)`
     22  * action set operations: `+` union, `-` complement, `&` intersect
     23  * `reads` clause: specify memory locations read by the function, the syntax of which is similar to `assigns` clause
     24* malicious primitives
     25  * wildcard term: `...`
     26 * additional parameter for `allocates` clause: specify the scope of the heap for allocation; if absent then the root scope is used
     27 * extension for range with steps: `lo .. hi # step`
     28
     29The contract grammar could be found bellow:
     30
     31{{{
     32function-contract ::= requires-clause∗ terminates-clause? decreases-clause? guards-clause?
     33                      simple-clause∗  named-behavior∗ completeness-clause∗
     34requires-clause ::= requires pred ;
     35terminates-clause ::= terminates pred ;
     36decreases-clause  ::= decreases term (for id)? ;
     37guards-clause ::= guards pred ;
     38simple-clause ::= assigns-clause | ensures-clause
     39                | allocation-clause | abrupt-clause-fn
     40                | reads-clause | depends-clause
     41assigns-clause ::= assigns tsets ;
     42tsets ::= location (, location) ∗
     43ensures-clause ::= ensures pred ;
     44allocation-clause ::= allocates tsets (, scope)? ; | frees tsets ;
     45reads-clause ::= reads tsets;
     46depends-clause := depends event (, event)*;
     47named-behavior ::= behavior id : behavior-body
     48behavior-body ::= assumes-clause∗ requires-clause∗ simple-clause∗
     49assumes-clause ::= assumes pred ;
     50completeness-clause ::= complete behaviors (id (, id)∗)? ;
     51                      | disjoint behaviors (id (, id)∗)? ;
     52term ::= \old ( term ) | \result | \nothing | ...
     53pred ::= \old ( pred )
     54}}}
     55
     56{{{
     57tset ::= \empty
     58       | tset -> id
     59       | tset . id * tset
     60       | & tset
     61       | tset [ tset ]
     62       | term? .. term?
     63       | \union ( tset (, tset)∗ )
     64       | \inter ( tset (, tset)∗ )
     65       | tset + tset
     66       | ( tset )
     67       | { tset | binders (; pred)? }
     68       | { term } term
     69}}}
     70
     71{{{
     72literal ::= \true | \false | integer | real | string | character
     73}}}
     74
     75{{{
     76bin-op ::= + | - | * | / | % | << | >>
     77         | == | != | <= | >= | > | <
     78         | && | || | ^^
     79         | & | | | --> | <--> | ^
     80}}}
     81
     82{{{
     83unary-op ::= + | - | ! | ~ | * | &
     84}}}
     85
     86{{{
     87term ::= literal | id | unary-op term | term bin-op term | term [ term ]
     88       | { term \with [ term ] = term }
     89       | term . id
     90       | {term \with.id =term }
     91       | term -> id
     92       | ( type-expr ) term
     93       | id ( term (, term)∗ )
     94       | (term)
     95       | term ? term : term
     96       | \let id = term ; term sizeof ( term )
     97       | sizeof ( C-type-name )
     98       | id : term
     99       | string : term
     100}}}
     101
     102
     103==  Contracts for Sequential Programs ==
    11104Sequential contracts are based on the theory of Hoare Logic. Contracts only state sequential properties on either
    12105the pre-state or post-state of the given procedure. All sequential contract constructors are inherited from ACLS, CIVL will start