13619
|
1 |
\section{Introduction}
|
|
2 |
|
|
3 |
Isar is an extension of Isabelle with structured proofs in a stylized
|
|
4 |
language of mathematics. These proofs are readable for both a human
|
|
5 |
and a machine. This document is a very compact introduction to
|
|
6 |
structured proofs in Isar/HOL, an extension of
|
|
7 |
Isabelle/HOL~\cite{LNCS2283}. We intentionally do not present the full
|
|
8 |
language but concentrate on the essentials. Neither do we give a
|
|
9 |
formal semantics of Isar. Instead we introduce Isar by example. Again
|
|
10 |
this is intentional: we believe that the language ``speaks for
|
13620
|
11 |
itself'' in the same way that traditional mathematical proofs do, which
|
13619
|
12 |
are also introduced by example rather than by teaching students logic
|
|
13 |
first. A detailed exposition of Isar can be found in Markus Wenzel's
|
|
14 |
PhD thesis~\cite{Wenzel-PhD} and the Isar reference
|
|
15 |
manual~\cite{Isar-Ref-Man}.
|
|
16 |
|
|
17 |
\subsection{Background}
|
|
18 |
|
|
19 |
Interactive theorem proving has been dominated by a model of proof
|
|
20 |
that goes back to the LCF system~\cite{LCF}: a proof is a more or less
|
|
21 |
structured sequence of commands that manipulate an implicit proof
|
|
22 |
state. Thus the proof text is only suitable for the machine; for a
|
|
23 |
human, the proof only comes alive when he can see the state changes
|
|
24 |
caused by the stepwise execution of the commands. Such proofs are like
|
|
25 |
uncommented assembly language programs. We call them
|
|
26 |
\emph{tactic-style} proofs because LCF proof commands were called
|
|
27 |
tactics.
|
|
28 |
|
|
29 |
A radically different approach was taken by the Mizar
|
13620
|
30 |
system~\cite{Rudnicki92} where proofs are written in a stylized language akin
|
|
31 |
to that used in ordinary mathematics texts. The most important argument in
|
|
32 |
favour of a mathematics-like proof language is communication: as soon as not
|
|
33 |
just the theorem but also the proof becomes an object of interest, it should
|
|
34 |
be readable. From a system development point of view there is a second
|
|
35 |
important argument against tactic-style proofs: they are much harder to
|
|
36 |
maintain when the system is modified. The reason is as follows. Since it is
|
|
37 |
usually quite unclear what exactly is proved at some point in the middle of a
|
|
38 |
command sequence, updating a failed proof often requires executing the proof
|
|
39 |
up to the point of failure using the old version of the system. In contrast,
|
|
40 |
mathematics-like proofs contain enough information to tell you what is proved
|
|
41 |
at any point.
|
13619
|
42 |
|
|
43 |
For these reasons the Isabelle system, originally firmly in the
|
|
44 |
LCF-tradition, was extended with a language for writing structured
|
|
45 |
proofs in a mathematics-like style. As the name already indicates,
|
13620
|
46 |
Isar was certainly inspired by Mizar. However, there are many
|
13619
|
47 |
differences. For a start, Isar is generic: only a few of the language
|
|
48 |
constructs described below are specific to HOL; many are generic and
|
|
49 |
thus available for any logic defined in Isabelle, e.g.\ ZF.
|
|
50 |
Furthermore, we have Isabelle's powerful automatic proof procedures at
|
|
51 |
our disposal. A closer comparison of Isar and Mizar can be found
|
|
52 |
elsewhere~\cite{WenzelW-JAR}.
|
|
53 |
|
|
54 |
Finally, a word of warning for potential writers of Isar proofs. It
|
|
55 |
has always been easier to write obscure rather than readable texts.
|
|
56 |
Similarly, tactic-style proofs are often (though by no means always!)
|
|
57 |
easier to write than readable ones: structure does not emerge
|
|
58 |
automatically but needs to be understood and imposed. If the precise
|
|
59 |
structure of the proof is not clear from the beginning, it can be
|
|
60 |
useful to start in a tactic-based style for exploratory purposes until
|
|
61 |
one has found a proof which can then be converted into a structured
|
|
62 |
text in a second step. Top down conversion is possible because Isar
|
|
63 |
allows tactic-style proofs as components of structured ones.
|
|
64 |
|
|
65 |
\subsection{A first glimpse of Isar}
|
|
66 |
|
|
67 |
Below you find a simplified grammar for Isar proofs.
|
|
68 |
Parentheses are used for grouping and $^?$ indicates an optional item:
|
|
69 |
\begin{center}
|
|
70 |
\begin{tabular}{lrl}
|
|
71 |
\emph{proof} & ::= & \isakeyword{proof} \emph{method}$^?$
|
|
72 |
\emph{statement}*
|
|
73 |
\isakeyword{qed} \\
|
|
74 |
&$\mid$& \isakeyword{by} \emph{method}\\[1ex]
|
|
75 |
\emph{statement} &::= & \isakeyword{fix} \emph{variables} \\
|
|
76 |
&$\mid$& \isakeyword{assume} \emph{propositions} \\
|
|
77 |
&$\mid$& (\isakeyword{from} \emph{facts})$^?$
|
|
78 |
(\isakeyword{show} $\mid$ \isakeyword{have})
|
|
79 |
\emph{propositions} \emph{proof} \\[1ex]
|
|
80 |
\emph{proposition} &::=& (\emph{label}{\bf:})$^?$ \emph{string} \\[1ex]
|
|
81 |
\emph{fact} &::=& \emph{label}
|
|
82 |
\end{tabular}
|
|
83 |
\end{center}
|
|
84 |
A proof can be either compound (\isakeyword{proof} --
|
|
85 |
\isakeyword{qed}) or atomic (\isakeyword{by}). A \emph{method} is a
|
13620
|
86 |
proof method (tactic) offered by the underlying theorem prover.
|
|
87 |
Thus this grammar is generic both w.r.t.\ the logic and the theorem prover.
|
13619
|
88 |
|
|
89 |
This is a typical proof skeleton:
|
|
90 |
\begin{center}
|
|
91 |
\begin{tabular}{@{}ll}
|
|
92 |
\isakeyword{proof}\\
|
|
93 |
\hspace*{3ex}\isakeyword{assume} \isa{"}\emph{the-assm}\isa{"}\\
|
|
94 |
\hspace*{3ex}\isakeyword{have} \isa{"}\dots\isa{"} & --- intermediate result\\
|
|
95 |
\hspace*{3ex}\vdots\\
|
|
96 |
\hspace*{3ex}\isakeyword{have} \isa{"}\dots\isa{"} & --- intermediate result\\
|
|
97 |
\hspace*{3ex}\isakeyword{show} \isa{"}\emph{the-concl}\isa{"}\\
|
|
98 |
\isakeyword{qed}
|
|
99 |
\end{tabular}
|
|
100 |
\end{center}
|
|
101 |
It proves \emph{the-assm}~$\Longrightarrow$~\emph{the-concl}. Text starting with
|
|
102 |
``---'' is a comment. The intermediate \isakeyword{have}s are only
|
|
103 |
there to bridge the gap between the assumption and the conclusion and
|
|
104 |
do not contribute to the theorem being proved. In contrast,
|
|
105 |
\isakeyword{show} establishes the conclusion of the theorem.
|
|
106 |
|
|
107 |
\subsection{Bits of Isabelle}
|
|
108 |
|
|
109 |
In order to make this paper self-contained we recall some basic
|
|
110 |
notions and notation from Isabelle~\cite{LNCS2283}. Isabelle's
|
|
111 |
meta-logic offers an implication $\Longrightarrow$ and a universal quantifier $\bigwedge$
|
|
112 |
for expressing inference rules and generality. Iterated implications
|
13620
|
113 |
$A_1 \Longrightarrow \dots A_n \Longrightarrow A$ may be abbreviated to $[\![ A_1; \dots; A_n
|
|
114 |
]\!] \Longrightarrow A$. Applying a theorem $A \Longrightarrow B$ (named \isa{T}) to a theorem
|
13619
|
115 |
$A$ (named \isa{U}) is written \isa{T[OF U]} and yields theorem $B$.
|
|
116 |
|
|
117 |
Isabelle terms are simply typed. Function types are
|
|
118 |
written $\tau_1 \Rightarrow \tau_2$.
|
|
119 |
|
13620
|
120 |
Free variables that may be instantiated (``logical variables'' in Prolog
|
|
121 |
parlance) are prefixed with a \isa{?}. Typically, theorems are stated with
|
|
122 |
ordinary free variables but after the proof those are automatically replaced
|
|
123 |
by \isa{?}-variables. Thus the theorem can be used with arbitrary instances
|
|
124 |
of its free variables.
|
13619
|
125 |
|
|
126 |
Isabelle/HOL offers all the usual logical symbols like $\longrightarrow$, $\land$,
|
|
127 |
$\forall$ etc. Proof methods include \isa{rule} (which performs a backwards
|
|
128 |
step with a given rule, unifying the conclusion of the rule with the
|
|
129 |
current subgoal and replacing the subgoal by the premises of the
|
|
130 |
rule), \isa{simp} (for simplification) and \isa{blast} (for predicate
|
|
131 |
calculus reasoning).
|
|
132 |
|
|
133 |
\subsection{Overview of the paper}
|
|
134 |
|
|
135 |
The rest of the paper is divided into two parts.
|
|
136 |
Section~\ref{sec:Logic} introduces proofs in pure logic based on
|
|
137 |
natural deduction. Section~\ref{sec:Induct} is dedicated to induction,
|
|
138 |
the key reasoning principle for computer science applications.
|
|
139 |
|
13620
|
140 |
There are at least two further areas where Isar provides specific support,
|
|
141 |
but which we do not document here. Reasoning by chains of (in)equations is
|
|
142 |
described elsewhere~\cite{BauerW-TPHOLs01}. Reasoning about axiomatically
|
|
143 |
defined structures by means of so called ``locales'' was first described in
|
|
144 |
\cite{KWP-TPHOLs99} but has evolved much since then.
|
13619
|
145 |
|
|
146 |
Do not be mislead by the simplicity of the formulae being proved,
|
|
147 |
especially in the beginning. Isar has been used very successfully in
|
|
148 |
large applications, for example the formalization of Java, in
|
|
149 |
particular the verification of the bytecode verifier~\cite{KleinN-TCS}.
|