Skip to content

Commit b1893fd

Browse files
1 parent 5b99c86 commit b1893fd

File tree

13 files changed

+406
-69
lines changed

13 files changed

+406
-69
lines changed

refman/_sources/tactics/proc.rst.txt

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
========================================================================
2-
Tactic: ``proc``
2+
Tactic: `proc`
33
========================================================================
44

5-
The ``proc`` tactic applies to program-logic goals where the procedure(s)
5+
The `proc` tactic applies to program-logic goals where the procedure(s)
66
under consideration are referred to by name rather than content. It is
77
typically the first tactic applied when reasoning about procedure calls
88
or top level program logic statements.
99

10-
There are two variants of the ``proc`` tactic, depending on whether the
10+
There are two variants of the `proc` tactic, depending on whether the
1111
procedure(s) in question are abstract (i.e., declared but not defined)
1212
or concrete (i.e., defined with a body of code).
1313

1414
The abstract variant is a bit different for probabilistic relational
1515
Hoare logic compared to the other program logics, so we describe it
16-
separately.
16+
separately. When one of the two procedures is abstract and the other is
17+
concrete the :ref:`proc* <procstar-tactic>` tactic can be used instead.
1718

1819
.. contents::
1920
:local:
@@ -24,9 +25,9 @@ Variant: Concrete procedure(s)
2425

2526
.. admonition:: Syntax
2627

27-
``proc``
28+
`proc`
2829

29-
The ``proc`` tactic, when applied to concrete procedures, unfolds the
30+
The `proc` tactic, when applied to concrete procedures, unfolds the
3031
procedure definition(s) at hand, replacing the procedure call(s)
3132
with the body(ies) of the corresponding procedure(s). The proof goal is
3233
then updated accordingly.
@@ -87,9 +88,9 @@ Variant: Abstract procedure (non-relational)
8788

8889
.. admonition:: Syntax
8990

90-
``proc {formulaI}``
91+
`proc {formulaI}`
9192

92-
Here, ``{formulaI}`` is an invariant that should be preserved by the
93+
Here, `{formulaI}` is an invariant that should be preserved by the
9394
procedure. The invariant can refer to global variables not being modified
9495
by the procedure. To ensure that variables of interest cannot be modified,
9596
it may be necessary to add restrictions to the module type of the abstract procedure, specifying which globals are not accessed.
@@ -229,34 +230,34 @@ of the procedure under consideration.
229230
Variant: Abstract procedure (relational)
230231
------------------------------------------------------------------------
231232

232-
The relational variant of the ``proc`` tactic for abstract procedures
233+
The relational variant of the `proc` tactic for abstract procedures
233234
requires both procedures to be the same, though their module arguments
234235
may differ.
235236

236237
.. admonition:: Syntax
237238

238-
- ``proc {formulaI}``
239-
- ``proc {formulaB} {formulaI}``
240-
- ``proc {formulaB} {formulaI} {formulaJ}``
239+
- `proc {formulaI}`
240+
- `proc {formulaB} {formulaI}`
241+
- `proc {formulaB} {formulaI} {formulaJ}`
241242

242243
Here:
243244

244-
- ``{formulaI}`` is a two-sided invariant that should be preserved by the
245+
- `{formulaI}` is a two-sided invariant that should be preserved by the
245246
pair of procedures.
246-
- ``{formulaB}`` is an optional formula representing a bad event on the
247+
- `{formulaB}` is an optional formula representing a bad event on the
247248
right side after which the invariant need no longer hold.
248-
- ``{formulaJ}`` is an optional formula representing the invariant after
249-
the bad event has occurred. This is optional even if ``{formulaB}`` is
250-
provided; in which case the invariant is taken to be ``true`` after the
249+
- `{formulaJ}` is an optional formula representing the invariant after
250+
the bad event has occurred. This is optional even if `{formulaB}` is
251+
provided; in which case the invariant is taken to be `true` after the
251252
bad event.
252253

253254
The tactic can be thought of as keeping both procedures in sync using
254-
``{formulaI}`` until the bad event ``{formulaB}`` occurs on the right
255-
side, after which they are no longer kept in sync. Instead ``{formulaJ}``
255+
`{formulaI}` until the bad event `{formulaB}` occurs on the right
256+
side, after which they are no longer kept in sync. Instead `{formulaJ}`
256257
is then preserved by the left and right procedures individually, no matter
257258
the order in which the two sides make progress.
258259

259-
When only ``{formulaI}`` is provided, the tactic works similarly to the
260+
When only `{formulaI}` is provided, the tactic works similarly to the
260261
non-relational variants, generating proof obligations to ensure that
261262
the invariant, equality of the globals of the module containing the
262263
procedure and equality of arguments holds and that equality of the
@@ -314,30 +315,30 @@ and yield equal results when called on equal arguments.
314315
(* Procedure g2 preserves invariant *)
315316
abort.
316317
317-
When ``{formulaB}`` and ``{formulaJ}`` are provided, the equality of
318-
arguments, results, globals and ``{formulaI}`` obligations are modified to
318+
When `{formulaB}` and `{formulaJ}` are provided, the equality of
319+
arguments, results, globals and `{formulaI}` obligations are modified to
319320
only hold/need to hold conditional on the bad event not having occurred on
320321
the right side. When the bad event has occurred, we instead require that
321-
``{formulaJ}`` holds without any additional equality requirements. Since
322+
`{formulaJ}` holds without any additional equality requirements. Since
322323
the behavior of the two sides is no longer synchronized after the bad
323324
event, an obligation is generated to ensure that the procedure is lossless
324325
when the procedures in its module arguments are lossless, to avoid the
325326
weights diverging after the bad event.
326327

