wenzelm@26767
|
1 |
(* $Id$ *)
|
wenzelm@26767
|
2 |
|
wenzelm@26767
|
3 |
theory pure
|
wenzelm@26767
|
4 |
imports CPure
|
wenzelm@26767
|
5 |
begin
|
wenzelm@26767
|
6 |
|
wenzelm@26767
|
7 |
chapter {* Basic language elements \label{ch:pure-syntax} *}
|
wenzelm@26767
|
8 |
|
wenzelm@26767
|
9 |
text {*
|
wenzelm@26767
|
10 |
Subsequently, we introduce the main part of Pure theory and proof
|
wenzelm@26767
|
11 |
commands, together with fundamental proof methods and attributes.
|
wenzelm@26767
|
12 |
\Chref{ch:gen-tools} describes further Isar elements provided by
|
wenzelm@26767
|
13 |
generic tools and packages (such as the Simplifier) that are either
|
wenzelm@26767
|
14 |
part of Pure Isabelle or pre-installed in most object logics.
|
wenzelm@26767
|
15 |
\Chref{ch:logics} refers to object-logic specific elements (mainly
|
wenzelm@26767
|
16 |
for HOL and ZF).
|
wenzelm@26767
|
17 |
|
wenzelm@26767
|
18 |
\medskip Isar commands may be either \emph{proper} document
|
wenzelm@26767
|
19 |
constructors, or \emph{improper commands}. Some proof methods and
|
wenzelm@26767
|
20 |
attributes introduced later are classified as improper as well.
|
wenzelm@26767
|
21 |
Improper Isar language elements, which are subsequently marked by
|
wenzelm@26767
|
22 |
``@{text "\<^sup>*"}'', are often helpful when developing proof
|
wenzelm@26767
|
23 |
documents, while their use is discouraged for the final
|
wenzelm@26767
|
24 |
human-readable outcome. Typical examples are diagnostic commands
|
wenzelm@26767
|
25 |
that print terms or theorems according to the current context; other
|
wenzelm@26767
|
26 |
commands emulate old-style tactical theorem proving.
|
wenzelm@26767
|
27 |
*}
|
wenzelm@26767
|
28 |
|
wenzelm@26767
|
29 |
|
wenzelm@26767
|
30 |
section {* Theory commands *}
|
wenzelm@26767
|
31 |
|
wenzelm@26767
|
32 |
subsection {* Defining theories \label{sec:begin-thy} *}
|
wenzelm@26767
|
33 |
|
wenzelm@26767
|
34 |
text {*
|
wenzelm@26767
|
35 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
36 |
@{command_def "header"} & : & \isarkeep{toplevel} \\
|
wenzelm@26767
|
37 |
@{command_def "theory"} & : & \isartrans{toplevel}{theory} \\
|
wenzelm@26767
|
38 |
@{command_def "end"} & : & \isartrans{theory}{toplevel} \\
|
wenzelm@26767
|
39 |
\end{matharray}
|
wenzelm@26767
|
40 |
|
wenzelm@26767
|
41 |
Isabelle/Isar theories are defined via theory, which contain both
|
wenzelm@26767
|
42 |
specifications and proofs; occasionally definitional mechanisms also
|
wenzelm@26767
|
43 |
require some explicit proof.
|
wenzelm@26767
|
44 |
|
wenzelm@26767
|
45 |
The first ``real'' command of any theory has to be @{command
|
wenzelm@26767
|
46 |
"theory"}, which starts a new theory based on the merge of existing
|
wenzelm@26767
|
47 |
ones. Just preceding the @{command "theory"} keyword, there may be
|
wenzelm@26767
|
48 |
an optional @{command "header"} declaration, which is relevant to
|
wenzelm@26767
|
49 |
document preparation only; it acts very much like a special
|
wenzelm@26767
|
50 |
pre-theory markup command (cf.\ \secref{sec:markup-thy} and
|
wenzelm@26767
|
51 |
\secref{sec:markup-thy}). The @{command "end"} command concludes a
|
wenzelm@26767
|
52 |
theory development; it has to be the very last command of any theory
|
wenzelm@26767
|
53 |
file loaded in batch-mode.
|
wenzelm@26767
|
54 |
|
wenzelm@26767
|
55 |
\begin{rail}
|
wenzelm@26767
|
56 |
'header' text
|
wenzelm@26767
|
57 |
;
|
wenzelm@26767
|
58 |
'theory' name 'imports' (name +) uses? 'begin'
|
wenzelm@26767
|
59 |
;
|
wenzelm@26767
|
60 |
|
wenzelm@26767
|
61 |
uses: 'uses' ((name | parname) +);
|
wenzelm@26767
|
62 |
\end{rail}
|
wenzelm@26767
|
63 |
|
wenzelm@26767
|
64 |
\begin{descr}
|
wenzelm@26767
|
65 |
|
wenzelm@26767
|
66 |
\item [@{command "header"}~@{text "text"}] provides plain text
|
wenzelm@26767
|
67 |
markup just preceding the formal beginning of a theory. In actual
|
wenzelm@26767
|
68 |
document preparation the corresponding {\LaTeX} macro @{verbatim
|
wenzelm@26767
|
69 |
"\\isamarkupheader"} may be redefined to produce chapter or section
|
wenzelm@26767
|
70 |
headings. See also \secref{sec:markup-thy} and
|
wenzelm@26767
|
71 |
\secref{sec:markup-prf} for further markup commands.
|
wenzelm@26767
|
72 |
|
wenzelm@26767
|
73 |
\item [@{command "theory"}~@{text "A \<IMPORTS> B\<^sub>1 \<dots>
|
wenzelm@26767
|
74 |
B\<^sub>n \<BEGIN>"}] starts a new theory @{text A} based on the
|
wenzelm@26767
|
75 |
merge of existing theories @{text "B\<^sub>1 \<dots> B\<^sub>n"}.
|
wenzelm@26767
|
76 |
|
wenzelm@26767
|
77 |
Due to inclusion of several ancestors, the overall theory structure
|
wenzelm@26767
|
78 |
emerging in an Isabelle session forms a directed acyclic graph
|
wenzelm@26767
|
79 |
(DAG). Isabelle's theory loader ensures that the sources
|
wenzelm@26767
|
80 |
contributing to the development graph are always up-to-date.
|
wenzelm@26767
|
81 |
Changed files are automatically reloaded when processing theory
|
wenzelm@26767
|
82 |
headers.
|
wenzelm@26767
|
83 |
|
wenzelm@26767
|
84 |
The optional @{keyword_def "uses"} specification declares additional
|
wenzelm@26767
|
85 |
dependencies on extra files (usually ML sources). Files will be
|
wenzelm@26767
|
86 |
loaded immediately (as ML), unless the name is put in parentheses,
|
wenzelm@26767
|
87 |
which merely documents the dependency to be resolved later in the
|
wenzelm@26767
|
88 |
text (typically via explicit @{command_ref "use"} in the body text,
|
wenzelm@26767
|
89 |
see \secref{sec:ML}).
|
wenzelm@26767
|
90 |
|
wenzelm@26767
|
91 |
\item [@{command "end"}] concludes the current theory definition or
|
wenzelm@26767
|
92 |
context switch.
|
wenzelm@26767
|
93 |
|
wenzelm@26767
|
94 |
\end{descr}
|
wenzelm@26767
|
95 |
*}
|
wenzelm@26767
|
96 |
|
wenzelm@26767
|
97 |
|
wenzelm@26767
|
98 |
subsection {* Markup commands \label{sec:markup-thy} *}
|
wenzelm@26767
|
99 |
|
wenzelm@26767
|
100 |
text {*
|
wenzelm@26767
|
101 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
102 |
@{command_def "chapter"} & : & \isarkeep{local{\dsh}theory} \\
|
wenzelm@26767
|
103 |
@{command_def "section"} & : & \isarkeep{local{\dsh}theory} \\
|
wenzelm@26767
|
104 |
@{command_def "subsection"} & : & \isarkeep{local{\dsh}theory} \\
|
wenzelm@26767
|
105 |
@{command_def "subsubsection"} & : & \isarkeep{local{\dsh}theory} \\
|
wenzelm@26767
|
106 |
@{command_def "text"} & : & \isarkeep{local{\dsh}theory} \\
|
wenzelm@26767
|
107 |
@{command_def "text_raw"} & : & \isarkeep{local{\dsh}theory} \\
|
wenzelm@26767
|
108 |
\end{matharray}
|
wenzelm@26767
|
109 |
|
wenzelm@26767
|
110 |
Apart from formal comments (see \secref{sec:comments}), markup
|
wenzelm@26767
|
111 |
commands provide a structured way to insert text into the document
|
wenzelm@26767
|
112 |
generated from a theory (see \cite{isabelle-sys} for more
|
wenzelm@26767
|
113 |
information on Isabelle's document preparation tools).
|
wenzelm@26767
|
114 |
|
wenzelm@26767
|
115 |
\begin{rail}
|
wenzelm@26767
|
116 |
('chapter' | 'section' | 'subsection' | 'subsubsection' | 'text') target? text
|
wenzelm@26767
|
117 |
;
|
wenzelm@26767
|
118 |
'text\_raw' text
|
wenzelm@26767
|
119 |
;
|
wenzelm@26767
|
120 |
\end{rail}
|
wenzelm@26767
|
121 |
|
wenzelm@26767
|
122 |
\begin{descr}
|
wenzelm@26767
|
123 |
|
wenzelm@26767
|
124 |
\item [@{command "chapter"}, @{command "section"}, @{command
|
wenzelm@26767
|
125 |
"subsection"}, and @{command "subsubsection"}] mark chapter and
|
wenzelm@26767
|
126 |
section headings.
|
wenzelm@26767
|
127 |
|
wenzelm@26767
|
128 |
\item [@{command "text"}] specifies paragraphs of plain text.
|
wenzelm@26767
|
129 |
|
wenzelm@26767
|
130 |
\item [@{command "text_raw"}] inserts {\LaTeX} source into the
|
wenzelm@26767
|
131 |
output, without additional markup. Thus the full range of document
|
wenzelm@26767
|
132 |
manipulations becomes available.
|
wenzelm@26767
|
133 |
|
wenzelm@26767
|
134 |
\end{descr}
|
wenzelm@26767
|
135 |
|
wenzelm@26767
|
136 |
The @{text "text"} argument of these markup commands (except for
|
wenzelm@26767
|
137 |
@{command "text_raw"}) may contain references to formal entities
|
wenzelm@26767
|
138 |
(``antiquotations'', see also \secref{sec:antiq}). These are
|
wenzelm@26767
|
139 |
interpreted in the present theory context, or the named @{text
|
wenzelm@26767
|
140 |
"target"}.
|
wenzelm@26767
|
141 |
|
wenzelm@26767
|
142 |
Any of these markup elements corresponds to a {\LaTeX} command with
|
wenzelm@26767
|
143 |
the name prefixed by @{verbatim "\\isamarkup"}. For the sectioning
|
wenzelm@26767
|
144 |
commands this is a plain macro with a single argument, e.g.\
|
wenzelm@26767
|
145 |
@{verbatim "\\isamarkupchapter{"}@{text "\<dots>"}@{verbatim "}"} for
|
wenzelm@26767
|
146 |
@{command "chapter"}. The @{command "text"} markup results in a
|
wenzelm@26767
|
147 |
{\LaTeX} environment @{verbatim "\\begin{isamarkuptext}"}~@{text
|
wenzelm@26767
|
148 |
"\<dots>"}~@{verbatim "\\end{isamarkuptext}"}, while @{command "text_raw"}
|
wenzelm@26767
|
149 |
causes the text to be inserted directly into the {\LaTeX} source.
|
wenzelm@26767
|
150 |
|
wenzelm@26767
|
151 |
\medskip Additional markup commands are available for proofs (see
|
wenzelm@26767
|
152 |
\secref{sec:markup-prf}). Also note that the @{command_ref
|
wenzelm@26767
|
153 |
"header"} declaration (see \secref{sec:begin-thy}) admits to insert
|
wenzelm@26767
|
154 |
section markup just preceding the actual theory definition.
|
wenzelm@26767
|
155 |
*}
|
wenzelm@26767
|
156 |
|
wenzelm@26767
|
157 |
|
wenzelm@26767
|
158 |
subsection {* Type classes and sorts \label{sec:classes} *}
|
wenzelm@26767
|
159 |
|
wenzelm@26767
|
160 |
text {*
|
wenzelm@26767
|
161 |
\begin{matharray}{rcll}
|
wenzelm@26767
|
162 |
@{command_def "classes"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
163 |
@{command_def "classrel"} & : & \isartrans{theory}{theory} & (axiomatic!) \\
|
wenzelm@26767
|
164 |
@{command_def "defaultsort"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
165 |
@{command_def "class_deps"} & : & \isarkeep{theory~|~proof} \\
|
wenzelm@26767
|
166 |
\end{matharray}
|
wenzelm@26767
|
167 |
|
wenzelm@26767
|
168 |
\begin{rail}
|
wenzelm@26767
|
169 |
'classes' (classdecl +)
|
wenzelm@26767
|
170 |
;
|
wenzelm@26767
|
171 |
'classrel' (nameref ('<' | subseteq) nameref + 'and')
|
wenzelm@26767
|
172 |
;
|
wenzelm@26767
|
173 |
'defaultsort' sort
|
wenzelm@26767
|
174 |
;
|
wenzelm@26767
|
175 |
\end{rail}
|
wenzelm@26767
|
176 |
|
wenzelm@26767
|
177 |
\begin{descr}
|
wenzelm@26767
|
178 |
|
wenzelm@26767
|
179 |
\item [@{command "classes"}~@{text "c \<subseteq> c\<^sub>1, \<dots>, c\<^sub>n"}]
|
wenzelm@26767
|
180 |
declares class @{text c} to be a subclass of existing classes @{text
|
wenzelm@26767
|
181 |
"c\<^sub>1, \<dots>, c\<^sub>n"}. Cyclic class structures are not permitted.
|
wenzelm@26767
|
182 |
|
wenzelm@26767
|
183 |
\item [@{command "classrel"}~@{text "c\<^sub>1 \<subseteq> c\<^sub>2"}] states
|
wenzelm@26767
|
184 |
subclass relations between existing classes @{text "c\<^sub>1"} and
|
wenzelm@26767
|
185 |
@{text "c\<^sub>2"}. This is done axiomatically! The @{command_ref
|
wenzelm@26767
|
186 |
"instance"} command (see \secref{sec:axclass}) provides a way to
|
wenzelm@26767
|
187 |
introduce proven class relations.
|
wenzelm@26767
|
188 |
|
wenzelm@26767
|
189 |
\item [@{command "defaultsort"}~@{text s}] makes sort @{text s} the
|
wenzelm@26767
|
190 |
new default sort for any type variables given without sort
|
wenzelm@26767
|
191 |
constraints. Usually, the default sort would be only changed when
|
wenzelm@26767
|
192 |
defining a new object-logic.
|
wenzelm@26767
|
193 |
|
wenzelm@26767
|
194 |
\item [@{command "class_deps"}] visualizes the subclass relation,
|
wenzelm@26767
|
195 |
using Isabelle's graph browser tool (see also \cite{isabelle-sys}).
|
wenzelm@26767
|
196 |
|
wenzelm@26767
|
197 |
\end{descr}
|
wenzelm@26767
|
198 |
*}
|
wenzelm@26767
|
199 |
|
wenzelm@26767
|
200 |
|
wenzelm@26767
|
201 |
subsection {* Primitive types and type abbreviations \label{sec:types-pure} *}
|
wenzelm@26767
|
202 |
|
wenzelm@26767
|
203 |
text {*
|
wenzelm@26767
|
204 |
\begin{matharray}{rcll}
|
wenzelm@26767
|
205 |
@{command_def "types"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
206 |
@{command_def "typedecl"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
207 |
@{command_def "nonterminals"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
208 |
@{command_def "arities"} & : & \isartrans{theory}{theory} & (axiomatic!) \\
|
wenzelm@26767
|
209 |
\end{matharray}
|
wenzelm@26767
|
210 |
|
wenzelm@26767
|
211 |
\begin{rail}
|
wenzelm@26767
|
212 |
'types' (typespec '=' type infix? +)
|
wenzelm@26767
|
213 |
;
|
wenzelm@26767
|
214 |
'typedecl' typespec infix?
|
wenzelm@26767
|
215 |
;
|
wenzelm@26767
|
216 |
'nonterminals' (name +)
|
wenzelm@26767
|
217 |
;
|
wenzelm@26767
|
218 |
'arities' (nameref '::' arity +)
|
wenzelm@26767
|
219 |
;
|
wenzelm@26767
|
220 |
\end{rail}
|
wenzelm@26767
|
221 |
|
wenzelm@26767
|
222 |
\begin{descr}
|
wenzelm@26767
|
223 |
|
wenzelm@26767
|
224 |
\item [@{command "types"}~@{text "(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>n) t = \<tau>"}]
|
wenzelm@26767
|
225 |
introduces \emph{type synonym} @{text "(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>n) t"}
|
wenzelm@26767
|
226 |
for existing type @{text "\<tau>"}. Unlike actual type definitions, as
|
wenzelm@26767
|
227 |
are available in Isabelle/HOL for example, type synonyms are just
|
wenzelm@26767
|
228 |
purely syntactic abbreviations without any logical significance.
|
wenzelm@26767
|
229 |
Internally, type synonyms are fully expanded.
|
wenzelm@26767
|
230 |
|
wenzelm@26767
|
231 |
\item [@{command "typedecl"}~@{text "(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>n) t"}]
|
wenzelm@26767
|
232 |
declares a new type constructor @{text t}, intended as an actual
|
wenzelm@26767
|
233 |
logical type (of the object-logic, if available).
|
wenzelm@26767
|
234 |
|
wenzelm@26767
|
235 |
\item [@{command "nonterminals"}~@{text c}] declares type
|
wenzelm@26767
|
236 |
constructors @{text c} (without arguments) to act as purely
|
wenzelm@26767
|
237 |
syntactic types, i.e.\ nonterminal symbols of Isabelle's inner
|
wenzelm@26767
|
238 |
syntax of terms or types.
|
wenzelm@26767
|
239 |
|
wenzelm@26767
|
240 |
\item [@{command "arities"}~@{text "t :: (s\<^sub>1, \<dots>, s\<^sub>n)
|
wenzelm@26767
|
241 |
s"}] augments Isabelle's order-sorted signature of types by new type
|
wenzelm@26767
|
242 |
constructor arities. This is done axiomatically! The @{command_ref
|
wenzelm@26767
|
243 |
"instance"} command (see \S\ref{sec:axclass}) provides a way to
|
wenzelm@26767
|
244 |
introduce proven type arities.
|
wenzelm@26767
|
245 |
|
wenzelm@26767
|
246 |
\end{descr}
|
wenzelm@26767
|
247 |
*}
|
wenzelm@26767
|
248 |
|
wenzelm@26767
|
249 |
|
wenzelm@26767
|
250 |
subsection {* Primitive constants and definitions \label{sec:consts} *}
|
wenzelm@26767
|
251 |
|
wenzelm@26767
|
252 |
text {*
|
wenzelm@26767
|
253 |
Definitions essentially express abbreviations within the logic. The
|
wenzelm@26767
|
254 |
simplest form of a definition is @{text "c :: \<sigma> \<equiv> t"}, where @{text
|
wenzelm@26767
|
255 |
c} is a newly declared constant. Isabelle also allows derived forms
|
wenzelm@26767
|
256 |
where the arguments of @{text c} appear on the left, abbreviating a
|
wenzelm@26767
|
257 |
prefix of @{text \<lambda>}-abstractions, e.g.\ @{text "c \<equiv> \<lambda>x y. t"} may be
|
wenzelm@26767
|
258 |
written more conveniently as @{text "c x y \<equiv> t"}. Moreover,
|
wenzelm@26767
|
259 |
definitions may be weakened by adding arbitrary pre-conditions:
|
wenzelm@26767
|
260 |
@{text "A \<Longrightarrow> c x y \<equiv> t"}.
|
wenzelm@26767
|
261 |
|
wenzelm@26767
|
262 |
\medskip The built-in well-formedness conditions for definitional
|
wenzelm@26767
|
263 |
specifications are:
|
wenzelm@26767
|
264 |
|
wenzelm@26767
|
265 |
\begin{itemize}
|
wenzelm@26767
|
266 |
|
wenzelm@26767
|
267 |
\item Arguments (on the left-hand side) must be distinct variables.
|
wenzelm@26767
|
268 |
|
wenzelm@26767
|
269 |
\item All variables on the right-hand side must also appear on the
|
wenzelm@26767
|
270 |
left-hand side.
|
wenzelm@26767
|
271 |
|
wenzelm@26767
|
272 |
\item All type variables on the right-hand side must also appear on
|
wenzelm@26767
|
273 |
the left-hand side; this prohibits @{text "0 :: nat \<equiv> length ([] ::
|
wenzelm@26767
|
274 |
\<alpha> list)"} for example.
|
wenzelm@26767
|
275 |
|
wenzelm@26767
|
276 |
\item The definition must not be recursive. Most object-logics
|
wenzelm@26767
|
277 |
provide definitional principles that can be used to express
|
wenzelm@26767
|
278 |
recursion safely.
|
wenzelm@26767
|
279 |
|
wenzelm@26767
|
280 |
\end{itemize}
|
wenzelm@26767
|
281 |
|
wenzelm@26767
|
282 |
Overloading means that a constant being declared as @{text "c :: \<alpha>
|
wenzelm@26767
|
283 |
decl"} may be defined separately on type instances @{text "c ::
|
wenzelm@26767
|
284 |
(\<beta>\<^sub>1, \<dots>, \<beta>\<^sub>n) t decl"} for each type constructor @{text
|
wenzelm@26767
|
285 |
t}. The right-hand side may mention overloaded constants
|
wenzelm@26767
|
286 |
recursively at type instances corresponding to the immediate
|
wenzelm@26767
|
287 |
argument types @{text "\<beta>\<^sub>1, \<dots>, \<beta>\<^sub>n"}. Incomplete
|
wenzelm@26767
|
288 |
specification patterns impose global constraints on all occurrences,
|
wenzelm@26767
|
289 |
e.g.\ @{text "d :: \<alpha> \<times> \<alpha>"} on the left-hand side means that all
|
wenzelm@26767
|
290 |
corresponding occurrences on some right-hand side need to be an
|
wenzelm@26767
|
291 |
instance of this, general @{text "d :: \<alpha> \<times> \<beta>"} will be disallowed.
|
wenzelm@26767
|
292 |
|
wenzelm@26767
|
293 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
294 |
@{command_def "consts"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
295 |
@{command_def "defs"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
296 |
@{command_def "constdefs"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
297 |
\end{matharray}
|
wenzelm@26767
|
298 |
|
wenzelm@26767
|
299 |
\begin{rail}
|
wenzelm@26767
|
300 |
'consts' ((name '::' type mixfix?) +)
|
wenzelm@26767
|
301 |
;
|
wenzelm@26767
|
302 |
'defs' ('(' 'unchecked'? 'overloaded'? ')')? \\ (axmdecl prop +)
|
wenzelm@26767
|
303 |
;
|
wenzelm@26767
|
304 |
\end{rail}
|
wenzelm@26767
|
305 |
|
wenzelm@26767
|
306 |
\begin{rail}
|
wenzelm@26767
|
307 |
'constdefs' structs? (constdecl? constdef +)
|
wenzelm@26767
|
308 |
;
|
wenzelm@26767
|
309 |
|
wenzelm@26767
|
310 |
structs: '(' 'structure' (vars + 'and') ')'
|
wenzelm@26767
|
311 |
;
|
wenzelm@26767
|
312 |
constdecl: ((name '::' type mixfix | name '::' type | name mixfix) 'where'?) | name 'where'
|
wenzelm@26767
|
313 |
;
|
wenzelm@26767
|
314 |
constdef: thmdecl? prop
|
wenzelm@26767
|
315 |
;
|
wenzelm@26767
|
316 |
\end{rail}
|
wenzelm@26767
|
317 |
|
wenzelm@26767
|
318 |
\begin{descr}
|
wenzelm@26767
|
319 |
|
wenzelm@26767
|
320 |
\item [@{command "consts"}~@{text "c :: \<sigma>"}] declares constant
|
wenzelm@26767
|
321 |
@{text c} to have any instance of type scheme @{text \<sigma>}. The
|
wenzelm@26767
|
322 |
optional mixfix annotations may attach concrete syntax to the
|
wenzelm@26767
|
323 |
constants declared.
|
wenzelm@26767
|
324 |
|
wenzelm@26767
|
325 |
\item [@{command "defs"}~@{text "name: eqn"}] introduces @{text eqn}
|
wenzelm@26767
|
326 |
as a definitional axiom for some existing constant.
|
wenzelm@26767
|
327 |
|
wenzelm@26767
|
328 |
The @{text "(unchecked)"} option disables global dependency checks
|
wenzelm@26767
|
329 |
for this definition, which is occasionally useful for exotic
|
wenzelm@26767
|
330 |
overloading. It is at the discretion of the user to avoid malformed
|
wenzelm@26767
|
331 |
theory specifications!
|
wenzelm@26767
|
332 |
|
wenzelm@26767
|
333 |
The @{text "(overloaded)"} option declares definitions to be
|
wenzelm@26767
|
334 |
potentially overloaded. Unless this option is given, a warning
|
wenzelm@26767
|
335 |
message would be issued for any definitional equation with a more
|
wenzelm@26767
|
336 |
special type than that of the corresponding constant declaration.
|
wenzelm@26767
|
337 |
|
wenzelm@26767
|
338 |
\item [@{command "constdefs"}] provides a streamlined combination of
|
wenzelm@26767
|
339 |
constants declarations and definitions: type-inference takes care of
|
wenzelm@26767
|
340 |
the most general typing of the given specification (the optional
|
wenzelm@26767
|
341 |
type constraint may refer to type-inference dummies ``@{verbatim
|
wenzelm@26767
|
342 |
_}'' as usual). The resulting type declaration needs to agree with
|
wenzelm@26767
|
343 |
that of the specification; overloading is \emph{not} supported here!
|
wenzelm@26767
|
344 |
|
wenzelm@26767
|
345 |
The constant name may be omitted altogether, if neither type nor
|
wenzelm@26767
|
346 |
syntax declarations are given. The canonical name of the
|
wenzelm@26767
|
347 |
definitional axiom for constant @{text c} will be @{text c_def},
|
wenzelm@26767
|
348 |
unless specified otherwise. Also note that the given list of
|
wenzelm@26767
|
349 |
specifications is processed in a strictly sequential manner, with
|
wenzelm@26767
|
350 |
type-checking being performed independently.
|
wenzelm@26767
|
351 |
|
wenzelm@26767
|
352 |
An optional initial context of @{text "(structure)"} declarations
|
wenzelm@26767
|
353 |
admits use of indexed syntax, using the special symbol @{verbatim
|
wenzelm@26767
|
354 |
"\<index>"} (printed as ``@{text "\<index>"}''). The latter concept is
|
wenzelm@26767
|
355 |
particularly useful with locales (see also \S\ref{sec:locale}).
|
wenzelm@26767
|
356 |
|
wenzelm@26767
|
357 |
\end{descr}
|
wenzelm@26767
|
358 |
*}
|
wenzelm@26767
|
359 |
|
wenzelm@26767
|
360 |
|
wenzelm@26767
|
361 |
subsection {* Syntax and translations \label{sec:syn-trans} *}
|
wenzelm@26767
|
362 |
|
wenzelm@26767
|
363 |
text {*
|
wenzelm@26767
|
364 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
365 |
@{command_def "syntax"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
366 |
@{command_def "no_syntax"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
367 |
@{command_def "translations"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
368 |
@{command_def "no_translations"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
369 |
\end{matharray}
|
wenzelm@26767
|
370 |
|
wenzelm@26767
|
371 |
\railalias{rightleftharpoons}{\isasymrightleftharpoons}
|
wenzelm@26767
|
372 |
\railterm{rightleftharpoons}
|
wenzelm@26767
|
373 |
|
wenzelm@26767
|
374 |
\railalias{rightharpoonup}{\isasymrightharpoonup}
|
wenzelm@26767
|
375 |
\railterm{rightharpoonup}
|
wenzelm@26767
|
376 |
|
wenzelm@26767
|
377 |
\railalias{leftharpoondown}{\isasymleftharpoondown}
|
wenzelm@26767
|
378 |
\railterm{leftharpoondown}
|
wenzelm@26767
|
379 |
|
wenzelm@26767
|
380 |
\begin{rail}
|
wenzelm@26767
|
381 |
('syntax' | 'no\_syntax') mode? (constdecl +)
|
wenzelm@26767
|
382 |
;
|
wenzelm@26767
|
383 |
('translations' | 'no\_translations') (transpat ('==' | '=>' | '<=' | rightleftharpoons | rightharpoonup | leftharpoondown) transpat +)
|
wenzelm@26767
|
384 |
;
|
wenzelm@26767
|
385 |
|
wenzelm@26767
|
386 |
mode: ('(' ( name | 'output' | name 'output' ) ')')
|
wenzelm@26767
|
387 |
;
|
wenzelm@26767
|
388 |
transpat: ('(' nameref ')')? string
|
wenzelm@26767
|
389 |
;
|
wenzelm@26767
|
390 |
\end{rail}
|
wenzelm@26767
|
391 |
|
wenzelm@26767
|
392 |
\begin{descr}
|
wenzelm@26767
|
393 |
|
wenzelm@26767
|
394 |
\item [@{command "syntax"}~@{text "(mode) decls"}] is similar to
|
wenzelm@26767
|
395 |
@{command "consts"}~@{text decls}, except that the actual logical
|
wenzelm@26767
|
396 |
signature extension is omitted. Thus the context free grammar of
|
wenzelm@26767
|
397 |
Isabelle's inner syntax may be augmented in arbitrary ways,
|
wenzelm@26767
|
398 |
independently of the logic. The @{text mode} argument refers to the
|
wenzelm@26767
|
399 |
print mode that the grammar rules belong; unless the @{keyword_ref
|
wenzelm@26767
|
400 |
"output"} indicator is given, all productions are added both to the
|
wenzelm@26767
|
401 |
input and output grammar.
|
wenzelm@26767
|
402 |
|
wenzelm@26767
|
403 |
\item [@{command "no_syntax"}~@{text "(mode) decls"}] removes
|
wenzelm@26767
|
404 |
grammar declarations (and translations) resulting from @{text
|
wenzelm@26767
|
405 |
decls}, which are interpreted in the same manner as for @{command
|
wenzelm@26767
|
406 |
"syntax"} above.
|
wenzelm@26767
|
407 |
|
wenzelm@26767
|
408 |
\item [@{command "translations"}~@{text rules}] specifies syntactic
|
wenzelm@26767
|
409 |
translation rules (i.e.\ macros): parse~/ print rules (@{text "\<rightleftharpoons>"}),
|
wenzelm@26767
|
410 |
parse rules (@{text "\<rightharpoonup>"}), or print rules (@{text "\<leftharpoondown>"}).
|
wenzelm@26767
|
411 |
Translation patterns may be prefixed by the syntactic category to be
|
wenzelm@26767
|
412 |
used for parsing; the default is @{text logic}.
|
wenzelm@26767
|
413 |
|
wenzelm@26767
|
414 |
\item [@{command "no_translations"}~@{text rules}] removes syntactic
|
wenzelm@26767
|
415 |
translation rules, which are interpreted in the same manner as for
|
wenzelm@26767
|
416 |
@{command "translations"} above.
|
wenzelm@26767
|
417 |
|
wenzelm@26767
|
418 |
\end{descr}
|
wenzelm@26767
|
419 |
*}
|
wenzelm@26767
|
420 |
|
wenzelm@26767
|
421 |
|
wenzelm@26767
|
422 |
subsection {* Axioms and theorems \label{sec:axms-thms} *}
|
wenzelm@26767
|
423 |
|
wenzelm@26767
|
424 |
text {*
|
wenzelm@26767
|
425 |
\begin{matharray}{rcll}
|
wenzelm@26767
|
426 |
@{command_def "axioms"} & : & \isartrans{theory}{theory} & (axiomatic!) \\
|
wenzelm@26767
|
427 |
@{command_def "lemmas"} & : & \isarkeep{local{\dsh}theory} \\
|
wenzelm@26767
|
428 |
@{command_def "theorems"} & : & isarkeep{local{\dsh}theory} \\
|
wenzelm@26767
|
429 |
\end{matharray}
|
wenzelm@26767
|
430 |
|
wenzelm@26767
|
431 |
\begin{rail}
|
wenzelm@26767
|
432 |
'axioms' (axmdecl prop +)
|
wenzelm@26767
|
433 |
;
|
wenzelm@26767
|
434 |
('lemmas' | 'theorems') target? (thmdef? thmrefs + 'and')
|
wenzelm@26767
|
435 |
;
|
wenzelm@26767
|
436 |
\end{rail}
|
wenzelm@26767
|
437 |
|
wenzelm@26767
|
438 |
\begin{descr}
|
wenzelm@26767
|
439 |
|
wenzelm@26767
|
440 |
\item [@{command "axioms"}~@{text "a: \<phi>"}] introduces arbitrary
|
wenzelm@26767
|
441 |
statements as axioms of the meta-logic. In fact, axioms are
|
wenzelm@26767
|
442 |
``axiomatic theorems'', and may be referred later just as any other
|
wenzelm@26767
|
443 |
theorem.
|
wenzelm@26767
|
444 |
|
wenzelm@26767
|
445 |
Axioms are usually only introduced when declaring new logical
|
wenzelm@26767
|
446 |
systems. Everyday work is typically done the hard way, with proper
|
wenzelm@26767
|
447 |
definitions and proven theorems.
|
wenzelm@26767
|
448 |
|
wenzelm@26767
|
449 |
\item [@{command "lemmas"}~@{text "a = b\<^sub>1 \<dots> b\<^sub>n"}]
|
wenzelm@26767
|
450 |
retrieves and stores existing facts in the theory context, or the
|
wenzelm@26767
|
451 |
specified target context (see also \secref{sec:target}). Typical
|
wenzelm@26767
|
452 |
applications would also involve attributes, to declare Simplifier
|
wenzelm@26767
|
453 |
rules, for example.
|
wenzelm@26767
|
454 |
|
wenzelm@26767
|
455 |
\item [@{command "theorems"}] is essentially the same as @{command
|
wenzelm@26767
|
456 |
"lemmas"}, but marks the result as a different kind of facts.
|
wenzelm@26767
|
457 |
|
wenzelm@26767
|
458 |
\end{descr}
|
wenzelm@26767
|
459 |
*}
|
wenzelm@26767
|
460 |
|
wenzelm@26767
|
461 |
|
wenzelm@26767
|
462 |
subsection {* Name spaces *}
|
wenzelm@26767
|
463 |
|
wenzelm@26767
|
464 |
text {*
|
wenzelm@26767
|
465 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
466 |
@{command_def "global"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
467 |
@{command_def "local"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
468 |
@{command_def "hide"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
469 |
\end{matharray}
|
wenzelm@26767
|
470 |
|
wenzelm@26767
|
471 |
\begin{rail}
|
wenzelm@26767
|
472 |
'hide' ('(open)')? name (nameref + )
|
wenzelm@26767
|
473 |
;
|
wenzelm@26767
|
474 |
\end{rail}
|
wenzelm@26767
|
475 |
|
wenzelm@26767
|
476 |
Isabelle organizes any kind of name declarations (of types,
|
wenzelm@26767
|
477 |
constants, theorems etc.) by separate hierarchically structured name
|
wenzelm@26767
|
478 |
spaces. Normally the user does not have to control the behavior of
|
wenzelm@26767
|
479 |
name spaces by hand, yet the following commands provide some way to
|
wenzelm@26767
|
480 |
do so.
|
wenzelm@26767
|
481 |
|
wenzelm@26767
|
482 |
\begin{descr}
|
wenzelm@26767
|
483 |
|
wenzelm@26767
|
484 |
\item [@{command "global"} and @{command "local"}] change the
|
wenzelm@26767
|
485 |
current name declaration mode. Initially, theories start in
|
wenzelm@26767
|
486 |
@{command "local"} mode, causing all names to be automatically
|
wenzelm@26767
|
487 |
qualified by the theory name. Changing this to @{command "global"}
|
wenzelm@26767
|
488 |
causes all names to be declared without the theory prefix, until
|
wenzelm@26767
|
489 |
@{command "local"} is declared again.
|
wenzelm@26767
|
490 |
|
wenzelm@26767
|
491 |
Note that global names are prone to get hidden accidently later,
|
wenzelm@26767
|
492 |
when qualified names of the same base name are introduced.
|
wenzelm@26767
|
493 |
|
wenzelm@26767
|
494 |
\item [@{command "hide"}~@{text "space names"}] fully removes
|
wenzelm@26767
|
495 |
declarations from a given name space (which may be @{text "class"},
|
wenzelm@26767
|
496 |
@{text "type"}, @{text "const"}, or @{text "fact"}); with the @{text
|
wenzelm@26767
|
497 |
"(open)"} option, only the base name is hidden. Global
|
wenzelm@26767
|
498 |
(unqualified) names may never be hidden.
|
wenzelm@26767
|
499 |
|
wenzelm@26767
|
500 |
Note that hiding name space accesses has no impact on logical
|
wenzelm@26767
|
501 |
declarations -- they remain valid internally. Entities that are no
|
wenzelm@26767
|
502 |
longer accessible to the user are printed with the special qualifier
|
wenzelm@26767
|
503 |
``@{text "??"}'' prefixed to the full internal name.
|
wenzelm@26767
|
504 |
|
wenzelm@26767
|
505 |
\end{descr}
|
wenzelm@26767
|
506 |
*}
|
wenzelm@26767
|
507 |
|
wenzelm@26767
|
508 |
|
wenzelm@26767
|
509 |
subsection {* Incorporating ML code \label{sec:ML} *}
|
wenzelm@26767
|
510 |
|
wenzelm@26767
|
511 |
text {*
|
wenzelm@26767
|
512 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
513 |
@{command_def "use"} & : & \isarkeep{theory~|~local{\dsh}theory} \\
|
wenzelm@26767
|
514 |
@{command_def "ML"} & : & \isarkeep{theory~|~local{\dsh}theory} \\
|
wenzelm@26767
|
515 |
@{command_def "ML_val"} & : & \isartrans{\cdot}{\cdot} \\
|
wenzelm@26767
|
516 |
@{command_def "ML_command"} & : & \isartrans{\cdot}{\cdot} \\
|
wenzelm@26767
|
517 |
@{command_def "setup"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
518 |
@{command_def "method_setup"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
519 |
\end{matharray}
|
wenzelm@26767
|
520 |
|
wenzelm@26767
|
521 |
\begin{rail}
|
wenzelm@26767
|
522 |
'use' name
|
wenzelm@26767
|
523 |
;
|
wenzelm@26767
|
524 |
('ML' | 'ML\_val' | 'ML\_command' | 'setup') text
|
wenzelm@26767
|
525 |
;
|
wenzelm@26767
|
526 |
'method\_setup' name '=' text text
|
wenzelm@26767
|
527 |
;
|
wenzelm@26767
|
528 |
\end{rail}
|
wenzelm@26767
|
529 |
|
wenzelm@26767
|
530 |
\begin{descr}
|
wenzelm@26767
|
531 |
|
wenzelm@26767
|
532 |
\item [@{command "use"}~@{text "file"}] reads and executes ML
|
wenzelm@26767
|
533 |
commands from @{text "file"}. The current theory context is passed
|
wenzelm@26767
|
534 |
down to the ML toplevel and may be modified, using @{ML
|
wenzelm@26767
|
535 |
"Context.>>"} or derived ML commands. The file name is checked with
|
wenzelm@26767
|
536 |
the @{keyword_ref "uses"} dependency declaration given in the theory
|
wenzelm@26767
|
537 |
header (see also \secref{sec:begin-thy}).
|
wenzelm@26767
|
538 |
|
wenzelm@26767
|
539 |
\item [@{command "ML"}~@{text "text"}] is similar to @{command
|
wenzelm@26767
|
540 |
"use"}, but executes ML commands directly from the given @{text
|
wenzelm@26767
|
541 |
"text"}.
|
wenzelm@26767
|
542 |
|
wenzelm@26767
|
543 |
\item [@{command "ML_val"} and @{command "ML_command"}] are
|
wenzelm@26767
|
544 |
diagnostic versions of @{command "ML"}, which means that the context
|
wenzelm@26767
|
545 |
may not be updated. @{command "ML_val"} echos the bindings produced
|
wenzelm@26767
|
546 |
at the ML toplevel, but @{command "ML_command"} is silent.
|
wenzelm@26767
|
547 |
|
wenzelm@26767
|
548 |
\item [@{command "setup"}~@{text "text"}] changes the current theory
|
wenzelm@26767
|
549 |
context by applying @{text "text"}, which refers to an ML expression
|
wenzelm@26767
|
550 |
of type @{ML_type "theory -> theory"}. This enables to initialize
|
wenzelm@26767
|
551 |
any object-logic specific tools and packages written in ML, for
|
wenzelm@26767
|
552 |
example.
|
wenzelm@26767
|
553 |
|
wenzelm@26767
|
554 |
\item [@{command "method_setup"}~@{text "name = text description"}]
|
wenzelm@26767
|
555 |
defines a proof method in the current theory. The given @{text
|
wenzelm@26767
|
556 |
"text"} has to be an ML expression of type @{ML_type "Args.src ->
|
wenzelm@26767
|
557 |
Proof.context -> Proof.method"}. Parsing concrete method syntax
|
wenzelm@26767
|
558 |
from @{ML_type Args.src} input can be quite tedious in general. The
|
wenzelm@26767
|
559 |
following simple examples are for methods without any explicit
|
wenzelm@26767
|
560 |
arguments, or a list of theorems, respectively.
|
wenzelm@26767
|
561 |
|
wenzelm@26767
|
562 |
%FIXME proper antiquotations
|
wenzelm@26767
|
563 |
{\footnotesize
|
wenzelm@26767
|
564 |
\begin{verbatim}
|
wenzelm@26767
|
565 |
Method.no_args (Method.METHOD (fn facts => foobar_tac))
|
wenzelm@26767
|
566 |
Method.thms_args (fn thms => Method.METHOD (fn facts => foobar_tac))
|
wenzelm@26767
|
567 |
Method.ctxt_args (fn ctxt => Method.METHOD (fn facts => foobar_tac))
|
wenzelm@26767
|
568 |
Method.thms_ctxt_args (fn thms => fn ctxt =>
|
wenzelm@26767
|
569 |
Method.METHOD (fn facts => foobar_tac))
|
wenzelm@26767
|
570 |
\end{verbatim}
|
wenzelm@26767
|
571 |
}
|
wenzelm@26767
|
572 |
|
wenzelm@26767
|
573 |
Note that mere tactic emulations may ignore the @{text facts}
|
wenzelm@26767
|
574 |
parameter above. Proper proof methods would do something
|
wenzelm@26767
|
575 |
appropriate with the list of current facts, though. Single-rule
|
wenzelm@26767
|
576 |
methods usually do strict forward-chaining (e.g.\ by using @{ML
|
wenzelm@26767
|
577 |
Drule.multi_resolves}), while automatic ones just insert the facts
|
wenzelm@26767
|
578 |
using @{ML Method.insert_tac} before applying the main tactic.
|
wenzelm@26767
|
579 |
|
wenzelm@26767
|
580 |
\end{descr}
|
wenzelm@26767
|
581 |
*}
|
wenzelm@26767
|
582 |
|
wenzelm@26767
|
583 |
|
wenzelm@26767
|
584 |
subsection {* Syntax translation functions *}
|
wenzelm@26767
|
585 |
|
wenzelm@26767
|
586 |
text {*
|
wenzelm@26767
|
587 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
588 |
@{command_def "parse_ast_translation"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
589 |
@{command_def "parse_translation"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
590 |
@{command_def "print_translation"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
591 |
@{command_def "typed_print_translation"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
592 |
@{command_def "print_ast_translation"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
593 |
@{command_def "token_translation"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
594 |
\end{matharray}
|
wenzelm@26767
|
595 |
|
wenzelm@26767
|
596 |
\begin{rail}
|
wenzelm@26767
|
597 |
( 'parse\_ast\_translation' | 'parse\_translation' | 'print\_translation' |
|
wenzelm@26767
|
598 |
'typed\_print\_translation' | 'print\_ast\_translation' ) ('(advanced)')? text
|
wenzelm@26767
|
599 |
;
|
wenzelm@26767
|
600 |
|
wenzelm@26767
|
601 |
'token\_translation' text
|
wenzelm@26767
|
602 |
;
|
wenzelm@26767
|
603 |
\end{rail}
|
wenzelm@26767
|
604 |
|
wenzelm@26767
|
605 |
Syntax translation functions written in ML admit almost arbitrary
|
wenzelm@26767
|
606 |
manipulations of Isabelle's inner syntax. Any of the above commands
|
wenzelm@26767
|
607 |
have a single \railqtok{text} argument that refers to an ML
|
wenzelm@26767
|
608 |
expression of appropriate type, which are as follows by default:
|
wenzelm@26767
|
609 |
|
wenzelm@26767
|
610 |
%FIXME proper antiquotations
|
wenzelm@26767
|
611 |
\begin{ttbox}
|
wenzelm@26767
|
612 |
val parse_ast_translation : (string * (ast list -> ast)) list
|
wenzelm@26767
|
613 |
val parse_translation : (string * (term list -> term)) list
|
wenzelm@26767
|
614 |
val print_translation : (string * (term list -> term)) list
|
wenzelm@26767
|
615 |
val typed_print_translation :
|
wenzelm@26767
|
616 |
(string * (bool -> typ -> term list -> term)) list
|
wenzelm@26767
|
617 |
val print_ast_translation : (string * (ast list -> ast)) list
|
wenzelm@26767
|
618 |
val token_translation :
|
wenzelm@26767
|
619 |
(string * string * (string -> string * real)) list
|
wenzelm@26767
|
620 |
\end{ttbox}
|
wenzelm@26767
|
621 |
|
wenzelm@26767
|
622 |
If the @{text "(advanced)"} option is given, the corresponding
|
wenzelm@26767
|
623 |
translation functions may depend on the current theory or proof
|
wenzelm@26767
|
624 |
context. This allows to implement advanced syntax mechanisms, as
|
wenzelm@26767
|
625 |
translations functions may refer to specific theory declarations or
|
wenzelm@26767
|
626 |
auxiliary proof data.
|
wenzelm@26767
|
627 |
|
wenzelm@26767
|
628 |
See also \cite[\S8]{isabelle-ref} for more information on the
|
wenzelm@26767
|
629 |
general concept of syntax transformations in Isabelle.
|
wenzelm@26767
|
630 |
|
wenzelm@26767
|
631 |
%FIXME proper antiquotations
|
wenzelm@26767
|
632 |
\begin{ttbox}
|
wenzelm@26767
|
633 |
val parse_ast_translation:
|
wenzelm@26767
|
634 |
(string * (Context.generic -> ast list -> ast)) list
|
wenzelm@26767
|
635 |
val parse_translation:
|
wenzelm@26767
|
636 |
(string * (Context.generic -> term list -> term)) list
|
wenzelm@26767
|
637 |
val print_translation:
|
wenzelm@26767
|
638 |
(string * (Context.generic -> term list -> term)) list
|
wenzelm@26767
|
639 |
val typed_print_translation:
|
wenzelm@26767
|
640 |
(string * (Context.generic -> bool -> typ -> term list -> term)) list
|
wenzelm@26767
|
641 |
val print_ast_translation:
|
wenzelm@26767
|
642 |
(string * (Context.generic -> ast list -> ast)) list
|
wenzelm@26767
|
643 |
\end{ttbox}
|
wenzelm@26767
|
644 |
*}
|
wenzelm@26767
|
645 |
|
wenzelm@26767
|
646 |
|
wenzelm@26767
|
647 |
subsection {* Oracles *}
|
wenzelm@26767
|
648 |
|
wenzelm@26767
|
649 |
text {*
|
wenzelm@26767
|
650 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
651 |
@{command_def "oracle"} & : & \isartrans{theory}{theory} \\
|
wenzelm@26767
|
652 |
\end{matharray}
|
wenzelm@26767
|
653 |
|
wenzelm@26767
|
654 |
The oracle interface promotes a given ML function @{ML_text
|
wenzelm@26767
|
655 |
"theory -> T -> term"} to @{ML_text "theory -> T -> thm"}, for some type
|
wenzelm@26767
|
656 |
@{ML_text T} given by the user. This acts like an infinitary
|
wenzelm@26767
|
657 |
specification of axioms -- there is no internal check of the
|
wenzelm@26767
|
658 |
correctness of the results! The inference kernel records oracle
|
wenzelm@26767
|
659 |
invocations within the internal derivation object of theorems, and
|
wenzelm@26767
|
660 |
the pretty printer attaches ``@{text "[!]"}'' to indicate results
|
wenzelm@26767
|
661 |
that are not fully checked by Isabelle inferences.
|
wenzelm@26767
|
662 |
|
wenzelm@26767
|
663 |
\begin{rail}
|
wenzelm@26767
|
664 |
'oracle' name '(' type ')' '=' text
|
wenzelm@26767
|
665 |
;
|
wenzelm@26767
|
666 |
\end{rail}
|
wenzelm@26767
|
667 |
|
wenzelm@26767
|
668 |
\begin{descr}
|
wenzelm@26767
|
669 |
|
wenzelm@26767
|
670 |
\item [@{command "oracle"}~@{text "name (type) = text"}] turns the
|
wenzelm@26767
|
671 |
given ML expression @{text "text"} of type @{ML_text "{theory
|
wenzelm@26767
|
672 |
->"}~@{text "type"}~@{ML_text "-> term"} into an ML function
|
wenzelm@26767
|
673 |
@{ML_text name} of type @{ML_text "{theory ->"}~@{text
|
wenzelm@26767
|
674 |
"type"}~@{ML_text "-> thm"}.
|
wenzelm@26767
|
675 |
|
wenzelm@26767
|
676 |
\end{descr}
|
wenzelm@26767
|
677 |
*}
|
wenzelm@26767
|
678 |
|
wenzelm@26767
|
679 |
|
wenzelm@26767
|
680 |
section {* Proof commands *}
|
wenzelm@26767
|
681 |
|
wenzelm@26767
|
682 |
text {*
|
wenzelm@26767
|
683 |
Proof commands perform transitions of Isar/VM machine
|
wenzelm@26767
|
684 |
configurations, which are block-structured, consisting of a stack of
|
wenzelm@26767
|
685 |
nodes with three main components: logical proof context, current
|
wenzelm@26767
|
686 |
facts, and open goals. Isar/VM transitions are \emph{typed}
|
wenzelm@26767
|
687 |
according to the following three different modes of operation:
|
wenzelm@26767
|
688 |
|
wenzelm@26767
|
689 |
\begin{descr}
|
wenzelm@26767
|
690 |
|
wenzelm@26767
|
691 |
\item [@{text "proof(prove)"}] means that a new goal has just been
|
wenzelm@26767
|
692 |
stated that is now to be \emph{proven}; the next command may refine
|
wenzelm@26767
|
693 |
it by some proof method, and enter a sub-proof to establish the
|
wenzelm@26767
|
694 |
actual result.
|
wenzelm@26767
|
695 |
|
wenzelm@26767
|
696 |
\item [@{text "proof(state)"}] is like a nested theory mode: the
|
wenzelm@26767
|
697 |
context may be augmented by \emph{stating} additional assumptions,
|
wenzelm@26767
|
698 |
intermediate results etc.
|
wenzelm@26767
|
699 |
|
wenzelm@26767
|
700 |
\item [@{text "proof(chain)"}] is intermediate between @{text
|
wenzelm@26767
|
701 |
"proof(state)"} and @{text "proof(prove)"}: existing facts (i.e.\
|
wenzelm@26767
|
702 |
the contents of the special ``@{fact_ref this}'' register) have been
|
wenzelm@26767
|
703 |
just picked up in order to be used when refining the goal claimed
|
wenzelm@26767
|
704 |
next.
|
wenzelm@26767
|
705 |
|
wenzelm@26767
|
706 |
\end{descr}
|
wenzelm@26767
|
707 |
|
wenzelm@26767
|
708 |
The proof mode indicator may be read as a verb telling the writer
|
wenzelm@26767
|
709 |
what kind of operation may be performed next. The corresponding
|
wenzelm@26767
|
710 |
typings of proof commands restricts the shape of well-formed proof
|
wenzelm@26767
|
711 |
texts to particular command sequences. So dynamic arrangements of
|
wenzelm@26767
|
712 |
commands eventually turn out as static texts of a certain structure.
|
wenzelm@26767
|
713 |
\Appref{ap:refcard} gives a simplified grammar of the overall
|
wenzelm@26767
|
714 |
(extensible) language emerging that way.
|
wenzelm@26767
|
715 |
*}
|
wenzelm@26767
|
716 |
|
wenzelm@26767
|
717 |
|
wenzelm@26767
|
718 |
subsection {* Markup commands \label{sec:markup-prf} *}
|
wenzelm@26767
|
719 |
|
wenzelm@26767
|
720 |
text {*
|
wenzelm@26767
|
721 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
722 |
@{command_def "sect"} & : & \isartrans{proof}{proof} \\
|
wenzelm@26767
|
723 |
@{command_def "subsect"} & : & \isartrans{proof}{proof} \\
|
wenzelm@26767
|
724 |
@{command_def "subsubsect"} & : & \isartrans{proof}{proof} \\
|
wenzelm@26767
|
725 |
@{command_def "txt"} & : & \isartrans{proof}{proof} \\
|
wenzelm@26767
|
726 |
@{command_def "txt_raw"} & : & \isartrans{proof}{proof} \\
|
wenzelm@26767
|
727 |
\end{matharray}
|
wenzelm@26767
|
728 |
|
wenzelm@26767
|
729 |
These markup commands for proof mode closely correspond to the ones
|
wenzelm@26767
|
730 |
of theory mode (see \S\ref{sec:markup-thy}).
|
wenzelm@26767
|
731 |
|
wenzelm@26767
|
732 |
\begin{rail}
|
wenzelm@26767
|
733 |
('sect' | 'subsect' | 'subsubsect' | 'txt' | 'txt\_raw') text
|
wenzelm@26767
|
734 |
;
|
wenzelm@26767
|
735 |
\end{rail}
|
wenzelm@26767
|
736 |
*}
|
wenzelm@26767
|
737 |
|
wenzelm@26767
|
738 |
|
wenzelm@26767
|
739 |
subsection {* Context elements \label{sec:proof-context} *}
|
wenzelm@26767
|
740 |
|
wenzelm@26767
|
741 |
text {*
|
wenzelm@26767
|
742 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
743 |
@{command_def "fix"} & : & \isartrans{proof(state)}{proof(state)} \\
|
wenzelm@26767
|
744 |
@{command_def "assume"} & : & \isartrans{proof(state)}{proof(state)} \\
|
wenzelm@26767
|
745 |
@{command_def "presume"} & : & \isartrans{proof(state)}{proof(state)} \\
|
wenzelm@26767
|
746 |
@{command_def "def"} & : & \isartrans{proof(state)}{proof(state)} \\
|
wenzelm@26767
|
747 |
\end{matharray}
|
wenzelm@26767
|
748 |
|
wenzelm@26767
|
749 |
The logical proof context consists of fixed variables and
|
wenzelm@26767
|
750 |
assumptions. The former closely correspond to Skolem constants, or
|
wenzelm@26767
|
751 |
meta-level universal quantification as provided by the Isabelle/Pure
|
wenzelm@26767
|
752 |
logical framework. Introducing some \emph{arbitrary, but fixed}
|
wenzelm@26767
|
753 |
variable via ``@{command "fix"}~@{text x} results in a local value
|
wenzelm@26767
|
754 |
that may be used in the subsequent proof as any other variable or
|
wenzelm@26767
|
755 |
constant. Furthermore, any result @{text "\<turnstile> \<phi>[x]"} exported from
|
wenzelm@26767
|
756 |
the context will be universally closed wrt.\ @{text x} at the
|
wenzelm@26767
|
757 |
outermost level: @{text "\<turnstile> \<And>x. \<phi>[x]"} (this is expressed in normal
|
wenzelm@26767
|
758 |
form using Isabelle's meta-variables).
|
wenzelm@26767
|
759 |
|
wenzelm@26767
|
760 |
Similarly, introducing some assumption @{text \<chi>} has two effects.
|
wenzelm@26767
|
761 |
On the one hand, a local theorem is created that may be used as a
|
wenzelm@26767
|
762 |
fact in subsequent proof steps. On the other hand, any result
|
wenzelm@26767
|
763 |
@{text "\<chi> \<turnstile> \<phi>"} exported from the context becomes conditional wrt.\
|
wenzelm@26767
|
764 |
the assumption: @{text "\<turnstile> \<chi> \<Longrightarrow> \<phi>"}. Thus, solving an enclosing goal
|
wenzelm@26767
|
765 |
using such a result would basically introduce a new subgoal stemming
|
wenzelm@26767
|
766 |
from the assumption. How this situation is handled depends on the
|
wenzelm@26767
|
767 |
version of assumption command used: while @{command "assume"}
|
wenzelm@26767
|
768 |
insists on solving the subgoal by unification with some premise of
|
wenzelm@26767
|
769 |
the goal, @{command "presume"} leaves the subgoal unchanged in order
|
wenzelm@26767
|
770 |
to be proved later by the user.
|
wenzelm@26767
|
771 |
|
wenzelm@26767
|
772 |
Local definitions, introduced by ``@{command "def"}~@{text "x \<equiv>
|
wenzelm@26767
|
773 |
t"}'', are achieved by combining ``@{command "fix"}~@{text x}'' with
|
wenzelm@26767
|
774 |
another version of assumption that causes any hypothetical equation
|
wenzelm@26767
|
775 |
@{text "x \<equiv> t"} to be eliminated by the reflexivity rule. Thus,
|
wenzelm@26767
|
776 |
exporting some result @{text "x \<equiv> t \<turnstile> \<phi>[x]"} yields @{text "\<turnstile>
|
wenzelm@26767
|
777 |
\<phi>[t]"}.
|
wenzelm@26767
|
778 |
|
wenzelm@26767
|
779 |
\railalias{equiv}{\isasymequiv}
|
wenzelm@26767
|
780 |
\railterm{equiv}
|
wenzelm@26767
|
781 |
|
wenzelm@26767
|
782 |
\begin{rail}
|
wenzelm@26767
|
783 |
'fix' (vars + 'and')
|
wenzelm@26767
|
784 |
;
|
wenzelm@26767
|
785 |
('assume' | 'presume') (props + 'and')
|
wenzelm@26767
|
786 |
;
|
wenzelm@26767
|
787 |
'def' (def + 'and')
|
wenzelm@26767
|
788 |
;
|
wenzelm@26767
|
789 |
def: thmdecl? \\ name ('==' | equiv) term termpat?
|
wenzelm@26767
|
790 |
;
|
wenzelm@26767
|
791 |
\end{rail}
|
wenzelm@26767
|
792 |
|
wenzelm@26767
|
793 |
\begin{descr}
|
wenzelm@26767
|
794 |
|
wenzelm@26767
|
795 |
\item [@{command "fix"}~@{text x}] introduces a local variable
|
wenzelm@26767
|
796 |
@{text x} that is \emph{arbitrary, but fixed.}
|
wenzelm@26767
|
797 |
|
wenzelm@26767
|
798 |
\item [@{command "assume"}~@{text "a: \<phi>"} and @{command
|
wenzelm@26767
|
799 |
"presume"}~@{text "a: \<phi>"}] introduce a local fact @{text "\<phi> \<turnstile> \<phi>"} by
|
wenzelm@26767
|
800 |
assumption. Subsequent results applied to an enclosing goal (e.g.\
|
wenzelm@26767
|
801 |
by @{command_ref "show"}) are handled as follows: @{command
|
wenzelm@26767
|
802 |
"assume"} expects to be able to unify with existing premises in the
|
wenzelm@26767
|
803 |
goal, while @{command "presume"} leaves @{text \<phi>} as new subgoals.
|
wenzelm@26767
|
804 |
|
wenzelm@26767
|
805 |
Several lists of assumptions may be given (separated by
|
wenzelm@26767
|
806 |
@{keyword_ref "and"}; the resulting list of current facts consists
|
wenzelm@26767
|
807 |
of all of these concatenated.
|
wenzelm@26767
|
808 |
|
wenzelm@26767
|
809 |
\item [@{command "def"}~@{text "x \<equiv> t"}] introduces a local
|
wenzelm@26767
|
810 |
(non-polymorphic) definition. In results exported from the context,
|
wenzelm@26767
|
811 |
@{text x} is replaced by @{text t}. Basically, ``@{command
|
wenzelm@26767
|
812 |
"def"}~@{text "x \<equiv> t"}'' abbreviates ``@{command "fix"}~@{text
|
wenzelm@26767
|
813 |
x}~@{command "assume"}~@{text "x \<equiv> t"}'', with the resulting
|
wenzelm@26767
|
814 |
hypothetical equation solved by reflexivity.
|
wenzelm@26767
|
815 |
|
wenzelm@26767
|
816 |
The default name for the definitional equation is @{text x_def}.
|
wenzelm@26767
|
817 |
Several simultaneous definitions may be given at the same time.
|
wenzelm@26767
|
818 |
|
wenzelm@26767
|
819 |
\end{descr}
|
wenzelm@26767
|
820 |
|
wenzelm@26767
|
821 |
The special name @{fact_ref prems} refers to all assumptions of the
|
wenzelm@26767
|
822 |
current context as a list of theorems. This feature should be used
|
wenzelm@26767
|
823 |
with great care! It is better avoided in final proof texts.
|
wenzelm@26767
|
824 |
*}
|
wenzelm@26767
|
825 |
|
wenzelm@26767
|
826 |
|
wenzelm@26767
|
827 |
subsection {* Facts and forward chaining *}
|
wenzelm@26767
|
828 |
|
wenzelm@26767
|
829 |
text {*
|
wenzelm@26767
|
830 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
831 |
@{command_def "note"} & : & \isartrans{proof(state)}{proof(state)} \\
|
wenzelm@26767
|
832 |
@{command_def "then"} & : & \isartrans{proof(state)}{proof(chain)} \\
|
wenzelm@26767
|
833 |
@{command_def "from"} & : & \isartrans{proof(state)}{proof(chain)} \\
|
wenzelm@26767
|
834 |
@{command_def "with"} & : & \isartrans{proof(state)}{proof(chain)} \\
|
wenzelm@26767
|
835 |
@{command_def "using"} & : & \isartrans{proof(prove)}{proof(prove)} \\
|
wenzelm@26767
|
836 |
@{command_def "unfolding"} & : & \isartrans{proof(prove)}{proof(prove)} \\
|
wenzelm@26767
|
837 |
\end{matharray}
|
wenzelm@26767
|
838 |
|
wenzelm@26767
|
839 |
New facts are established either by assumption or proof of local
|
wenzelm@26767
|
840 |
statements. Any fact will usually be involved in further proofs,
|
wenzelm@26767
|
841 |
either as explicit arguments of proof methods, or when forward
|
wenzelm@26767
|
842 |
chaining towards the next goal via @{command "then"} (and variants);
|
wenzelm@26767
|
843 |
@{command "from"} and @{command "with"} are composite forms
|
wenzelm@26767
|
844 |
involving @{command "note"}. The @{command "using"} elements
|
wenzelm@26767
|
845 |
augments the collection of used facts \emph{after} a goal has been
|
wenzelm@26767
|
846 |
stated. Note that the special theorem name @{fact_ref this} refers
|
wenzelm@26767
|
847 |
to the most recently established facts, but only \emph{before}
|
wenzelm@26767
|
848 |
issuing a follow-up claim.
|
wenzelm@26767
|
849 |
|
wenzelm@26767
|
850 |
\begin{rail}
|
wenzelm@26767
|
851 |
'note' (thmdef? thmrefs + 'and')
|
wenzelm@26767
|
852 |
;
|
wenzelm@26767
|
853 |
('from' | 'with' | 'using' | 'unfolding') (thmrefs + 'and')
|
wenzelm@26767
|
854 |
;
|
wenzelm@26767
|
855 |
\end{rail}
|
wenzelm@26767
|
856 |
|
wenzelm@26767
|
857 |
\begin{descr}
|
wenzelm@26767
|
858 |
|
wenzelm@26767
|
859 |
\item [@{command "note"}~@{text "a = b\<^sub>1 \<dots> b\<^sub>n"}]
|
wenzelm@26767
|
860 |
recalls existing facts @{text "b\<^sub>1, \<dots>, b\<^sub>n"}, binding
|
wenzelm@26767
|
861 |
the result as @{text a}. Note that attributes may be involved as
|
wenzelm@26767
|
862 |
well, both on the left and right hand sides.
|
wenzelm@26767
|
863 |
|
wenzelm@26767
|
864 |
\item [@{command "then"}] indicates forward chaining by the current
|
wenzelm@26767
|
865 |
facts in order to establish the goal to be claimed next. The
|
wenzelm@26767
|
866 |
initial proof method invoked to refine that will be offered the
|
wenzelm@26767
|
867 |
facts to do ``anything appropriate'' (see also
|
wenzelm@26767
|
868 |
\secref{sec:proof-steps}). For example, method @{method_ref rule}
|
wenzelm@26767
|
869 |
(see \secref{sec:pure-meth-att}) would typically do an elimination
|
wenzelm@26767
|
870 |
rather than an introduction. Automatic methods usually insert the
|
wenzelm@26767
|
871 |
facts into the goal state before operation. This provides a simple
|
wenzelm@26767
|
872 |
scheme to control relevance of facts in automated proof search.
|
wenzelm@26767
|
873 |
|
wenzelm@26767
|
874 |
\item [@{command "from"}~@{text b}] abbreviates ``@{command
|
wenzelm@26767
|
875 |
"note"}~@{text b}~@{command "then"}''; thus @{command "then"} is
|
wenzelm@26767
|
876 |
equivalent to ``@{command "from"}~@{text this}''.
|
wenzelm@26767
|
877 |
|
wenzelm@26767
|
878 |
\item [@{command "with"}~@{text "b\<^sub>1 \<dots> b\<^sub>n"}]
|
wenzelm@26767
|
879 |
abbreviates ``@{command "from"}~@{text "b\<^sub>1 \<dots> b\<^sub>n \<AND>
|
wenzelm@26767
|
880 |
this"}''; thus the forward chaining is from earlier facts together
|
wenzelm@26767
|
881 |
with the current ones.
|
wenzelm@26767
|
882 |
|
wenzelm@26767
|
883 |
\item [@{command "using"}~@{text "b\<^sub>1 \<dots> b\<^sub>n"}] augments
|
wenzelm@26767
|
884 |
the facts being currently indicated for use by a subsequent
|
wenzelm@26767
|
885 |
refinement step (such as @{command_ref "apply"} or @{command_ref
|
wenzelm@26767
|
886 |
"proof"}).
|
wenzelm@26767
|
887 |
|
wenzelm@26767
|
888 |
\item [@{command "unfolding"}~@{text "b\<^sub>1 \<dots> b\<^sub>n"}] is
|
wenzelm@26767
|
889 |
structurally similar to @{command "using"}, but unfolds definitional
|
wenzelm@26767
|
890 |
equations @{text "b\<^sub>1, \<dots> b\<^sub>n"} throughout the goal state
|
wenzelm@26767
|
891 |
and facts.
|
wenzelm@26767
|
892 |
|
wenzelm@26767
|
893 |
\end{descr}
|
wenzelm@26767
|
894 |
|
wenzelm@26767
|
895 |
Forward chaining with an empty list of theorems is the same as not
|
wenzelm@26767
|
896 |
chaining at all. Thus ``@{command "from"}~@{text nothing}'' has no
|
wenzelm@26767
|
897 |
effect apart from entering @{text "prove(chain)"} mode, since
|
wenzelm@26767
|
898 |
@{fact_ref nothing} is bound to the empty list of theorems.
|
wenzelm@26767
|
899 |
|
wenzelm@26767
|
900 |
Basic proof methods (such as @{method_ref rule}) expect multiple
|
wenzelm@26767
|
901 |
facts to be given in their proper order, corresponding to a prefix
|
wenzelm@26767
|
902 |
of the premises of the rule involved. Note that positions may be
|
wenzelm@26767
|
903 |
easily skipped using something like @{command "from"}~@{text "_
|
wenzelm@26767
|
904 |
\<AND> a \<AND> b"}, for example. This involves the trivial rule
|
wenzelm@26767
|
905 |
@{text "PROP \<psi> \<Longrightarrow> PROP \<psi>"}, which is bound in Isabelle/Pure as
|
wenzelm@26767
|
906 |
``@{fact_ref "_"}'' (underscore).
|
wenzelm@26767
|
907 |
|
wenzelm@26767
|
908 |
Automated methods (such as @{method simp} or @{method auto}) just
|
wenzelm@26767
|
909 |
insert any given facts before their usual operation. Depending on
|
wenzelm@26767
|
910 |
the kind of procedure involved, the order of facts is less
|
wenzelm@26767
|
911 |
significant here.
|
wenzelm@26767
|
912 |
*}
|
wenzelm@26767
|
913 |
|
wenzelm@26767
|
914 |
|
wenzelm@26767
|
915 |
subsection {* Goal statements \label{sec:goals} *}
|
wenzelm@26767
|
916 |
|
wenzelm@26767
|
917 |
text {*
|
wenzelm@26767
|
918 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
919 |
\isarcmd{lemma} & : & \isartrans{local{\dsh}theory}{proof(prove)} \\
|
wenzelm@26767
|
920 |
\isarcmd{theorem} & : & \isartrans{local{\dsh}theory}{proof(prove)} \\
|
wenzelm@26767
|
921 |
\isarcmd{corollary} & : & \isartrans{local{\dsh}theory}{proof(prove)} \\
|
wenzelm@26767
|
922 |
\isarcmd{have} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\
|
wenzelm@26767
|
923 |
\isarcmd{show} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\
|
wenzelm@26767
|
924 |
\isarcmd{hence} & : & \isartrans{proof(state)}{proof(prove)} \\
|
wenzelm@26767
|
925 |
\isarcmd{thus} & : & \isartrans{proof(state)}{proof(prove)} \\
|
wenzelm@26767
|
926 |
\isarcmd{print_statement}^* & : & \isarkeep{theory~|~proof} \\
|
wenzelm@26767
|
927 |
\end{matharray}
|
wenzelm@26767
|
928 |
|
wenzelm@26767
|
929 |
From a theory context, proof mode is entered by an initial goal
|
wenzelm@26767
|
930 |
command such as @{command "lemma"}, @{command "theorem"}, or
|
wenzelm@26767
|
931 |
@{command "corollary"}. Within a proof, new claims may be
|
wenzelm@26767
|
932 |
introduced locally as well; four variants are available here to
|
wenzelm@26767
|
933 |
indicate whether forward chaining of facts should be performed
|
wenzelm@26767
|
934 |
initially (via @{command_ref "then"}), and whether the final result
|
wenzelm@26767
|
935 |
is meant to solve some pending goal.
|
wenzelm@26767
|
936 |
|
wenzelm@26767
|
937 |
Goals may consist of multiple statements, resulting in a list of
|
wenzelm@26767
|
938 |
facts eventually. A pending multi-goal is internally represented as
|
wenzelm@26767
|
939 |
a meta-level conjunction (printed as @{text "&&"}), which is usually
|
wenzelm@26767
|
940 |
split into the corresponding number of sub-goals prior to an initial
|
wenzelm@26767
|
941 |
method application, via @{command_ref "proof"}
|
wenzelm@26767
|
942 |
(\secref{sec:proof-steps}) or @{command_ref "apply"}
|
wenzelm@26767
|
943 |
(\secref{sec:tactic-commands}). The @{method_ref induct} method
|
wenzelm@26767
|
944 |
covered in \secref{sec:cases-induct} acts on multiple claims
|
wenzelm@26767
|
945 |
simultaneously.
|
wenzelm@26767
|
946 |
|
wenzelm@26767
|
947 |
Claims at the theory level may be either in short or long form. A
|
wenzelm@26767
|
948 |
short goal merely consists of several simultaneous propositions
|
wenzelm@26767
|
949 |
(often just one). A long goal includes an explicit context
|
wenzelm@26767
|
950 |
specification for the subsequent conclusion, involving local
|
wenzelm@26767
|
951 |
parameters and assumptions. Here the role of each part of the
|
wenzelm@26767
|
952 |
statement is explicitly marked by separate keywords (see also
|
wenzelm@26767
|
953 |
\secref{sec:locale}); the local assumptions being introduced here
|
wenzelm@26767
|
954 |
are available as @{fact_ref assms} in the proof. Moreover, there
|
wenzelm@26767
|
955 |
are two kinds of conclusions: @{element_def "shows"} states several
|
wenzelm@26767
|
956 |
simultaneous propositions (essentially a big conjunction), while
|
wenzelm@26767
|
957 |
@{element_def "obtains"} claims several simultaneous simultaneous
|
wenzelm@26767
|
958 |
contexts of (essentially a big disjunction of eliminated parameters
|
wenzelm@26767
|
959 |
and assumptions, cf.\ \secref{sec:obtain}).
|
wenzelm@26767
|
960 |
|
wenzelm@26767
|
961 |
\begin{rail}
|
wenzelm@26767
|
962 |
('lemma' | 'theorem' | 'corollary') target? (goal | longgoal)
|
wenzelm@26767
|
963 |
;
|
wenzelm@26767
|
964 |
('have' | 'show' | 'hence' | 'thus') goal
|
wenzelm@26767
|
965 |
;
|
wenzelm@26767
|
966 |
'print\_statement' modes? thmrefs
|
wenzelm@26767
|
967 |
;
|
wenzelm@26767
|
968 |
|
wenzelm@26767
|
969 |
goal: (props + 'and')
|
wenzelm@26767
|
970 |
;
|
wenzelm@26767
|
971 |
longgoal: thmdecl? (contextelem *) conclusion
|
wenzelm@26767
|
972 |
;
|
wenzelm@26767
|
973 |
conclusion: 'shows' goal | 'obtains' (parname? case + '|')
|
wenzelm@26767
|
974 |
;
|
wenzelm@26767
|
975 |
case: (vars + 'and') 'where' (props + 'and')
|
wenzelm@26767
|
976 |
;
|
wenzelm@26767
|
977 |
\end{rail}
|
wenzelm@26767
|
978 |
|
wenzelm@26767
|
979 |
\begin{descr}
|
wenzelm@26767
|
980 |
|
wenzelm@26767
|
981 |
\item [@{command "lemma"}~@{text "a: \<phi>"}] enters proof mode with
|
wenzelm@26767
|
982 |
@{text \<phi>} as main goal, eventually resulting in some fact @{text "\<turnstile>
|
wenzelm@26767
|
983 |
\<phi>"} to be put back into the target context. An additional
|
wenzelm@26767
|
984 |
\railnonterm{context} specification may build up an initial proof
|
wenzelm@26767
|
985 |
context for the subsequent claim; this includes local definitions
|
wenzelm@26767
|
986 |
and syntax as well, see the definition of @{syntax contextelem} in
|
wenzelm@26767
|
987 |
\secref{sec:locale}.
|
wenzelm@26767
|
988 |
|
wenzelm@26767
|
989 |
\item [@{command "theorem"}~@{text "a: \<phi>"} and @{command
|
wenzelm@26767
|
990 |
"corollary"}~@{text "a: \<phi>"}] are essentially the same as @{command
|
wenzelm@26767
|
991 |
"lemma"}~@{text "a: \<phi>"}, but the facts are internally marked as
|
wenzelm@26767
|
992 |
being of a different kind. This discrimination acts like a formal
|
wenzelm@26767
|
993 |
comment.
|
wenzelm@26767
|
994 |
|
wenzelm@26767
|
995 |
\item [@{command "have"}~@{text "a: \<phi>"}] claims a local goal,
|
wenzelm@26767
|
996 |
eventually resulting in a fact within the current logical context.
|
wenzelm@26767
|
997 |
This operation is completely independent of any pending sub-goals of
|
wenzelm@26767
|
998 |
an enclosing goal statements, so @{command "have"} may be freely
|
wenzelm@26767
|
999 |
used for experimental exploration of potential results within a
|
wenzelm@26767
|
1000 |
proof body.
|
wenzelm@26767
|
1001 |
|
wenzelm@26767
|
1002 |
\item [@{command "show"}~@{text "a: \<phi>"}] is like @{command
|
wenzelm@26767
|
1003 |
"have"}~@{text "a: \<phi>"} plus a second stage to refine some pending
|
wenzelm@26767
|
1004 |
sub-goal for each one of the finished result, after having been
|
wenzelm@26767
|
1005 |
exported into the corresponding context (at the head of the
|
wenzelm@26767
|
1006 |
sub-proof of this @{command "show"} command).
|
wenzelm@26767
|
1007 |
|
wenzelm@26767
|
1008 |
To accommodate interactive debugging, resulting rules are printed
|
wenzelm@26767
|
1009 |
before being applied internally. Even more, interactive execution
|
wenzelm@26767
|
1010 |
of @{command "show"} predicts potential failure and displays the
|
wenzelm@26767
|
1011 |
resulting error as a warning beforehand. Watch out for the
|
wenzelm@26767
|
1012 |
following message:
|
wenzelm@26767
|
1013 |
|
wenzelm@26767
|
1014 |
%FIXME proper antiquitation
|
wenzelm@26767
|
1015 |
\begin{ttbox}
|
wenzelm@26767
|
1016 |
Problem! Local statement will fail to solve any pending goal
|
wenzelm@26767
|
1017 |
\end{ttbox}
|
wenzelm@26767
|
1018 |
|
wenzelm@26767
|
1019 |
\item [@{command "hence"}] abbreviates ``@{command "then"}~@{command
|
wenzelm@26767
|
1020 |
"have"}'', i.e.\ claims a local goal to be proven by forward
|
wenzelm@26767
|
1021 |
chaining the current facts. Note that @{command "hence"} is also
|
wenzelm@26767
|
1022 |
equivalent to ``@{command "from"}~@{text this}~@{command "have"}''.
|
wenzelm@26767
|
1023 |
|
wenzelm@26767
|
1024 |
\item [@{command "thus"}] abbreviates ``@{command "then"}~@{command
|
wenzelm@26767
|
1025 |
"show"}''. Note that @{command "thus"} is also equivalent to
|
wenzelm@26767
|
1026 |
``@{command "from"}~@{text this}~@{command "show"}''.
|
wenzelm@26767
|
1027 |
|
wenzelm@26767
|
1028 |
\item [@{command "print_statement"}~@{text a}] prints facts from the
|
wenzelm@26767
|
1029 |
current theory or proof context in long statement form, according to
|
wenzelm@26767
|
1030 |
the syntax for @{command "lemma"} given above.
|
wenzelm@26767
|
1031 |
|
wenzelm@26767
|
1032 |
\end{descr}
|
wenzelm@26767
|
1033 |
|
wenzelm@26767
|
1034 |
Any goal statement causes some term abbreviations (such as
|
wenzelm@26767
|
1035 |
@{variable_ref "?thesis"}) to be bound automatically, see also
|
wenzelm@26767
|
1036 |
\secref{sec:term-abbrev}. Furthermore, the local context of a
|
wenzelm@26767
|
1037 |
(non-atomic) goal is provided via the @{case_ref rule_context} case.
|
wenzelm@26767
|
1038 |
|
wenzelm@26767
|
1039 |
The optional case names of @{element_ref "obtains"} have a twofold
|
wenzelm@26767
|
1040 |
meaning: (1) during the of this claim they refer to the the local
|
wenzelm@26767
|
1041 |
context introductions, (2) the resulting rule is annotated
|
wenzelm@26767
|
1042 |
accordingly to support symbolic case splits when used with the
|
wenzelm@26767
|
1043 |
@{method_ref cases} method (cf. \secref{sec:cases-induct}).
|
wenzelm@26767
|
1044 |
|
wenzelm@26767
|
1045 |
\medskip
|
wenzelm@26767
|
1046 |
|
wenzelm@26767
|
1047 |
\begin{warn}
|
wenzelm@26767
|
1048 |
Isabelle/Isar suffers theory-level goal statements to contain
|
wenzelm@26767
|
1049 |
\emph{unbound schematic variables}, although this does not conform
|
wenzelm@26767
|
1050 |
to the aim of human-readable proof documents! The main problem
|
wenzelm@26767
|
1051 |
with schematic goals is that the actual outcome is usually hard to
|
wenzelm@26767
|
1052 |
predict, depending on the behavior of the proof methods applied
|
wenzelm@26767
|
1053 |
during the course of reasoning. Note that most semi-automated
|
wenzelm@26767
|
1054 |
methods heavily depend on several kinds of implicit rule
|
wenzelm@26767
|
1055 |
declarations within the current theory context. As this would
|
wenzelm@26767
|
1056 |
also result in non-compositional checking of sub-proofs,
|
wenzelm@26767
|
1057 |
\emph{local goals} are not allowed to be schematic at all.
|
wenzelm@26767
|
1058 |
Nevertheless, schematic goals do have their use in Prolog-style
|
wenzelm@26767
|
1059 |
interactive synthesis of proven results, usually by stepwise
|
wenzelm@26767
|
1060 |
refinement via emulation of traditional Isabelle tactic scripts
|
wenzelm@26767
|
1061 |
(see also \secref{sec:tactic-commands}). In any case, users
|
wenzelm@26767
|
1062 |
should know what they are doing.
|
wenzelm@26767
|
1063 |
\end{warn}
|
wenzelm@26767
|
1064 |
*}
|
wenzelm@26767
|
1065 |
|
wenzelm@26767
|
1066 |
|
wenzelm@26767
|
1067 |
subsection {* Initial and terminal proof steps \label{sec:proof-steps} *}
|
wenzelm@26767
|
1068 |
|
wenzelm@26767
|
1069 |
text {*
|
wenzelm@26767
|
1070 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
1071 |
@{command_def "proof"} & : & \isartrans{proof(prove)}{proof(state)} \\
|
wenzelm@26767
|
1072 |
@{command_def "qed"} & : & \isartrans{proof(state)}{proof(state) ~|~ theory} \\
|
wenzelm@26767
|
1073 |
@{command_def "by"} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
|
wenzelm@26767
|
1074 |
@{command_def ".."} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
|
wenzelm@26767
|
1075 |
@{command_def "."} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
|
wenzelm@26767
|
1076 |
@{command_def "sorry"} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
|
wenzelm@26767
|
1077 |
\end{matharray}
|
wenzelm@26767
|
1078 |
|
wenzelm@26767
|
1079 |
Arbitrary goal refinement via tactics is considered harmful.
|
wenzelm@26767
|
1080 |
Structured proof composition in Isar admits proof methods to be
|
wenzelm@26767
|
1081 |
invoked in two places only.
|
wenzelm@26767
|
1082 |
|
wenzelm@26767
|
1083 |
\begin{enumerate}
|
wenzelm@26767
|
1084 |
|
wenzelm@26767
|
1085 |
\item An \emph{initial} refinement step @{command_ref
|
wenzelm@26767
|
1086 |
"proof"}~@{text "m\<^sub>1"} reduces a newly stated goal to a number
|
wenzelm@26767
|
1087 |
of sub-goals that are to be solved later. Facts are passed to
|
wenzelm@26767
|
1088 |
@{text "m\<^sub>1"} for forward chaining, if so indicated by @{text
|
wenzelm@26767
|
1089 |
"proof(chain)"} mode.
|
wenzelm@26767
|
1090 |
|
wenzelm@26767
|
1091 |
\item A \emph{terminal} conclusion step @{command_ref "qed"}~@{text
|
wenzelm@26767
|
1092 |
"m\<^sub>2"} is intended to solve remaining goals. No facts are
|
wenzelm@26767
|
1093 |
passed to @{text "m\<^sub>2"}.
|
wenzelm@26767
|
1094 |
|
wenzelm@26767
|
1095 |
\end{enumerate}
|
wenzelm@26767
|
1096 |
|
wenzelm@26767
|
1097 |
The only other (proper) way to affect pending goals in a proof body
|
wenzelm@26767
|
1098 |
is by @{command_ref "show"}, which involves an explicit statement of
|
wenzelm@26767
|
1099 |
what is to be solved eventually. Thus we avoid the fundamental
|
wenzelm@26767
|
1100 |
problem of unstructured tactic scripts that consist of numerous
|
wenzelm@26767
|
1101 |
consecutive goal transformations, with invisible effects.
|
wenzelm@26767
|
1102 |
|
wenzelm@26767
|
1103 |
\medskip As a general rule of thumb for good proof style, initial
|
wenzelm@26767
|
1104 |
proof methods should either solve the goal completely, or constitute
|
wenzelm@26767
|
1105 |
some well-understood reduction to new sub-goals. Arbitrary
|
wenzelm@26767
|
1106 |
automatic proof tools that are prone leave a large number of badly
|
wenzelm@26767
|
1107 |
structured sub-goals are no help in continuing the proof document in
|
wenzelm@26767
|
1108 |
an intelligible manner.
|
wenzelm@26767
|
1109 |
|
wenzelm@26767
|
1110 |
Unless given explicitly by the user, the default initial method is
|
wenzelm@26767
|
1111 |
``@{method_ref rule}'', which applies a single standard elimination
|
wenzelm@26767
|
1112 |
or introduction rule according to the topmost symbol involved.
|
wenzelm@26767
|
1113 |
There is no separate default terminal method. Any remaining goals
|
wenzelm@26767
|
1114 |
are always solved by assumption in the very last step.
|
wenzelm@26767
|
1115 |
|
wenzelm@26767
|
1116 |
\begin{rail}
|
wenzelm@26767
|
1117 |
'proof' method?
|
wenzelm@26767
|
1118 |
;
|
wenzelm@26767
|
1119 |
'qed' method?
|
wenzelm@26767
|
1120 |
;
|
wenzelm@26767
|
1121 |
'by' method method?
|
wenzelm@26767
|
1122 |
;
|
wenzelm@26767
|
1123 |
('.' | '..' | 'sorry')
|
wenzelm@26767
|
1124 |
;
|
wenzelm@26767
|
1125 |
\end{rail}
|
wenzelm@26767
|
1126 |
|
wenzelm@26767
|
1127 |
\begin{descr}
|
wenzelm@26767
|
1128 |
|
wenzelm@26767
|
1129 |
\item [@{command "proof"}~@{text "m\<^sub>1"}] refines the goal by
|
wenzelm@26767
|
1130 |
proof method @{text "m\<^sub>1"}; facts for forward chaining are
|
wenzelm@26767
|
1131 |
passed if so indicated by @{text "proof(chain)"} mode.
|
wenzelm@26767
|
1132 |
|
wenzelm@26767
|
1133 |
\item [@{command "qed"}~@{text "m\<^sub>2"}] refines any remaining
|
wenzelm@26767
|
1134 |
goals by proof method @{text "m\<^sub>2"} and concludes the
|
wenzelm@26767
|
1135 |
sub-proof by assumption. If the goal had been @{text "show"} (or
|
wenzelm@26767
|
1136 |
@{text "thus"}), some pending sub-goal is solved as well by the rule
|
wenzelm@26767
|
1137 |
resulting from the result \emph{exported} into the enclosing goal
|
wenzelm@26767
|
1138 |
context. Thus @{text "qed"} may fail for two reasons: either @{text
|
wenzelm@26767
|
1139 |
"m\<^sub>2"} fails, or the resulting rule does not fit to any
|
wenzelm@26767
|
1140 |
pending goal\footnote{This includes any additional ``strong''
|
wenzelm@26767
|
1141 |
assumptions as introduced by @{text "assume"}.} of the enclosing
|
wenzelm@26767
|
1142 |
context. Debugging such a situation might involve temporarily
|
wenzelm@26767
|
1143 |
changing @{command "show"} into @{command "have"}, or weakening the
|
wenzelm@26767
|
1144 |
local context by replacing occurrences of @{command "assume"} by
|
wenzelm@26767
|
1145 |
@{command "presume"}.
|
wenzelm@26767
|
1146 |
|
wenzelm@26767
|
1147 |
\item [@{command "by"}~@{text "m\<^sub>1 m\<^sub>2"}] is a
|
wenzelm@26767
|
1148 |
\emph{terminal proof}\index{proof!terminal}; it abbreviates
|
wenzelm@26767
|
1149 |
@{command "proof"}~@{text "m\<^sub>1"}~@{text "qed"}~@{text
|
wenzelm@26767
|
1150 |
"m\<^sub>2"}, but with backtracking across both methods. Debugging
|
wenzelm@26767
|
1151 |
an unsuccessful @{command "by"}~@{text "m\<^sub>1 m\<^sub>2"}
|
wenzelm@26767
|
1152 |
command can be done by expanding its definition; in many cases
|
wenzelm@26767
|
1153 |
@{command "proof"}~@{text "m\<^sub>1"} (or even @{text
|
wenzelm@26767
|
1154 |
"apply"}~@{text "m\<^sub>1"}) is already sufficient to see the
|
wenzelm@26767
|
1155 |
problem.
|
wenzelm@26767
|
1156 |
|
wenzelm@26767
|
1157 |
\item [``@{command ".."}''] is a \emph{default
|
wenzelm@26767
|
1158 |
proof}\index{proof!default}; it abbreviates @{command "by"}~@{text
|
wenzelm@26767
|
1159 |
"rule"}.
|
wenzelm@26767
|
1160 |
|
wenzelm@26767
|
1161 |
\item [``@{command "."}''] is a \emph{trivial
|
wenzelm@26767
|
1162 |
proof}\index{proof!trivial}; it abbreviates @{command "by"}~@{text
|
wenzelm@26767
|
1163 |
"this"}.
|
wenzelm@26767
|
1164 |
|
wenzelm@26767
|
1165 |
\item [@{command "sorry"}] is a \emph{fake proof}\index{proof!fake}
|
wenzelm@26767
|
1166 |
pretending to solve the pending claim without further ado. This
|
wenzelm@26767
|
1167 |
only works in interactive development, or if the @{ML
|
wenzelm@26767
|
1168 |
quick_and_dirty} flag is enabled (in ML). Facts emerging from fake
|
wenzelm@26767
|
1169 |
proofs are not the real thing. Internally, each theorem container
|
wenzelm@26767
|
1170 |
is tainted by an oracle invocation, which is indicated as ``@{text
|
wenzelm@26767
|
1171 |
"[!]"}'' in the printed result.
|
wenzelm@26767
|
1172 |
|
wenzelm@26767
|
1173 |
The most important application of @{command "sorry"} is to support
|
wenzelm@26767
|
1174 |
experimentation and top-down proof development.
|
wenzelm@26767
|
1175 |
|
wenzelm@26767
|
1176 |
\end{descr}
|
wenzelm@26767
|
1177 |
*}
|
wenzelm@26767
|
1178 |
|
wenzelm@26767
|
1179 |
|
wenzelm@26767
|
1180 |
subsection {* Fundamental methods and attributes \label{sec:pure-meth-att} *}
|
wenzelm@26767
|
1181 |
|
wenzelm@26767
|
1182 |
text {*
|
wenzelm@26767
|
1183 |
The following proof methods and attributes refer to basic logical
|
wenzelm@26767
|
1184 |
operations of Isar. Further methods and attributes are provided by
|
wenzelm@26767
|
1185 |
several generic and object-logic specific tools and packages (see
|
wenzelm@26767
|
1186 |
\chref{ch:gen-tools} and \chref{ch:logics}).
|
wenzelm@26767
|
1187 |
|
wenzelm@26767
|
1188 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
1189 |
@{method_def "-"} & : & \isarmeth \\
|
wenzelm@26767
|
1190 |
@{method_def "fact"} & : & \isarmeth \\
|
wenzelm@26767
|
1191 |
@{method_def "assumption"} & : & \isarmeth \\
|
wenzelm@26767
|
1192 |
@{method_def "this"} & : & \isarmeth \\
|
wenzelm@26767
|
1193 |
@{method_def "rule"} & : & \isarmeth \\
|
wenzelm@26767
|
1194 |
@{method_def "iprover"} & : & \isarmeth \\[0.5ex]
|
wenzelm@26767
|
1195 |
@{attribute_def "intro"} & : & \isaratt \\
|
wenzelm@26767
|
1196 |
@{attribute_def "elim"} & : & \isaratt \\
|
wenzelm@26767
|
1197 |
@{attribute_def "dest"} & : & \isaratt \\
|
wenzelm@26767
|
1198 |
@{attribute_def "rule"} & : & \isaratt \\[0.5ex]
|
wenzelm@26767
|
1199 |
@{attribute_def "OF"} & : & \isaratt \\
|
wenzelm@26767
|
1200 |
@{attribute_def "of"} & : & \isaratt \\
|
wenzelm@26767
|
1201 |
@{attribute_def "where"} & : & \isaratt \\
|
wenzelm@26767
|
1202 |
\end{matharray}
|
wenzelm@26767
|
1203 |
|
wenzelm@26767
|
1204 |
\begin{rail}
|
wenzelm@26767
|
1205 |
'fact' thmrefs?
|
wenzelm@26767
|
1206 |
;
|
wenzelm@26767
|
1207 |
'rule' thmrefs?
|
wenzelm@26767
|
1208 |
;
|
wenzelm@26767
|
1209 |
'iprover' ('!' ?) (rulemod *)
|
wenzelm@26767
|
1210 |
;
|
wenzelm@26767
|
1211 |
rulemod: ('intro' | 'elim' | 'dest') ((('!' | () | '?') nat?) | 'del') ':' thmrefs
|
wenzelm@26767
|
1212 |
;
|
wenzelm@26767
|
1213 |
('intro' | 'elim' | 'dest') ('!' | () | '?') nat?
|
wenzelm@26767
|
1214 |
;
|
wenzelm@26767
|
1215 |
'rule' 'del'
|
wenzelm@26767
|
1216 |
;
|
wenzelm@26767
|
1217 |
'OF' thmrefs
|
wenzelm@26767
|
1218 |
;
|
wenzelm@26767
|
1219 |
'of' insts ('concl' ':' insts)?
|
wenzelm@26767
|
1220 |
;
|
wenzelm@26767
|
1221 |
'where' ((name | var | typefree | typevar) '=' (type | term) * 'and')
|
wenzelm@26767
|
1222 |
;
|
wenzelm@26767
|
1223 |
\end{rail}
|
wenzelm@26767
|
1224 |
|
wenzelm@26767
|
1225 |
\begin{descr}
|
wenzelm@26767
|
1226 |
|
wenzelm@26767
|
1227 |
\item [``@{method "-"}''] does nothing but insert the forward
|
wenzelm@26767
|
1228 |
chaining facts as premises into the goal. Note that command
|
wenzelm@26767
|
1229 |
@{command_ref "proof"} without any method actually performs a single
|
wenzelm@26767
|
1230 |
reduction step using the @{method_ref rule} method; thus a plain
|
wenzelm@26767
|
1231 |
\emph{do-nothing} proof step would be ``@{command "proof"}~@{text
|
wenzelm@26767
|
1232 |
"-"}'' rather than @{command "proof"} alone.
|
wenzelm@26767
|
1233 |
|
wenzelm@26767
|
1234 |
\item [@{method "fact"}~@{text "a\<^sub>1 \<dots> a\<^sub>n"}] composes
|
wenzelm@26767
|
1235 |
some fact from @{text "a\<^sub>1, \<dots>, a\<^sub>n"} (or implicitly from
|
wenzelm@26767
|
1236 |
the current proof context) modulo unification of schematic type and
|
wenzelm@26767
|
1237 |
term variables. The rule structure is not taken into account, i.e.\
|
wenzelm@26767
|
1238 |
meta-level implication is considered atomic. This is the same
|
wenzelm@26767
|
1239 |
principle underlying literal facts (cf.\ \secref{sec:syn-att}):
|
wenzelm@26767
|
1240 |
``@{command "have"}~@{text "\<phi>"}~@{command "by"}~@{text fact}'' is
|
wenzelm@26767
|
1241 |
equivalent to ``@{command "note"}~@{verbatim "`"}@{text \<phi>}@{verbatim
|
wenzelm@26767
|
1242 |
"`"}'' provided that @{text "\<turnstile> \<phi>"} is an instance of some known
|
wenzelm@26767
|
1243 |
@{text "\<turnstile> \<phi>"} in the proof context.
|
wenzelm@26767
|
1244 |
|
wenzelm@26767
|
1245 |
\item [@{method assumption}] solves some goal by a single assumption
|
wenzelm@26767
|
1246 |
step. All given facts are guaranteed to participate in the
|
wenzelm@26767
|
1247 |
refinement; this means there may be only 0 or 1 in the first place.
|
wenzelm@26767
|
1248 |
Recall that @{command "qed"} (\secref{sec:proof-steps}) already
|
wenzelm@26767
|
1249 |
concludes any remaining sub-goals by assumption, so structured
|
wenzelm@26767
|
1250 |
proofs usually need not quote the @{method assumption} method at
|
wenzelm@26767
|
1251 |
all.
|
wenzelm@26767
|
1252 |
|
wenzelm@26767
|
1253 |
\item [@{method this}] applies all of the current facts directly as
|
wenzelm@26767
|
1254 |
rules. Recall that ``@{command "."}'' (dot) abbreviates ``@{command
|
wenzelm@26767
|
1255 |
"by"}~@{text this}''.
|
wenzelm@26767
|
1256 |
|
wenzelm@26767
|
1257 |
\item [@{method rule}~@{text "a\<^sub>1 \<dots> a\<^sub>n"}] applies some
|
wenzelm@26767
|
1258 |
rule given as argument in backward manner; facts are used to reduce
|
wenzelm@26767
|
1259 |
the rule before applying it to the goal. Thus @{method rule}
|
wenzelm@26767
|
1260 |
without facts is plain introduction, while with facts it becomes
|
wenzelm@26767
|
1261 |
elimination.
|
wenzelm@26767
|
1262 |
|
wenzelm@26767
|
1263 |
When no arguments are given, the @{method rule} method tries to pick
|
wenzelm@26767
|
1264 |
appropriate rules automatically, as declared in the current context
|
wenzelm@26767
|
1265 |
using the @{attribute intro}, @{attribute elim}, @{attribute dest}
|
wenzelm@26767
|
1266 |
attributes (see below). This is the default behavior of @{command
|
wenzelm@26767
|
1267 |
"proof"} and ``@{command ".."}'' (double-dot) steps (see
|
wenzelm@26767
|
1268 |
\secref{sec:proof-steps}).
|
wenzelm@26767
|
1269 |
|
wenzelm@26767
|
1270 |
\item [@{method iprover}] performs intuitionistic proof search,
|
wenzelm@26767
|
1271 |
depending on specifically declared rules from the context, or given
|
wenzelm@26767
|
1272 |
as explicit arguments. Chained facts are inserted into the goal
|
wenzelm@26767
|
1273 |
before commencing proof search; ``@{method iprover}@{text "!"}''
|
wenzelm@26767
|
1274 |
means to include the current @{fact prems} as well.
|
wenzelm@26767
|
1275 |
|
wenzelm@26767
|
1276 |
Rules need to be classified as @{attribute intro}, @{attribute
|
wenzelm@26767
|
1277 |
elim}, or @{attribute dest}; here the ``@{text "!"} indicator refers
|
wenzelm@26767
|
1278 |
to ``safe'' rules, which may be applied aggressively (without
|
wenzelm@26767
|
1279 |
considering back-tracking later). Rules declared with ``@{text
|
wenzelm@26767
|
1280 |
"?"}'' are ignored in proof search (the single-step @{method rule}
|
wenzelm@26767
|
1281 |
method still observes these). An explicit weight annotation may be
|
wenzelm@26767
|
1282 |
given as well; otherwise the number of rule premises will be taken
|
wenzelm@26767
|
1283 |
into account here.
|
wenzelm@26767
|
1284 |
|
wenzelm@26767
|
1285 |
\item [@{attribute intro}, @{attribute elim}, and @{attribute dest}]
|
wenzelm@26767
|
1286 |
declare introduction, elimination, and destruct rules, to be used
|
wenzelm@26767
|
1287 |
with the @{method rule} and @{method iprover} methods. Note that
|
wenzelm@26767
|
1288 |
the latter will ignore rules declared with ``@{text "?"}'', while
|
wenzelm@26767
|
1289 |
``@{text "!"}'' are used most aggressively.
|
wenzelm@26767
|
1290 |
|
wenzelm@26767
|
1291 |
The classical reasoner (see \secref{sec:classical}) introduces its
|
wenzelm@26767
|
1292 |
own variants of these attributes; use qualified names to access the
|
wenzelm@26767
|
1293 |
present versions of Isabelle/Pure, i.e.\ @{attribute "Pure.intro"}.
|
wenzelm@26767
|
1294 |
|
wenzelm@26767
|
1295 |
\item [@{attribute rule}~@{text del}] undeclares introduction,
|
wenzelm@26767
|
1296 |
elimination, or destruct rules.
|
wenzelm@26767
|
1297 |
|
wenzelm@26767
|
1298 |
\item [@{attribute OF}~@{text "a\<^sub>1 \<dots> a\<^sub>n"}] applies some
|
wenzelm@26767
|
1299 |
theorem to all of the given rules @{text "a\<^sub>1, \<dots>, a\<^sub>n"}
|
wenzelm@26767
|
1300 |
(in parallel). This corresponds to the @{ML "op MRS"} operation in
|
wenzelm@26767
|
1301 |
ML, but note the reversed order. Positions may be effectively
|
wenzelm@26767
|
1302 |
skipped by including ``@{verbatim _}'' (underscore) as argument.
|
wenzelm@26767
|
1303 |
|
wenzelm@26767
|
1304 |
\item [@{attribute of}~@{text "t\<^sub>1 \<dots> t\<^sub>n"}] performs
|
wenzelm@26767
|
1305 |
positional instantiation of term variables. The terms @{text
|
wenzelm@26767
|
1306 |
"t\<^sub>1, \<dots>, t\<^sub>n"} are substituted for any schematic
|
wenzelm@26767
|
1307 |
variables occurring in a theorem from left to right; ``@{verbatim
|
wenzelm@26767
|
1308 |
_}'' (underscore) indicates to skip a position. Arguments following
|
wenzelm@26767
|
1309 |
a ``@{keyword "concl"}@{text ":"}'' specification refer to positions
|
wenzelm@26767
|
1310 |
of the conclusion of a rule.
|
wenzelm@26767
|
1311 |
|
wenzelm@26767
|
1312 |
\item [@{attribute "where"}~@{text "x\<^sub>1 = t\<^sub>1 \<AND> \<dots>
|
wenzelm@26767
|
1313 |
\<AND> x\<^sub>n = t\<^sub>n"}] performs named instantiation of
|
wenzelm@26767
|
1314 |
schematic type and term variables occurring in a theorem. Schematic
|
wenzelm@26767
|
1315 |
variables have to be specified on the left-hand side (e.g.\ @{text
|
wenzelm@26767
|
1316 |
"?x1.3"}). The question mark may be omitted if the variable name is
|
wenzelm@26767
|
1317 |
a plain identifier without index. As type instantiations are
|
wenzelm@26767
|
1318 |
inferred from term instantiations, explicit type instantiations are
|
wenzelm@26767
|
1319 |
seldom necessary.
|
wenzelm@26767
|
1320 |
|
wenzelm@26767
|
1321 |
\end{descr}
|
wenzelm@26767
|
1322 |
*}
|
wenzelm@26767
|
1323 |
|
wenzelm@26767
|
1324 |
|
wenzelm@26767
|
1325 |
subsection {* Term abbreviations \label{sec:term-abbrev} *}
|
wenzelm@26767
|
1326 |
|
wenzelm@26767
|
1327 |
text {*
|
wenzelm@26767
|
1328 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
1329 |
@{command_def "let"} & : & \isartrans{proof(state)}{proof(state)} \\
|
wenzelm@26767
|
1330 |
@{keyword_def "is"} & : & syntax \\
|
wenzelm@26767
|
1331 |
\end{matharray}
|
wenzelm@26767
|
1332 |
|
wenzelm@26767
|
1333 |
Abbreviations may be either bound by explicit @{command "let"}@{text
|
wenzelm@26767
|
1334 |
"p \<equiv> t"} statements, or by annotating assumptions or goal statements
|
wenzelm@26767
|
1335 |
with a list of patterns ``@{text "\<IS> p\<^sub>1 \<dots> p\<^sub>n"}''.
|
wenzelm@26767
|
1336 |
In both cases, higher-order matching is invoked to bind
|
wenzelm@26767
|
1337 |
extra-logical term variables, which may be either named schematic
|
wenzelm@26767
|
1338 |
variables of the form @{text ?x}, or nameless dummies ``@{variable
|
wenzelm@26767
|
1339 |
_}'' (underscore). Note that in the @{command "let"} form the
|
wenzelm@26767
|
1340 |
patterns occur on the left-hand side, while the @{keyword "is"}
|
wenzelm@26767
|
1341 |
patterns are in postfix position.
|
wenzelm@26767
|
1342 |
|
wenzelm@26767
|
1343 |
Polymorphism of term bindings is handled in Hindley-Milner style,
|
wenzelm@26767
|
1344 |
similar to ML. Type variables referring to local assumptions or
|
wenzelm@26767
|
1345 |
open goal statements are \emph{fixed}, while those of finished
|
wenzelm@26767
|
1346 |
results or bound by @{command "let"} may occur in \emph{arbitrary}
|
wenzelm@26767
|
1347 |
instances later. Even though actual polymorphism should be rarely
|
wenzelm@26767
|
1348 |
used in practice, this mechanism is essential to achieve proper
|
wenzelm@26767
|
1349 |
incremental type-inference, as the user proceeds to build up the
|
wenzelm@26767
|
1350 |
Isar proof text from left to right.
|
wenzelm@26767
|
1351 |
|
wenzelm@26767
|
1352 |
\medskip Term abbreviations are quite different from local
|
wenzelm@26767
|
1353 |
definitions as introduced via @{command "def"} (see
|
wenzelm@26767
|
1354 |
\secref{sec:proof-context}). The latter are visible within the
|
wenzelm@26767
|
1355 |
logic as actual equations, while abbreviations disappear during the
|
wenzelm@26767
|
1356 |
input process just after type checking. Also note that @{command
|
wenzelm@26767
|
1357 |
"def"} does not support polymorphism.
|
wenzelm@26767
|
1358 |
|
wenzelm@26767
|
1359 |
\begin{rail}
|
wenzelm@26767
|
1360 |
'let' ((term + 'and') '=' term + 'and')
|
wenzelm@26767
|
1361 |
;
|
wenzelm@26767
|
1362 |
\end{rail}
|
wenzelm@26767
|
1363 |
|
wenzelm@26767
|
1364 |
The syntax of @{keyword "is"} patterns follows \railnonterm{termpat}
|
wenzelm@26767
|
1365 |
or \railnonterm{proppat} (see \secref{sec:term-decls}).
|
wenzelm@26767
|
1366 |
|
wenzelm@26767
|
1367 |
\begin{descr}
|
wenzelm@26767
|
1368 |
|
wenzelm@26767
|
1369 |
\item [@{command "let"}~@{text "p\<^sub>1 = t\<^sub>1 \<AND>
|
wenzelm@26767
|
1370 |
\<dots>p\<^sub>n = t\<^sub>n"}] binds any text variables in patterns
|
wenzelm@26767
|
1371 |
@{text "p\<^sub>1, \<dots>, p\<^sub>n"} by simultaneous higher-order
|
wenzelm@26767
|
1372 |
matching against terms @{text "t\<^sub>1, \<dots>, t\<^sub>n"}.
|
wenzelm@26767
|
1373 |
|
wenzelm@26767
|
1374 |
\item [@{text "(\<IS> p\<^sub>1 \<dots> p\<^sub>n)"}] resembles @{command
|
wenzelm@26767
|
1375 |
"let"}, but matches @{text "p\<^sub>1, \<dots>, p\<^sub>n"} against the
|
wenzelm@26767
|
1376 |
preceding statement. Also note that @{keyword "is"} is not a
|
wenzelm@26767
|
1377 |
separate command, but part of others (such as @{command "assume"},
|
wenzelm@26767
|
1378 |
@{command "have"} etc.).
|
wenzelm@26767
|
1379 |
|
wenzelm@26767
|
1380 |
\end{descr}
|
wenzelm@26767
|
1381 |
|
wenzelm@26767
|
1382 |
Some \emph{implicit} term abbreviations\index{term abbreviations}
|
wenzelm@26767
|
1383 |
for goals and facts are available as well. For any open goal,
|
wenzelm@26767
|
1384 |
@{variable_ref thesis} refers to its object-level statement,
|
wenzelm@26767
|
1385 |
abstracted over any meta-level parameters (if present). Likewise,
|
wenzelm@26767
|
1386 |
@{variable_ref this} is bound for fact statements resulting from
|
wenzelm@26767
|
1387 |
assumptions or finished goals. In case @{variable this} refers to
|
wenzelm@26767
|
1388 |
an object-logic statement that is an application @{text "f t"}, then
|
wenzelm@26767
|
1389 |
@{text t} is bound to the special text variable ``@{variable "\<dots>"}''
|
wenzelm@26767
|
1390 |
(three dots). The canonical application of this convenience are
|
wenzelm@26767
|
1391 |
calculational proofs (see \secref{sec:calculation}).
|
wenzelm@26767
|
1392 |
*}
|
wenzelm@26767
|
1393 |
|
wenzelm@26767
|
1394 |
|
wenzelm@26767
|
1395 |
subsection {* Block structure *}
|
wenzelm@26767
|
1396 |
|
wenzelm@26767
|
1397 |
text {*
|
wenzelm@26767
|
1398 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
1399 |
@{command_def "next"} & : & \isartrans{proof(state)}{proof(state)} \\
|
wenzelm@26767
|
1400 |
@{command_def "{"} & : & \isartrans{proof(state)}{proof(state)} \\
|
wenzelm@26767
|
1401 |
@{command_def "}"} & : & \isartrans{proof(state)}{proof(state)} \\
|
wenzelm@26767
|
1402 |
\end{matharray}
|
wenzelm@26767
|
1403 |
|
wenzelm@26767
|
1404 |
While Isar is inherently block-structured, opening and closing
|
wenzelm@26767
|
1405 |
blocks is mostly handled rather casually, with little explicit
|
wenzelm@26767
|
1406 |
user-intervention. Any local goal statement automatically opens
|
wenzelm@26767
|
1407 |
\emph{two} internal blocks, which are closed again when concluding
|
wenzelm@26767
|
1408 |
the sub-proof (by @{command "qed"} etc.). Sections of different
|
wenzelm@26767
|
1409 |
context within a sub-proof may be switched via @{command "next"},
|
wenzelm@26767
|
1410 |
which is just a single block-close followed by block-open again.
|
wenzelm@26767
|
1411 |
The effect of @{command "next"} is to reset the local proof context;
|
wenzelm@26767
|
1412 |
there is no goal focus involved here!
|
wenzelm@26767
|
1413 |
|
wenzelm@26767
|
1414 |
For slightly more advanced applications, there are explicit block
|
wenzelm@26767
|
1415 |
parentheses as well. These typically achieve a stronger forward
|
wenzelm@26767
|
1416 |
style of reasoning.
|
wenzelm@26767
|
1417 |
|
wenzelm@26767
|
1418 |
\begin{descr}
|
wenzelm@26767
|
1419 |
|
wenzelm@26767
|
1420 |
\item [@{command "next"}] switches to a fresh block within a
|
wenzelm@26767
|
1421 |
sub-proof, resetting the local context to the initial one.
|
wenzelm@26767
|
1422 |
|
wenzelm@26767
|
1423 |
\item [@{command "{"} and @{command "}"}] explicitly open and close
|
wenzelm@26767
|
1424 |
blocks. Any current facts pass through ``@{command "{"}''
|
wenzelm@26767
|
1425 |
unchanged, while ``@{command "}"}'' causes any result to be
|
wenzelm@26767
|
1426 |
\emph{exported} into the enclosing context. Thus fixed variables
|
wenzelm@26767
|
1427 |
are generalized, assumptions discharged, and local definitions
|
wenzelm@26767
|
1428 |
unfolded (cf.\ \secref{sec:proof-context}). There is no difference
|
wenzelm@26767
|
1429 |
of @{command "assume"} and @{command "presume"} in this mode of
|
wenzelm@26767
|
1430 |
forward reasoning --- in contrast to plain backward reasoning with
|
wenzelm@26767
|
1431 |
the result exported at @{command "show"} time.
|
wenzelm@26767
|
1432 |
|
wenzelm@26767
|
1433 |
\end{descr}
|
wenzelm@26767
|
1434 |
*}
|
wenzelm@26767
|
1435 |
|
wenzelm@26767
|
1436 |
|
wenzelm@26767
|
1437 |
subsection {* Emulating tactic scripts \label{sec:tactic-commands} *}
|
wenzelm@26767
|
1438 |
|
wenzelm@26767
|
1439 |
text {*
|
wenzelm@26767
|
1440 |
The Isar provides separate commands to accommodate tactic-style
|
wenzelm@26767
|
1441 |
proof scripts within the same system. While being outside the
|
wenzelm@26767
|
1442 |
orthodox Isar proof language, these might come in handy for
|
wenzelm@26767
|
1443 |
interactive exploration and debugging, or even actual tactical proof
|
wenzelm@26767
|
1444 |
within new-style theories (to benefit from document preparation, for
|
wenzelm@26767
|
1445 |
example). See also \secref{sec:tactics} for actual tactics, that
|
wenzelm@26767
|
1446 |
have been encapsulated as proof methods. Proper proof methods may
|
wenzelm@26767
|
1447 |
be used in scripts, too.
|
wenzelm@26767
|
1448 |
|
wenzelm@26767
|
1449 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
1450 |
@{command_def "apply"}^* & : & \isartrans{proof(prove)}{proof(prove)} \\
|
wenzelm@26767
|
1451 |
@{command_def "apply_end"}^* & : & \isartrans{proof(state)}{proof(state)} \\
|
wenzelm@26767
|
1452 |
@{command_def "done"}^* & : & \isartrans{proof(prove)}{proof(state)} \\
|
wenzelm@26767
|
1453 |
@{command_def "defer"}^* & : & \isartrans{proof}{proof} \\
|
wenzelm@26767
|
1454 |
@{command_def "prefer"}^* & : & \isartrans{proof}{proof} \\
|
wenzelm@26767
|
1455 |
@{command_def "back"}^* & : & \isartrans{proof}{proof} \\
|
wenzelm@26767
|
1456 |
\end{matharray}
|
wenzelm@26767
|
1457 |
|
wenzelm@26767
|
1458 |
\begin{rail}
|
wenzelm@26767
|
1459 |
( 'apply' | 'apply\_end' ) method
|
wenzelm@26767
|
1460 |
;
|
wenzelm@26767
|
1461 |
'defer' nat?
|
wenzelm@26767
|
1462 |
;
|
wenzelm@26767
|
1463 |
'prefer' nat
|
wenzelm@26767
|
1464 |
;
|
wenzelm@26767
|
1465 |
\end{rail}
|
wenzelm@26767
|
1466 |
|
wenzelm@26767
|
1467 |
\begin{descr}
|
wenzelm@26767
|
1468 |
|
wenzelm@26767
|
1469 |
\item [@{command "apply"}~@{text m}] applies proof method @{text m}
|
wenzelm@26767
|
1470 |
in initial position, but unlike @{command "proof"} it retains
|
wenzelm@26767
|
1471 |
``@{text "proof(prove)"}'' mode. Thus consecutive method
|
wenzelm@26767
|
1472 |
applications may be given just as in tactic scripts.
|
wenzelm@26767
|
1473 |
|
wenzelm@26767
|
1474 |
Facts are passed to @{text m} as indicated by the goal's
|
wenzelm@26767
|
1475 |
forward-chain mode, and are \emph{consumed} afterwards. Thus any
|
wenzelm@26767
|
1476 |
further @{command "apply"} command would always work in a purely
|
wenzelm@26767
|
1477 |
backward manner.
|
wenzelm@26767
|
1478 |
|
wenzelm@26767
|
1479 |
\item [@{command "apply_end"}~@{text "m"}] applies proof method
|
wenzelm@26767
|
1480 |
@{text m} as if in terminal position. Basically, this simulates a
|
wenzelm@26767
|
1481 |
multi-step tactic script for @{command "qed"}, but may be given
|
wenzelm@26767
|
1482 |
anywhere within the proof body.
|
wenzelm@26767
|
1483 |
|
wenzelm@26767
|
1484 |
No facts are passed to @{method m} here. Furthermore, the static
|
wenzelm@26767
|
1485 |
context is that of the enclosing goal (as for actual @{command
|
wenzelm@26767
|
1486 |
"qed"}). Thus the proof method may not refer to any assumptions
|
wenzelm@26767
|
1487 |
introduced in the current body, for example.
|
wenzelm@26767
|
1488 |
|
wenzelm@26767
|
1489 |
\item [@{command "done"}] completes a proof script, provided that
|
wenzelm@26767
|
1490 |
the current goal state is solved completely. Note that actual
|
wenzelm@26767
|
1491 |
structured proof commands (e.g.\ ``@{command "."}'' or @{command
|
wenzelm@26767
|
1492 |
"sorry"}) may be used to conclude proof scripts as well.
|
wenzelm@26767
|
1493 |
|
wenzelm@26767
|
1494 |
\item [@{command "defer"}~@{text n} and @{command "prefer"}~@{text
|
wenzelm@26767
|
1495 |
n}] shuffle the list of pending goals: @{command "defer"} puts off
|
wenzelm@26767
|
1496 |
sub-goal @{text n} to the end of the list (@{text "n = 1"} by
|
wenzelm@26767
|
1497 |
default), while @{command "prefer"} brings sub-goal @{text n} to the
|
wenzelm@26767
|
1498 |
front.
|
wenzelm@26767
|
1499 |
|
wenzelm@26767
|
1500 |
\item [@{command "back"}] does back-tracking over the result
|
wenzelm@26767
|
1501 |
sequence of the latest proof command. Basically, any proof command
|
wenzelm@26767
|
1502 |
may return multiple results.
|
wenzelm@26767
|
1503 |
|
wenzelm@26767
|
1504 |
\end{descr}
|
wenzelm@26767
|
1505 |
|
wenzelm@26767
|
1506 |
Any proper Isar proof method may be used with tactic script commands
|
wenzelm@26767
|
1507 |
such as @{command "apply"}. A few additional emulations of actual
|
wenzelm@26767
|
1508 |
tactics are provided as well; these would be never used in actual
|
wenzelm@26767
|
1509 |
structured proofs, of course.
|
wenzelm@26767
|
1510 |
*}
|
wenzelm@26767
|
1511 |
|
wenzelm@26767
|
1512 |
|
wenzelm@26767
|
1513 |
subsection {* Meta-linguistic features *}
|
wenzelm@26767
|
1514 |
|
wenzelm@26767
|
1515 |
text {*
|
wenzelm@26767
|
1516 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
1517 |
@{command_def "oops"} & : & \isartrans{proof}{theory} \\
|
wenzelm@26767
|
1518 |
\end{matharray}
|
wenzelm@26767
|
1519 |
|
wenzelm@26767
|
1520 |
The @{command "oops"} command discontinues the current proof
|
wenzelm@26767
|
1521 |
attempt, while considering the partial proof text as properly
|
wenzelm@26767
|
1522 |
processed. This is conceptually quite different from ``faking''
|
wenzelm@26767
|
1523 |
actual proofs via @{command_ref "sorry"} (see
|
wenzelm@26767
|
1524 |
\secref{sec:proof-steps}): @{command "oops"} does not observe the
|
wenzelm@26767
|
1525 |
proof structure at all, but goes back right to the theory level.
|
wenzelm@26767
|
1526 |
Furthermore, @{command "oops"} does not produce any result theorem
|
wenzelm@26767
|
1527 |
--- there is no intended claim to be able to complete the proof
|
wenzelm@26767
|
1528 |
anyhow.
|
wenzelm@26767
|
1529 |
|
wenzelm@26767
|
1530 |
A typical application of @{command "oops"} is to explain Isar proofs
|
wenzelm@26767
|
1531 |
\emph{within} the system itself, in conjunction with the document
|
wenzelm@26767
|
1532 |
preparation tools of Isabelle described in \cite{isabelle-sys}.
|
wenzelm@26767
|
1533 |
Thus partial or even wrong proof attempts can be discussed in a
|
wenzelm@26767
|
1534 |
logically sound manner. Note that the Isabelle {\LaTeX} macros can
|
wenzelm@26767
|
1535 |
be easily adapted to print something like ``@{text "\<dots>"}'' instead of
|
wenzelm@26767
|
1536 |
the keyword ``@{command "oops"}''.
|
wenzelm@26767
|
1537 |
|
wenzelm@26767
|
1538 |
\medskip The @{command "oops"} command is undo-able, unlike
|
wenzelm@26767
|
1539 |
@{command_ref "kill"} (see \secref{sec:history}). The effect is to
|
wenzelm@26767
|
1540 |
get back to the theory just before the opening of the proof.
|
wenzelm@26767
|
1541 |
*}
|
wenzelm@26767
|
1542 |
|
wenzelm@26767
|
1543 |
|
wenzelm@26767
|
1544 |
section {* Other commands *}
|
wenzelm@26767
|
1545 |
|
wenzelm@26767
|
1546 |
subsection {* Diagnostics *}
|
wenzelm@26767
|
1547 |
|
wenzelm@26767
|
1548 |
text {*
|
wenzelm@26767
|
1549 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
1550 |
\isarcmd{pr}^* & : & \isarkeep{\cdot} \\
|
wenzelm@26767
|
1551 |
\isarcmd{thm}^* & : & \isarkeep{theory~|~proof} \\
|
wenzelm@26767
|
1552 |
\isarcmd{term}^* & : & \isarkeep{theory~|~proof} \\
|
wenzelm@26767
|
1553 |
\isarcmd{prop}^* & : & \isarkeep{theory~|~proof} \\
|
wenzelm@26767
|
1554 |
\isarcmd{typ}^* & : & \isarkeep{theory~|~proof} \\
|
wenzelm@26767
|
1555 |
\isarcmd{prf}^* & : & \isarkeep{theory~|~proof} \\
|
wenzelm@26767
|
1556 |
\isarcmd{full_prf}^* & : & \isarkeep{theory~|~proof} \\
|
wenzelm@26767
|
1557 |
\end{matharray}
|
wenzelm@26767
|
1558 |
|
wenzelm@26767
|
1559 |
These diagnostic commands assist interactive development. Note that
|
wenzelm@26767
|
1560 |
@{command undo} does not apply here, the theory or proof
|
wenzelm@26767
|
1561 |
configuration is not changed.
|
wenzelm@26767
|
1562 |
|
wenzelm@26767
|
1563 |
\begin{rail}
|
wenzelm@26767
|
1564 |
'pr' modes? nat? (',' nat)?
|
wenzelm@26767
|
1565 |
;
|
wenzelm@26767
|
1566 |
'thm' modes? thmrefs
|
wenzelm@26767
|
1567 |
;
|
wenzelm@26767
|
1568 |
'term' modes? term
|
wenzelm@26767
|
1569 |
;
|
wenzelm@26767
|
1570 |
'prop' modes? prop
|
wenzelm@26767
|
1571 |
;
|
wenzelm@26767
|
1572 |
'typ' modes? type
|
wenzelm@26767
|
1573 |
;
|
wenzelm@26767
|
1574 |
'prf' modes? thmrefs?
|
wenzelm@26767
|
1575 |
;
|
wenzelm@26767
|
1576 |
'full\_prf' modes? thmrefs?
|
wenzelm@26767
|
1577 |
;
|
wenzelm@26767
|
1578 |
|
wenzelm@26767
|
1579 |
modes: '(' (name + ) ')'
|
wenzelm@26767
|
1580 |
;
|
wenzelm@26767
|
1581 |
\end{rail}
|
wenzelm@26767
|
1582 |
|
wenzelm@26767
|
1583 |
\begin{descr}
|
wenzelm@26767
|
1584 |
|
wenzelm@26767
|
1585 |
\item [@{command "pr"}~@{text "goals, prems"}] prints the current
|
wenzelm@26767
|
1586 |
proof state (if present), including the proof context, current facts
|
wenzelm@26767
|
1587 |
and goals. The optional limit arguments affect the number of goals
|
wenzelm@26767
|
1588 |
and premises to be displayed, which is initially 10 for both.
|
wenzelm@26767
|
1589 |
Omitting limit values leaves the current setting unchanged.
|
wenzelm@26767
|
1590 |
|
wenzelm@26767
|
1591 |
\item [@{command "thm"}~@{text "a\<^sub>1 \<dots> a\<^sub>n"}] retrieves
|
wenzelm@26767
|
1592 |
theorems from the current theory or proof context. Note that any
|
wenzelm@26767
|
1593 |
attributes included in the theorem specifications are applied to a
|
wenzelm@26767
|
1594 |
temporary context derived from the current theory or proof; the
|
wenzelm@26767
|
1595 |
result is discarded, i.e.\ attributes involved in @{text "a\<^sub>1,
|
wenzelm@26767
|
1596 |
\<dots>, a\<^sub>n"} do not have any permanent effect.
|
wenzelm@26767
|
1597 |
|
wenzelm@26767
|
1598 |
\item [@{command "term"}~@{text t} and @{command "prop"}~@{text \<phi>}]
|
wenzelm@26767
|
1599 |
read, type-check and print terms or propositions according to the
|
wenzelm@26767
|
1600 |
current theory or proof context; the inferred type of @{text t} is
|
wenzelm@26767
|
1601 |
output as well. Note that these commands are also useful in
|
wenzelm@26767
|
1602 |
inspecting the current environment of term abbreviations.
|
wenzelm@26767
|
1603 |
|
wenzelm@26767
|
1604 |
\item [@{command "typ"}~@{text \<tau>}] reads and prints types of the
|
wenzelm@26767
|
1605 |
meta-logic according to the current theory or proof context.
|
wenzelm@26767
|
1606 |
|
wenzelm@26767
|
1607 |
\item [@{command "prf"}] displays the (compact) proof term of the
|
wenzelm@26767
|
1608 |
current proof state (if present), or of the given theorems. Note
|
wenzelm@26767
|
1609 |
that this requires proof terms to be switched on for the current
|
wenzelm@26767
|
1610 |
object logic (see the ``Proof terms'' section of the Isabelle
|
wenzelm@26767
|
1611 |
reference manual for information on how to do this).
|
wenzelm@26767
|
1612 |
|
wenzelm@26767
|
1613 |
\item [@{command "full_prf"}] is like @{command "prf"}, but displays
|
wenzelm@26767
|
1614 |
the full proof term, i.e.\ also displays information omitted in the
|
wenzelm@26767
|
1615 |
compact proof term, which is denoted by ``@{verbatim _}''
|
wenzelm@26767
|
1616 |
placeholders there.
|
wenzelm@26767
|
1617 |
|
wenzelm@26767
|
1618 |
\end{descr}
|
wenzelm@26767
|
1619 |
|
wenzelm@26767
|
1620 |
All of the diagnostic commands above admit a list of @{text modes}
|
wenzelm@26767
|
1621 |
to be specified, which is appended to the current print mode (see
|
wenzelm@26767
|
1622 |
also \cite{isabelle-ref}). Thus the output behavior may be modified
|
wenzelm@26767
|
1623 |
according particular print mode features. For example, @{command
|
wenzelm@26767
|
1624 |
"pr"}~@{text "(latex xsymbols symbols)"} would print the current
|
wenzelm@26767
|
1625 |
proof state with mathematical symbols and special characters
|
wenzelm@26767
|
1626 |
represented in {\LaTeX} source, according to the Isabelle style
|
wenzelm@26767
|
1627 |
\cite{isabelle-sys}.
|
wenzelm@26767
|
1628 |
|
wenzelm@26767
|
1629 |
Note that antiquotations (cf.\ \secref{sec:antiq}) provide a more
|
wenzelm@26767
|
1630 |
systematic way to include formal items into the printed text
|
wenzelm@26767
|
1631 |
document.
|
wenzelm@26767
|
1632 |
*}
|
wenzelm@26767
|
1633 |
|
wenzelm@26767
|
1634 |
|
wenzelm@26767
|
1635 |
subsection {* Inspecting the context *}
|
wenzelm@26767
|
1636 |
|
wenzelm@26767
|
1637 |
text {*
|
wenzelm@26767
|
1638 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
1639 |
@{command_def "print_commands"}^* & : & \isarkeep{\cdot} \\
|
wenzelm@26767
|
1640 |
@{command_def "print_theory"}^* & : & \isarkeep{theory~|~proof} \\
|
wenzelm@26767
|
1641 |
@{command_def "print_syntax"}^* & : & \isarkeep{theory~|~proof} \\
|
wenzelm@26767
|
1642 |
@{command_def "print_methods"}^* & : & \isarkeep{theory~|~proof} \\
|
wenzelm@26767
|
1643 |
@{command_def "print_attributes"}^* & : & \isarkeep{theory~|~proof} \\
|
wenzelm@26767
|
1644 |
@{command_def "print_theorems"}^* & : & \isarkeep{theory~|~proof} \\
|
wenzelm@26767
|
1645 |
@{command_def "find_theorems"}^* & : & \isarkeep{theory~|~proof} \\
|
wenzelm@26767
|
1646 |
@{command_def "thms_deps"}^* & : & \isarkeep{theory~|~proof} \\
|
wenzelm@26767
|
1647 |
@{command_def "print_facts"}^* & : & \isarkeep{proof} \\
|
wenzelm@26767
|
1648 |
@{command_def "print_binds"}^* & : & \isarkeep{proof} \\
|
wenzelm@26767
|
1649 |
\end{matharray}
|
wenzelm@26767
|
1650 |
|
wenzelm@26767
|
1651 |
\begin{rail}
|
wenzelm@26767
|
1652 |
'print\_theory' ( '!'?)
|
wenzelm@26767
|
1653 |
;
|
wenzelm@26767
|
1654 |
|
wenzelm@26767
|
1655 |
'find\_theorems' (('(' (nat)? ('with\_dups')? ')')?) (criterion *)
|
wenzelm@26767
|
1656 |
;
|
wenzelm@26767
|
1657 |
criterion: ('-'?) ('name' ':' nameref | 'intro' | 'elim' | 'dest' |
|
wenzelm@26767
|
1658 |
'simp' ':' term | term)
|
wenzelm@26767
|
1659 |
;
|
wenzelm@26767
|
1660 |
'thm\_deps' thmrefs
|
wenzelm@26767
|
1661 |
;
|
wenzelm@26767
|
1662 |
\end{rail}
|
wenzelm@26767
|
1663 |
|
wenzelm@26767
|
1664 |
These commands print certain parts of the theory and proof context.
|
wenzelm@26767
|
1665 |
Note that there are some further ones available, such as for the set
|
wenzelm@26767
|
1666 |
of rules declared for simplifications.
|
wenzelm@26767
|
1667 |
|
wenzelm@26767
|
1668 |
\begin{descr}
|
wenzelm@26767
|
1669 |
|
wenzelm@26767
|
1670 |
\item [@{command "print_commands"}] prints Isabelle's outer theory
|
wenzelm@26767
|
1671 |
syntax, including keywords and command.
|
wenzelm@26767
|
1672 |
|
wenzelm@26767
|
1673 |
\item [@{command "print_theory"}] prints the main logical content of
|
wenzelm@26767
|
1674 |
the theory context; the ``@{text "!"}'' option indicates extra
|
wenzelm@26767
|
1675 |
verbosity.
|
wenzelm@26767
|
1676 |
|
wenzelm@26767
|
1677 |
\item [@{command "print_syntax"}] prints the inner syntax of types
|
wenzelm@26767
|
1678 |
and terms, depending on the current context. The output can be very
|
wenzelm@26767
|
1679 |
verbose, including grammar tables and syntax translation rules. See
|
wenzelm@26767
|
1680 |
\cite[\S7, \S8]{isabelle-ref} for further information on Isabelle's
|
wenzelm@26767
|
1681 |
inner syntax.
|
wenzelm@26767
|
1682 |
|
wenzelm@26767
|
1683 |
\item [@{command "print_methods"}] prints all proof methods
|
wenzelm@26767
|
1684 |
available in the current theory context.
|
wenzelm@26767
|
1685 |
|
wenzelm@26767
|
1686 |
\item [@{command "print_attributes"}] prints all attributes
|
wenzelm@26767
|
1687 |
available in the current theory context.
|
wenzelm@26767
|
1688 |
|
wenzelm@26767
|
1689 |
\item [@{command "print_theorems"}] prints theorems resulting from
|
wenzelm@26767
|
1690 |
the last command.
|
wenzelm@26767
|
1691 |
|
wenzelm@26767
|
1692 |
\item [@{command "find_theorems"}~@{text criteria}] retrieves facts
|
wenzelm@26767
|
1693 |
from the theory or proof context matching all of given search
|
wenzelm@26767
|
1694 |
criteria. The criterion @{text "name: p"} selects all theorems
|
wenzelm@26767
|
1695 |
whose fully qualified name matches pattern @{text p}, which may
|
wenzelm@26767
|
1696 |
contain ``@{text "*"}'' wildcards. The criteria @{text intro},
|
wenzelm@26767
|
1697 |
@{text elim}, and @{text dest} select theorems that match the
|
wenzelm@26767
|
1698 |
current goal as introduction, elimination or destruction rules,
|
wenzelm@26767
|
1699 |
respectively. The criterion @{text "simp: t"} selects all rewrite
|
wenzelm@26767
|
1700 |
rules whose left-hand side matches the given term. The criterion
|
wenzelm@26767
|
1701 |
term @{text t} selects all theorems that contain the pattern @{text
|
wenzelm@26767
|
1702 |
t} -- as usual, patterns may contain occurrences of the dummy
|
wenzelm@26767
|
1703 |
``@{verbatim _}'', schematic variables, and type constraints.
|
wenzelm@26767
|
1704 |
|
wenzelm@26767
|
1705 |
Criteria can be preceded by ``@{text "-"}'' to select theorems that
|
wenzelm@26767
|
1706 |
do \emph{not} match. Note that giving the empty list of criteria
|
wenzelm@26767
|
1707 |
yields \emph{all} currently known facts. An optional limit for the
|
wenzelm@26767
|
1708 |
number of printed facts may be given; the default is 40. By
|
wenzelm@26767
|
1709 |
default, duplicates are removed from the search result. Use
|
wenzelm@26767
|
1710 |
@{keyword "with_dups"} to display duplicates.
|
wenzelm@26767
|
1711 |
|
wenzelm@26767
|
1712 |
\item [@{command "thm_deps"}~@{text "a\<^sub>1 \<dots> a\<^sub>n"}]
|
wenzelm@26767
|
1713 |
visualizes dependencies of facts, using Isabelle's graph browser
|
wenzelm@26767
|
1714 |
tool (see also \cite{isabelle-sys}).
|
wenzelm@26767
|
1715 |
|
wenzelm@26767
|
1716 |
\item [@{command "print_facts"}] prints all local facts of the
|
wenzelm@26767
|
1717 |
current context, both named and unnamed ones.
|
wenzelm@26767
|
1718 |
|
wenzelm@26767
|
1719 |
\item [@{command "print_binds"}] prints all term abbreviations
|
wenzelm@26767
|
1720 |
present in the context.
|
wenzelm@26767
|
1721 |
|
wenzelm@26767
|
1722 |
\end{descr}
|
wenzelm@26767
|
1723 |
*}
|
wenzelm@26767
|
1724 |
|
wenzelm@26767
|
1725 |
|
wenzelm@26767
|
1726 |
subsection {* History commands \label{sec:history} *}
|
wenzelm@26767
|
1727 |
|
wenzelm@26767
|
1728 |
text {*
|
wenzelm@26767
|
1729 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
1730 |
@{command_def "undo"}^{{ * }{ * }} & : & \isarkeep{\cdot} \\
|
wenzelm@26767
|
1731 |
@{command_def "redo"}^{{ * }{ * }} & : & \isarkeep{\cdot} \\
|
wenzelm@26767
|
1732 |
@{command_def "kill"}^{{ * }{ * }} & : & \isarkeep{\cdot} \\
|
wenzelm@26767
|
1733 |
\end{matharray}
|
wenzelm@26767
|
1734 |
|
wenzelm@26767
|
1735 |
The Isabelle/Isar top-level maintains a two-stage history, for
|
wenzelm@26767
|
1736 |
theory and proof state transformation. Basically, any command can
|
wenzelm@26767
|
1737 |
be undone using @{command "undo"}, excluding mere diagnostic
|
wenzelm@26767
|
1738 |
elements. Its effect may be revoked via @{command "redo"}, unless
|
wenzelm@26767
|
1739 |
the corresponding @{command "undo"} step has crossed the beginning
|
wenzelm@26767
|
1740 |
of a proof or theory. The @{command "kill"} command aborts the
|
wenzelm@26767
|
1741 |
current history node altogether, discontinuing a proof or even the
|
wenzelm@26767
|
1742 |
whole theory. This operation is \emph{not} undo-able.
|
wenzelm@26767
|
1743 |
|
wenzelm@26767
|
1744 |
\begin{warn}
|
wenzelm@26767
|
1745 |
History commands should never be used with user interfaces such as
|
wenzelm@26767
|
1746 |
Proof~General \cite{proofgeneral,Aspinall:TACAS:2000}, which takes
|
wenzelm@26767
|
1747 |
care of stepping forth and back itself. Interfering by manual
|
wenzelm@26767
|
1748 |
@{command "undo"}, @{command "redo"}, or even @{command "kill"}
|
wenzelm@26767
|
1749 |
commands would quickly result in utter confusion.
|
wenzelm@26767
|
1750 |
\end{warn}
|
wenzelm@26767
|
1751 |
*}
|
wenzelm@26767
|
1752 |
|
wenzelm@26767
|
1753 |
|
wenzelm@26767
|
1754 |
subsection {* System operations *}
|
wenzelm@26767
|
1755 |
|
wenzelm@26767
|
1756 |
text {*
|
wenzelm@26767
|
1757 |
\begin{matharray}{rcl}
|
wenzelm@26767
|
1758 |
@{command_def "cd"}^* & : & \isarkeep{\cdot} \\
|
wenzelm@26767
|
1759 |
@{command_def "pwd"}^* & : & \isarkeep{\cdot} \\
|
wenzelm@26767
|
1760 |
@{command_def "use_thy"}^* & : & \isarkeep{\cdot} \\
|
wenzelm@26767
|
1761 |
@{command_def "display_drafts"}^* & : & \isarkeep{\cdot} \\
|
wenzelm@26767
|
1762 |
@{command_def "print_drafts"}^* & : & \isarkeep{\cdot} \\
|
wenzelm@26767
|
1763 |
\end{matharray}
|
wenzelm@26767
|
1764 |
|
wenzelm@26767
|
1765 |
\begin{rail}
|
wenzelm@26767
|
1766 |
('cd' | 'use\_thy' | 'update\_thy') name
|
wenzelm@26767
|
1767 |
;
|
wenzelm@26767
|
1768 |
('display\_drafts' | 'print\_drafts') (name +)
|
wenzelm@26767
|
1769 |
;
|
wenzelm@26767
|
1770 |
\end{rail}
|
wenzelm@26767
|
1771 |
|
wenzelm@26767
|
1772 |
\begin{descr}
|
wenzelm@26767
|
1773 |
|
wenzelm@26767
|
1774 |
\item [@{command "cd"}~@{text path}] changes the current directory
|
wenzelm@26767
|
1775 |
of the Isabelle process.
|
wenzelm@26767
|
1776 |
|
wenzelm@26767
|
1777 |
\item [@{command "pwd"}] prints the current working directory.
|
wenzelm@26767
|
1778 |
|
wenzelm@26767
|
1779 |
\item [@{command "use_thy"}~@{text A}] preload theory @{text A}.
|
wenzelm@26767
|
1780 |
These system commands are scarcely used when working interactively,
|
wenzelm@26767
|
1781 |
since loading of theories is done automatically as required.
|
wenzelm@26767
|
1782 |
|
wenzelm@26767
|
1783 |
\item [@{command "display_drafts"}~@{text paths} and @{command
|
wenzelm@26767
|
1784 |
"print_drafts"}~@{text paths}] perform simple output of a given list
|
wenzelm@26767
|
1785 |
of raw source files. Only those symbols that do not require
|
wenzelm@26767
|
1786 |
additional {\LaTeX} packages are displayed properly, everything else
|
wenzelm@26767
|
1787 |
is left verbatim.
|
wenzelm@26767
|
1788 |
|
wenzelm@26767
|
1789 |
\end{descr}
|
wenzelm@26767
|
1790 |
*}
|
wenzelm@26767
|
1791 |
|
wenzelm@26767
|
1792 |
end
|