Skip to content

Commit 278370d

Browse files
Merge pull request #71 from mgerrard/english_edits
English edits
2 parents 78dc1dd + 266a8be commit 278370d

27 files changed

Lines changed: 875 additions & 843 deletions

english/acsl-logic-definitions.tex

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
specification and, more importantly, proof. On one hand they force some
1111
properties to be more abstract when an explicit modeling would involve too much
1212
computation during proof. On the other hand, they force some properties to be
13-
explicitly modeled when they are harder to reason about when they are implicit.
14-
15-
Using these notions, we expose ourselves to the possibility to make our
16-
proof irrelevant if we make mistakes writing specification with it. Inductive
17-
predicates and axiomatic definitions involve the risk to introduce ``false'' in
18-
our assumptions, or to write imprecise definitions. Ghost code, if it does not
19-
verify some properties, opens the risk to silently modify the verified program
13+
explicitly modeled when they are harder to reason about if they were
14+
to be left implicit.
15+
16+
Using these notions, we expose ourselves to the possibility of making our
17+
proof irrelevant if we make mistakes writing specifications with it. Inductive
18+
predicates and axiomatic definitions involve the risk of introducing ``false'' in
19+
our assumptions, or of writing imprecise definitions. Ghost code, if it does not
20+
verify some properties, opens the risk of silently modifying the verified program
2021
\ldots{} making us prove another program, which is not the one we want to prove.
2122

2223

@@ -46,11 +47,11 @@
4647

4748

4849
In this part, we have covered some advanced constructions of the ACSL
49-
language that allow to express and prove more complex properties about
50+
language that allow us to express and prove more complex properties about
5051
programs.
5152

52-
Badly used, these features can make our analyses incorrect, we then need
53+
Badly used, these features can make our analyses incorrect, so we need
5354
to be careful manipulating them and not hesitate to check them again and
54-
again, or possibly express properties to verify about them to assure us
55+
again, or possibly express properties to verify about them to assure ourselves
5556
that we are not introducing an incoherence in our program or our
5657
assumptions.

english/acsl-logic-definitions/axiomatic.tex

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
a good way to state complex properties that will allow the proof process
33
to be more efficient by abstracting their complexity. Of course, as any
44
property expressed as an axiom is assumed to be true, we have to be very
5-
careful when we use them to defined properties: if we introduce a false
5+
careful when we use them to define properties: if we introduce a false
66
property in our assumptions, ``false'' becomes ``true'' and we can then
77
prove anything.
88

@@ -26,7 +26,7 @@
2626
axiom other_axiom_name { Label0, ..., LabelM }:
2727
// property ;
2828

29-
// ... we can put as many axioms we need
29+
// ... we can put as many axioms as we need
3030
}
3131
*/
3232
\end{CodeBlock}
@@ -63,11 +63,11 @@
6363

6464

6565

66-
Lemmas and axioms allows to express the same kinds of properties.
67-
Namely, properties expressed about quantified variables (and possibly
68-
global variables, but it is quite rare since it is often difficult to
66+
Lemmas and axioms allows us to express the same kinds of properties.
67+
Namely, they express properties about quantified variables (and possibly
68+
global variables, but this is quite rare since it is often difficult to
6969
find a global property about such variables being both true and
70-
interesting). Apart this first common point, we can also notice that
70+
interesting). In addition to this first common point, we can also notice that
7171
when we are not considering the definition of the lemma itself, lemmas
7272
are assumed to be true by WP exactly as axioms are.
7373

@@ -89,8 +89,8 @@
8989

9090

9191

92-
The idea is then not to define directly the function or the predicate
93-
but to declare it and then to define axioms that specify its
92+
The idea is to avoid defining the function or the predicate
93+
directly; instead we should declare it and then define axioms that specify its
9494
behavior. If we come back to the factorial function, we can define it
9595
axiomatically as follows:
9696

@@ -114,18 +114,18 @@
114114

