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