author | nipkow |
Mon, 04 Aug 1997 11:50:35 +0200 | |
changeset 3586 | 2ee1ed79c802 |
parent 3485 | f27a30a18a17 |
child 4317 | 7264fa2ff2ec |
permissions | -rw-r--r-- |
3201 | 1 |
|
104 | 2 |
%% $Id$ |
145 | 3 |
|
104 | 4 |
\chapter{Theories, Terms and Types} \label{theories} |
5 |
\index{theories|(}\index{signatures|bold} |
|
3108 | 6 |
\index{reading!axioms|see{{\tt assume_ax}}} Theories organize the |
7 |
syntax, declarations and axioms of a mathematical development. They |
|
8 |
are built, starting from the {\Pure} or {\CPure} theory, by extending |
|
9 |
and merging existing theories. They have the \ML\ type |
|
10 |
\mltydx{theory}. Theory operations signal errors by raising exception |
|
11 |
\xdx{THEORY}, returning a message and a list of theories. |
|
104 | 12 |
|
13 |
Signatures, which contain information about sorts, types, constants and |
|
332 | 14 |
syntax, have the \ML\ type~\mltydx{Sign.sg}. For identification, each |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
15 |
signature carries a unique list of \bfindex{stamps}, which are \ML\ |
324 | 16 |
references to strings. The strings serve as human-readable names; the |
104 | 17 |
references serve as unique identifiers. Each primitive signature has a |
18 |
single stamp. When two signatures are merged, their lists of stamps are |
|
19 |
also merged. Every theory carries a unique signature. |
|
20 |
||
21 |
Terms and types are the underlying representation of logical syntax. Their |
|
275 | 22 |
\ML\ definitions are irrelevant to naive Isabelle users. Programmers who |
23 |
wish to extend Isabelle may need to know such details, say to code a tactic |
|
24 |
that looks for subgoals of a particular form. Terms and types may be |
|
104 | 25 |
`certified' to be well-formed with respect to a given signature. |
26 |
||
324 | 27 |
|
28 |
\section{Defining theories}\label{sec:ref-defining-theories} |
|
104 | 29 |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
30 |
Theories are usually defined using theory definition files (which have a name |
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3201
diff
changeset
|
31 |
suffix {\tt .thy}). There is also a low level interface provided by certain |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
32 |
\ML{} functions (see \S\ref{BuildingATheory}). |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
33 |
Appendix~\ref{app:TheorySyntax} presents the concrete syntax for theory |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
34 |
definitions; here is an explanation of the constituent parts: |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
35 |
\begin{description} |
3108 | 36 |
\item[{\it theoryDef}] is the full definition. The new theory is |
37 |
called $id$. It is the union of the named {\bf parent |
|
38 |
theories}\indexbold{theories!parent}, possibly extended with new |
|
39 |
components. \thydx{Pure} and \thydx{CPure} are the basic theories, |
|
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3201
diff
changeset
|
40 |
which contain only the meta-logic. They differ just in their |
3108 | 41 |
concrete syntax for function applications. |
138
9ba8bff1addc
added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents:
104
diff
changeset
|
42 |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
43 |
Normally each {\it name\/} is an identifier, the name of the parent theory. |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
44 |
Quoted strings can be used to document additional file dependencies; see |
275 | 45 |
\S\ref{LoadingTheories} for details. |
324 | 46 |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
47 |
\item[$classes$] |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
48 |
is a series of class declarations. Declaring {\tt$id$ < $id@1$ \dots\ |
324 | 49 |
$id@n$} makes $id$ a subclass of the existing classes $id@1\dots |
50 |
id@n$. This rules out cyclic class structures. Isabelle automatically |
|
51 |
computes the transitive closure of subclass hierarchies; it is not |
|
52 |
necessary to declare {\tt c < e} in addition to {\tt c < d} and {\tt d < |
|
53 |
e}. |
|
54 |
||
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
55 |
\item[$default$] |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
56 |
introduces $sort$ as the new default sort for type variables. This applies |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
57 |
to unconstrained type variables in an input string but not to type |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
58 |
variables created internally. If omitted, the default sort is the listwise |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
59 |
union of the default sorts of the parent theories (i.e.\ their logical |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
60 |
intersection). |
3108 | 61 |
|
62 |
\item[$sort$] is a finite set of classes. A single class $id$ |
|
63 |
abbreviates the sort $\ttlbrace id\ttrbrace$. |
|
324 | 64 |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
65 |
\item[$types$] |
324 | 66 |
is a series of type declarations. Each declares a new type constructor |
67 |
or type synonym. An $n$-place type constructor is specified by |
|
68 |
$(\alpha@1,\dots,\alpha@n)name$, where the type variables serve only to |
|
69 |
indicate the number~$n$. |
|
70 |
||
332 | 71 |
A {\bf type synonym}\indexbold{type synonyms} is an abbreviation |
1387 | 72 |
$(\alpha@1,\dots,\alpha@n)name = \tau$, where $name$ and $\tau$ can |
73 |
be strings. |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
74 |
|
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
75 |
\item[$infix$] |
324 | 76 |
declares a type or constant to be an infix operator of priority $nat$ |
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3201
diff
changeset
|
77 |
associating to the left ({\tt infixl}) or right ({\tt infixr}). Only |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
78 |
2-place type constructors can have infix status; an example is {\tt |
3108 | 79 |
('a,'b)~"*"~(infixr~20)}, which may express binary product types. |
324 | 80 |
|
3108 | 81 |
\item[$arities$] is a series of type arity declarations. Each assigns |
82 |
arities to type constructors. The $name$ must be an existing type |
|
83 |
constructor, which is given the additional arity $arity$. |
|
84 |
||
85 |
\item[$consts$] is a series of constant declarations. Each new |
|
86 |
constant $name$ is given the specified type. The optional $mixfix$ |
|
87 |
annotations may attach concrete syntax to the constant. |
|
88 |
||
89 |
\item[$syntax$] \index{*syntax section}\index{print mode} is a variant |
|
90 |
of $consts$ which adds just syntax without actually declaring |
|
91 |
logical constants. This gives full control over a theory's context |
|
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3201
diff
changeset
|
92 |
free grammar. The optional $mode$ specifies the print mode where the |
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3201
diff
changeset
|
93 |
mixfix productions should be added. If there is no \texttt{output} |
3108 | 94 |
option given, all productions are also added to the input syntax |
95 |
(regardless of the print mode). |
|
324 | 96 |
|
97 |
\item[$mixfix$] \index{mixfix declarations} |
|
98 |
annotations can take three forms: |
|
273 | 99 |
\begin{itemize} |
100 |
\item A mixfix template given as a $string$ of the form |
|
101 |
{\tt"}\dots{\tt\_}\dots{\tt\_}\dots{\tt"} where the $i$-th underscore |
|
324 | 102 |
indicates the position where the $i$-th argument should go. The list |
103 |
of numbers gives the priority of each argument. The final number gives |
|
104 |
the priority of the whole construct. |
|
104 | 105 |
|
324 | 106 |
\item A constant $f$ of type $\tau@1\To(\tau@2\To\tau)$ can be given {\bf |
107 |
infix} status. |
|
104 | 108 |
|
324 | 109 |
\item A constant $f$ of type $(\tau@1\To\tau@2)\To\tau$ can be given {\bf |
110 |
binder} status. The declaration {\tt binder} $\cal Q$ $p$ causes |
|
286 | 111 |
${\cal Q}\,x.F(x)$ to be treated |
112 |
like $f(F)$, where $p$ is the priority. |
|
273 | 113 |
\end{itemize} |
324 | 114 |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
115 |
\item[$trans$] |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
116 |
specifies syntactic translation rules (macros). There are three forms: |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
117 |
parse rules ({\tt =>}), print rules ({\tt <=}), and parse/print rules ({\tt |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
118 |
==}). |
324 | 119 |
|
1650 | 120 |
\item[$rules$] |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
121 |
is a series of rule declarations. Each has a name $id$ and the formula is |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
122 |
given by the $string$. Rule names must be distinct within any single |
3108 | 123 |
theory. |
324 | 124 |
|
1905 | 125 |
\item[$defs$] is a series of definitions. They are just like $rules$, except |
126 |
that every $string$ must be a definition (see below for details). |
|
1650 | 127 |
|
128 |
\item[$constdefs$] combines the declaration of constants and their |
|
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3201
diff
changeset
|
129 |
definition. The first $string$ is the type, the second the definition. |
3108 | 130 |
|
131 |
\item[$axclass$] \index{*axclass section} defines an |
|
132 |
\rmindex{axiomatic type class} as the intersection of existing |
|
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3201
diff
changeset
|
133 |
classes, with additional axioms holding. Class axioms may not |
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3201
diff
changeset
|
134 |
contain more than one type variable. The class axioms (with implicit |
3108 | 135 |
sort constraints added) are bound to the given names. Furthermore a |
136 |
class introduction rule is generated, which is automatically |
|
137 |
employed by $instance$ to prove instantiations of this class. |
|
138 |
||
139 |
\item[$instance$] \index{*instance section} proves class inclusions or |
|
140 |
type arities at the logical level and then transfers these to the |
|
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3201
diff
changeset
|
141 |
type signature. The instantiation is proven and checked properly. |
3108 | 142 |
The user has to supply sufficient witness information: theorems |
143 |
($longident$), axioms ($string$), or even arbitrary \ML{} tactic |
|
144 |
code $verbatim$. |
|
1650 | 145 |
|
1846 | 146 |
\item[$oracle$] links the theory to a trusted external reasoner. It is |
147 |
allowed to create theorems, but each theorem carries a proof object |
|
148 |
describing the oracle invocation. See \S\ref{sec:oracles} for details. |
|
149 |
||
324 | 150 |
\item[$ml$] \index{*ML section} |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
151 |
consists of \ML\ code, typically for parse and print translation functions. |
104 | 152 |
\end{description} |
324 | 153 |
% |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
154 |
Chapters~\ref{Defining-Logics} and \ref{chap:syntax} explain mixfix |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
155 |
declarations, translation rules and the {\tt ML} section in more detail. |
145 | 156 |
|
157 |
||
1905 | 158 |
\subsection{Definitions}\indexbold{definitions} |
159 |
||
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3201
diff
changeset
|
160 |
{\bf Definitions} are intended to express abbreviations. The simplest |
3108 | 161 |
form of a definition is $f \equiv t$, where $f$ is a constant. |
162 |
Isabelle also allows a derived forms where the arguments of~$f$ appear |
|
163 |
on the left, abbreviating a string of $\lambda$-abstractions. |
|
1905 | 164 |
|
165 |
Isabelle makes the following checks on definitions: |
|
166 |
\begin{itemize} |
|
3108 | 167 |
\item Arguments (on the left-hand side) must be distinct variables. |
1905 | 168 |
\item All variables on the right-hand side must also appear on the left-hand |
169 |
side. |
|
3108 | 170 |
\item All type variables on the right-hand side must also appear on |
171 |
the left-hand side; this prohibits definitions such as {\tt |
|
172 |
(zero::nat) == length ([]::'a list)}. |
|
1905 | 173 |
\item The definition must not be recursive. Most object-logics provide |
174 |
definitional principles that can be used to express recursion safely. |
|
175 |
\end{itemize} |
|
176 |
These checks are intended to catch the sort of errors that might be made |
|
177 |
accidentally. Misspellings, for instance, might result in additional |
|
178 |
variables appearing on the right-hand side. More elaborate checks could be |
|
179 |
made, but the cost might be overly strict rules on declaration order, etc. |
|
180 |
||
181 |
||
275 | 182 |
\subsection{*Classes and arities} |
324 | 183 |
\index{classes!context conditions}\index{arities!context conditions} |
145 | 184 |
|
286 | 185 |
In order to guarantee principal types~\cite{nipkow-prehofer}, |
324 | 186 |
arity declarations must obey two conditions: |
145 | 187 |
\begin{itemize} |
3108 | 188 |
\item There must not be any two declarations $ty :: (\vec{r})c$ and |
189 |
$ty :: (\vec{s})c$ with $\vec{r} \neq \vec{s}$. For example, this |
|
190 |
excludes the following: |
|
145 | 191 |
\begin{ttbox} |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
192 |
arities |
3108 | 193 |
foo :: ({\ttlbrace}logic{\ttrbrace}) logic |
194 |
foo :: ({\ttlbrace}{\ttrbrace})logic |
|
145 | 195 |
\end{ttbox} |
286 | 196 |
|
145 | 197 |
\item If there are two declarations $ty :: (s@1,\dots,s@n)c$ and $ty :: |
198 |
(s@1',\dots,s@n')c'$ such that $c' < c$ then $s@i' \preceq s@i$ must hold |
|
199 |
for $i=1,\dots,n$. The relationship $\preceq$, defined as |
|
200 |
\[ s' \preceq s \iff \forall c\in s. \exists c'\in s'.~ c'\le c, \] |
|
3108 | 201 |
expresses that the set of types represented by $s'$ is a subset of the |
202 |
set of types represented by $s$. Assuming $term \preceq logic$, the |
|
203 |
following is forbidden: |
|
145 | 204 |
\begin{ttbox} |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
205 |
arities |
3108 | 206 |
foo :: ({\ttlbrace}logic{\ttrbrace})logic |
207 |
foo :: ({\ttlbrace}{\ttrbrace})term |
|
145 | 208 |
\end{ttbox} |
286 | 209 |
|
145 | 210 |
\end{itemize} |
211 |
||
104 | 212 |
|
324 | 213 |
\section{Loading a new theory}\label{LoadingTheories} |
214 |
\index{theories!loading}\index{files!reading} |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
215 |
\begin{ttbox} |
286 | 216 |
use_thy : string -> unit |
217 |
time_use_thy : string -> unit |
|
218 |
loadpath : string list ref \hfill{\bf initially {\tt["."]}} |
|
219 |
delete_tmpfiles : bool ref \hfill{\bf initially true} |
|
220 |
\end{ttbox} |
|
221 |
||
324 | 222 |
\begin{ttdescription} |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
223 |
\item[\ttindexbold{use_thy} $thyname$] |
286 | 224 |
reads the theory $thyname$ and creates an \ML{} structure as described below. |
275 | 225 |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
226 |
\item[\ttindexbold{time_use_thy} $thyname$] |
286 | 227 |
calls {\tt use_thy} $thyname$ and reports the time taken. |
138
9ba8bff1addc
added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents:
104
diff
changeset
|
228 |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
229 |
\item[\ttindexbold{loadpath}] |
286 | 230 |
contains a list of directories to search when locating the files that |
231 |
define a theory. This list is only used if the theory name in {\tt |
|
232 |
use_thy} does not specify the path explicitly. |
|
233 |
||
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
234 |
\item[\ttindexbold{delete_tmpfiles} := false;] |
286 | 235 |
suppresses the deletion of temporary files. |
324 | 236 |
\end{ttdescription} |
286 | 237 |
% |
3108 | 238 |
Each theory definition must reside in a separate file. Let the file |
239 |
{\it T}{\tt.thy} contain the definition of a theory called~$T$, whose |
|
240 |
parent theories are $TB@1$ \dots $TB@n$. Calling |
|
241 |
\ttindex{use_thy}~{\tt"{\it T\/}"} reads the file {\it T}{\tt.thy}, |
|
242 |
writes a temporary \ML{} file {\tt.{\it T}.thy.ML}, and reads the |
|
243 |
latter file. Recursive {\tt use_thy} calls load those parent theories |
|
244 |
that have not been loaded previously; the recursive calls may continue |
|
245 |
to any depth. One {\tt use_thy} call can read an entire logic |
|
246 |
provided all theories are linked appropriately. |
|
138
9ba8bff1addc
added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents:
104
diff
changeset
|
247 |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
248 |
The result is an \ML\ structure~$T$ containing at least a component {\tt thy} |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
249 |
for the new theory and components for each of the rules. The structure also |
332 | 250 |
contains the definitions of the {\tt ML} section, if present. The file |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
251 |
{\tt.{\it T}.thy.ML} is then deleted if {\tt delete_tmpfiles} is set to {\tt |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
252 |
true} and no errors occurred. |
138
9ba8bff1addc
added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents:
104
diff
changeset
|
253 |
|
3108 | 254 |
Finally the file {\it T}{\tt.ML} is read, if it exists. Since the |
255 |
structure $T$ is automatically open in this context, proof scripts may |
|
256 |
(or even should) refer to its components by unqualified names. |
|
332 | 257 |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
258 |
Some applications construct theories directly by calling \ML\ functions. In |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
259 |
this situation there is no {\tt.thy} file, only an {\tt.ML} file. The |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
260 |
{\tt.ML} file must declare an \ML\ structure having the theory's name and a |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
261 |
component {\tt thy} containing the new theory object. |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
262 |
Section~\ref{sec:pseudo-theories} below describes a way of linking such |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
263 |
theories to their parents. |
324 | 264 |
|
265 |
\begin{warn} |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
266 |
Temporary files are written to the current directory, so this must be |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
267 |
writable. Isabelle inherits the current directory from the operating |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
268 |
system; you can change it within Isabelle by typing {\tt |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
269 |
cd"$dir$"}\index{*cd}. |
273 | 270 |
\end{warn} |
138
9ba8bff1addc
added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents:
104
diff
changeset
|
271 |
|
9ba8bff1addc
added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents:
104
diff
changeset
|
272 |
|
324 | 273 |
\section{Reloading modified theories}\label{sec:reloading-theories} |
274 |
\indexbold{theories!reloading} |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
275 |
\begin{ttbox} |
286 | 276 |
update : unit -> unit |
277 |
unlink_thy : string -> unit |
|
278 |
\end{ttbox} |
|
332 | 279 |
Changing a theory on disk often makes it necessary to reload all theories |
280 |
descended from it. However, {\tt use_thy} reads only one theory, even if |
|
281 |
some of the parent theories are out of date. In this case you should call |
|
282 |
{\tt update()}. |
|
283 |
||
286 | 284 |
Isabelle keeps track of all loaded theories and their files. If |
285 |
\ttindex{use_thy} finds that the theory to be loaded has been read before, |
|
286 |
it determines whether to reload the theory as follows. First it looks for |
|
287 |
the theory's files in their previous location. If it finds them, it |
|
288 |
compares their modification times to the internal data and stops if they |
|
289 |
are equal. If the files have been moved, {\tt use_thy} searches for them |
|
290 |
as it would for a new theory. After {\tt use_thy} reloads a theory, it |
|
291 |
marks the children as out-of-date. |
|
292 |
||
324 | 293 |
\begin{ttdescription} |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
294 |
\item[\ttindexbold{update}()] |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
295 |
reloads all modified theories and their descendants in the correct order. |
138
9ba8bff1addc
added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents:
104
diff
changeset
|
296 |
|
286 | 297 |
\item[\ttindexbold{unlink_thy} $thyname$]\indexbold{theories!removing} |
298 |
informs Isabelle that theory $thyname$ no longer exists. If you delete the |
|
299 |
theory files for $thyname$ then you must execute {\tt unlink_thy}; |
|
300 |
otherwise {\tt update} will complain about a missing file. |
|
324 | 301 |
\end{ttdescription} |
286 | 302 |
|
303 |
||
332 | 304 |
\subsection{*Pseudo theories}\label{sec:pseudo-theories} |
305 |
\indexbold{theories!pseudo}% |
|
275 | 306 |
Any automatic reloading facility requires complete knowledge of all |
286 | 307 |
dependencies. Sometimes theories depend on objects created in \ML{} files |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
308 |
with no associated theory definition file. These objects may be theories but |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
309 |
they could also be theorems, proof procedures, etc. |
332 | 310 |
|
311 |
Unless such dependencies are documented, {\tt update} fails to reload these |
|
312 |
\ML{} files and the system is left in a state where some objects, such as |
|
313 |
theorems, still refer to old versions of theories. This may lead to the |
|
314 |
error |
|
275 | 315 |
\begin{ttbox} |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
316 |
Attempt to merge different versions of theories: \dots |
275 | 317 |
\end{ttbox} |
324 | 318 |
Therefore there is a way to link theories and {\bf orphaned} \ML{} files --- |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
319 |
those not associated with a theory definition. |
138
9ba8bff1addc
added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents:
104
diff
changeset
|
320 |
|
324 | 321 |
Let us assume we have an orphaned \ML{} file named {\tt orphan.ML} and a |
332 | 322 |
theory~$B$ that depends on {\tt orphan.ML} --- for example, {\tt B.ML} uses |
323 |
theorems proved in {\tt orphan.ML}. Then {\tt B.thy} should |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
324 |
mention this dependency as follows: |
138
9ba8bff1addc
added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents:
104
diff
changeset
|
325 |
\begin{ttbox} |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
326 |
B = \(\ldots\) + "orphan" + \(\ldots\) |
138
9ba8bff1addc
added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents:
104
diff
changeset
|
327 |
\end{ttbox} |
1369 | 328 |
Quoted strings stand for theories which have to be loaded before the |
329 |
current theory is read but which are not used in building the base of |
|
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3201
diff
changeset
|
330 |
theory~$B$. Whenever {\tt orphan} changes and is reloaded, Isabelle |
1369 | 331 |
knows that $B$ has to be updated, too. |
275 | 332 |
|
1369 | 333 |
Note that it's necessary for {\tt orphan} to declare a special ML |
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3201
diff
changeset
|
334 |
object of type {\tt theory} which is present in all theories. This is |
1369 | 335 |
normally achieved by adding the file {\tt orphan.thy} to make {\tt |
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3201
diff
changeset
|
336 |
orphan} a {\bf pseudo theory}. A minimum version of {\tt orphan.thy} |
1369 | 337 |
would be |
338 |
||
339 |
\begin{ttbox} |
|
340 |
orphan = Pure |
|
341 |
\end{ttbox} |
|
342 |
||
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3201
diff
changeset
|
343 |
which uses {\tt Pure} to make a dummy theory. Normally though the |
1369 | 344 |
orphaned file has its own dependencies. If {\tt orphan.ML} depends on |
345 |
theories or files $A@1$, \ldots, $A@n$, record this by creating the |
|
346 |
pseudo theory in the following way: |
|
275 | 347 |
\begin{ttbox} |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
348 |
orphan = \(A@1\) + \(\ldots\) + \(A@n\) |
275 | 349 |
\end{ttbox} |
1369 | 350 |
The resulting theory ensures that {\tt update} reloads {\tt orphan} |
351 |
whenever it reloads one of the $A@i$. |
|
138
9ba8bff1addc
added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents:
104
diff
changeset
|
352 |
|
3108 | 353 |
For an extensive example of how this technique can be used to link |
354 |
lots of theory files and load them by just a few {\tt use_thy} calls |
|
355 |
see the sources of one of the major object-logics (e.g.\ \ZF). |
|
138
9ba8bff1addc
added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents:
104
diff
changeset
|
356 |
|
104 | 357 |
|
358 |
||
866
2d3d020eef11
added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
clasohm
parents:
864
diff
changeset
|
359 |
\section{Basic operations on theories}\label{BasicOperationsOnTheories} |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
360 |
\subsection{Extracting an axiom or theorem from a theory} |
324 | 361 |
\index{theories!axioms of}\index{axioms!extracting} |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
362 |
\index{theories!theorems of}\index{theorems!extracting} |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
363 |
\begin{ttbox} |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
364 |
get_axiom : theory -> string -> thm |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
365 |
get_thm : theory -> string -> thm |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
366 |
assume_ax : theory -> string -> thm |
104 | 367 |
\end{ttbox} |
324 | 368 |
\begin{ttdescription} |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
369 |
\item[\ttindexbold{get_axiom} $thy$ $name$] |
866
2d3d020eef11
added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
clasohm
parents:
864
diff
changeset
|
370 |
returns an axiom with the given $name$ from $thy$, raising exception |
2d3d020eef11
added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
clasohm
parents:
864
diff
changeset
|
371 |
\xdx{THEORY} if none exists. Merging theories can cause several axioms |
2d3d020eef11
added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
clasohm
parents:
864
diff
changeset
|
372 |
to have the same name; {\tt get_axiom} returns an arbitrary one. |
104 | 373 |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
374 |
\item[\ttindexbold{get_thm} $thy$ $name$] |
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3201
diff
changeset
|
375 |
is analogous to {\tt get_axiom}, but looks for a stored theorem. Like |
866
2d3d020eef11
added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
clasohm
parents:
864
diff
changeset
|
376 |
{\tt get_axiom} it searches all parents of a theory if the theorem |
2d3d020eef11
added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
clasohm
parents:
864
diff
changeset
|
377 |
is not associated with $thy$. |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
378 |
|
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
379 |
\item[\ttindexbold{assume_ax} $thy$ $formula$] |
286 | 380 |
reads the {\it formula} using the syntax of $thy$, following the same |
381 |
conventions as axioms in a theory definition. You can thus pretend that |
|
382 |
{\it formula} is an axiom and use the resulting theorem like an axiom. |
|
383 |
Actually {\tt assume_ax} returns an assumption; \ttindex{result} |
|
384 |
complains about additional assumptions, but \ttindex{uresult} does not. |
|
104 | 385 |
|
386 |
For example, if {\it formula} is |
|
332 | 387 |
\hbox{\tt a=b ==> b=a} then the resulting theorem has the form |
388 |
\hbox{\verb'?a=?b ==> ?b=?a [!!a b. a=b ==> b=a]'} |
|
324 | 389 |
\end{ttdescription} |
104 | 390 |
|
3108 | 391 |
\subsection{*Building a theory} |
286 | 392 |
\label{BuildingATheory} |
393 |
\index{theories!constructing|bold} |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
394 |
\begin{ttbox} |
3108 | 395 |
Pure.thy : theory |
396 |
CPure.thy : theory |
|
332 | 397 |
merge_theories : theory * theory -> theory |
286 | 398 |
\end{ttbox} |
3108 | 399 |
\begin{description} |
400 |
\item[\ttindexbold{Pure.thy}, \ttindexbold{CPure.thy}] contain the |
|
401 |
syntax and signature of the meta-logic. There are no axioms: |
|
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3201
diff
changeset
|
402 |
meta-level inferences are carried out by \ML\ functions. The two |
3108 | 403 |
\Pure s just differ in their concrete syntax of function |
404 |
application: $t(u@1, \ldots, u@n)$ vs.\ $t\,u@1,\ldots\,u@n$. |
|
405 |
||
286 | 406 |
\item[\ttindexbold{merge_theories} ($thy@1$, $thy@2$)] merges the two |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
407 |
theories $thy@1$ and $thy@2$. The resulting theory contains all of the |
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3201
diff
changeset
|
408 |
syntax, signature and axioms of the constituent theories. Merging theories |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
409 |
that contain different identification stamps of the same name fails with |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
410 |
the following message |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
411 |
\begin{ttbox} |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
412 |
Attempt to merge different versions of theories: "\(T@1\)", \(\ldots\), "\(T@n\)" |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
413 |
\end{ttbox} |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
414 |
This error may especially occur when a theory is redeclared --- say to |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
415 |
change an incorrect axiom --- and bindings to old versions persist. |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
416 |
Isabelle ensures that old and new theories of the same name are not |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
417 |
involved in a proof. |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
418 |
|
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
419 |
%% FIXME |
478 | 420 |
%\item [\ttindexbold{extend_theory} $thy$ {\tt"}$T${\tt"} $\cdots$] extends |
421 |
% the theory $thy$ with new types, constants, etc. $T$ identifies the theory |
|
422 |
% internally. When a theory is redeclared, say to change an incorrect axiom, |
|
423 |
% bindings to the old axiom may persist. Isabelle ensures that the old and |
|
424 |
% new theories are not involved in the same proof. Attempting to combine |
|
425 |
% different theories having the same name $T$ yields the fatal error |
|
426 |
%extend_theory : theory -> string -> \(\cdots\) -> theory |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
427 |
%\begin{ttbox} |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
428 |
%Attempt to merge different versions of theory: \(T\) |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
429 |
%\end{ttbox} |
3108 | 430 |
\end{description} |
286 | 431 |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
432 |
%% FIXME |
275 | 433 |
%\item [\ttindexbold{extend_theory} $thy$ {\tt"}$T${\tt"} |
434 |
% ($classes$, $default$, $types$, $arities$, $consts$, $sextopt$) $rules$] |
|
435 |
%\hfill\break %%% include if line is just too short |
|
286 | 436 |
%is the \ML{} equivalent of the following theory definition: |
275 | 437 |
%\begin{ttbox} |
438 |
%\(T\) = \(thy\) + |
|
439 |
%classes \(c\) < \(c@1\),\(\dots\),\(c@m\) |
|
440 |
% \dots |
|
441 |
%default {\(d@1,\dots,d@r\)} |
|
442 |
%types \(tycon@1\),\dots,\(tycon@i\) \(n\) |
|
443 |
% \dots |
|
444 |
%arities \(tycon@1'\),\dots,\(tycon@j'\) :: (\(s@1\),\dots,\(s@n\))\(c\) |
|
445 |
% \dots |
|
446 |
%consts \(b@1\),\dots,\(b@k\) :: \(\tau\) |
|
447 |
% \dots |
|
448 |
%rules \(name\) \(rule\) |
|
449 |
% \dots |
|
450 |
%end |
|
451 |
%\end{ttbox} |
|
452 |
%where |
|
453 |
%\begin{tabular}[t]{l@{~=~}l} |
|
454 |
%$classes$ & \tt[("$c$",["$c@1$",\dots,"$c@m$"]),\dots] \\ |
|
455 |
%$default$ & \tt["$d@1$",\dots,"$d@r$"]\\ |
|
456 |
%$types$ & \tt[([$tycon@1$,\dots,$tycon@i$], $n$),\dots] \\ |
|
457 |
%$arities$ & \tt[([$tycon'@1$,\dots,$tycon'@j$], ([$s@1$,\dots,$s@n$],$c$)),\dots] |
|
458 |
%\\ |
|
459 |
%$consts$ & \tt[([$b@1$,\dots,$b@k$],$\tau$),\dots] \\ |
|
460 |
%$rules$ & \tt[("$name$",$rule$),\dots] |
|
461 |
%\end{tabular} |
|
104 | 462 |
|
463 |
||
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
464 |
\subsection{Inspecting a theory}\label{sec:inspct-thy} |
104 | 465 |
\index{theories!inspecting|bold} |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
466 |
\begin{ttbox} |
3108 | 467 |
print_syntax : theory -> unit |
104 | 468 |
print_theory : theory -> unit |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
469 |
axioms_of : theory -> (string * thm) list |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
470 |
thms_of : theory -> (string * thm) list |
104 | 471 |
parents_of : theory -> theory list |
472 |
sign_of : theory -> Sign.sg |
|
473 |
stamps_of_thy : theory -> string ref list |
|
474 |
\end{ttbox} |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
475 |
These provide means of viewing a theory's components. |
324 | 476 |
\begin{ttdescription} |
3108 | 477 |
\item[\ttindexbold{print_syntax} $thy$] prints the syntax of $thy$ |
478 |
(grammar, macros, translation functions etc., see |
|
479 |
page~\pageref{pg:print_syn} for more details). |
|
480 |
||
481 |
\item[\ttindexbold{print_theory} $thy$] prints the logical parts of |
|
482 |
$thy$, excluding the syntax. |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
483 |
|
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
484 |
\item[\ttindexbold{axioms_of} $thy$] |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
485 |
returns the additional axioms of the most recent extend node of~$thy$. |
104 | 486 |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
487 |
\item[\ttindexbold{thms_of} $thy$] |
866
2d3d020eef11
added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
clasohm
parents:
864
diff
changeset
|
488 |
returns all theorems that are associated with $thy$. |
104 | 489 |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
490 |
\item[\ttindexbold{parents_of} $thy$] |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
491 |
returns the direct ancestors of~$thy$. |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
492 |
|
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
493 |
\item[\ttindexbold{sign_of} $thy$] |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
494 |
returns the signature associated with~$thy$. It is useful with functions |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
495 |
like {\tt read_instantiate_sg}, which take a signature as an argument. |
104 | 496 |
|
497 |
\item[\ttindexbold{stamps_of_thy} $thy$]\index{signatures} |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
498 |
returns the identification \rmindex{stamps} of the signature associated |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
499 |
with~$thy$. |
324 | 500 |
\end{ttdescription} |
104 | 501 |
|
1369 | 502 |
|
104 | 503 |
\section{Terms} |
504 |
\index{terms|bold} |
|
324 | 505 |
Terms belong to the \ML\ type \mltydx{term}, which is a concrete datatype |
3108 | 506 |
with six constructors: |
104 | 507 |
\begin{ttbox} |
508 |
type indexname = string * int; |
|
509 |
infix 9 $; |
|
510 |
datatype term = Const of string * typ |
|
511 |
| Free of string * typ |
|
512 |
| Var of indexname * typ |
|
513 |
| Bound of int |
|
514 |
| Abs of string * typ * term |
|
515 |
| op $ of term * term; |
|
516 |
\end{ttbox} |
|
324 | 517 |
\begin{ttdescription} |
518 |
\item[\ttindexbold{Const}($a$, $T$)] \index{constants|bold} |
|
286 | 519 |
is the {\bf constant} with name~$a$ and type~$T$. Constants include |
520 |
connectives like $\land$ and $\forall$ as well as constants like~0 |
|
521 |
and~$Suc$. Other constants may be required to define a logic's concrete |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
522 |
syntax. |
104 | 523 |
|
324 | 524 |
\item[\ttindexbold{Free}($a$, $T$)] \index{variables!free|bold} |
525 |
is the {\bf free variable} with name~$a$ and type~$T$. |
|
104 | 526 |
|
324 | 527 |
\item[\ttindexbold{Var}($v$, $T$)] \index{unknowns|bold} |
528 |
is the {\bf scheme variable} with indexname~$v$ and type~$T$. An |
|
529 |
\mltydx{indexname} is a string paired with a non-negative index, or |
|
530 |
subscript; a term's scheme variables can be systematically renamed by |
|
531 |
incrementing their subscripts. Scheme variables are essentially free |
|
532 |
variables, but may be instantiated during unification. |
|
104 | 533 |
|
324 | 534 |
\item[\ttindexbold{Bound} $i$] \index{variables!bound|bold} |
535 |
is the {\bf bound variable} with de Bruijn index~$i$, which counts the |
|
536 |
number of lambdas, starting from zero, between a variable's occurrence |
|
537 |
and its binding. The representation prevents capture of variables. For |
|
538 |
more information see de Bruijn \cite{debruijn72} or |
|
539 |
Paulson~\cite[page~336]{paulson91}. |
|
104 | 540 |
|
324 | 541 |
\item[\ttindexbold{Abs}($a$, $T$, $u$)] |
542 |
\index{lambda abs@$\lambda$-abstractions|bold} |
|
543 |
is the $\lambda$-{\bf abstraction} with body~$u$, and whose bound |
|
544 |
variable has name~$a$ and type~$T$. The name is used only for parsing |
|
545 |
and printing; it has no logical significance. |
|
104 | 546 |
|
324 | 547 |
\item[$t$ \$ $u$] \index{$@{\tt\$}|bold} \index{function applications|bold} |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
548 |
is the {\bf application} of~$t$ to~$u$. |
324 | 549 |
\end{ttdescription} |
286 | 550 |
Application is written as an infix operator to aid readability. |
332 | 551 |
Here is an \ML\ pattern to recognize \FOL{} formulae of |
104 | 552 |
the form~$A\imp B$, binding the subformulae to~$A$ and~$B$: |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
553 |
\begin{ttbox} |
104 | 554 |
Const("Trueprop",_) $ (Const("op -->",_) $ A $ B) |
555 |
\end{ttbox} |
|
556 |
||
557 |
||
324 | 558 |
\section{Variable binding} |
286 | 559 |
\begin{ttbox} |
560 |
loose_bnos : term -> int list |
|
561 |
incr_boundvars : int -> term -> term |
|
562 |
abstract_over : term*term -> term |
|
563 |
variant_abs : string * typ * term -> string * term |
|
564 |
aconv : term*term -> bool\hfill{\bf infix} |
|
565 |
\end{ttbox} |
|
566 |
These functions are all concerned with the de Bruijn representation of |
|
567 |
bound variables. |
|
324 | 568 |
\begin{ttdescription} |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
569 |
\item[\ttindexbold{loose_bnos} $t$] |
286 | 570 |
returns the list of all dangling bound variable references. In |
571 |
particular, {\tt Bound~0} is loose unless it is enclosed in an |
|
572 |
abstraction. Similarly {\tt Bound~1} is loose unless it is enclosed in |
|
573 |
at least two abstractions; if enclosed in just one, the list will contain |
|
574 |
the number 0. A well-formed term does not contain any loose variables. |
|
575 |
||
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
576 |
\item[\ttindexbold{incr_boundvars} $j$] |
332 | 577 |
increases a term's dangling bound variables by the offset~$j$. This is |
286 | 578 |
required when moving a subterm into a context where it is enclosed by a |
579 |
different number of abstractions. Bound variables with a matching |
|
580 |
abstraction are unaffected. |
|
581 |
||
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
582 |
\item[\ttindexbold{abstract_over} $(v,t)$] |
286 | 583 |
forms the abstraction of~$t$ over~$v$, which may be any well-formed term. |
584 |
It replaces every occurrence of \(v\) by a {\tt Bound} variable with the |
|
585 |
correct index. |
|
586 |
||
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
587 |
\item[\ttindexbold{variant_abs} $(a,T,u)$] |
286 | 588 |
substitutes into $u$, which should be the body of an abstraction. |
589 |
It replaces each occurrence of the outermost bound variable by a free |
|
590 |
variable. The free variable has type~$T$ and its name is a variant |
|
332 | 591 |
of~$a$ chosen to be distinct from all constants and from all variables |
286 | 592 |
free in~$u$. |
593 |
||
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
594 |
\item[$t$ \ttindexbold{aconv} $u$] |
286 | 595 |
tests whether terms~$t$ and~$u$ are \(\alpha\)-convertible: identical up |
596 |
to renaming of bound variables. |
|
597 |
\begin{itemize} |
|
598 |
\item |
|
599 |
Two constants, {\tt Free}s, or {\tt Var}s are \(\alpha\)-convertible |
|
600 |
if their names and types are equal. |
|
601 |
(Variables having the same name but different types are thus distinct. |
|
602 |
This confusing situation should be avoided!) |
|
603 |
\item |
|
604 |
Two bound variables are \(\alpha\)-convertible |
|
605 |
if they have the same number. |
|
606 |
\item |
|
607 |
Two abstractions are \(\alpha\)-convertible |
|
608 |
if their bodies are, and their bound variables have the same type. |
|
609 |
\item |
|
610 |
Two applications are \(\alpha\)-convertible |
|
611 |
if the corresponding subterms are. |
|
612 |
\end{itemize} |
|
613 |
||
324 | 614 |
\end{ttdescription} |
286 | 615 |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
616 |
\section{Certified terms}\index{terms!certified|bold}\index{signatures} |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
617 |
A term $t$ can be {\bf certified} under a signature to ensure that every type |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
618 |
in~$t$ is well-formed and every constant in~$t$ is a type instance of a |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
619 |
constant declared in the signature. The term must be well-typed and its use |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
620 |
of bound variables must be well-formed. Meta-rules such as {\tt forall_elim} |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
621 |
take certified terms as arguments. |
104 | 622 |
|
324 | 623 |
Certified terms belong to the abstract type \mltydx{cterm}. |
104 | 624 |
Elements of the type can only be created through the certification process. |
625 |
In case of error, Isabelle raises exception~\ttindex{TERM}\@. |
|
626 |
||
627 |
\subsection{Printing terms} |
|
324 | 628 |
\index{terms!printing of} |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
629 |
\begin{ttbox} |
275 | 630 |
string_of_cterm : cterm -> string |
104 | 631 |
Sign.string_of_term : Sign.sg -> term -> string |
632 |
\end{ttbox} |
|
324 | 633 |
\begin{ttdescription} |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
634 |
\item[\ttindexbold{string_of_cterm} $ct$] |
104 | 635 |
displays $ct$ as a string. |
636 |
||
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
637 |
\item[\ttindexbold{Sign.string_of_term} $sign$ $t$] |
104 | 638 |
displays $t$ as a string, using the syntax of~$sign$. |
324 | 639 |
\end{ttdescription} |
104 | 640 |
|
641 |
\subsection{Making and inspecting certified terms} |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
642 |
\begin{ttbox} |
275 | 643 |
cterm_of : Sign.sg -> term -> cterm |
644 |
read_cterm : Sign.sg -> string * typ -> cterm |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
645 |
cert_axm : Sign.sg -> string * term -> string * term |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
646 |
read_axm : Sign.sg -> string * string -> string * term |
3108 | 647 |
rep_cterm : cterm -> {\ttlbrace}T:typ, t:term, sign:Sign.sg, maxidx:int\ttrbrace |
104 | 648 |
\end{ttbox} |
324 | 649 |
\begin{ttdescription} |
275 | 650 |
\item[\ttindexbold{cterm_of} $sign$ $t$] \index{signatures} |
104 | 651 |
certifies $t$ with respect to signature~$sign$. |
652 |
||
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
653 |
\item[\ttindexbold{read_cterm} $sign$ ($s$, $T$)] |
104 | 654 |
reads the string~$s$ using the syntax of~$sign$, creating a certified term. |
655 |
The term is checked to have type~$T$; this type also tells the parser what |
|
656 |
kind of phrase to parse. |
|
657 |
||
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
658 |
\item[\ttindexbold{cert_axm} $sign$ ($name$, $t$)] |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
659 |
certifies $t$ with respect to $sign$ as a meta-proposition and converts all |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
660 |
exceptions to an error, including the final message |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
661 |
\begin{ttbox} |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
662 |
The error(s) above occurred in axiom "\(name\)" |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
663 |
\end{ttbox} |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
664 |
|
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
665 |
\item[\ttindexbold{read_axm} $sign$ ($name$, $s$)] |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
666 |
similar to {\tt cert_axm}, but first reads the string $s$ using the syntax of |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
667 |
$sign$. |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
668 |
|
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
669 |
\item[\ttindexbold{rep_cterm} $ct$] |
104 | 670 |
decomposes $ct$ as a record containing its type, the term itself, its |
671 |
signature, and the maximum subscript of its unknowns. The type and maximum |
|
672 |
subscript are computed during certification. |
|
324 | 673 |
\end{ttdescription} |
104 | 674 |
|
675 |
||
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
676 |
\section{Types}\index{types|bold} |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
677 |
Types belong to the \ML\ type \mltydx{typ}, which is a concrete datatype with |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
678 |
three constructor functions. These correspond to type constructors, free |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
679 |
type variables and schematic type variables. Types are classified by sorts, |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
680 |
which are lists of classes (representing an intersection). A class is |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
681 |
represented by a string. |
104 | 682 |
\begin{ttbox} |
683 |
type class = string; |
|
684 |
type sort = class list; |
|
685 |
||
686 |
datatype typ = Type of string * typ list |
|
687 |
| TFree of string * sort |
|
688 |
| TVar of indexname * sort; |
|
689 |
||
690 |
infixr 5 -->; |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
691 |
fun S --> T = Type ("fun", [S, T]); |
104 | 692 |
\end{ttbox} |
324 | 693 |
\begin{ttdescription} |
694 |
\item[\ttindexbold{Type}($a$, $Ts$)] \index{type constructors|bold} |
|
695 |
applies the {\bf type constructor} named~$a$ to the type operands~$Ts$. |
|
696 |
Type constructors include~\tydx{fun}, the binary function space |
|
697 |
constructor, as well as nullary type constructors such as~\tydx{prop}. |
|
698 |
Other type constructors may be introduced. In expressions, but not in |
|
699 |
patterns, \hbox{\tt$S$-->$T$} is a convenient shorthand for function |
|
700 |
types. |
|
104 | 701 |
|
324 | 702 |
\item[\ttindexbold{TFree}($a$, $s$)] \index{type variables|bold} |
703 |
is the {\bf type variable} with name~$a$ and sort~$s$. |
|
104 | 704 |
|
324 | 705 |
\item[\ttindexbold{TVar}($v$, $s$)] \index{type unknowns|bold} |
706 |
is the {\bf type unknown} with indexname~$v$ and sort~$s$. |
|
707 |
Type unknowns are essentially free type variables, but may be |
|
708 |
instantiated during unification. |
|
709 |
\end{ttdescription} |
|
104 | 710 |
|
711 |
||
712 |
\section{Certified types} |
|
713 |
\index{types!certified|bold} |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
714 |
Certified types, which are analogous to certified terms, have type |
275 | 715 |
\ttindexbold{ctyp}. |
104 | 716 |
|
717 |
\subsection{Printing types} |
|
324 | 718 |
\index{types!printing of} |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
719 |
\begin{ttbox} |
275 | 720 |
string_of_ctyp : ctyp -> string |
104 | 721 |
Sign.string_of_typ : Sign.sg -> typ -> string |
722 |
\end{ttbox} |
|
324 | 723 |
\begin{ttdescription} |
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
724 |
\item[\ttindexbold{string_of_ctyp} $cT$] |
104 | 725 |
displays $cT$ as a string. |
726 |
||
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
727 |
\item[\ttindexbold{Sign.string_of_typ} $sign$ $T$] |
104 | 728 |
displays $T$ as a string, using the syntax of~$sign$. |
324 | 729 |
\end{ttdescription} |
104 | 730 |
|
731 |
||
732 |
\subsection{Making and inspecting certified types} |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
733 |
\begin{ttbox} |
275 | 734 |
ctyp_of : Sign.sg -> typ -> ctyp |
3108 | 735 |
rep_ctyp : ctyp -> {\ttlbrace}T: typ, sign: Sign.sg\ttrbrace |
104 | 736 |
\end{ttbox} |
324 | 737 |
\begin{ttdescription} |
275 | 738 |
\item[\ttindexbold{ctyp_of} $sign$ $T$] \index{signatures} |
104 | 739 |
certifies $T$ with respect to signature~$sign$. |
740 |
||
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
478
diff
changeset
|
741 |
\item[\ttindexbold{rep_ctyp} $cT$] |
104 | 742 |
decomposes $cT$ as a record containing the type itself and its signature. |
324 | 743 |
\end{ttdescription} |
104 | 744 |
|
1846 | 745 |
|
746 |
\section{Oracles: calling external reasoners } |
|
747 |
\label{sec:oracles} |
|
748 |
\index{oracles|(} |
|
749 |
||
750 |
Oracles allow Isabelle to take advantage of external reasoners such as |
|
751 |
arithmetic decision procedures, model checkers, fast tautology checkers or |
|
752 |
computer algebra systems. Invoked as an oracle, an external reasoner can |
|
753 |
create arbitrary Isabelle theorems. It is your responsibility to ensure that |
|
754 |
the external reasoner is as trustworthy as your application requires. |
|
755 |
Isabelle's proof objects~(\S\ref{sec:proofObjects}) record how each theorem |
|
756 |
depends upon oracle calls. |
|
757 |
||
758 |
\begin{ttbox} |
|
759 |
invoke_oracle : theory * Sign.sg * exn -> thm |
|
1880 | 760 |
set_oracle : (Sign.sg * exn -> term) -> theory -> theory |
1846 | 761 |
\end{ttbox} |
762 |
\begin{ttdescription} |
|
763 |
\item[\ttindexbold{invoke_oracle} ($thy$, $sign$, $exn$)] invokes the oracle |
|
764 |
of theory $thy$ passing the information contained in the exception value |
|
765 |
$exn$ and creating a theorem having signature $sign$. Errors arise if $thy$ |
|
766 |
does not have an oracle, if the oracle rejects its arguments or if its |
|
767 |
result is ill-typed. |
|
768 |
||
769 |
\item[\ttindexbold{set_oracle} $fn$ $thy$] sets the oracle of theory $thy$ to |
|
770 |
be $fn$. It is seldom called explicitly, as there is syntax for oracles in |
|
3108 | 771 |
theory files. Any theory node can have at most one oracle. |
1846 | 772 |
\end{ttdescription} |
773 |
||
774 |
A curious feature of {\ML} exceptions is that they are ordinary constructors. |
|
775 |
The {\ML} type {\tt exn} is a datatype that can be extended at any time. (See |
|
776 |
my {\em {ML} for the Working Programmer}~\cite{paulson-ml2}, especially |
|
777 |
page~136.) The oracle mechanism takes advantage of this to allow an oracle to |
|
778 |
take any information whatever. |
|
779 |
||
780 |
There must be some way of invoking the external reasoner from \ML, either |
|
781 |
because it is coded in {\ML} or via an operating system interface. Isabelle |
|
782 |
expects the {\ML} function to take two arguments: a signature and an |
|
783 |
exception. |
|
784 |
\begin{itemize} |
|
785 |
\item The signature will typically be that of a desendant of the theory |
|
786 |
declaring the oracle. The oracle will use it to distinguish constants from |
|
787 |
variables, etc., and it will be attached to the generated theorems. |
|
788 |
||
789 |
\item The exception is used to pass arbitrary information to the oracle. This |
|
790 |
information must contain a full description of the problem to be solved by |
|
791 |
the external reasoner, including any additional information that might be |
|
792 |
required. The oracle may raise the exception to indicate that it cannot |
|
793 |
solve the specified problem. |
|
794 |
\end{itemize} |
|
795 |
||
796 |
A trivial example is provided on directory {\tt FOL/ex}. This oracle |
|
797 |
generates tautologies of the form $P\bimp\cdots\bimp P$, with an even number |
|
798 |
of $P$s. |
|
799 |
||
800 |
File {\tt declIffOracle.ML} begins by declaring a new exception constructor |
|
801 |
for the oracle the information it requires: here, just an integer. It |
|
802 |
contains some code (suppressed below) for creating the tautologies, and |
|
803 |
finally declares the oracle function itself: |
|
804 |
\begin{ttbox} |
|
805 |
exception IffOracleExn of int; |
|
806 |
\(\vdots\) |
|
807 |
fun mk_iff_oracle (sign, IffOracleExn n) = |
|
808 |
if n>0 andalso n mod 2 = 0 |
|
809 |
then Trueprop $ mk_iff n |
|
810 |
else raise IffOracleExn n; |
|
811 |
\end{ttbox} |
|
812 |
Observe the function two arguments, the signature {\tt sign} and the exception |
|
813 |
given as a pattern. The function checks its argument for validity. If $n$ is |
|
814 |
positive and even then it creates a tautology containing $n$ occurrences |
|
815 |
of~$P$. Otherwise it signals error by raising its own exception. Errors may |
|
816 |
be signalled by other means, such as returning the theorem {\tt True}. |
|
817 |
Please ensure that the oracle's result is correctly typed; Isabelle will |
|
818 |
reject ill-typed theorems by raising a cryptic exception at top level. |
|
819 |
||
820 |
The theory file {\tt IffOracle.thy} packages up the function above as an |
|
821 |
oracle. The first line indicates that the new theory depends upon the file |
|
822 |
{\tt declIffOracle.ML} (which declares the {\ML} code) as well as on \FOL. |
|
823 |
The second line informs Isabelle that this theory has an oracle given by the |
|
824 |
function {\tt mk_iff_oracle}. |
|
825 |
\begin{ttbox} |
|
826 |
IffOracle = "declIffOracle" + FOL + |
|
827 |
oracle mk_iff_oracle |
|
828 |
end |
|
829 |
\end{ttbox} |
|
830 |
Because a theory can have at most one oracle, the theory itself serves to |
|
831 |
identify the oracle. |
|
832 |
||
833 |
Here are some examples of invoking the oracle. An argument of 10 is allowed, |
|
834 |
but one of 5 is forbidden: |
|
835 |
\begin{ttbox} |
|
836 |
invoke_oracle (IffOracle.thy, sign_of IffOracle.thy, IffOracleExn 10); |
|
837 |
{\out "P <-> P <-> P <-> P <-> P <-> P <-> P <-> P <-> P <-> P" : thm} |
|
838 |
invoke_oracle (IffOracle.thy, sign_of IffOracle.thy, IffOracleExn 5); |
|
839 |
{\out Exception- IffOracleExn 5 raised} |
|
840 |
\end{ttbox} |
|
841 |
||
842 |
\index{oracles|)} |
|
104 | 843 |
\index{theories|)} |