115115
In this axiomatic definition, our function does not have a body. Its
116116
behavior is only defined by the axioms we have stated about it.
117-
Except this, nothing changes, in particular the logic function can
117+
Apart from this, nothing changes, in particular the logic function can
118118
be used in our specification just as before.
119119

120120

121121

122122
A small subtlety that we must take care of is the fact that if some
123-
axioms state properties about the content of some pointed memory cells,
124-
we have to specify considered memory blocks using the \CodeInline{reads}
123+
axioms state properties about the content of some pointed-to memory cells,
124+
we have to specify the memory blocks under consideration using the \CodeInline{reads}
125125
notation in the declaration. If we omit such a specification, the
126126
predicate or function will be considered to be stated about the received
127127
pointers and not about pointer memory blocks. So, if the code modifies
128-
the content of an array for which we had proven that the predicate or
128+
the contents of an array for which we had proven that the predicate or
129129
function gives some result, this result will not be considered to be
130130
potentially different.
131131

@@ -144,18 +144,18 @@
144144
Notice the \CodeInline{reads[b .. e-1]} that specifies the memory location
145145
on which the predicate depends. While it is not necessary to specify what are
146146
the memory locations read in an inductive definition, we have to specify such
147-
an information for axiomatically defined properties.
147+
information for axiomatically-defined properties.
148148

149149

150150
\levelThreeTitle{Consistency}
151151

152152

153153
By adding axioms to our knowledge base, we can produce more complex
154-
proofs since some part of these proofs, expressed by axioms, do not need
154+
proofs since some parts of these proofs, expressed by axioms, do not need
155155
to be proved (they are already specified to be true) shortening
156156
the proof process. However, using axiomatic definitions, \textbf{we must
157157
be extremely careful}. Indeed, even a small error could introduce false
158-
in the knowledge base, making our whole reasoning futile. Our reasoning
158+
into the knowledge base, making our whole reasoning futile. Our reasoning
159159
would still be correct, but relying on false knowledge, it would only
160160
learn incorrect things.
161161

@@ -169,7 +169,7 @@
169169

170170

171171

172-
And everything is proved, comprising the fact that the dereferencing of
172+
And everything is proved, including the fact that the dereferencing of
173173
0 is valid:
174174

175175

@@ -180,7 +180,7 @@
180180
Of course, this example is extreme, we would not write such an axiom.
181181
The problem is in fact that it is really easy to write an axiomatic
182182
definition that is subtly false when we express more complex properties,
183-
or adding assumptions about the global state of the system.
183+
or add assumptions about the global state of the system.
184184

185185

186186

@@ -190,11 +190,11 @@
190190

191191
When we start to create axiomatic definitions, it is worth adding
192192
assertions or postconditions requiring a proof of false that we expect
193-
to fail to ensure that the definition is not inconsistent. However, it
194-
is often not enough! If the subtlety that creates the inconsistency is
193+
to fail to ensure that the definition is not inconsistent. However,
194+
this is often not enough! If the subtlety that creates the inconsistency is
195195
hard enough to find, provers could need a lot of information other than
196196
the axiomatic definition itself to be able to find and use the
197-
inconsistency, we then need to always be careful!
197+
inconsistency, so we need to always be careful!
198198

199199

200200

@@ -223,19 +223,19 @@
223223

224224
Note that unlike inductive definitions, where Why3 provides us a way to control
225225
that what we write in ACSL is relatively well-defined, we do not have such a
226-
mechanism for axiomatic definitions. Basically, even with Why3 such a definition
226+
mechanism for axiomatic definitions. Basically, even with Why3, such a definition
227227
is translated into a list of axioms that are thus assumed.
228228

229229

230230
\levelThreeTitle{Cluster of axiomatic blocks}
231231

232232

233233
Most global annotations (logic functions, predicates, lemmas, ...) can be
234-
defined at two different levels: either at top-level, the level of the
234+
defined at two different levels: either at the top-level, i.e., the level of the
235235
functions, global variables, etc. (except for axioms and abstract functions and
236-
predicates) or in axiomatic blocks. While top-level global annotations (in
236+
predicates); or in axiomatic blocks. While top-level global annotations (in
237237
particular lemmas) are always embedded in the context of verification
238-
conditions, it is not the case for the annotations in axiomatic blocks.
238+
conditions, this is not the case for the annotations in axiomatic blocks.
239239