327328
For every procedure of every module argument to the abstract procedure on
328329
the left, an additional proof obligation is generated to ensure that the
329-
when the bad event has happened and ``{formulaJ}`` holds for some right
330+
when the bad event has happened and `{formulaJ}` holds for some right
330331
memory, then it is guaranteed to still hold for that right memory after
331332
running the procedure of the argument on the left. Similarly, for every
332333
procedure of every module argument to the abstract procedure on the right,
333334
an additional proof obligation is generated to ensure that when the bad
334-
event has happened and ``{formulaJ}`` holds for some left memory, then the
335-
bad event on the right and the two-sided invariant ``{formulaJ}`` is
335+
event has happened and `{formulaJ}` holds for some left memory, then the
336+
bad event on the right and the two-sided invariant `{formulaJ}` is
336337
guaranteed to still hold for the left memory after running the procedure
337338
of the argument on the right.
338339

339340
If you want the bad event to be on the left side instead, you can swap the
340-
two programs using the ``sym`` tactic before applying ``proc``.
341+
two programs using the `sym` tactic before applying `proc`.
341342

342343
.. ecproof::
343344
:title: Probabilistic Relational Hoare logic example with bad event
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
.. _procstar-tactic:
2+
========================================================================
3+
Tactic: `proc*`
4+
========================================================================
5+
6+
The `proc*` tactic applies to program-logic goals where the procedure(s)
7+
under consideration are referred to by name rather than content.
8+
9+
It replaces the procedure(s) with a statement calling that procedure.
10+
This is useful, for example, when the goal is relational, but one of
11+
the two procedures is abstract, while the other is concrete.
12+
In that case no variant of `proc` can be applied, but `proc*` can,
13+
after which things like inlining the concrete procedure can be
14+
used to make progress.
15+
16+
.. admonition:: Syntax
17+
18+
`proc*`
19+
20+
.. ecproof::
21+
:title: Hoare logic example
22+
23+
require import AllCore.
24+
25+
module M = {
26+
proc f(x : int) = {
27+
x <- x + 1;
28+
x <- x * 2;
29+
return x;
30+
}
31+
}.
32+
33+
pred p : int.
34+
pred q : int.
35+
36+
lemma L : hoare[M.f : p x ==> q res].
37+
proof.
38+
(*$*) proc*.
39+
abort.
40+
41+
.. ecproof::
42+
:title: Probabilistic relational Hoare logic example
43+
44+
require import AllCore.
45+
46+
module M1 = {
47+
proc f(x : int) = {
48+
x <- x + 1;
49+
x <- x * 2;
50+
return x;
51+
}
52+
}.
53+
54+
module M2 = {
55+
proc f(x : int) = {
56+
x <- x * 10;
57+
x <- x - 3;
58+
return x;
59+
}
60+
}.
61+
62+
pred p : int & int.
63+
pred q : int & int.
64+
65+
lemma L : equiv[M1.f ~ M2.f : p x{1} x{2} ==> q res{1} res{2}].
66+
proof.
67+
(*$*) proc*.
68+
abort.

refman/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ <h1>EasyCrypt reference manual<a class="headerlink" href="#easycrypt-reference-m
8181
<li class="toctree-l1"><a class="reference internal" href="tactics.html">Proof tactics reference</a><ul>
8282
<li class="toctree-l2"><a class="reference internal" href="tactics/clear.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">clear</span></code></a></li>
8383
<li class="toctree-l2"><a class="reference internal" href="tactics/if.html">Tactic: <code class="docutils literal notranslate"><span class="pre">if</span></code></a></li>
84-
<li class="toctree-l2"><a class="reference internal" href="tactics/proc.html">Tactic: <code class="docutils literal notranslate"><span class="pre">proc</span></code></a></li>
84+
<li class="toctree-l2"><a class="reference internal" href="tactics/proc.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">proc</span></code></a></li>
85+
<li class="toctree-l2"><a class="reference internal" href="tactics/procstar.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">proc</span><span class="o">*</span></code></a></li>
8586
<li class="toctree-l2"><a class="reference internal" href="tactics/skip.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">skip</span></code></a></li>
8687
<li class="toctree-l2"><a class="reference internal" href="tactics/splitwhile.html">Tactic: <code class="docutils literal notranslate"><span class="pre">splitwhile</span></code> Tactic</a></li>
8788
<li class="toctree-l2"><a class="reference internal" href="tactics/swap.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">swap</span></code></a></li>

refman/objects.inv

37 Bytes
Binary file not shown.

