author | wenzelm |
Thu, 19 Nov 2020 17:50:14 +0100 | |
changeset 72661 | fca4d6abebda |
parent 71925 | bf085daea304 |
child 76987 | 4c275405faae |
permissions | -rw-r--r-- |
61656 | 1 |
(*:maxLineLen=78:*) |
2 |
||
29716 | 3 |
theory Framework |
63531 | 4 |
imports Main Base |
29716 | 5 |
begin |
6 |
||
58618 | 7 |
chapter \<open>The Isabelle/Isar Framework \label{ch:isar-framework}\<close> |
29716 | 8 |
|
58618 | 9 |
text \<open> |
58552 | 10 |
Isabelle/Isar @{cite "Wenzel:1999:TPHOL" and "Wenzel-PhD" and |
62276 | 11 |
"Nipkow-TYPES02" and "Wiedijk:1999:Mizar" and "Wenzel-Paulson:2006" and |
12 |
"Wenzel:2006:Festschrift"} is a generic framework for developing formal |
|
13 |
mathematical documents with full proof checking. Definitions, statements and |
|
14 |
proofs are organized as theories. A collection of theories sources may be |
|
15 |
presented as a printed document; see also \chref{ch:document-prep}. |
|
29716 | 16 |
|
62276 | 17 |
The main concern of Isar is the design of a human-readable structured proof |
18 |
language, which is called the ``primary proof format'' in Isar terminology. |
|
19 |
Such a primary proof language is somewhere in the middle between the |
|
20 |
extremes of primitive proof objects and actual natural language. |
|
29716 | 21 |
|
62276 | 22 |
Thus Isar challenges the traditional way of recording informal proofs in |
62275 | 23 |
mathematical prose, as well as the common tendency to see fully formal |
24 |
proofs directly as objects of some logical calculus (e.g.\ \<open>\<lambda>\<close>-terms in a |
|
62276 | 25 |
version of type theory). Technically, Isar is an interpreter of a simple |
26 |
block-structured language for describing the data flow of local facts and |
|
27 |
goals, interspersed with occasional invocations of proof methods. Everything |
|
28 |
is reduced to logical inferences internally, but these steps are somewhat |
|
29 |
marginal compared to the overall bookkeeping of the interpretation process. |
|
30 |
Thanks to careful design of the syntax and semantics of Isar language |
|
31 |
elements, a formal record of Isar commands may later appear as an |
|
32 |
intelligible text to the human reader. |
|
29716 | 33 |
|
62275 | 34 |
The Isar proof language has emerged from careful analysis of some inherent |
62276 | 35 |
virtues of the logical framework Isabelle/Pure @{cite "paulson-found" and |
36 |
"paulson700"}, notably composition of higher-order natural deduction rules, |
|
37 |
which is a generalization of Gentzen's original calculus @{cite |
|
38 |
"Gentzen:1935"}. The approach of generic inference systems in Pure is |
|
39 |
continued by Isar towards actual proof texts. See also |
|
40 |
\figref{fig:natural-deduction} |
|
41 |
||
42 |
\begin{figure}[htb] |
|
43 |
||
44 |
\begin{center} |
|
45 |
\begin{minipage}[t]{0.9\textwidth} |
|
46 |
||
47 |
\textbf{Inferences:} |
|
48 |
\begin{center} |
|
49 |
\begin{tabular}{l@ {\qquad}l} |
|
50 |
\infer{\<open>B\<close>}{\<open>A \<longrightarrow> B\<close> & \<open>A\<close>} & |
|
51 |
\infer{\<open>A \<longrightarrow> B\<close>}{\infer*{\<open>B\<close>}{\<open>[A]\<close>}} \\ |
|
52 |
\end{tabular} |
|
53 |
\end{center} |
|
29716 | 54 |
|
62276 | 55 |
\textbf{Isabelle/Pure:} |
56 |
\begin{center} |
|
57 |
\begin{tabular}{l@ {\qquad}l} |
|
58 |
\<open>(A \<longrightarrow> B) \<Longrightarrow> A \<Longrightarrow> B\<close> & |
|
59 |
\<open>(A \<Longrightarrow> B) \<Longrightarrow> A \<longrightarrow> B\<close> |
|
60 |
\end{tabular} |
|
61 |
\end{center} |
|
62 |
||
63 |
\textbf{Isabelle/Isar:} |
|
64 |
\begin{center} |
|
65 |
\begin{minipage}[t]{0.4\textwidth} |
|
66 |
@{theory_text [display, indent = 2] |
|
67 |
\<open>have "A \<longrightarrow> B" \<proof> |
|
68 |
also have A \<proof> |
|
69 |
finally have B .\<close>} |
|
70 |
\end{minipage} |
|
71 |
\begin{minipage}[t]{0.4\textwidth} |
|
72 |
@{theory_text [display, indent = 2] |
|
73 |
\<open>have "A \<longrightarrow> B" |
|
74 |
proof |
|
75 |
assume A |
|
76 |
then show B \<proof> |
|
77 |
qed\<close>} |
|
78 |
\end{minipage} |
|
79 |
\end{center} |
|
80 |
||
81 |
\end{minipage} |
|
82 |
\end{center} |
|
83 |
||
84 |
\caption{Natural Deduction via inferences according to Gentzen, rules in |
|
85 |
Isabelle/Pure, and proofs in Isabelle/Isar}\label{fig:natural-deduction} |
|
86 |
||
87 |
\end{figure} |
|
29721 | 88 |
|
61421 | 89 |
\<^medskip> |
62276 | 90 |
Concrete applications require another intermediate layer: an object-logic. |
91 |
Isabelle/HOL @{cite "isa-tutorial"} (simply-typed set-theory) is most |
|
71925
bf085daea304
clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
71924
diff
changeset
|
92 |
commonly used; elementary examples are given in the directories |
bf085daea304
clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
71924
diff
changeset
|
93 |
\<^dir>\<open>~~/src/Pure/Examples\<close> and \<^dir>\<open>~~/src/HOL/Examples\<close>. Some examples |
bf085daea304
clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
71924
diff
changeset
|
94 |
demonstrate how to start a fresh object-logic from Isabelle/Pure, and use |
bf085daea304
clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
71924
diff
changeset
|
95 |
Isar proofs from the very start, despite the lack of advanced proof tools at |
bf085daea304
clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
71924
diff
changeset
|
96 |
such an early stage (e.g.\ see |
71924
e5df9c8d9d4b
clarified sessions: "Notable Examples in Isabelle/Pure";
wenzelm
parents:
69597
diff
changeset
|
97 |
\<^file>\<open>~~/src/Pure/Examples/Higher_Order_Logic.thy\<close>). Isabelle/FOL @{cite |
63680 | 98 |
"isabelle-logics"} and Isabelle/ZF @{cite "isabelle-ZF"} also work, but are |
99 |
much less developed. |
|
62276 | 100 |
|
101 |
In order to illustrate natural deduction in Isar, we shall subsequently |
|
102 |
refer to the background theory and library of Isabelle/HOL. This includes |
|
103 |
common notions of predicate logic, naive set-theory etc.\ using fairly |
|
104 |
standard mathematical notation. From the perspective of generic natural |
|
105 |
deduction there is nothing special about the logical connectives of HOL |
|
106 |
(\<open>\<and>\<close>, \<open>\<or>\<close>, \<open>\<forall>\<close>, \<open>\<exists>\<close>, etc.), only the resulting reasoning principles are |
|
107 |
relevant to the user. There are similar rules available for set-theory |
|
108 |
operators (\<open>\<inter>\<close>, \<open>\<union>\<close>, \<open>\<Inter>\<close>, \<open>\<Union>\<close>, etc.), or any other theory developed in the |
|
109 |
library (lattice theory, topology etc.). |
|
29721 | 110 |
|
62275 | 111 |
Subsequently we briefly review fragments of Isar proof texts corresponding |
112 |
directly to such general deduction schemes. The examples shall refer to |
|
113 |
set-theory, to minimize the danger of understanding connectives of predicate |
|
114 |
logic as something special. |
|
29721 | 115 |
|
61421 | 116 |
\<^medskip> |
62275 | 117 |
The following deduction performs \<open>\<inter>\<close>-introduction, working forwards from |
118 |
assumptions towards the conclusion. We give both the Isar text, and depict |
|
62276 | 119 |
the primitive rule involved, as determined by unification of fact and goal |
120 |
statements against rules that are declared in the library context. |
|
58618 | 121 |
\<close> |
29721 | 122 |
|
58618 | 123 |
text_raw \<open>\medskip\begin{minipage}{0.6\textwidth}\<close> |
29721 | 124 |
|
125 |
(*<*) |
|
40964 | 126 |
notepad |
127 |
begin |
|
62276 | 128 |
fix x :: 'a and A B |
29721 | 129 |
(*>*) |
130 |
assume "x \<in> A" and "x \<in> B" |
|
131 |
then have "x \<in> A \<inter> B" .. |
|
132 |
(*<*) |
|
40964 | 133 |
end |
29721 | 134 |
(*>*) |
135 |
||
58618 | 136 |
text_raw \<open>\end{minipage}\begin{minipage}{0.4\textwidth}\<close> |
29721 | 137 |
|
58618 | 138 |
text \<open> |
62276 | 139 |
\infer{\<open>x \<in> A \<inter> B\<close>}{\<open>x \<in> A\<close> & \<open>x \<in> B\<close>} |
58618 | 140 |
\<close> |
29721 | 141 |
|
58618 | 142 |
text_raw \<open>\end{minipage}\<close> |
29721 | 143 |
|
58618 | 144 |
text \<open> |
61421 | 145 |
\<^medskip> |
62276 | 146 |
Note that \<^theory_text>\<open>assume\<close> augments the proof context, \<^theory_text>\<open>then\<close> indicates that the |
147 |
current fact shall be used in the next step, and \<^theory_text>\<open>have\<close> states an |
|
148 |
intermediate goal. The two dots ``\<^theory_text>\<open>..\<close>'' refer to a complete proof of this |
|
149 |
claim, using the indicated facts and a canonical rule from the context. We |
|
150 |
could have been more explicit here by spelling out the final proof step via |
|
151 |
the \<^theory_text>\<open>by\<close> command: |
|
58618 | 152 |
\<close> |
29721 | 153 |
|
154 |
(*<*) |
|
40964 | 155 |
notepad |
156 |
begin |
|
62276 | 157 |
fix x :: 'a and A B |
29721 | 158 |
(*>*) |
159 |
assume "x \<in> A" and "x \<in> B" |
|
160 |
then have "x \<in> A \<inter> B" by (rule IntI) |
|
161 |
(*<*) |
|
40964 | 162 |
end |
29721 | 163 |
(*>*) |
164 |
||
58618 | 165 |
text \<open> |
62275 | 166 |
The format of the \<open>\<inter>\<close>-introduction rule represents the most basic inference, |
167 |
which proceeds from given premises to a conclusion, without any nested proof |
|
168 |
context involved. |
|
29721 | 169 |
|
62276 | 170 |
The next example performs backwards introduction of \<open>\<Inter>\<A>\<close>, the intersection |
171 |
of all sets within a given set. This requires a nested proof of set |
|
172 |
membership within a local context, where \<open>A\<close> is an arbitrary-but-fixed |
|
173 |
member of the collection: |
|
58618 | 174 |
\<close> |
29721 | 175 |
|
58618 | 176 |
text_raw \<open>\medskip\begin{minipage}{0.6\textwidth}\<close> |
29721 | 177 |
|
178 |
(*<*) |
|
40964 | 179 |
notepad |
180 |
begin |
|
62276 | 181 |
fix x :: 'a and \<A> |
29721 | 182 |
(*>*) |
183 |
have "x \<in> \<Inter>\<A>" |
|
184 |
proof |
|
185 |
fix A |
|
186 |
assume "A \<in> \<A>" |
|
62271 | 187 |
show "x \<in> A" \<proof> |
29721 | 188 |
qed |
189 |
(*<*) |
|
40964 | 190 |
end |
29721 | 191 |
(*>*) |
192 |
||
58618 | 193 |
text_raw \<open>\end{minipage}\begin{minipage}{0.4\textwidth}\<close> |
29721 | 194 |
|
58618 | 195 |
text \<open> |
62276 | 196 |
\infer{\<open>x \<in> \<Inter>\<A>\<close>}{\infer*{\<open>x \<in> A\<close>}{\<open>[A][A \<in> \<A>]\<close>}} |
58618 | 197 |
\<close> |
29721 | 198 |
|
58618 | 199 |
text_raw \<open>\end{minipage}\<close> |
29721 | 200 |
|
58618 | 201 |
text \<open> |
61421 | 202 |
\<^medskip> |
62275 | 203 |
This Isar reasoning pattern again refers to the primitive rule depicted |
62276 | 204 |
above. The system determines it in the ``\<^theory_text>\<open>proof\<close>'' step, which could have |
205 |
been spelled out more explicitly as ``\<^theory_text>\<open>proof (rule InterI)\<close>''. Note that |
|
206 |
the rule involves both a local parameter \<open>A\<close> and an assumption \<open>A \<in> \<A>\<close> in |
|
207 |
the nested reasoning. Such compound rules typically demands a genuine |
|
62277 | 208 |
subproof in Isar, working backwards rather than forwards as seen before. In |
62276 | 209 |
the proof body we encounter the \<^theory_text>\<open>fix\<close>-\<^theory_text>\<open>assume\<close>-\<^theory_text>\<open>show\<close> outline of nested |
62277 | 210 |
subproofs that is typical for Isar. The final \<^theory_text>\<open>show\<close> is like \<^theory_text>\<open>have\<close> |
62276 | 211 |
followed by an additional refinement of the enclosing claim, using the rule |
212 |
derived from the proof body. |
|
29721 | 213 |
|
61421 | 214 |
\<^medskip> |
62276 | 215 |
The next example involves \<open>\<Union>\<A>\<close>, which can be characterized as the set of |
216 |
all \<open>x\<close> such that \<open>\<exists>A. x \<in> A \<and> A \<in> \<A>\<close>. The elimination rule for \<open>x \<in> \<Union>\<A>\<close> |
|
217 |
does not mention \<open>\<exists>\<close> and \<open>\<and>\<close> at all, but admits to obtain directly a local |
|
218 |
\<open>A\<close> such that \<open>x \<in> A\<close> and \<open>A \<in> \<A>\<close> hold. This corresponds to the following |
|
219 |
Isar proof and inference rule, respectively: |
|
58618 | 220 |
\<close> |
29721 | 221 |
|
58618 | 222 |
text_raw \<open>\medskip\begin{minipage}{0.6\textwidth}\<close> |
29721 | 223 |
|
224 |
(*<*) |
|
40964 | 225 |
notepad |
226 |
begin |
|
62276 | 227 |
fix x :: 'a and \<A> C |
29721 | 228 |
(*>*) |
229 |
assume "x \<in> \<Union>\<A>" |
|
230 |
then have C |
|
231 |
proof |
|
232 |
fix A |
|
233 |
assume "x \<in> A" and "A \<in> \<A>" |
|
62271 | 234 |
show C \<proof> |
29721 | 235 |
qed |
236 |
(*<*) |
|
40964 | 237 |
end |
29721 | 238 |
(*>*) |
239 |
||
58618 | 240 |
text_raw \<open>\end{minipage}\begin{minipage}{0.4\textwidth}\<close> |
29721 | 241 |
|
58618 | 242 |
text \<open> |
62276 | 243 |
\infer{\<open>C\<close>}{\<open>x \<in> \<Union>\<A>\<close> & \infer*{\<open>C\<close>~}{\<open>[A][x \<in> A, A \<in> \<A>]\<close>}} |
58618 | 244 |
\<close> |
29721 | 245 |
|
58618 | 246 |
text_raw \<open>\end{minipage}\<close> |
29721 | 247 |
|
58618 | 248 |
text \<open> |
61421 | 249 |
\<^medskip> |
62275 | 250 |
Although the Isar proof follows the natural deduction rule closely, the text |
251 |
reads not as natural as anticipated. There is a double occurrence of an |
|
62276 | 252 |
arbitrary conclusion \<open>C\<close>, which represents the final result, but is |
62275 | 253 |
irrelevant for now. This issue arises for any elimination rule involving |
62276 | 254 |
local parameters. Isar provides the derived language element \<^theory_text>\<open>obtain\<close>, |
255 |
which is able to perform the same elimination proof more conveniently: |
|
58618 | 256 |
\<close> |
29721 | 257 |
|
258 |
(*<*) |
|
40964 | 259 |
notepad |
260 |
begin |
|
62276 | 261 |
fix x :: 'a and \<A> |
29721 | 262 |
(*>*) |
263 |
assume "x \<in> \<Union>\<A>" |
|
264 |
then obtain A where "x \<in> A" and "A \<in> \<A>" .. |
|
265 |
(*<*) |
|
40964 | 266 |
end |
29721 | 267 |
(*>*) |
268 |
||
58618 | 269 |
text \<open> |
62276 | 270 |
Here we avoid to mention the final conclusion \<open>C\<close> and return to plain |
271 |
forward reasoning. The rule involved in the ``\<^theory_text>\<open>..\<close>'' proof is the same as |
|
272 |
before. |
|
58618 | 273 |
\<close> |
29716 | 274 |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
275 |
|
58618 | 276 |
section \<open>The Pure framework \label{sec:framework-pure}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
277 |
|
58618 | 278 |
text \<open> |
58552 | 279 |
The Pure logic @{cite "paulson-found" and "paulson700"} is an intuitionistic |
62275 | 280 |
fragment of higher-order logic @{cite "church40"}. In type-theoretic |
281 |
parlance, there are three levels of \<open>\<lambda>\<close>-calculus with corresponding arrows |
|
282 |
\<open>\<Rightarrow>\<close>/\<open>\<And>\<close>/\<open>\<Longrightarrow>\<close>: |
|
29735 | 283 |
|
61421 | 284 |
\<^medskip> |
29735 | 285 |
\begin{tabular}{ll} |
61493 | 286 |
\<open>\<alpha> \<Rightarrow> \<beta>\<close> & syntactic function space (terms depending on terms) \\ |
287 |
\<open>\<And>x. B(x)\<close> & universal quantification (proofs depending on terms) \\ |
|
288 |
\<open>A \<Longrightarrow> B\<close> & implication (proofs depending on proofs) \\ |
|
29735 | 289 |
\end{tabular} |
61421 | 290 |
\<^medskip> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
291 |
|
62275 | 292 |
Here only the types of syntactic terms, and the propositions of proof terms |
293 |
have been shown. The \<open>\<lambda>\<close>-structure of proofs can be recorded as an optional |
|
294 |
feature of the Pure inference kernel @{cite "Berghofer-Nipkow:2000:TPHOL"}, |
|
295 |
but the formal system can never depend on them due to \<^emph>\<open>proof irrelevance\<close>. |
|
29735 | 296 |
|
62275 | 297 |
On top of this most primitive layer of proofs, Pure implements a generic |
298 |
calculus for nested natural deduction rules, similar to @{cite |
|
299 |
"Schroeder-Heister:1984"}. Here object-logic inferences are internalized as |
|
300 |
formulae over \<open>\<And>\<close> and \<open>\<Longrightarrow>\<close>. Combining such rule statements may involve |
|
301 |
higher-order unification @{cite "paulson-natural"}. |
|
58618 | 302 |
\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
303 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
304 |
|
58618 | 305 |
subsection \<open>Primitive inferences\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
306 |
|
58618 | 307 |
text \<open> |
62275 | 308 |
Term syntax provides explicit notation for abstraction \<open>\<lambda>x :: \<alpha>. b(x)\<close> and |
309 |
application \<open>b a\<close>, while types are usually implicit thanks to |
|
310 |
type-inference; terms of type \<open>prop\<close> are called propositions. Logical |
|
311 |
statements are composed via \<open>\<And>x :: \<alpha>. B(x)\<close> and \<open>A \<Longrightarrow> B\<close>. Primitive reasoning |
|
312 |
operates on judgments of the form \<open>\<Gamma> \<turnstile> \<phi>\<close>, with standard introduction and |
|
313 |
elimination rules for \<open>\<And>\<close> and \<open>\<Longrightarrow>\<close> that refer to fixed parameters \<open>x\<^sub>1, \<dots>, |
|
314 |
x\<^sub>m\<close> and hypotheses \<open>A\<^sub>1, \<dots>, A\<^sub>n\<close> from the context \<open>\<Gamma>\<close>; the corresponding |
|
315 |
proof terms are left implicit. The subsequent inference rules define \<open>\<Gamma> \<turnstile> \<phi>\<close> |
|
62276 | 316 |
inductively, relative to a collection of axioms from the implicit background |
317 |
theory: |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
318 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
319 |
\[ |
62276 | 320 |
\infer{\<open>\<turnstile> A\<close>}{\<open>A\<close> \mbox{~is axiom}} |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
321 |
\qquad |
61493 | 322 |
\infer{\<open>A \<turnstile> A\<close>}{} |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
323 |
\] |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
324 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
325 |
\[ |
61493 | 326 |
\infer{\<open>\<Gamma> \<turnstile> \<And>x. B(x)\<close>}{\<open>\<Gamma> \<turnstile> B(x)\<close> & \<open>x \<notin> \<Gamma>\<close>} |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
327 |
\qquad |
61493 | 328 |
\infer{\<open>\<Gamma> \<turnstile> B(a)\<close>}{\<open>\<Gamma> \<turnstile> \<And>x. B(x)\<close>} |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
329 |
\] |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
330 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
331 |
\[ |
61493 | 332 |
\infer{\<open>\<Gamma> - A \<turnstile> A \<Longrightarrow> B\<close>}{\<open>\<Gamma> \<turnstile> B\<close>} |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
333 |
\qquad |
61493 | 334 |
\infer{\<open>\<Gamma>\<^sub>1 \<union> \<Gamma>\<^sub>2 \<turnstile> B\<close>}{\<open>\<Gamma>\<^sub>1 \<turnstile> A \<Longrightarrow> B\<close> & \<open>\<Gamma>\<^sub>2 \<turnstile> A\<close>} |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
335 |
\] |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
336 |
|
62275 | 337 |
Furthermore, Pure provides a built-in equality \<open>\<equiv> :: \<alpha> \<Rightarrow> \<alpha> \<Rightarrow> prop\<close> with |
338 |
axioms for reflexivity, substitution, extensionality, and \<open>\<alpha>\<beta>\<eta>\<close>-conversion |
|
339 |
on \<open>\<lambda>\<close>-terms. |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
340 |
|
61421 | 341 |
\<^medskip> |
62276 | 342 |
|
62275 | 343 |
An object-logic introduces another layer on top of Pure, e.g.\ with types |
344 |
\<open>i\<close> for individuals and \<open>o\<close> for propositions, term constants \<open>Trueprop :: o |
|
345 |
\<Rightarrow> prop\<close> as (implicit) derivability judgment and connectives like \<open>\<and> :: o \<Rightarrow> o |
|
346 |
\<Rightarrow> o\<close> or \<open>\<forall> :: (i \<Rightarrow> o) \<Rightarrow> o\<close>, and axioms for object-level rules such as |
|
347 |
\<open>conjI: A \<Longrightarrow> B \<Longrightarrow> A \<and> B\<close> or \<open>allI: (\<And>x. B x) \<Longrightarrow> \<forall>x. B x\<close>. Derived object rules |
|
348 |
are represented as theorems of Pure. After the initial object-logic setup, |
|
62276 | 349 |
further axiomatizations are usually avoided: definitional principles are |
350 |
used instead (e.g.\ \<^theory_text>\<open>definition\<close>, \<^theory_text>\<open>inductive\<close>, \<^theory_text>\<open>fun\<close>, \<^theory_text>\<open>function\<close>). |
|
58618 | 351 |
\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
352 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
353 |
|
58618 | 354 |
subsection \<open>Reasoning with rules \label{sec:framework-resolution}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
355 |
|
58618 | 356 |
text \<open> |
62275 | 357 |
Primitive inferences mostly serve foundational purposes. The main reasoning |
358 |
mechanisms of Pure operate on nested natural deduction rules expressed as |
|
359 |
formulae, using \<open>\<And>\<close> to bind local parameters and \<open>\<Longrightarrow>\<close> to express entailment. |
|
360 |
Multiple parameters and premises are represented by repeating these |
|
29735 | 361 |
connectives in a right-associative manner. |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
362 |
|
69597 | 363 |
Thanks to the Pure theorem \<^prop>\<open>(A \<Longrightarrow> (\<And>x. B x)) \<equiv> (\<And>x. A \<Longrightarrow> B x)\<close> the |
62276 | 364 |
connectives \<open>\<And>\<close> and \<open>\<Longrightarrow>\<close> commute. So we may assume w.l.o.g.\ that rule |
365 |
statements always observe the normal form where quantifiers are pulled in |
|
366 |
front of implications at each level of nesting. This means that any Pure |
|
367 |
proposition may be presented as a \<^emph>\<open>Hereditary Harrop Formula\<close> @{cite |
|
368 |
"Miller:1991"} which is of the form \<open>\<And>x\<^sub>1 \<dots> x\<^sub>m. H\<^sub>1 \<Longrightarrow> \<dots> H\<^sub>n \<Longrightarrow> A\<close> for \<open>m, n |
|
369 |
\<ge> 0\<close>, and \<open>A\<close> atomic, and \<open>H\<^sub>1, \<dots>, H\<^sub>n\<close> being recursively of the same |
|
370 |
format. Following the convention that outermost quantifiers are implicit, |
|
371 |
Horn clauses \<open>A\<^sub>1 \<Longrightarrow> \<dots> A\<^sub>n \<Longrightarrow> A\<close> are a special case of this. |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
372 |
|
62276 | 373 |
For example, the \<open>\<inter>\<close>-introduction rule encountered before is represented as |
374 |
a Pure theorem as follows: |
|
29735 | 375 |
\[ |
69597 | 376 |
\<open>IntI:\<close>~\<^prop>\<open>x \<in> A \<Longrightarrow> x \<in> B \<Longrightarrow> x \<in> A \<inter> B\<close> |
29735 | 377 |
\] |
378 |
||
62275 | 379 |
This is a plain Horn clause, since no further nesting on the left is |
380 |
involved. The general \<open>\<Inter>\<close>-introduction corresponds to a Hereditary Harrop |
|
381 |
Formula with one additional level of nesting: |
|
29735 | 382 |
\[ |
69597 | 383 |
\<open>InterI:\<close>~\<^prop>\<open>(\<And>A. A \<in> \<A> \<Longrightarrow> x \<in> A) \<Longrightarrow> x \<in> \<Inter>\<A>\<close> |
29735 | 384 |
\] |
385 |
||
61421 | 386 |
\<^medskip> |
62275 | 387 |
Goals are also represented as rules: \<open>A\<^sub>1 \<Longrightarrow> \<dots> A\<^sub>n \<Longrightarrow> C\<close> states that the |
62277 | 388 |
subgoals \<open>A\<^sub>1, \<dots>, A\<^sub>n\<close> entail the result \<open>C\<close>; for \<open>n = 0\<close> the goal is |
62276 | 389 |
finished. To allow \<open>C\<close> being a rule statement itself, there is an internal |
62275 | 390 |
protective marker \<open># :: prop \<Rightarrow> prop\<close>, which is defined as identity and |
391 |
hidden from the user. We initialize and finish goal states as follows: |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
392 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
393 |
\[ |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
394 |
\begin{array}{c@ {\qquad}c} |
61493 | 395 |
\infer[(@{inference_def init})]{\<open>C \<Longrightarrow> #C\<close>}{} & |
396 |
\infer[(@{inference_def finish})]{\<open>C\<close>}{\<open>#C\<close>} |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
397 |
\end{array} |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
398 |
\] |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
399 |
|
62275 | 400 |
Goal states are refined in intermediate proof steps until a finished form is |
401 |
achieved. Here the two main reasoning principles are @{inference |
|
62277 | 402 |
resolution}, for back-chaining a rule against a subgoal (replacing it by |
403 |
zero or more subgoals), and @{inference assumption}, for solving a subgoal |
|
62275 | 404 |
(finding a short-circuit with local assumptions). Below \<open>\<^vec>x\<close> stands |
62276 | 405 |
for \<open>x\<^sub>1, \<dots>, x\<^sub>n\<close> (for \<open>n \<ge> 0\<close>). |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
406 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
407 |
\[ |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
408 |
\infer[(@{inference_def resolution})] |
61493 | 409 |
{\<open>(\<And>\<^vec>x. \<^vec>H \<^vec>x \<Longrightarrow> \<^vec>A (\<^vec>a \<^vec>x))\<vartheta> \<Longrightarrow> C\<vartheta>\<close>} |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
410 |
{\begin{tabular}{rl} |
61493 | 411 |
\<open>rule:\<close> & |
412 |
\<open>\<^vec>A \<^vec>a \<Longrightarrow> B \<^vec>a\<close> \\ |
|
413 |
\<open>goal:\<close> & |
|
414 |
\<open>(\<And>\<^vec>x. \<^vec>H \<^vec>x \<Longrightarrow> B' \<^vec>x) \<Longrightarrow> C\<close> \\ |
|
415 |
\<open>goal unifier:\<close> & |
|
416 |
\<open>(\<lambda>\<^vec>x. B (\<^vec>a \<^vec>x))\<vartheta> = B'\<vartheta>\<close> \\ |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
417 |
\end{tabular}} |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
418 |
\] |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
419 |
|
61421 | 420 |
\<^medskip> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
421 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
422 |
\[ |
61493 | 423 |
\infer[(@{inference_def assumption})]{\<open>C\<vartheta>\<close>} |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
424 |
{\begin{tabular}{rl} |
61493 | 425 |
\<open>goal:\<close> & |
426 |
\<open>(\<And>\<^vec>x. \<^vec>H \<^vec>x \<Longrightarrow> A \<^vec>x) \<Longrightarrow> C\<close> \\ |
|
62276 | 427 |
\<open>assm unifier:\<close> & \<open>A\<vartheta> = H\<^sub>i\<vartheta>\<close>~~\mbox{for some~\<open>H\<^sub>i\<close>} \\ |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
428 |
\end{tabular}} |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
429 |
\] |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
430 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
431 |
The following trace illustrates goal-oriented reasoning in |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
432 |
Isabelle/Pure: |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
433 |
|
29735 | 434 |
{\footnotesize |
61421 | 435 |
\<^medskip> |
29735 | 436 |
\begin{tabular}{r@ {\quad}l} |
61493 | 437 |
\<open>(A \<and> B \<Longrightarrow> B \<and> A) \<Longrightarrow> #(A \<and> B \<Longrightarrow> B \<and> A)\<close> & \<open>(init)\<close> \\ |
438 |
\<open>(A \<and> B \<Longrightarrow> B) \<Longrightarrow> (A \<and> B \<Longrightarrow> A) \<Longrightarrow> #\<dots>\<close> & \<open>(resolution B \<Longrightarrow> A \<Longrightarrow> B \<and> A)\<close> \\ |
|
439 |
\<open>(A \<and> B \<Longrightarrow> A \<and> B) \<Longrightarrow> (A \<and> B \<Longrightarrow> A) \<Longrightarrow> #\<dots>\<close> & \<open>(resolution A \<and> B \<Longrightarrow> B)\<close> \\ |
|
440 |
\<open>(A \<and> B \<Longrightarrow> A) \<Longrightarrow> #\<dots>\<close> & \<open>(assumption)\<close> \\ |
|
441 |
\<open>(A \<and> B \<Longrightarrow> A \<and> B) \<Longrightarrow> #\<dots>\<close> & \<open>(resolution A \<and> B \<Longrightarrow> A)\<close> \\ |
|
442 |
\<open>#\<dots>\<close> & \<open>(assumption)\<close> \\ |
|
443 |
\<open>A \<and> B \<Longrightarrow> B \<and> A\<close> & \<open>(finish)\<close> \\ |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
444 |
\end{tabular} |
61421 | 445 |
\<^medskip> |
29735 | 446 |
} |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
447 |
|
62275 | 448 |
Compositions of @{inference assumption} after @{inference resolution} occurs |
449 |
quite often, typically in elimination steps. Traditional Isabelle tactics |
|
450 |
accommodate this by a combined @{inference_def elim_resolution} principle. |
|
62277 | 451 |
In contrast, Isar uses a combined refinement rule as follows:\footnote{For |
452 |
simplicity and clarity, the presentation ignores \<^emph>\<open>weak premises\<close> as |
|
453 |
introduced via \<^theory_text>\<open>presume\<close> or \<^theory_text>\<open>show \<dots> when\<close>.} |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
454 |
|
62277 | 455 |
{\small |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
456 |
\[ |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
457 |
\infer[(@{inference refinement})] |
62277 | 458 |
{\<open>C\<vartheta>\<close>} |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
459 |
{\begin{tabular}{rl} |
62277 | 460 |
\<open>subgoal:\<close> & |
61493 | 461 |
\<open>(\<And>\<^vec>x. \<^vec>H \<^vec>x \<Longrightarrow> B' \<^vec>x) \<Longrightarrow> C\<close> \\ |
62277 | 462 |
\<open>subproof:\<close> & |
463 |
\<open>\<^vec>G \<^vec>a \<Longrightarrow> B \<^vec>a\<close> \quad for schematic \<open>\<^vec>a\<close> \\ |
|
464 |
\<open>concl unifier:\<close> & |
|
61493 | 465 |
\<open>(\<lambda>\<^vec>x. B (\<^vec>a \<^vec>x))\<vartheta> = B'\<vartheta>\<close> \\ |
466 |
\<open>assm unifiers:\<close> & |
|
62277 | 467 |
\<open>(\<lambda>\<^vec>x. G\<^sub>j (\<^vec>a \<^vec>x))\<vartheta> = H\<^sub>i\<vartheta>\<close> \quad for each \<open>G\<^sub>j\<close> some \<open>H\<^sub>i\<close> \\ |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
468 |
\end{tabular}} |
62277 | 469 |
\]} |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
470 |
|
62277 | 471 |
Here the \<open>subproof\<close> rule stems from the main \<^theory_text>\<open>fix\<close>-\<^theory_text>\<open>assume\<close>-\<^theory_text>\<open>show\<close> |
62276 | 472 |
outline of Isar (cf.\ \secref{sec:framework-subproof}): each assumption |
62277 | 473 |
indicated in the text results in a marked premise \<open>G\<close> above. Consequently, |
474 |
\<^theory_text>\<open>fix\<close>-\<^theory_text>\<open>assume\<close>-\<^theory_text>\<open>show\<close> enables to fit the result of a subproof quite |
|
475 |
robustly into a pending subgoal, while maintaining a good measure of |
|
476 |
flexibility: the subproof only needs to fit modulo unification, and its |
|
477 |
assumptions may be a proper subset of the subgoal premises (see |
|
478 |
\secref{sec:framework-subproof}). |
|
58618 | 479 |
\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
480 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
481 |
|
58618 | 482 |
section \<open>The Isar proof language \label{sec:framework-isar}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
483 |
|
58618 | 484 |
text \<open> |
62275 | 485 |
Structured proofs are presented as high-level expressions for composing |
486 |
entities of Pure (propositions, facts, and goals). The Isar proof language |
|
487 |
allows to organize reasoning within the underlying rule calculus of Pure, |
|
62278 | 488 |
but Isar is not another logical calculus. Isar merely imposes certain |
64510 | 489 |
structure and policies on Pure inferences. The main grammar of the Isar |
490 |
proof language is given in \figref{fig:isar-syntax}. |
|
62278 | 491 |
|
64510 | 492 |
\begin{figure}[htb] |
493 |
\begin{center} |
|
494 |
\begin{tabular}{rcl} |
|
495 |
\<open>main\<close> & \<open>=\<close> & \<^theory_text>\<open>notepad begin "statement\<^sup>*" end\<close> \\ |
|
496 |
& \<open>|\<close> & \<^theory_text>\<open>theorem name: props if name: props for vars\<close> \\ |
|
497 |
& \<open>|\<close> & \<^theory_text>\<open>theorem name:\<close> \\ |
|
498 |
& & \quad\<^theory_text>\<open>fixes vars\<close> \\ |
|
499 |
& & \quad\<^theory_text>\<open>assumes name: props\<close> \\ |
|
500 |
& & \quad\<^theory_text>\<open>shows name: props "proof"\<close> \\ |
|
501 |
& \<open>|\<close> & \<^theory_text>\<open>theorem name:\<close> \\ |
|
502 |
& & \quad\<^theory_text>\<open>fixes vars\<close> \\ |
|
503 |
& & \quad\<^theory_text>\<open>assumes name: props\<close> \\ |
|
504 |
& & \quad\<^theory_text>\<open>obtains (name) clause "\<^bold>|" \<dots> "proof"\<close> \\ |
|
505 |
\<open>proof\<close> & \<open>=\<close> & \<^theory_text>\<open>"refinement\<^sup>* proper_proof"\<close> \\ |
|
506 |
\<open>refinement\<close> & \<open>=\<close> & \<^theory_text>\<open>apply method\<close> \\ |
|
507 |
& \<open>|\<close> & \<^theory_text>\<open>supply name = thms\<close> \\ |
|
508 |
& \<open>|\<close> & \<^theory_text>\<open>subgoal premises name for vars "proof"\<close> \\ |
|
509 |
& \<open>|\<close> & \<^theory_text>\<open>using thms\<close> \\ |
|
510 |
& \<open>|\<close> & \<^theory_text>\<open>unfolding thms\<close> \\ |
|
511 |
\<open>proper_proof\<close> & \<open>=\<close> & \<^theory_text>\<open>proof "method\<^sup>?" "statement\<^sup>*" qed "method\<^sup>?"\<close> \\ |
|
512 |
& \<open>|\<close> & \<^theory_text>\<open>by method method\<close>~~~\<open>|\<close>~~~\<^theory_text>\<open>..\<close>~~~\<open>|\<close>~~~\<^theory_text>\<open>.\<close>~~~\<open>|\<close>~~~\<^theory_text>\<open>sorry\<close>~~~\<open>|\<close>~~~\<^theory_text>\<open>done\<close> \\ |
|
513 |
\<open>statement\<close> & \<open>=\<close> & \<^theory_text>\<open>{ "statement\<^sup>*" }\<close>~~~\<open>|\<close>~~~\<^theory_text>\<open>next\<close> \\ |
|
514 |
& \<open>|\<close> & \<^theory_text>\<open>note name = thms\<close> \\ |
|
515 |
& \<open>|\<close> & \<^theory_text>\<open>let "term" = "term"\<close> \\ |
|
516 |
& \<open>|\<close> & \<^theory_text>\<open>write name (mixfix)\<close> \\ |
|
517 |
& \<open>|\<close> & \<^theory_text>\<open>fix vars\<close> \\ |
|
518 |
& \<open>|\<close> & \<^theory_text>\<open>assume name: props if props for vars\<close> \\ |
|
519 |
& \<open>|\<close> & \<^theory_text>\<open>presume name: props if props for vars\<close> \\ |
|
520 |
& \<open>|\<close> & \<^theory_text>\<open>define clause\<close> \\ |
|
521 |
& \<open>|\<close> & \<^theory_text>\<open>case name: "case"\<close> \\ |
|
522 |
& \<open>|\<close> & \<^theory_text>\<open>then"\<^sup>?" goal\<close> \\ |
|
523 |
& \<open>|\<close> & \<^theory_text>\<open>from thms goal\<close> \\ |
|
524 |
& \<open>|\<close> & \<^theory_text>\<open>with thms goal\<close> \\ |
|
525 |
& \<open>|\<close> & \<^theory_text>\<open>also\<close>~~~\<open>|\<close>~~~\<^theory_text>\<open>finally goal\<close> \\ |
|
526 |
& \<open>|\<close> & \<^theory_text>\<open>moreover\<close>~~~\<open>|\<close>~~~\<^theory_text>\<open>ultimately goal\<close> \\ |
|
527 |
\<open>goal\<close> & \<open>=\<close> & \<^theory_text>\<open>have name: props if name: props for vars "proof"\<close> \\ |
|
528 |
& \<open>|\<close> & \<^theory_text>\<open>show name: props if name: props for vars "proof"\<close> \\ |
|
529 |
& \<open>|\<close> & \<^theory_text>\<open>show name: props when name: props for vars "proof"\<close> \\ |
|
530 |
& \<open>|\<close> & \<^theory_text>\<open>consider (name) clause "\<^bold>|" \<dots> "proof"\<close> \\ |
|
531 |
& \<open>|\<close> & \<^theory_text>\<open>obtain (name) clause "proof"\<close> \\ |
|
532 |
\<open>clause\<close> & \<open>=\<close> & \<^theory_text>\<open>vars where name: props if props for vars\<close> \\ |
|
533 |
\end{tabular} |
|
534 |
\end{center} |
|
535 |
\caption{Main grammar of the Isar proof language}\label{fig:isar-syntax} |
|
536 |
\end{figure} |
|
537 |
||
538 |
The construction of the Isar proof language proceeds in a bottom-up fashion, |
|
539 |
as an exercise in purity and minimalism. The grammar in |
|
540 |
\appref{ap:main-grammar} describes the primitive parts of the core language |
|
62278 | 541 |
(category \<open>proof\<close>), which is embedded into the main outer theory syntax via |
542 |
elements that require a proof (e.g.\ \<^theory_text>\<open>theorem\<close>, \<^theory_text>\<open>lemma\<close>, \<^theory_text>\<open>function\<close>, |
|
543 |
\<^theory_text>\<open>termination\<close>). |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
544 |
|
62278 | 545 |
The syntax for terms and propositions is inherited from Pure (and the |
546 |
object-logic). A \<open>pattern\<close> is a \<open>term\<close> with schematic variables, to be bound |
|
547 |
by higher-order matching. Simultaneous propositions or facts may be |
|
548 |
separated by the \<^theory_text>\<open>and\<close> keyword. |
|
549 |
||
550 |
\<^medskip> |
|
551 |
Facts may be referenced by name or proposition. For example, the result of |
|
552 |
``\<^theory_text>\<open>have a: A \<proof>\<close>'' becomes accessible both via the name \<open>a\<close> and the |
|
553 |
literal proposition \<open>\<open>A\<close>\<close>. Moreover, fact expressions may involve attributes |
|
554 |
that modify either the theorem or the background context. For example, the |
|
555 |
expression ``\<open>a [OF b]\<close>'' refers to the composition of two facts according |
|
556 |
to the @{inference resolution} inference of |
|
557 |
\secref{sec:framework-resolution}, while ``\<open>a [intro]\<close>'' declares a fact as |
|
558 |
introduction rule in the context. |
|
559 |
||
560 |
The special fact called ``@{fact this}'' always refers to the last result, |
|
561 |
as produced by \<^theory_text>\<open>note\<close>, \<^theory_text>\<open>assume\<close>, \<^theory_text>\<open>have\<close>, or \<^theory_text>\<open>show\<close>. Since \<^theory_text>\<open>note\<close> occurs |
|
562 |
frequently together with \<^theory_text>\<open>then\<close>, there are some abbreviations: |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
563 |
|
61421 | 564 |
\<^medskip> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
565 |
\begin{tabular}{rcl} |
62278 | 566 |
\<^theory_text>\<open>from a\<close> & \<open>\<equiv>\<close> & \<^theory_text>\<open>note a then\<close> \\ |
567 |
\<^theory_text>\<open>with a\<close> & \<open>\<equiv>\<close> & \<^theory_text>\<open>from a and this\<close> \\ |
|
29737
866841668584
replaced 'assm' by 'assume' -- regular 'assume' is default, if inference is omitted;
wenzelm
parents:
29735
diff
changeset
|
568 |
\end{tabular} |
61421 | 569 |
\<^medskip> |
29737
866841668584
replaced 'assm' by 'assume' -- regular 'assume' is default, if inference is omitted;
wenzelm
parents:
29735
diff
changeset
|
570 |
|
62278 | 571 |
The \<open>method\<close> category is essentially a parameter of the Isar language and |
572 |
may be populated later. The command \<^theory_text>\<open>method_setup\<close> allows to define proof |
|
573 |
methods semantically in Isabelle/ML. The Eisbach language allows to define |
|
574 |
proof methods symbolically, as recursive expressions over existing methods |
|
63680 | 575 |
@{cite "Matichuk-et-al:2014"}; see also \<^dir>\<open>~~/src/HOL/Eisbach\<close>. |
62278 | 576 |
|
577 |
Methods use the facts indicated by \<^theory_text>\<open>then\<close> or \<^theory_text>\<open>using\<close>, and then operate on |
|
578 |
the goal state. Some basic methods are predefined in Pure: ``@{method "-"}'' |
|
579 |
leaves the goal unchanged, ``@{method this}'' applies the facts as rules to |
|
580 |
the goal, ``@{method (Pure) "rule"}'' applies the facts to another rule and |
|
581 |
the result to the goal (both ``@{method this}'' and ``@{method (Pure) |
|
582 |
rule}'' refer to @{inference resolution} of |
|
62275 | 583 |
\secref{sec:framework-resolution}). The secondary arguments to ``@{method |
584 |
(Pure) rule}'' may be specified explicitly as in ``\<open>(rule a)\<close>'', or picked |
|
585 |
from the context. In the latter case, the system first tries rules declared |
|
586 |
as @{attribute (Pure) elim} or @{attribute (Pure) dest}, followed by those |
|
587 |
declared as @{attribute (Pure) intro}. |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
588 |
|
62278 | 589 |
The default method for \<^theory_text>\<open>proof\<close> is ``@{method standard}'' (which subsumes |
590 |
@{method rule} with arguments picked from the context), for \<^theory_text>\<open>qed\<close> it is |
|
591 |
``@{method "succeed"}''. Further abbreviations for terminal proof steps are |
|
592 |
``\<^theory_text>\<open>by method\<^sub>1 method\<^sub>2\<close>'' for ``\<^theory_text>\<open>proof method\<^sub>1 qed method\<^sub>2\<close>'', and |
|
593 |
``\<^theory_text>\<open>..\<close>'' for ``\<^theory_text>\<open>by standard\<close>, and ``\<^theory_text>\<open>.\<close>'' for ``\<^theory_text>\<open>by this\<close>''. The command |
|
594 |
``\<^theory_text>\<open>unfolding facts\<close>'' operates directly on the goal by applying equalities. |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
595 |
|
61421 | 596 |
\<^medskip> |
62278 | 597 |
Block structure can be indicated explicitly by ``\<^theory_text>\<open>{ \<dots> }\<close>'', although the |
598 |
body of a subproof ``\<^theory_text>\<open>proof \<dots> qed\<close>'' already provides implicit nesting. In |
|
599 |
both situations, \<^theory_text>\<open>next\<close> jumps into the next section of a block, i.e.\ it |
|
600 |
acts like closing an implicit block scope and opening another one. There is |
|
601 |
no direct connection to subgoals here! |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
602 |
|
62278 | 603 |
The commands \<^theory_text>\<open>fix\<close> and \<^theory_text>\<open>assume\<close> build up a local context (see |
604 |
\secref{sec:framework-context}), while \<^theory_text>\<open>show\<close> refines a pending subgoal by |
|
605 |
the rule resulting from a nested subproof (see |
|
62275 | 606 |
\secref{sec:framework-subproof}). Further derived concepts will support |
607 |
calculational reasoning (see \secref{sec:framework-calc}). |
|
58618 | 608 |
\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
609 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
610 |
|
58618 | 611 |
subsection \<open>Context elements \label{sec:framework-context}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
612 |
|
58618 | 613 |
text \<open> |
62275 | 614 |
In judgments \<open>\<Gamma> \<turnstile> \<phi>\<close> of the primitive framework, \<open>\<Gamma>\<close> essentially acts like a |
62278 | 615 |
proof context. Isar elaborates this idea towards a more advanced concept, |
616 |
with additional information for type-inference, term abbreviations, local |
|
617 |
facts, hypotheses etc. |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
618 |
|
62278 | 619 |
The element \<^theory_text>\<open>fix x :: \<alpha>\<close> declares a local parameter, i.e.\ an |
62275 | 620 |
arbitrary-but-fixed entity of a given type; in results exported from the |
62278 | 621 |
context, \<open>x\<close> may become anything. The \<^theory_text>\<open>assume \<guillemotleft>inference\<guillemotright>\<close> element provides |
622 |
a general interface to hypotheses: \<^theory_text>\<open>assume \<guillemotleft>inference\<guillemotright> A\<close> produces \<open>A \<turnstile> A\<close> |
|
623 |
locally, while the included inference tells how to discharge \<open>A\<close> from |
|
624 |
results \<open>A \<turnstile> B\<close> later on. There is no surface syntax for \<open>\<guillemotleft>inference\<guillemotright>\<close>, |
|
625 |
i.e.\ it may only occur internally when derived commands are defined in ML. |
|
29737
866841668584
replaced 'assm' by 'assume' -- regular 'assume' is default, if inference is omitted;
wenzelm
parents:
29735
diff
changeset
|
626 |
|
62278 | 627 |
The default inference for \<^theory_text>\<open>assume\<close> is @{inference export} as given below. |
63039 | 628 |
The derived element \<^theory_text>\<open>define x where "x \<equiv> a"\<close> is defined as \<^theory_text>\<open>fix x assume |
629 |
\<guillemotleft>expand\<guillemotright> x \<equiv> a\<close>, with the subsequent inference @{inference expand}. |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
630 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
631 |
\[ |
62278 | 632 |
\infer[(@{inference_def export})]{\<open>\<strut>\<Gamma> - A \<turnstile> A \<Longrightarrow> B\<close>}{\<open>\<strut>\<Gamma> \<turnstile> B\<close>} |
633 |
\qquad |
|
634 |
\infer[(@{inference_def expand})]{\<open>\<strut>\<Gamma> - (x \<equiv> a) \<turnstile> B a\<close>}{\<open>\<strut>\<Gamma> \<turnstile> B x\<close>} |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
635 |
\] |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
636 |
|
61421 | 637 |
\<^medskip> |
62278 | 638 |
The most interesting derived context element in Isar is \<^theory_text>\<open>obtain\<close> @{cite |
639 |
\<open>\S5.3\<close> "Wenzel-PhD"}, which supports generalized elimination steps in a |
|
640 |
purely forward manner. The \<^theory_text>\<open>obtain\<close> command takes a specification of |
|
641 |
parameters \<open>\<^vec>x\<close> and assumptions \<open>\<^vec>A\<close> to be added to the context, |
|
642 |
together with a proof of a case rule stating that this extension is |
|
643 |
conservative (i.e.\ may be removed from closed results later on): |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
644 |
|
61421 | 645 |
\<^medskip> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
646 |
\begin{tabular}{l} |
62278 | 647 |
\<^theory_text>\<open>\<langle>facts\<rangle> obtain "\<^vec>x" where "\<^vec>A" "\<^vec>x" \<proof> \<equiv>\<close> \\[0.5ex] |
648 |
\quad \<^theory_text>\<open>have "case": "\<And>thesis. (\<And>\<^vec>x. \<^vec>A \<^vec>x \<Longrightarrow> thesis) \<Longrightarrow> thesis"\<close> \\ |
|
649 |
\quad \<^theory_text>\<open>proof -\<close> \\ |
|
650 |
\qquad \<^theory_text>\<open>fix thesis\<close> \\ |
|
651 |
\qquad \<^theory_text>\<open>assume [intro]: "\<And>\<^vec>x. \<^vec>A \<^vec>x \<Longrightarrow> thesis"\<close> \\ |
|
652 |
\qquad \<^theory_text>\<open>show thesis using \<langle>facts\<rangle> \<proof>\<close> \\ |
|
653 |
\quad \<^theory_text>\<open>qed\<close> \\ |
|
654 |
\quad \<^theory_text>\<open>fix "\<^vec>x" assume \<guillemotleft>elimination "case"\<guillemotright> "\<^vec>A \<^vec>x"\<close> \\ |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
655 |
\end{tabular} |
61421 | 656 |
\<^medskip> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
657 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
658 |
\[ |
61493 | 659 |
\infer[(@{inference elimination})]{\<open>\<Gamma> \<turnstile> B\<close>}{ |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
660 |
\begin{tabular}{rl} |
61493 | 661 |
\<open>case:\<close> & |
662 |
\<open>\<Gamma> \<turnstile> \<And>thesis. (\<And>\<^vec>x. \<^vec>A \<^vec>x \<Longrightarrow> thesis) \<Longrightarrow> thesis\<close> \\[0.2ex] |
|
663 |
\<open>result:\<close> & |
|
664 |
\<open>\<Gamma> \<union> \<^vec>A \<^vec>y \<turnstile> B\<close> \\[0.2ex] |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
665 |
\end{tabular}} |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
666 |
\] |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
667 |
|
62275 | 668 |
Here the name ``\<open>thesis\<close>'' is a specific convention for an |
669 |
arbitrary-but-fixed proposition; in the primitive natural deduction rules |
|
670 |
shown before we have occasionally used \<open>C\<close>. The whole statement of |
|
62278 | 671 |
``\<^theory_text>\<open>obtain x where A x\<close>'' can be read as a claim that \<open>A x\<close> may be assumed |
672 |
for some arbitrary-but-fixed \<open>x\<close>. Also note that ``\<^theory_text>\<open>obtain A and B\<close>'' |
|
673 |
without parameters is similar to ``\<^theory_text>\<open>have A and B\<close>'', but the latter |
|
674 |
involves multiple subgoals that need to be proven separately. |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
675 |
|
61421 | 676 |
\<^medskip> |
62275 | 677 |
The subsequent Isar proof texts explain all context elements introduced |
678 |
above using the formal proof language itself. After finishing a local proof |
|
62278 | 679 |
within a block, the exported result is indicated via \<^theory_text>\<open>note\<close>. |
58618 | 680 |
\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
681 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
682 |
(*<*) |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
683 |
theorem True |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
684 |
proof |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
685 |
(*>*) |
58999
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58618
diff
changeset
|
686 |
text_raw \<open>\begin{minipage}[t]{0.45\textwidth}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
687 |
{ |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
688 |
fix x |
62271 | 689 |
have "B x" \<proof> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
690 |
} |
58618 | 691 |
note \<open>\<And>x. B x\<close> |
58999
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58618
diff
changeset
|
692 |
text_raw \<open>\end{minipage}\quad\begin{minipage}[t]{0.45\textwidth}\<close>(*<*)next(*>*) |
29735 | 693 |
{ |
694 |
assume A |
|
62271 | 695 |
have B \<proof> |
29735 | 696 |
} |
58618 | 697 |
note \<open>A \<Longrightarrow> B\<close> |
58999
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58618
diff
changeset
|
698 |
text_raw \<open>\end{minipage}\\[3ex]\begin{minipage}[t]{0.45\textwidth}\<close>(*<*)next(*>*) |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
699 |
{ |
63039 | 700 |
define x where "x \<equiv> a" |
62271 | 701 |
have "B x" \<proof> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
702 |
} |
58618 | 703 |
note \<open>B a\<close> |
58999
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58618
diff
changeset
|
704 |
text_raw \<open>\end{minipage}\quad\begin{minipage}[t]{0.45\textwidth}\<close>(*<*)next(*>*) |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
705 |
{ |
62271 | 706 |
obtain x where "A x" \<proof> |
707 |
have B \<proof> |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
708 |
} |
58618 | 709 |
note \<open>B\<close> |
58999
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58618
diff
changeset
|
710 |
text_raw \<open>\end{minipage}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
711 |
(*<*) |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
712 |
qed |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
713 |
(*>*) |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
714 |
|
58618 | 715 |
text \<open> |
61421 | 716 |
\<^bigskip> |
62278 | 717 |
This explains the meaning of Isar context elements without, without goal |
718 |
states getting in the way. |
|
58618 | 719 |
\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
720 |
|
61421 | 721 |
|
58618 | 722 |
subsection \<open>Structured statements \label{sec:framework-stmt}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
723 |
|
58618 | 724 |
text \<open> |
62278 | 725 |
The syntax of top-level theorem statements is defined as follows: |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
726 |
|
61421 | 727 |
\<^medskip> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
728 |
\begin{tabular}{rcl} |
62278 | 729 |
\<open>statement\<close> & \<open>\<equiv>\<close> & \<^theory_text>\<open>name: props and \<dots>\<close> \\ |
61493 | 730 |
& \<open>|\<close> & \<open>context\<^sup>* conclusion\<close> \\[0.5ex] |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
731 |
|
62278 | 732 |
\<open>context\<close> & \<open>\<equiv>\<close> & \<^theory_text>\<open>fixes vars and \<dots>\<close> \\ |
733 |
& \<open>|\<close> & \<^theory_text>\<open>assumes name: props and \<dots>\<close> \\ |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
734 |
|
62278 | 735 |
\<open>conclusion\<close> & \<open>\<equiv>\<close> & \<^theory_text>\<open>shows name: props and \<dots>\<close> \\ |
736 |
& \<open>|\<close> & \<^theory_text>\<open>obtains vars and \<dots> where name: props and \<dots>\<close> \\ |
|
61493 | 737 |
& & \quad \<open>\<BBAR> \<dots>\<close> \\ |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
738 |
\end{tabular} |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
739 |
|
61421 | 740 |
\<^medskip> |
62278 | 741 |
A simple statement consists of named propositions. The full form admits |
742 |
local context elements followed by the actual conclusions, such as ``\<^theory_text>\<open>fixes |
|
743 |
x assumes A x shows B x\<close>''. The final result emerges as a Pure rule after |
|
69597 | 744 |
discharging the context: \<^prop>\<open>\<And>x. A x \<Longrightarrow> B x\<close>. |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
745 |
|
62278 | 746 |
The \<^theory_text>\<open>obtains\<close> variant is another abbreviation defined below; unlike |
747 |
\<^theory_text>\<open>obtain\<close> (cf.\ \secref{sec:framework-context}) there may be several |
|
748 |
``cases'' separated by ``\<open>\<BBAR>\<close>'', each consisting of several parameters |
|
749 |
(\<open>vars\<close>) and several premises (\<open>props\<close>). This specifies multi-branch |
|
750 |
elimination rules. |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
751 |
|
61421 | 752 |
\<^medskip> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
753 |
\begin{tabular}{l} |
62278 | 754 |
\<^theory_text>\<open>obtains "\<^vec>x" where "\<^vec>A" "\<^vec>x" "\<BBAR>" \<dots> \<equiv>\<close> \\[0.5ex] |
755 |
\quad \<^theory_text>\<open>fixes thesis\<close> \\ |
|
756 |
\quad \<^theory_text>\<open>assumes [intro]: "\<And>\<^vec>x. \<^vec>A \<^vec>x \<Longrightarrow> thesis" and \<dots>\<close> \\ |
|
757 |
\quad \<^theory_text>\<open>shows thesis\<close> \\ |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
758 |
\end{tabular} |
61421 | 759 |
\<^medskip> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
760 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
761 |
Presenting structured statements in such an ``open'' format usually |
62275 | 762 |
simplifies the subsequent proof, because the outer structure of the problem |
763 |
is already laid out directly. E.g.\ consider the following canonical |
|
62278 | 764 |
patterns for \<^theory_text>\<open>shows\<close> and \<^theory_text>\<open>obtains\<close>, respectively: |
58618 | 765 |
\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
766 |
|
58618 | 767 |
text_raw \<open>\begin{minipage}{0.5\textwidth}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
768 |
|
62278 | 769 |
theorem |
770 |
fixes x and y |
|
771 |
assumes "A x" and "B y" |
|
772 |
shows "C x y" |
|
773 |
proof - |
|
774 |
from \<open>A x\<close> and \<open>B y\<close> |
|
775 |
show "C x y" \<proof> |
|
776 |
qed |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
777 |
|
58618 | 778 |
text_raw \<open>\end{minipage}\begin{minipage}{0.5\textwidth}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
779 |
|
62278 | 780 |
theorem |
781 |
obtains x and y |
|
782 |
where "A x" and "B y" |
|
783 |
proof - |
|
784 |
have "A a" and "B b" \<proof> |
|
785 |
then show thesis .. |
|
786 |
qed |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
787 |
|
58618 | 788 |
text_raw \<open>\end{minipage}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
789 |
|
58618 | 790 |
text \<open> |
61421 | 791 |
\<^medskip> |
62278 | 792 |
Here local facts \<open>\<open>A x\<close>\<close> and \<open>\<open>B y\<close>\<close> are referenced immediately; there is no |
793 |
need to decompose the logical rule structure again. In the second proof the |
|
794 |
final ``\<^theory_text>\<open>then show thesis ..\<close>'' involves the local rule case \<open>\<And>x y. A x \<Longrightarrow> B |
|
62275 | 795 |
y \<Longrightarrow> thesis\<close> for the particular instance of terms \<open>a\<close> and \<open>b\<close> produced in the |
62278 | 796 |
body. |
797 |
\<close> |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
798 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
799 |
|
58618 | 800 |
subsection \<open>Structured proof refinement \label{sec:framework-subproof}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
801 |
|
58618 | 802 |
text \<open> |
62275 | 803 |
By breaking up the grammar for the Isar proof language, we may understand a |
804 |
proof text as a linear sequence of individual proof commands. These are |
|
805 |
interpreted as transitions of the Isar virtual machine (Isar/VM), which |
|
806 |
operates on a block-structured configuration in single steps. This allows |
|
807 |
users to write proof texts in an incremental manner, and inspect |
|
808 |
intermediate configurations for debugging. |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
809 |
|
62275 | 810 |
The basic idea is analogous to evaluating algebraic expressions on a stack |
811 |
machine: \<open>(a + b) \<cdot> c\<close> then corresponds to a sequence of single transitions |
|
812 |
for each symbol \<open>(, a, +, b, ), \<cdot>, c\<close>. In Isar the algebraic values are |
|
813 |
facts or goals, and the operations are inferences. |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
814 |
|
61421 | 815 |
\<^medskip> |
62275 | 816 |
The Isar/VM state maintains a stack of nodes, each node contains the local |
817 |
proof context, the linguistic mode, and a pending goal (optional). The mode |
|
818 |
determines the type of transition that may be performed next, it essentially |
|
819 |
alternates between forward and backward reasoning, with an intermediate |
|
820 |
stage for chained facts (see \figref{fig:isar-vm}). |
|
29738 | 821 |
|
822 |
\begin{figure}[htb] |
|
823 |
\begin{center} |
|
48958
12afbf6eb7f9
more standard document preparation within session context;
wenzelm
parents:
48279
diff
changeset
|
824 |
\includegraphics[width=0.8\textwidth]{isar-vm} |
29738 | 825 |
\end{center} |
826 |
\caption{Isar/VM modes}\label{fig:isar-vm} |
|
827 |
\end{figure} |
|
828 |
||
62275 | 829 |
For example, in \<open>state\<close> mode Isar acts like a mathematical scratch-pad, |
62278 | 830 |
accepting declarations like \<^theory_text>\<open>fix\<close>, \<^theory_text>\<open>assume\<close>, and claims like \<^theory_text>\<open>have\<close>, |
831 |
\<^theory_text>\<open>show\<close>. A goal statement changes the mode to \<open>prove\<close>, which means that we |
|
832 |
may now refine the problem via \<^theory_text>\<open>unfolding\<close> or \<^theory_text>\<open>proof\<close>. Then we are again |
|
833 |
in \<open>state\<close> mode of a proof body, which may issue \<^theory_text>\<open>show\<close> statements to solve |
|
834 |
pending subgoals. A concluding \<^theory_text>\<open>qed\<close> will return to the original \<open>state\<close> |
|
835 |
mode one level upwards. The subsequent Isar/VM trace indicates block |
|
836 |
structure, linguistic mode, goal state, and inferences: |
|
58618 | 837 |
\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
838 |
|
58618 | 839 |
text_raw \<open>\begingroup\footnotesize\<close> |
40964 | 840 |
(*<*)notepad begin |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
841 |
(*>*) |
58999
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58618
diff
changeset
|
842 |
text_raw \<open>\begin{minipage}[t]{0.18\textwidth}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
843 |
have "A \<longrightarrow> B" |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
844 |
proof |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
845 |
assume A |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
846 |
show B |
62271 | 847 |
\<proof> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
848 |
qed |
58999
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58618
diff
changeset
|
849 |
text_raw \<open>\end{minipage}\quad |
29735 | 850 |
\begin{minipage}[t]{0.06\textwidth} |
61493 | 851 |
\<open>begin\<close> \\ |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
852 |
\\ |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
853 |
\\ |
61493 | 854 |
\<open>begin\<close> \\ |
855 |
\<open>end\<close> \\ |
|
856 |
\<open>end\<close> \\ |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
857 |
\end{minipage} |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
858 |
\begin{minipage}[t]{0.08\textwidth} |
61493 | 859 |
\<open>prove\<close> \\ |
860 |
\<open>state\<close> \\ |
|
861 |
\<open>state\<close> \\ |
|
862 |
\<open>prove\<close> \\ |
|
863 |
\<open>state\<close> \\ |
|
864 |
\<open>state\<close> \\ |
|
29735 | 865 |
\end{minipage}\begin{minipage}[t]{0.35\textwidth} |
61493 | 866 |
\<open>(A \<longrightarrow> B) \<Longrightarrow> #(A \<longrightarrow> B)\<close> \\ |
867 |
\<open>(A \<Longrightarrow> B) \<Longrightarrow> #(A \<longrightarrow> B)\<close> \\ |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
868 |
\\ |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
869 |
\\ |
61493 | 870 |
\<open>#(A \<longrightarrow> B)\<close> \\ |
871 |
\<open>A \<longrightarrow> B\<close> \\ |
|
29735 | 872 |
\end{minipage}\begin{minipage}[t]{0.4\textwidth} |
61493 | 873 |
\<open>(init)\<close> \\ |
874 |
\<open>(resolution impI)\<close> \\ |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
875 |
\\ |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
876 |
\\ |
61493 | 877 |
\<open>(refinement #A \<Longrightarrow> B)\<close> \\ |
878 |
\<open>(finish)\<close> \\ |
|
58618 | 879 |
\end{minipage}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
880 |
(*<*) |
40964 | 881 |
end |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
882 |
(*>*) |
58618 | 883 |
text_raw \<open>\endgroup\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
884 |
|
58618 | 885 |
text \<open> |
61420 | 886 |
Here the @{inference refinement} inference from |
62277 | 887 |
\secref{sec:framework-resolution} mediates composition of Isar subproofs |
62275 | 888 |
nicely. Observe that this principle incorporates some degree of freedom in |
889 |
proof composition. In particular, the proof body allows parameters and |
|
890 |
assumptions to be re-ordered, or commuted according to Hereditary Harrop |
|
62277 | 891 |
Form. Moreover, context elements that are not used in a subproof may be |
62275 | 892 |
omitted altogether. For example: |
58618 | 893 |
\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
894 |
|
58618 | 895 |
text_raw \<open>\begin{minipage}{0.5\textwidth}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
896 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
897 |
(*<*) |
40964 | 898 |
notepad |
899 |
begin |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
900 |
(*>*) |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
901 |
have "\<And>x y. A x \<Longrightarrow> B y \<Longrightarrow> C x y" |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
902 |
proof - |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
903 |
fix x and y |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
904 |
assume "A x" and "B y" |
62271 | 905 |
show "C x y" \<proof> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
906 |
qed |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
907 |
|
58999
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58618
diff
changeset
|
908 |
text_raw \<open>\end{minipage}\begin{minipage}{0.5\textwidth}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
909 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
910 |
(*<*) |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
911 |
next |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
912 |
(*>*) |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
913 |
have "\<And>x y. A x \<Longrightarrow> B y \<Longrightarrow> C x y" |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
914 |
proof - |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
915 |
fix x assume "A x" |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
916 |
fix y assume "B y" |
62271 | 917 |
show "C x y" \<proof> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
918 |
qed |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
919 |
|
58999
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58618
diff
changeset
|
920 |
text_raw \<open>\end{minipage}\\[3ex]\begin{minipage}{0.5\textwidth}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
921 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
922 |
(*<*) |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
923 |
next |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
924 |
(*>*) |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
925 |
have "\<And>x y. A x \<Longrightarrow> B y \<Longrightarrow> C x y" |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
926 |
proof - |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
927 |
fix y assume "B y" |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
928 |
fix x assume "A x" |
62271 | 929 |
show "C x y" \<proof> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
930 |
qed |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
931 |
|
58999
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58618
diff
changeset
|
932 |
text_raw \<open>\end{minipage}\begin{minipage}{0.5\textwidth}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
933 |
(*<*) |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
934 |
next |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
935 |
(*>*) |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
936 |
have "\<And>x y. A x \<Longrightarrow> B y \<Longrightarrow> C x y" |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
937 |
proof - |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
938 |
fix y assume "B y" |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
939 |
fix x |
62271 | 940 |
show "C x y" \<proof> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
941 |
qed |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
942 |
(*<*) |
40964 | 943 |
end |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
944 |
(*>*) |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
945 |
|
58618 | 946 |
text_raw \<open>\end{minipage}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
947 |
|
58618 | 948 |
text \<open> |
61421 | 949 |
\<^medskip> |
62278 | 950 |
Such fine-tuning of Isar text is practically important to improve |
951 |
readability. Contexts elements are rearranged according to the natural flow |
|
952 |
of reasoning in the body, while still observing the overall scoping rules. |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
953 |
|
61421 | 954 |
\<^medskip> |
62275 | 955 |
This illustrates the basic idea of structured proof processing in Isar. The |
956 |
main mechanisms are based on natural deduction rule composition within the |
|
957 |
Pure framework. In particular, there are no direct operations on goal states |
|
958 |
within the proof body. Moreover, there is no hidden automated reasoning |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
959 |
involved, just plain unification. |
58618 | 960 |
\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
961 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
962 |
|
58618 | 963 |
subsection \<open>Calculational reasoning \label{sec:framework-calc}\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
964 |
|
58618 | 965 |
text \<open> |
29735 | 966 |
The existing Isar infrastructure is sufficiently flexible to support |
62275 | 967 |
calculational reasoning (chains of transitivity steps) as derived concept. |
968 |
The generic proof elements introduced below depend on rules declared as |
|
969 |
@{attribute trans} in the context. It is left to the object-logic to provide |
|
970 |
a suitable rule collection for mixed relations of \<open>=\<close>, \<open><\<close>, \<open>\<le>\<close>, \<open>\<subset>\<close>, \<open>\<subseteq>\<close> |
|
971 |
etc. Due to the flexibility of rule composition |
|
972 |
(\secref{sec:framework-resolution}), substitution of equals by equals is |
|
973 |
covered as well, even substitution of inequalities involving monotonicity |
|
974 |
conditions; see also @{cite \<open>\S6\<close> "Wenzel-PhD"} and @{cite |
|
975 |
"Bauer-Wenzel:2001"}. |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
976 |
|
62275 | 977 |
The generic calculational mechanism is based on the observation that rules |
69597 | 978 |
such as \<open>trans:\<close>~\<^prop>\<open>x = y \<Longrightarrow> y = z \<Longrightarrow> x = z\<close> proceed from the premises |
62275 | 979 |
towards the conclusion in a deterministic fashion. Thus we may reason in |
980 |
forward mode, feeding intermediate results into rules selected from the |
|
981 |
context. The course of reasoning is organized by maintaining a secondary |
|
982 |
fact called ``@{fact calculation}'', apart from the primary ``@{fact this}'' |
|
983 |
already provided by the Isar primitives. In the definitions below, |
|
29735 | 984 |
@{attribute OF} refers to @{inference resolution} |
62275 | 985 |
(\secref{sec:framework-resolution}) with multiple rule arguments, and |
986 |
\<open>trans\<close> represents to a suitable rule from the context: |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
987 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
988 |
\begin{matharray}{rcl} |
62278 | 989 |
\<^theory_text>\<open>also"\<^sub>0"\<close> & \equiv & \<^theory_text>\<open>note calculation = this\<close> \\ |
990 |
\<^theory_text>\<open>also"\<^sub>n\<^sub>+\<^sub>1"\<close> & \equiv & \<^theory_text>\<open>note calculation = trans [OF calculation this]\<close> \\[0.5ex] |
|
991 |
\<^theory_text>\<open>finally\<close> & \equiv & \<^theory_text>\<open>also from calculation\<close> \\ |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
992 |
\end{matharray} |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
993 |
|
62275 | 994 |
The start of a calculation is determined implicitly in the text: here |
62278 | 995 |
\<^theory_text>\<open>also\<close> sets @{fact calculation} to the current result; any subsequent |
996 |
occurrence will update @{fact calculation} by combination with the next |
|
997 |
result and a transitivity rule. The calculational sequence is concluded via |
|
998 |
\<^theory_text>\<open>finally\<close>, where the final result is exposed for use in a concluding claim. |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
999 |
|
62278 | 1000 |
Here is a canonical proof pattern, using \<^theory_text>\<open>have\<close> to establish the |
62275 | 1001 |
intermediate results: |
58618 | 1002 |
\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
1003 |
|
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
1004 |
(*<*) |
40964 | 1005 |
notepad |
1006 |
begin |
|
62278 | 1007 |
fix a b c d :: 'a |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
1008 |
(*>*) |
62271 | 1009 |
have "a = b" \<proof> |
1010 |
also have "\<dots> = c" \<proof> |
|
1011 |
also have "\<dots> = d" \<proof> |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
1012 |
finally have "a = d" . |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
1013 |
(*<*) |
40964 | 1014 |
end |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
1015 |
(*>*) |
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
1016 |
|
58618 | 1017 |
text \<open> |
62278 | 1018 |
The term ``\<open>\<dots>\<close>'' (literal ellipsis) is a special abbreviation provided by |
1019 |
the Isabelle/Isar term syntax: it statically refers to the right-hand side |
|
62275 | 1020 |
argument of the previous statement given in the text. Thus it happens to |
1021 |
coincide with relevant sub-expressions in the calculational chain, but the |
|
1022 |
exact correspondence is dependent on the transitivity rules being involved. |
|
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
1023 |
|
61421 | 1024 |
\<^medskip> |
69597 | 1025 |
Symmetry rules such as \<^prop>\<open>x = y \<Longrightarrow> y = x\<close> are like transitivities with |
62275 | 1026 |
only one premise. Isar maintains a separate rule collection declared via the |
1027 |
@{attribute sym} attribute, to be used in fact expressions ``\<open>a |
|
62278 | 1028 |
[symmetric]\<close>'', or single-step proofs ``\<^theory_text>\<open>assume "x = y" then have "y = x" |
1029 |
..\<close>''. |
|
58618 | 1030 |
\<close> |
29729
c2e926455fcc
more on Isar framework -- mostly from Trybulec Festschrift;
wenzelm
parents:
29721
diff
changeset
|
1031 |
|
67399 | 1032 |
end |