240240

241241
In the following example:
@@ -246,16 +246,16 @@
246246

247247
Since the \CodeInline{ensures} clause only uses \CodeInline{P} which is defined
248248
in the axiomatic block \CodeInline{X}, WP only loads the axiom \CodeInline{x}.
249-
On the opposite, if we replace \CodeInline{P(p)} with \CodeInline{Q(p)} in the
249+
On the other hand, if we replace \CodeInline{P(p)} with \CodeInline{Q(p)} in the
250250
\CodeInline{ensures} clause, WP loads the axiomatic block \CodeInline{Y}, thus
251251
the axiom \CodeInline{y} that uses \CodeInline{P}. Consequently, the axiomatic
252252
block \CodeInline{X} is loaded too. The transitive closure of the loaded
253253
axiomatic blocks forms a cluster of axiomatic definitions.
254254

255255

256256
One can use this behavior to avoid providing too many lemmas and axioms to SMT
257-
solvers. This can improve proof performances in some situations. We will present
258-
more details about how to guide proof using lemmas in
257+
solvers. This can improve proof performance in some situations. We will present
258+
more details about how to guide proofs using lemmas in
259259
Section~\ref{l2:proof-methodologies-triggering-lemmas}.
260260

261261

@@ -317,7 +317,7 @@
317317
manually proved lemmas, we can often add useful tools to provers to
318318
manipulate more efficiently our axiomatic definitions, without directly
319319
adding new axioms that would augment the chances to introduce errors.
320-
Here, we still have to realize the proof of the lemma to get a complete
320+
Here, we still have to carry out the proof of the lemma to get a complete
321321
proof.
322322

323323

@@ -344,13 +344,13 @@
344344

345345

