29716
|
1 |
theory Framework
|
|
2 |
imports Main
|
|
3 |
begin
|
|
4 |
|
|
5 |
chapter {* The Isabelle/Isar Framework \label{ch:isar-framework} *}
|
|
6 |
|
|
7 |
text {*
|
|
8 |
Isabelle/Isar
|
|
9 |
\cite{Wenzel:1999:TPHOL,Wenzel-PhD,Nipkow-TYPES02,Wenzel-Paulson:2006,Wenzel:2006:Festschrift}
|
|
10 |
is intended as a generic framework for developing formal
|
|
11 |
mathematical documents with full proof checking. Definitions and
|
|
12 |
proofs are organized as theories; an assembly of theory sources may
|
|
13 |
be presented as a printed document; see also
|
|
14 |
\chref{ch:document-prep}.
|
|
15 |
|
|
16 |
The main objective of Isar is the design of a human-readable
|
|
17 |
structured proof language, which is called the ``primary proof
|
|
18 |
format'' in Isar terminology. Such a primary proof language is
|
|
19 |
somewhere in the middle between the extremes of primitive proof
|
|
20 |
objects and actual natural language. In this respect, Isar is a bit
|
|
21 |
more formalistic than Mizar
|
|
22 |
\cite{Trybulec:1993:MizarFeatures,Rudnicki:1992:MizarOverview,Wiedijk:1999:Mizar},
|
|
23 |
using logical symbols for certain reasoning schemes where Mizar
|
|
24 |
would prefer English words; see \cite{Wenzel-Wiedijk:2002} for
|
|
25 |
further comparisons of these systems.
|
|
26 |
|
|
27 |
So Isar challenges the traditional way of recording informal proofs
|
|
28 |
in mathematical prose, as well as the common tendency to see fully
|
|
29 |
formal proofs directly as objects of some logical calculus (e.g.\
|
|
30 |
@{text "\<lambda>"}-terms in a version of type theory). In fact, Isar is
|
|
31 |
better understood as an interpreter of a simple block-structured
|
|
32 |
language for describing data flow of local facts and goals,
|
|
33 |
interspersed with occasional invocations of proof methods.
|
|
34 |
Everything is reduced to logical inferences internally, but these
|
|
35 |
steps are somewhat marginal compared to the overall bookkeeping of
|
|
36 |
the interpretation process. Thanks to careful design of the syntax
|
|
37 |
and semantics of Isar language elements, a formal record of Isar
|
|
38 |
instructions may later appear as an intelligible text to the
|
|
39 |
attentive reader.
|
|
40 |
|
|
41 |
The Isar proof language has emerged from careful analysis of some
|
|
42 |
inherent virtues of the existing logical framework of Isabelle/Pure
|
|
43 |
\cite{paulson-found,paulson700}, notably composition of higher-order
|
|
44 |
natural deduction rules, which is a generalization of Gentzen's
|
|
45 |
original calculus \cite{Gentzen:1935}. The approach of generic
|
|
46 |
inference systems in Pure is continued by Isar towards actual proof
|
|
47 |
texts.
|
|
48 |
|
|
49 |
Concrete applications require another intermediate layer: an
|
|
50 |
object-logic. Isabelle/HOL \cite{isa-tutorial} (simply-typed
|
|
51 |
set-theory) is being used most of the time; Isabelle/ZF
|
|
52 |
\cite{isabelle-ZF} is less extensively developed, although it would
|
|
53 |
probably fit better for classical mathematics.
|
29721
|
54 |
|
|
55 |
\medskip In order to illustrate typical natural deduction reasoning
|
|
56 |
in Isar, we shall refer to the background theory and library of
|
|
57 |
Isabelle/HOL. This includes common notions of predicate logic,
|
|
58 |
naive set-theory etc.\ using fairly standard mathematical notation.
|
|
59 |
From the perspective of generic natural deduction there is nothing
|
|
60 |
special about the logical connectives of HOL (@{text "\<and>"}, @{text
|
|
61 |
"\<or>"}, @{text "\<forall>"}, @{text "\<exists>"}, etc.), only the resulting reasoning
|
|
62 |
principles are relevant to the user. There are similar rules
|
|
63 |
available for set-theory operators (@{text "\<inter>"}, @{text "\<union>"}, @{text
|
|
64 |
"\<Inter>"}, @{text "\<Union>"}, etc.), or any other theory developed in the
|
|
65 |
library (lattice theory, topology etc.).
|
|
66 |
|
|
67 |
Subsequently we briefly review fragments of Isar proof texts
|
|
68 |
corresponding directly to such general natural deduction schemes.
|
|
69 |
The examples shall refer to set-theory, to minimize the danger of
|
|
70 |
understanding connectives of predicate logic as something special.
|
|
71 |
|
|
72 |
\medskip The following deduction performs @{text "\<inter>"}-introduction,
|
|
73 |
working forwards from assumptions towards the conclusion. We give
|
|
74 |
both the Isar text, and depict the primitive rule involved, as
|
|
75 |
determined by unification of the problem against rules from the
|
|
76 |
context.
|
|
77 |
*}
|
|
78 |
|
|
79 |
text_raw {*\medskip\begin{minipage}{0.6\textwidth}*}
|
|
80 |
|
|
81 |
(*<*)
|
|
82 |
lemma True
|
|
83 |
proof
|
|
84 |
(*>*)
|
|
85 |
assume "x \<in> A" and "x \<in> B"
|
|
86 |
then have "x \<in> A \<inter> B" ..
|
|
87 |
(*<*)
|
|
88 |
qed
|
|
89 |
(*>*)
|
|
90 |
|
|
91 |
text_raw {*\end{minipage}\begin{minipage}{0.4\textwidth}*}
|
|
92 |
|
|
93 |
text {*
|
|
94 |
\infer{@{prop "x \<in> A \<inter> B"}}{@{prop "x \<in> A"} & @{prop "x \<in> B"}}
|
|
95 |
*}
|
|
96 |
|
|
97 |
text_raw {*\end{minipage}*}
|
|
98 |
|
|
99 |
text {*
|
|
100 |
\medskip\noindent Note that @{command "assume"} augments the
|
|
101 |
context, @{command "then"} indicates that the current facts shall be
|
|
102 |
used in the next step, and @{command "have"} states a local claim.
|
|
103 |
The two dots ``@{command ".."}'' above refer to a complete proof of
|
|
104 |
the claim, using the indicated facts and a canonical rule from the
|
|
105 |
context. We could have been more explicit here by spelling out the
|
|
106 |
final proof step via the @{command "by"} command:
|
|
107 |
*}
|
|
108 |
|
|
109 |
(*<*)
|
|
110 |
lemma True
|
|
111 |
proof
|
|
112 |
(*>*)
|
|
113 |
assume "x \<in> A" and "x \<in> B"
|
|
114 |
then have "x \<in> A \<inter> B" by (rule IntI)
|
|
115 |
(*<*)
|
|
116 |
qed
|
|
117 |
(*>*)
|
|
118 |
|
|
119 |
text {*
|
|
120 |
\noindent The format of the @{text "\<inter>"}-introduction rule represents
|
|
121 |
the most basic inference, which proceeds from given premises to a
|
|
122 |
conclusion, without any additional context involved.
|
|
123 |
|
|
124 |
\medskip The next example performs backwards introduction on @{term
|
|
125 |
"\<Inter>\<A>"}, the intersection of all sets within a given set. This
|
|
126 |
requires a nested proof of set membership within a local context of
|
|
127 |
an arbitrary-but-fixed member of the collection:
|
|
128 |
*}
|
|
129 |
|
|
130 |
text_raw {*\medskip\begin{minipage}{0.6\textwidth}*}
|
|
131 |
|
|
132 |
(*<*)
|
|
133 |
lemma True
|
|
134 |
proof
|
|
135 |
(*>*)
|
|
136 |
have "x \<in> \<Inter>\<A>"
|
|
137 |
proof
|
|
138 |
fix A
|
|
139 |
assume "A \<in> \<A>"
|
|
140 |
show "x \<in> A" sorry
|
|
141 |
qed
|
|
142 |
(*<*)
|
|
143 |
qed
|
|
144 |
(*>*)
|
|
145 |
|
|
146 |
text_raw {*\end{minipage}\begin{minipage}{0.4\textwidth}*}
|
|
147 |
|
|
148 |
text {*
|
|
149 |
\infer{@{prop "x \<in> \<Inter>\<A>"}}{\infer*{@{prop "x \<in> A"}}{@{text "[A][A \<in> \<A>]"}}}
|
|
150 |
*}
|
|
151 |
|
|
152 |
text_raw {*\end{minipage}*}
|
|
153 |
|
|
154 |
text {*
|
|
155 |
\medskip\noindent This Isar reasoning pattern again refers to the
|
|
156 |
primitive rule depicted above. The system determines it in the
|
|
157 |
``@{command "proof"}'' step, which could have been spelt out more
|
|
158 |
explicitly as ``@{command "proof"}~@{text "("}@{method rule}~@{fact
|
|
159 |
InterI}@{text ")"}''. Note that this rule involves both a local
|
|
160 |
parameter @{term "A"} and an assumption @{prop "A \<in> \<A>"} in the
|
|
161 |
nested reasoning. This kind of compound rule typically demands a
|
|
162 |
genuine sub-proof in Isar, working backwards rather than forwards as
|
|
163 |
seen before. In the proof body we encounter the @{command
|
|
164 |
"fix"}-@{command "assume"}-@{command "show"} skeleton of nested
|
|
165 |
sub-proofs that is typical for Isar. The final @{command "show"} is
|
|
166 |
like @{command "have"} followed by an additional refinement of the
|
|
167 |
enclosing claim, using the rule derived from the proof body. The
|
|
168 |
@{command "sorry"} command stands for a hole in the proof -- it may
|
|
169 |
be understood as an excuse for not providing a proper proof yet.
|
|
170 |
|
|
171 |
\medskip The next example involves @{term "\<Union>\<A>"}, which can be
|
|
172 |
characterized as the set of all @{term "x"} such that @{prop "\<exists>A. x
|
|
173 |
\<in> A \<and> A \<in> \<A>"}. The elimination rule for @{prop "x \<in> \<Union>\<A>"} does
|
|
174 |
not mention @{text "\<exists>"} and @{text "\<and>"} at all, but admits to obtain
|
|
175 |
directly a local @{term "A"} such that @{prop "x \<in> A"} and @{prop "A
|
|
176 |
\<in> \<A>"} hold. This corresponds to the following Isar proof and
|
|
177 |
inference rule, respectively:
|
|
178 |
*}
|
|
179 |
|
|
180 |
text_raw {*\medskip\begin{minipage}{0.6\textwidth}*}
|
|
181 |
|
|
182 |
(*<*)
|
|
183 |
lemma True
|
|
184 |
proof
|
|
185 |
(*>*)
|
|
186 |
assume "x \<in> \<Union>\<A>"
|
|
187 |
then have C
|
|
188 |
proof
|
|
189 |
fix A
|
|
190 |
assume "x \<in> A" and "A \<in> \<A>"
|
|
191 |
show C sorry
|
|
192 |
qed
|
|
193 |
(*<*)
|
|
194 |
qed
|
|
195 |
(*>*)
|
|
196 |
|
|
197 |
text_raw {*\end{minipage}\begin{minipage}{0.4\textwidth}*}
|
|
198 |
|
|
199 |
text {*
|
|
200 |
\infer{@{prop "C"}}{@{prop "x \<in> \<Union>\<A>"} & \infer*{@{prop "C"}~}{@{text "[A][x \<in> A, A \<in> \<A>]"}}}
|
|
201 |
*}
|
|
202 |
|
|
203 |
text_raw {*\end{minipage}*}
|
|
204 |
|
|
205 |
text {*
|
|
206 |
\medskip\noindent Although the Isar proof follows the natural
|
|
207 |
deduction rule closely, the text reads not as natural as
|
|
208 |
anticipated. There is a double occurrence of an arbitrary
|
|
209 |
conclusion @{prop "C"}, which represents the final result, but is
|
|
210 |
irrelevant for now. This issue arises for any elimination rule
|
|
211 |
involving local parameters. Isar provides the derived language
|
|
212 |
element @{command "obtain"}, which is able to perform the same
|
|
213 |
elimination proof more conveniently:
|
|
214 |
*}
|
|
215 |
|
|
216 |
(*<*)
|
|
217 |
lemma True
|
|
218 |
proof
|
|
219 |
(*>*)
|
|
220 |
assume "x \<in> \<Union>\<A>"
|
|
221 |
then obtain A where "x \<in> A" and "A \<in> \<A>" ..
|
|
222 |
(*<*)
|
|
223 |
qed
|
|
224 |
(*>*)
|
|
225 |
|
|
226 |
text {*
|
|
227 |
\noindent Here we avoid to mention the final conclusion @{prop "C"}
|
|
228 |
and return to plain forward reasoning. The rule involved in the
|
|
229 |
``@{command ".."}'' proof is the same as before.
|
29716
|
230 |
*}
|
|
231 |
|
|
232 |
end
|