Skip to content

Commit 78a96c3

Browse files
author
Remi Delmas
committed
CONTRACTS: documentation fixes
1 parent 283d820 commit 78a96c3

9 files changed

+31
-42
lines changed

src/goto-instrument/contracts/doc/developer/contracts-dev-spec-contract-replacement.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ret_t foo(foo_params, write_set_t caller_write_set) {
3535
__CPROVER_contracts_write_set_ptr_t requires_write_set;
3636
__CPROVER_contracts_write_set_create(requires_write_set, 0, 0);
3737
38-
// assume requires clauses
38+
// assert requires clauses
3939
assert(contract::requires(foo_params, requires_write_set));
4040
assert(contract::requires_contract(foo_params, requires_write_set));
4141

src/goto-instrument/contracts/doc/developer/contracts-dev-spec-dfcc-runtime.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ typedef struct __CPROVER_contracts_car_set_t
4141
__CPROVER_contracts_car_t *elems;
4242
} __CPROVER_contracts_car_set_t;
4343
```
44-
The allocated size of si set is determined by the maximym number of targets
44+
The allocated size of a set is determined by the maximum number of targets
4545
found in the assigns clause of the contract of interest.
4646

4747
Objects for which all bytes are assignable (or freeable) do not need to be

src/goto-instrument/contracts/doc/developer/contracts-dev-spec-dfcc.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Back to top @ref contracts-dev-spec
77
## Overview
88
Frame condition checking consists in checking that a function (and any
99
functions it calls) only assigns to memory locations allowed by the contract's
10-
assigns clause, and only deallocates objects allowed by the contract frees
10+
assigns clause, and only deallocates objects allowed by the contract's frees
1111
clause.
1212

1313
To implement frame condition checking we use a method inspired by
@@ -24,7 +24,7 @@ The method consists in:
2424
In our approach a dynamic frame is represented by the
2525
@ref __CPROVER_contracts_write_set_t data type defined in @ref cprover_contracts.c.
2626

27-
From an simplified point of view, a @ref __CPROVER_contracts_write_set_t
27+
From an simple point of view, a @ref __CPROVER_contracts_write_set_t
2828
tracks 4 sets of memory locations:
2929

3030
```c
@@ -51,7 +51,7 @@ struct __CPROVER_contracts_write_set_t {
5151
of the contract of interest;
5252
- `allocated` is the set of identifiers of objects
5353
(as given by `__CPROVER_POINTER_OBJECT(x)`) that were locally allocated
54-
since first entering the function under verification
54+
since first entering the function under verification
5555
(on the stack using `DECL x` or on the heap using
5656
`x = __CPROVER_allocate(...)`);
5757
- `deallocated` is the set of pointers `p` that were deallocated using
@@ -64,14 +64,14 @@ allowing to (cf @ref cprover_contracts.c):
6464
- add contents to `contract_frees`;
6565
- record an object allocation in `allocated`;
6666
- record an object deallocation in `deallocated`;
67-
- check wether a given `car_t` is contained within `contract_assigns` or
68-
`allocated`;
69-
- check wether the object pointed to by a given pointer is contained in
70-
`contract_frees` or `allocated`;
67+
- check wether a given `car_t` describing a location about to be assigned is
68+
contained within `contract_assigns` or `allocated`;
69+
- check wether the object pointed to by a given pointer about to be freed is
70+
contained in `contract_frees` or `allocated`;
7171
- check weither all memory locations of a candidate write set are included in
72-
- some element of a given reference write set.
72+
some element of a given reference write set.
7373

74-
The instrumentation adds as @ref __CPROVER_contracts_write_set_ptr_t parameter
74+
The instrumentation adds a @ref __CPROVER_contracts_write_set_ptr_t parameter
7575
to all functions of the GOTO model as follows:
7676

7777
```c
@@ -81,7 +81,7 @@ ret_t f(<original-parameters>, __CPROVER_contracts_write_set_ptr_t write_set);
8181
The bodies of the functions are instrumented so that:
8282
- when the given `write_set` is `NULL`, no checks are performed;
8383
- when the given `write_set` is not `NULL`, the following checks are performed:
84-
- The address range corresponding to the LHS of assignments instructions are
84+
- The address ranges corresponding to the LHS of assignments instructions are
8585
checked for inclusion in `contract_assigns` or `allocated`;
8686
- stack-allocated objects (`DECL`) and heap-allocated objects
8787
(`__CPROVER_allocate`) are recorded in `allocated`

src/goto-instrument/contracts/doc/developer/contracts-dev-spec-reminder.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Back to top @ref contracts-dev-spec
55
@tableofcontents
66

77
The user documentation for function contracts is available at @ref contracts-functions,
8-
but we briefly remind the structure of a contract below.
8+
but we briefly remind the developer of the structure of a contract below.
99

1010

1111
A contract is defined by adding one or more clauses to a function declaration or
@@ -34,7 +34,7 @@ __CPROVER_frees(F)
3434
- A `__CPROVER_requires_contract` clause clause specifies the precondition that
3535
a function pointer expression P satisfies a contract C, where P may only
3636
depend on program globals and function parameters;
37-
- A `__CPROVER_ensures clause (@ref contracts-requires-ensures) specifies a
37+
- A `__CPROVER_ensures` clause (@ref contracts-requires-ensures) specifies a
3838
postcondition as boolean expression E that may only depend on program globals,
3939
function parameters, [memory predicates](@ref contracts-memory-predicates),
4040
deterministic, side effect-free function calls,
@@ -60,4 +60,4 @@ symbol. We call `contract::foo` the **pure contract** associated with the functi
6060
---
6161
Prev | Next
6262
:-----|:------
63-
@ref contracts-dev-spec | @ref contracts-dev-spec-transfo-params
63+
@ref contracts-dev-spec | @ref contracts-dev-spec-transform-params

src/goto-instrument/contracts/doc/developer/contracts-dev-spec-spec-rewriting.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ declaratively by calling special built-ins from regular C functions,
99
as described in @ref contracts-assigns and @ref contracts-frees.
1010

1111
Such functions require a rewriting pass in order to turn them into active
12-
functions that can effectivel populate a write set with new targets.
12+
functions that can effectively populate a write set with new targets.
1313

1414
## Rewriting Assigns Clause Functions {#contracts-dev-spec-spec-rewriting-assigns}
1515

@@ -20,10 +20,10 @@ signature:
2020
void foo(parameter-list);
2121
```
2222
23-
They can have been generated from an assigns clause or written by the user.
23+
They can be generated from an assigns clause or written by the user.
2424
25-
To convert them to active functions, the first step is to inline their body to
26-
remove all function calls to check the result to be loop free.
25+
To convert them to active functions, the first step is to inline their body and
26+
remove all function calls, the result of which must be loop-free.
2727
2828
Then, a second pass adds the write set to be filled as new parameter to the
2929
function:
@@ -95,10 +95,10 @@ signature:
9595
void foo(parameter-list);
9696
```
9797

98-
They can have been generated from an assigns clause or written by the user.
98+
They can be generated from an assigns clause or written by the user.
9999

100-
To convert them to havoc functions, the first step is to inline their body to
101-
remove all function calls to check the result to be loop free.
100+
To convert them to havoc functions, the first step is to inline their body and
101+
remove all function calls, the result of which must be loop-free.
102102

103103
Then, a second pass adds the write set to be havoced as new parameter to the
104104
function:

src/goto-instrument/contracts/doc/developer/contracts-dev-spec-transfo-params.md renamed to src/goto-instrument/contracts/doc/developer/contracts-dev-spec-transform-params.md

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
1-
# Program Transformation Overview {#contracts-dev-spec-transfo-params}
1+
# Program Transformation Overview {#contracts-dev-spec-transform-params}
22

33
Back to top @ref contracts-dev-spec
44

55
@tableofcontents
66

7-
The program transformation takes the following parameters:
7+
These are the main parameter of the program transformation:
88

9-
```
10-
goto-instrument --dfcc harness [--enforce-contract f_top/c_top] (--replace-with-contract f/c)* in.gb out.gb
11-
```
12-
13-
Where:
14-
- `--dfcc harness` specifies the identifier of the proof harness;
15-
- `--enforce-contract f_top/c_top` specifies is optional and specifies that
9+
- `harness_id` specifies the identifier of the proof harness;
10+
- `(f_top,c_top)` an optional pair and specifies that
1611
the function `f_top` must be checked against the contract carried by function
17-
`c_top`, by the pure contract `contract::c_top`. The contract `/c_top` can be
18-
omitted in which case it is assumed that `f_top` needs to be checked against
19-
its own contract `contract::f_top`;
20-
- `--replace-call-with-contract f/c` specifies that function `f` must be replaced
12+
`c_top`, by the pure contract `contract::c_top`.
13+
- `(f,c)` a possibly empty set of pairs where each `f` must be replaced
2114
with the contract carried by function `c`, i.e. by the pure contract `contract::c`.
22-
The contract `/c` can be omitted in which case it is assumed that `f` needs to
23-
be replaced by its own contract `contract::f`;
2415

2516
The program transformation steps are applied as follows:
2617
1. @ref contracts-dev-spec-codegen is applied to all contracts to check or replace;
@@ -29,8 +20,6 @@ The program transformation steps are applied as follows:
2920
4. @ref contracts-dev-spec-contract-checking is applied to the function to be checked against a contract;
3021
5. @ref contracts-dev-spec-contract-replacement is applied to each function to be replaced by a contract;
3122

32-
33-
3423
---
3524
Prev | Next
3625
:-----|:------

src/goto-instrument/contracts/doc/developer/contracts-dev-spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The program transformation specification is broken down in the following
66
sections:
77

88
1. @subpage contracts-dev-spec-reminder
9-
2. @subpage contracts-dev-spec-transfo-params
9+
2. @subpage contracts-dev-spec-transform-params
1010
3. @subpage contracts-dev-spec-codegen
1111
4. @subpage contracts-dev-spec-spec-rewriting
1212
5. @subpage contracts-dev-spec-dfcc

src/goto-instrument/contracts/doc/user/contracts-assigns.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ target ::= lvalue-expr
2626
```
2727
2828
The set of locations writable by a function is the union of the sets of locations
29-
specified by its assigns clauses, or the empty set of no _assigns_ clause is
29+
specified by its assigns clauses, or the empty set if no _assigns_ clause is
3030
specified.
3131
While, in general, an _assigns_ clause could be interpreted with either
3232
_writes_ or _modifies_ semantics, this design is based on the former.

src/goto-instrument/contracts/doc/user/contracts-cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Where:
1818
The program transformation takes the following parameters:
1919

2020
```
21-
goto-instrument --dfcc harness [--enforce-contract f] (--replace-with-contract g)* [--apply-loop-contracts] in.gb out.gb
21+
goto-instrument --dfcc harness [--enforce-contract f] (--replace-call-with-contract g)* [--apply-loop-contracts] in.gb out.gb
2222
```
2323

2424
Where:

0 commit comments

Comments
 (0)