Skip to content

Commit b1e5f06

Browse files
committed
make \ecinput macro a bit more robust
1 parent b46d5c2 commit b1e5f06

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+793
-785
lines changed

common/easycrypt-common.tex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848
{\lstset{language=easycrypt,float=tp,caption={#2},label={#3},#1}}%
4949
{}
5050

51-
\newcommand{\ecinput}[5][]%
52-
{\lstinputlisting[language=easycrypt,linerange={#4},caption={#3},label={#5},#1]{#2}}
51+
\newcommand{\ecinput}[2][]%
52+
{\lstinputlisting[language=easycrypt,#1]{#2}}
5353

54-
\newcommand{\ecinputfloat}[4]%
55-
{\lstinputlisting[language=easycrypt,float=tp,linerange={#3},caption={#2},label={#4}]{#1}}
54+
\newcommand{\ecinputfloat}[1]%
55+
{\lstinputlisting[language=easycrypt,float=tp]{#1}}
5656

5757
\def\ls{\lstinline}
5858
\def\ec#1{\lstinline[language=easycrypt-math]"#1"}

refman/Makefile

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,34 @@
33
# --------------------------------------------------------------------
44
.PHONY: all clean __force__
55

6-
LATEXMK := latexmk -bibtex -output-directory=_build -silent
6+
EXTRAMK ?=
7+
LATEXMK := latexmk -bibtex -auxdir=_build -silent
78
LATEXMK += -latex="latex --shell-escape %O %S"
89
LATEXMK += -pdflatex="pdflatex --shell-escape %O %S"
9-
LATEXMK += -synctex=1
10+
LATEXMK += -synctex=1 -halt-on-error -interaction=nonstopmode
11+
LATEXMK += $(EXTRAMK)
1012
LATEXKO :=
11-
EXTRAMK ?=
12-
ITMODE ?= errorstopmode
13-
LINKS := log synctex.gz
1413
MAIN := refman
1514

1615
ifneq (${DRAFT},)
1716
LATEXMK += -e '$$max_repeat = 1'
1817
LATEXKO += -
1918
endif
2019

21-
LATEXMK += -interaction=$(ITMODE) $(EXTRAMK)
22-
2320
export TEXINPUTS := ../common:.:${TEXINPUTS}
2421

2522
# --------------------------------------------------------------------
26-
.PHONY: all links force scratch clean purge __force__
23+
.PHONY: all force scratch clean
2724

28-
define latex
29-
$(LATEXMK) -pdf $* $(MAIN); err=$$?; \
30-
[ -f _build/$(MAIN).pdf ] && cp _build/$(MAIN).pdf .; \
31-
exit $$err
32-
endef
25+
all:
26+
$(LATEXKO)$(LATEXMK) -pdf $(MAIN)
3327

34-
all: prepare __force__
35-
$(LATEXKO)$(call latex)
28+
force:
29+
$(LATEXKO)$(LATEXMK) -pdf -g $(MAIN)
3630

37-
force: prepare __force__
38-
$(LATEXKO)$(call latex,-g)
39-
40-
prepare: __force__
41-
for i in $(LINKS); do ln -sf _build/$(MAIN).$$i .; done
42-
rm -f _build/$(MAIN).pdf
43-
44-
scratch: purge all
31+
scratch: clean all
4532
@true
4633

4734
clean:
48-
rm -rf _build/ $(LINKS:%=$(MAIN).%)
49-
50-
purge: clean
51-
rm -f $(MAIN).pdf
35+
latexmk -C $(MAIN)
36+
rm -rf _build/

refman/ambient-logic.tex

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -281,67 +281,67 @@ \subsection{Introduction and Generalization}
281281
equivalent to \rtactic{idtac}.
282282
In its simplest form, the introduction tactical simply gives names
283283
to assumptions. For example, if the current goal is
284-
\ecinput{examps/parts/tactics/introduction/1-1.0.ec}{}{}{}{}
284+
\ecinput{examps/parts/tactics/introduction/1-1.0.ec}
285285
then running
286-
\ecinput{examps/parts/tactics/introduction/1-1.ec}{}{}{}{}
286+
\ecinput{examps/parts/tactics/introduction/1-1.ec}
287287
produces
288-
\ecinput{examps/parts/tactics/introduction/1-1.1.ec}{}{}{}{}
288+
\ecinput{examps/parts/tactics/introduction/1-1.1.ec}
289289
Alternatively, we can use the introduction pattern \ec{?}
290290
to let \EasyCrypt choose the assumption names, using
291291
\ec{H} as a base for formula assumptions and starting
292292
from the identifier names given in universal quantifiers:
293-
\ecinput{examps/parts/tactics/introduction/2-1.ec}{}{}{}{}
293+
\ecinput{examps/parts/tactics/introduction/2-1.ec}
294294
produces
295-
\ecinput{examps/parts/tactics/introduction/2-1.1.ec}{}{}{}{}
295+
\ecinput{examps/parts/tactics/introduction/2-1.1.ec}
296296

297297
To see how the \ec{->} rewriting pattern works, suppose
298298
the current goal is
299-
\ecinput{examps/parts/tactics/introduction/4-1.0.ec}{}{}{}{}
299+
\ecinput{examps/parts/tactics/introduction/4-1.0.ec}
300300
Then running
301-
\ecinput{examps/parts/tactics/introduction/4-1.ec}{}{}{}{}
301+
\ecinput{examps/parts/tactics/introduction/4-1.ec}
302302
produces
303-
\ecinput{examps/parts/tactics/introduction/4-1.1.ec}{}{}{}{}
303+
\ecinput{examps/parts/tactics/introduction/4-1.1.ec}
304304
Alternatively, one can introduce the assumption \ec{x = y},
305305
and then use the \ec{->>} substitution pattern:
306306
if the current goal is
307-
\ecinput{examps/parts/tactics/introduction/8-1.0.ec}{}{}{}{}
307+
\ecinput{examps/parts/tactics/introduction/8-1.0.ec}
308308
then running
309-
\ecinput{examps/parts/tactics/introduction/8-1.ec}{}{}{}{}
309+
\ecinput{examps/parts/tactics/introduction/8-1.ec}
310310
produces
311-
\ecinput{examps/parts/tactics/introduction/8-1.1.ec}{}{}{}{}
311+
\ecinput{examps/parts/tactics/introduction/8-1.1.ec}
312312

313313
To see how a view may be applied to a not-yet-introduced formula
314314
assumption, suppose the current goal is
315-
\ecinput{examps/parts/tactics/introduction/5-1.0.ec}{}{}{}{}
315+
\ecinput{examps/parts/tactics/introduction/5-1.0.ec}
316316
Then running
317-
\ecinput{examps/parts/tactics/introduction/5-1.ec}{}{}{}{}
317+
\ecinput{examps/parts/tactics/introduction/5-1.ec}
318318
produces
319-
\ecinput{examps/parts/tactics/introduction/5-1.1.ec}{}{}{}{}
319+
\ecinput{examps/parts/tactics/introduction/5-1.1.ec}
320320
And then running
321-
\ecinput{examps/parts/tactics/introduction/5-2.ec}{}{}{}{}
321+
\ecinput{examps/parts/tactics/introduction/5-2.ec}
322322
on this goal produces
323-
\ecinput{examps/parts/tactics/introduction/5-2.1.ec}{}{}{}{}
323+
\ecinput{examps/parts/tactics/introduction/5-2.1.ec}
324324

325325
Finally, let's see examples of how a disjunction assumption
326326
may be destructed, either using the \ec{case} tactic followed
327327
by a case introduction pattern, or by making the
328328
case introduction pattern do the destruction.
329329
For the first case, if the current goal is
330-
\ecinput{examps/parts/tactics/introduction/6-1.0.ec}{}{}{}{}
330+
\ecinput{examps/parts/tactics/introduction/6-1.0.ec}
331331
then running
332-
\ecinput{examps/parts/tactics/introduction/6-1.ec}{}{}{}{}
332+
\ecinput{examps/parts/tactics/introduction/6-1.ec}
333333
produces the two goals
334-
\ecinput{examps/parts/tactics/introduction/6-1.1.ec}{}{}{}{}
334+
\ecinput{examps/parts/tactics/introduction/6-1.1.ec}
335335
and
336-
\ecinput{examps/parts/tactics/introduction/6-1.2.ec}{}{}{}{}
336+
\ecinput{examps/parts/tactics/introduction/6-1.2.ec}
337337
And for the second case, if the current goal is
338-
\ecinput{examps/parts/tactics/introduction/7-1.0.ec}{}{}{}{}
338+
\ecinput{examps/parts/tactics/introduction/7-1.0.ec}
339339
then running
340-
\ecinput{examps/parts/tactics/introduction/7-1.ec}{}{}{}{}
340+
\ecinput{examps/parts/tactics/introduction/7-1.ec}
341341
produces the two goals
342-
\ecinput{examps/parts/tactics/introduction/7-1.1.ec}{}{}{}{}
342+
\ecinput{examps/parts/tactics/introduction/7-1.1.ec}
343343
and
344-
\ecinput{examps/parts/tactics/introduction/7-1.2.ec}{}{}{}{}
344+
\ecinput{examps/parts/tactics/introduction/7-1.2.ec}
345345
Note how we used the clear pattern to discard the assumption
346346
\ec{X}.
347347
\end{tsyntax}
@@ -368,10 +368,10 @@ \subsection{Introduction and Generalization}
368368
generalizing the former.
369369

370370
For example, if the current goal is
371-
\ecinput{examps/parts/tactics/generalize/2-1.0.ec}{}{}{}{} then
372-
running \ecinput{examps/parts/tactics/generalize/2-1.ec}{}{}{}{}
371+
\ecinput{examps/parts/tactics/generalize/2-1.0.ec} then
372+
running \ecinput{examps/parts/tactics/generalize/2-1.ec}
373373
produces
374-
\ecinput{examps/parts/tactics/generalize/2-1.1.ec}{}{}{}{} In
374+
\ecinput{examps/parts/tactics/generalize/2-1.1.ec} In
375375
this example, one can't generalize \ec{x} without also
376376
generalizing \ec{eq_xy}.
377377

@@ -381,14 +381,14 @@ \subsection{Introduction and Generalization}
381381
universally quantified identifier of the approprate type.
382382

383383
For example, if the current goal is
384-
\ecinput{examps/parts/tactics/generalize/1-1.0.ec}{}{}{}{} then
385-
running \ecinput{examps/parts/tactics/generalize/1-1.ec}{}{}{}{}
384+
\ecinput{examps/parts/tactics/generalize/1-1.0.ec} then
385+
running \ecinput{examps/parts/tactics/generalize/1-1.ec}
386386
produces
387-
\ecinput{examps/parts/tactics/generalize/1-1.1.ec}{}{}{}{}
387+
\ecinput{examps/parts/tactics/generalize/1-1.1.ec}
388388
Alternatively, running
389-
\ecinput{examps/parts/tactics/generalize/3-1.ec}{}{}{}{}
389+
\ecinput{examps/parts/tactics/generalize/3-1.ec}
390390
produces
391-
\ecinput{examps/parts/tactics/generalize/3-1.1.ec}{}{}{}{}
391+
\ecinput{examps/parts/tactics/generalize/3-1.1.ec}
392392
\end{itemize}
393393
\end{tsyntax}
394394
\end{tactic}
@@ -444,10 +444,10 @@ \subsection{Tacticals}
444444
\ec{($\tau_1$; $\;\tau_2$); $\;\tau_3$}.
445445

446446
For example, if the current goal is
447-
\ecinput{examps/parts/tactics/sequence-tactical/1-1.0.ec}{}{}{}{} then
448-
running \ecinput{examps/parts/tactics/sequence-tactical/1-1.ec}{}{}{}{}
447+
\ecinput{examps/parts/tactics/sequence-tactical/1-1.0.ec} then
448+
running \ecinput{examps/parts/tactics/sequence-tactical/1-1.ec}
449449
produces the goals
450-
\ecinput{examps/parts/tactics/sequence-tactical/1-1.1.ec}{}{}{}{}
450+
\ecinput{examps/parts/tactics/sequence-tactical/1-1.1.ec}
451451
\end{tsyntax}
452452
\end{tactic}
453453

@@ -457,8 +457,8 @@ \subsection{Tacticals}
457457
Then apply $\tau'_i$ to $G_i$, for all $i$.
458458

459459
For example, if the current goal is
460-
\ecinput{examps/parts/tactics/sequence-branching-tactical/1-1.0.ec}{}{}{}{} then
461-
running \ecinput{examps/parts/tactics/sequence-branching-tactical/1-1.ec}{}{}{}{}
460+
\ecinput{examps/parts/tactics/sequence-branching-tactical/1-1.0.ec} then
461+
running \ecinput{examps/parts/tactics/sequence-branching-tactical/1-1.ec}
462462
solves the goal.
463463
\end{tsyntax}
464464
\end{tactic}
@@ -489,12 +489,12 @@ \subsection{Tacticals}
489489
\end{tsyntax}
490490

491491
For example, if the current goal is
492-
\ecinput{examps/parts/tactics/do-tactical/1-1.0.ec}{}{}{}{} then
493-
running \ecinput{examps/parts/tactics/do-tactical/1-1.ec}{}{}{}{}
492+
\ecinput{examps/parts/tactics/do-tactical/1-1.0.ec} then
493+
running \ecinput{examps/parts/tactics/do-tactical/1-1.ec}
494494
produces the goals
495-
\ecinput{examps/parts/tactics/do-tactical/1-1.1.ec}{}{}{}{}
495+
\ecinput{examps/parts/tactics/do-tactical/1-1.1.ec}
496496
and
497-
\ecinput{examps/parts/tactics/do-tactical/1-1.2.ec}{}{}{}{}
497+
\ecinput{examps/parts/tactics/do-tactical/1-1.2.ec}
498498

499499
\paragraph{Variants.}\strut
500500

@@ -534,12 +534,12 @@ \subsection{Tacticals}
534534

535535
\bigskip
536536
For example, if the current goal is
537-
\ecinput{examps/parts/tactics/sequence-reordering-tactical/1-1.0.ec}{}{}{}{} then
538-
running \ecinput{examps/parts/tactics/sequence-reordering-tactical/1-1.ec}{}{}{}{}
537+
\ecinput{examps/parts/tactics/sequence-reordering-tactical/1-1.0.ec} then
538+
running \ecinput{examps/parts/tactics/sequence-reordering-tactical/1-1.ec}
539539
produces the goals
540-
\ecinput{examps/parts/tactics/sequence-reordering-tactical/1-1.1.ec}{}{}{}{}
540+
\ecinput{examps/parts/tactics/sequence-reordering-tactical/1-1.1.ec}
541541
and
542-
\ecinput{examps/parts/tactics/sequence-reordering-tactical/1-1.2.ec}{}{}{}{}
542+
\ecinput{examps/parts/tactics/sequence-reordering-tactical/1-1.2.ec}
543543
\end{tsyntax}
544544
\end{tactic}
545545

refman/specifications.tex

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,7 @@ \subsection{Modules}
881881
which have different name spaces.
882882
Listing~\ref{list:simpmod} contains the definition of a simple module,
883883
\ec{M}, which exemplifies much of the module language.
884-
\ecinput{examps/specifications-examp1.ec}{Simple
885-
Module}{}{list:simpmod}
884+
\ecinput[caption={Simple Module},label=list:simpmod]{examps/specifications-examp1.ec}
886885
\ec{M} has one \emph{global variable}---\ec{x}---which is used by the
887886
\emph{procedures} of \ec{M}---\ec{init}, \ec{incr}, \ec{get} and
888887
\ec{main}. Global variables must be declared before the procedures
@@ -923,9 +922,13 @@ \subsection{Modules}
923922
924923
\EasyCrypt tries to infer the return types of procedures and the
925924
types of parameters and local variables. E.g., our example module
926-
could be written \ecinput{examps/specifications-examp1a.ec}{Simple
927-
Module with Type Inference}{3-25}{SimpModInfer} As we've seen, each
928-
declaration or statement of a procedure is terminated with a
925+
could be written
926+
%
927+
\ecinput
928+
[linerange=3-25,caption={Simple Module with Type Inference},label={SimpModInfer}]
929+
{examps/specifications-examp1a.ec}
930+
%
931+
As we've seen, each declaration or statement of a procedure is terminated with a
929932
semicolon. One may combine multiple local variable declarations, as
930933
in:
931934
\begin{easycrypt}{}{}
@@ -961,8 +964,11 @@ \subsection{Modules}
961964
The two remaining kinds of statements are illustrated in
962965
Listing~\ref{list:condwhileexamp}: \emph{conditionals} and \emph{while
963966
loops}.
964-
\ecinput{examps/specifications-examp2.ec}{Conditionals
965-
and While Loops} {}{list:condwhileexamp}
967+
%
968+
\ecinput
969+
[caption={Conditionals and While Loops},label=list:condwhileexamp]
970+
{examps/specifications-examp2.ec}
971+
%
966972
\ec{N} has a single procedure,
967973
\ec{loop}, which begins by initializing a local variable \ec{y} to
968974
\ec{0}. It then enters a while loop, which continues executing until
@@ -995,9 +1001,12 @@ \subsection{Modules}
9951001
As illustrated in Listing~\ref{list:usingothermoduleexamp}, modules may
9961002
access the global variables, and call the procedures, of previously
9971003
declared modules.
998-
\ecinput{examps/specifications-examp3.ec}{One
999-
Module Using Another Module} {}{list:usingothermoduleexamp} Procedure
1000-
\ec{g} of \ec{N} both accesses the global variable \ec{x} of module
1004+
%
1005+
\ecinput
1006+
[caption={One Module Using Another Module},label=list:usingothermoduleexamp]
1007+
{examps/specifications-examp3.ec}
1008+
%
1009+
Procedure \ec{g} of \ec{N} both accesses the global variable \ec{x} of module
10011010
\ec{M} (\ec{M.x}), and calls \ec{M}'s procedure, \ec{f} (\ec{M.f}).
10021011
The parameter list of \ec{g} could equivalently be written:
10031012
\begin{easycrypt}{}{}
@@ -1050,7 +1059,10 @@ \subsection{Module Types}
10501059
10511060
\EasyCrypt's \emph{module types} specify the types of a set of
10521061
procedures. E.g., consider the module type \ec{OR} :
1053-
\ecinput{examps/specifications-examp4.ec}{} {3-7}{} \ec{OR} describes
1062+
%
1063+
\ecinput[linerange=3-7]{examps/specifications-examp4.ec}
1064+
%
1065+
\ec{OR} describes
10541066
minimum expectations for a ``guessing oracle''---that it provide at
10551067
least procedures with the specified types. The order of the
10561068
procedures in a module type is irrelevant. In a procedure's type, one
@@ -1068,8 +1080,13 @@ \subsection{Module Types}
10681080
should have. Modules types have a different name space than modules.
10691081
10701082
Listing~\ref{list:guessormodule} contains an example guessing oracle
1071-
implementation. \ecinput{examps/specifications-examp4.ec}{Guessing
1072-
Oracle Module} {9-30}{list:guessormodule} Its \ec{init} procedure stores
1083+
implementation.
1084+
%
1085+
\ecinput
1086+
[linerange=9-30,caption={Guessing Oracle Module},label=list:guessormodule]
1087+
{examps/specifications-examp4.ec}
1088+
%
1089+
Its \ec{init} procedure stores
10731090
the supplied secret in the global variable \ec{sec}, initializes the
10741091
allowed number of guesses in the global variable \ec{tris}, and
10751092
initializes the \ec{guessed} global variable to record that the secret
@@ -1083,8 +1100,11 @@ \subsection{Module Types}
10831100
module type \ec{OR}, and we can ask \EasyCrypt to check this by
10841101
supplying that module type when declaring \ec{Or}, as in
10851102
Listing~\ref{list:guessormodulecheck}.
1086-
\ecinput{examps/specifications-examp5.ec}{Guessing Oracle Module with
1087-
Module Type Check}{9-30}{list:guessormodulecheck}
1103+
%
1104+
\ecinput
1105+
[linerange=9-30,caption={Guessing Oracle Module with Module Type Check},label=list:guessormodulecheck]
1106+
{examps/specifications-examp5.ec}
1107+
%
10881108
Supplying a module type \emph{doesn't} change the result of a module
10891109
declaration. E.g., if we had omitted \ec{guessed} from the module type
10901110
\ec{OR}, the module \ec{Or} would still have had the procedure
@@ -1162,8 +1182,9 @@ \subsection{Module Types}
11621182
tactics).
11631183
11641184
The full Guessing Game example is contained in Listing~\ref{list:fullguessing}.
1165-
\ecinput{examps/specifications-examp5.ec}{Full
1166-
Guessing Game Example} {}{list:fullguessing}
1185+
\ecinput
1186+
[caption={Full Guessing Game Example},label=list:fullguessing]
1187+
{examps/specifications-examp5.ec}
11671188
\ec{SimpAdv} is a simple implementation of an adversary.
11681189
The inclusion of the constraint \ec{SimpAdv : ADV} in \ec{SimpAdv}'s declaration
11691190
\begin{easycrypt}{}{}

refman/started.tex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ \section{Running \EasyCrypt}
7979
Chapter~\ref{chap:advanced}.
8080

8181
A sample \EasyCrypt script is shown in Listing~\ref{list:startedexamp}.
82-
\ecinput[xleftmargin=.09\textwidth,xrightmargin=.09\textwidth]{examps/started-examp-1.ec}{Sample \EasyCrypt
83-
Script}{}{list:startedexamp}
82+
%
83+
\ecinput
84+
[caption={Sample \EasyCrypt Script},label=list:startedexamp,xleftmargin=.09\textwidth,xrightmargin=.09\textwidth]
85+
{examps/started-examp-1.ec}
8486
%%
8587
As can be inferred from the example, comments begin and end with
8688
\ec{(*} and \ec{*)}, respectively; they may be nested. Each sentence

0 commit comments

Comments
 (0)