346346
Basically, we want to receive a valid string in input, and we want to
347-
compute a value that equals to the result of our logic function
347+
compute a value that is equal to the result of our logic function
348348
\CodeInline{strlen} applied to this string, of course this function
349349
does not assign anything. Defining what is a valid string is not that
350350
simple. Indeed, previously in this tutorial, we only worked with
351-
arrays, receiving in input both the array and the size of the array,
352-
however here, and as it is common in C, we suppose that the string ends
353-
with a character \CodeInline{'\textbackslash{}0'}. That means that we
351+
arrays, receiving as input both the array and the size of the array,
352+
however here, as is common in C, we suppose that the string ends
353+
with the character \CodeInline{'\textbackslash{}0'}. That means that we
354354
basically need the \CodeInline{strlen} function to define what is a
355355
valid string. Let us first use this definition (note that we use the
356356
\CodeInline{\textbackslash{}valid\_read} variant of pointer validity
@@ -375,11 +375,11 @@
375375

376376
Thus, let us define this function axiomatically. First, let us define what
377377
is read by the function, which is: any memory cell from the pointer to an
378-
infinite range of address. Then we consider two cases: the string is
379-
finite, or it is not, that leads to two axioms: \CodeInline{strlen} returns
378+
infinite range of addresses. Then we consider two cases: the string is
379+
finite, or it is not, which leads to two axioms: \CodeInline{strlen} returns
380380
a positive value that corresponds to the index of the first
381381
\CodeInline{'\textbackslash{}0'} character, and returns a negative value if
382-
no such value exists.
382+
no such character exists.
383383

384384

385385

@@ -389,8 +389,8 @@
389389

390390
And now, we can be more precise for our definition of
391391
\CodeInline{\textbackslash{}valid\_read\_string}, a valid string is a
392-
string such that it is valid from the first index to \CodeInline{strlen}
393-
of the string and, such that this value is greater than 0 (since an
392+
string that is valid from the first index to \CodeInline{strlen}
393+
of the string, and whose value is nonnegative (since an
394394
infinite string is not a valid string):
395395

396396

@@ -402,14 +402,14 @@
402402

403403

404404
With this definition we can now go further and provide a suitable
405-
invariant to the loop of the \CodeInline{strlen} function. It is quite
406-
simple: \CodeInline{i} ranges between 0 and \CodeInline{strlen(s)}, for
407-
all values met before the iteration \CodeInline{i}, they are not
405+
invariant for the loop of the \CodeInline{strlen} function. This loop invariant is quite
406+
simple: \CodeInline{i} ranges between 0 and \CodeInline{strlen(s)}, and for
407+
all values met before iteration \CodeInline{i}, they are not
408408
\CodeInline{'\textbackslash{}0'}. This loop assigns \CodeInline{i} and
409409
the variant corresponds to the distance between \CodeInline{i} and
410410
\CodeInline{strlen(s)}. However, if we try to produce the proof of
411411
correctness of the function, it fails. And to get more information
412-
we can try a verification asking RTE with the verification that unsigned
412+
we can try a verification asking RTE to verify that unsigned
413413
integers do not overflow:
414414

415415

@@ -429,14 +429,14 @@
429429

430430

431431

432-
However, it is not enough, and the reason is that while we have defined
433-
that the value of \CodeInline{strlen(s)} is defined to be the index of
432+
However, this is not enough, and the reason is that while we have defined
433+
the value of \CodeInline{strlen(s)} to be the index of
434434
the first \CodeInline{'\textbackslash{}0'} in the array, the converse is
435435
not true: knowing that the value of \CodeInline{strlen(s)} is positive
436436
is not enough to deduce that the value at the corresponding index is
437437
\CodeInline{'\textbackslash{}0'}. Thus, we extend the axiomatic definition
438438
with another proposition that gives us this fact (we also add one for the
439-
values that precede the \CodeInline{strlen(s)} index even if here, it is
439+
values that precede the \CodeInline{strlen(s)} index, even if this is
440440
not necessary):
441441

442442

@@ -450,8 +450,8 @@
450450
library headers, and they include an
451451
axiomatic definition for the \CodeInline{strlen} logic function. It can
452452
be found in the installation directory of Frama-C, under the directory
453-
\CodeInline{libc}, the file is named \CodeInline{\_\_fc\_string\_axiomatic.h}.
454-
Note that this definition include more axioms in order to be able to
453+
\CodeInline{share/libc}, the file is named \CodeInline{\_\_fc\_string\_axiomatic.h}.
454+
Note that this definition includes more axioms in order to be able to
455455
deduce more properties about \CodeInline{strlen}.
456456

457457

@@ -469,15 +469,15 @@
469469
\CodeBlockInput[18][30]{c}{ex-1-occurrences_of.c}
470470

471471

472-
Re-express the axiomatic definition in a form that allows to prove the
472+
Re-express the axiomatic definition in a form that allows you to prove the
473473
program.
474474

475475

476476
\levelFourTitle{Greatest Common Divisor}
477477

478478

479-
Express the logic function that allows to compute the greatest common divisor as
480-
an axiomatic definition, write the contract of the \CodeInline{gcd} function and
479+
Express the logic function that allows you to compute the greatest common divisor as
480+
an axiomatic definition. Write the contract of the \CodeInline{gcd} function and
481481
prove it:
482482

483483

@@ -487,7 +487,7 @@
487487
\levelFourTitle{Sum of the N first integers}
488488

489489

490-
Express the logic function that allows to compute the sum of the N first
490+
Express the logic function that allows you to compute the sum of the N first
491491
integers as an axiomatic definition. Write the contract of the following
492492
\CodeInline{sum\_n} function and prove it:
493493

@@ -498,7 +498,7 @@
498498
\levelFourTitle{Permutation}
499499

500500

501-
Take back the example about selection sort
501+
Let's take another look at the example about selection sort
502502
(section~\ref{l3:acsl-logic-definitions-inductive-sort}). Re-express the
503503
permutation predicate using an axiomatic definition. Take care of the
504504
\CodeInline{reads} clause (in particular, note that the predicate relates

0 commit comments

Comments
 (0)