refman/searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

refman/tactics.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
<li class="toctree-l1 current"><a class="current reference internal" href="#">Proof tactics reference</a><ul>
5252
<li class="toctree-l2"><a class="reference internal" href="tactics/clear.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">clear</span></code></a></li>
5353
<li class="toctree-l2"><a class="reference internal" href="tactics/if.html">Tactic: <code class="docutils literal notranslate"><span class="pre">if</span></code></a></li>
54-
<li class="toctree-l2"><a class="reference internal" href="tactics/proc.html">Tactic: <code class="docutils literal notranslate"><span class="pre">proc</span></code></a></li>
54+
<li class="toctree-l2"><a class="reference internal" href="tactics/proc.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">proc</span></code></a></li>
55+
<li class="toctree-l2"><a class="reference internal" href="tactics/procstar.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">proc</span><span class="o">*</span></code></a></li>
5556
<li class="toctree-l2"><a class="reference internal" href="tactics/skip.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">skip</span></code></a></li>
5657
<li class="toctree-l2"><a class="reference internal" href="tactics/splitwhile.html">Tactic: <code class="docutils literal notranslate"><span class="pre">splitwhile</span></code> Tactic</a></li>
5758
<li class="toctree-l2"><a class="reference internal" href="tactics/swap.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">swap</span></code></a></li>
@@ -89,7 +90,8 @@ <h1>Proof tactics reference<a class="headerlink" href="#proof-tactics-reference"
8990
<ul>
9091
<li class="toctree-l1"><a class="reference internal" href="tactics/clear.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">clear</span></code></a></li>
9192
<li class="toctree-l1"><a class="reference internal" href="tactics/if.html">Tactic: <code class="docutils literal notranslate"><span class="pre">if</span></code></a></li>
92-
<li class="toctree-l1"><a class="reference internal" href="tactics/proc.html">Tactic: <code class="docutils literal notranslate"><span class="pre">proc</span></code></a></li>
93+
<li class="toctree-l1"><a class="reference internal" href="tactics/proc.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">proc</span></code></a></li>
94+
<li class="toctree-l1"><a class="reference internal" href="tactics/procstar.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">proc</span><span class="o">*</span></code></a></li>
9395
<li class="toctree-l1"><a class="reference internal" href="tactics/skip.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">skip</span></code></a></li>
9496
<li class="toctree-l1"><a class="reference internal" href="tactics/splitwhile.html">Tactic: <code class="docutils literal notranslate"><span class="pre">splitwhile</span></code> Tactic</a></li>
9597
<li class="toctree-l1"><a class="reference internal" href="tactics/swap.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">swap</span></code></a></li>

refman/tactics/clear.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
<li class="toctree-l1 current"><a class="reference internal" href="../tactics.html">Proof tactics reference</a><ul class="current">
5252
<li class="toctree-l2 current"><a class="current reference internal" href="#">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">clear</span></code></a></li>
5353
<li class="toctree-l2"><a class="reference internal" href="if.html">Tactic: <code class="docutils literal notranslate"><span class="pre">if</span></code></a></li>
54-
<li class="toctree-l2"><a class="reference internal" href="proc.html">Tactic: <code class="docutils literal notranslate"><span class="pre">proc</span></code></a></li>
54+
<li class="toctree-l2"><a class="reference internal" href="proc.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">proc</span></code></a></li>
55+
<li class="toctree-l2"><a class="reference internal" href="procstar.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">proc</span><span class="o">*</span></code></a></li>
5556
<li class="toctree-l2"><a class="reference internal" href="skip.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">skip</span></code></a></li>
5657
<li class="toctree-l2"><a class="reference internal" href="splitwhile.html">Tactic: <code class="docutils literal notranslate"><span class="pre">splitwhile</span></code> Tactic</a></li>
5758
<li class="toctree-l2"><a class="reference internal" href="swap.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">swap</span></code></a></li>

refman/tactics/if.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
<li class="toctree-l3"><a class="reference internal" href="#variant-if-ehl">Variant: <code class="docutils literal notranslate"><span class="pre">if</span></code> (eHL)</a></li>
5959
</ul>
6060
</li>
61-
<li class="toctree-l2"><a class="reference internal" href="proc.html">Tactic: <code class="docutils literal notranslate"><span class="pre">proc</span></code></a></li>
61+
<li class="toctree-l2"><a class="reference internal" href="proc.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">proc</span></code></a></li>
62+
<li class="toctree-l2"><a class="reference internal" href="procstar.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">proc</span><span class="o">*</span></code></a></li>
6263
<li class="toctree-l2"><a class="reference internal" href="skip.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">skip</span></code></a></li>
6364
<li class="toctree-l2"><a class="reference internal" href="splitwhile.html">Tactic: <code class="docutils literal notranslate"><span class="pre">splitwhile</span></code> Tactic</a></li>
6465
<li class="toctree-l2"><a class="reference internal" href="swap.html">Tactic: <code class="code highlight easycrypt docutils literal highlight-easycrypt"><span class="kr">swap</span></code></a></li>

0 commit comments

Comments
 (0)