30296
|
1 |
%
|
|
2 |
\begin{isabellebody}%
|
|
3 |
\def\isabellecontext{Integration}%
|
|
4 |
%
|
|
5 |
\isadelimtheory
|
|
6 |
%
|
|
7 |
\endisadelimtheory
|
|
8 |
%
|
|
9 |
\isatagtheory
|
|
10 |
\isacommand{theory}\isamarkupfalse%
|
|
11 |
\ Integration\isanewline
|
|
12 |
\isakeyword{imports}\ Base\isanewline
|
|
13 |
\isakeyword{begin}%
|
|
14 |
\endisatagtheory
|
|
15 |
{\isafoldtheory}%
|
|
16 |
%
|
|
17 |
\isadelimtheory
|
|
18 |
%
|
|
19 |
\endisadelimtheory
|
|
20 |
%
|
|
21 |
\isamarkupchapter{System integration%
|
|
22 |
}
|
|
23 |
\isamarkuptrue%
|
|
24 |
%
|
|
25 |
\isamarkupsection{Isar toplevel \label{sec:isar-toplevel}%
|
|
26 |
}
|
|
27 |
\isamarkuptrue%
|
|
28 |
%
|
|
29 |
\begin{isamarkuptext}%
|
|
30 |
The Isar toplevel may be considered the centeral hub of the
|
|
31 |
Isabelle/Isar system, where all key components and sub-systems are
|
|
32 |
integrated into a single read-eval-print loop of Isar commands. We
|
|
33 |
shall even incorporate the existing {\ML} toplevel of the compiler
|
|
34 |
and run-time system (cf.\ \secref{sec:ML-toplevel}).
|
|
35 |
|
|
36 |
Isabelle/Isar departs from the original ``LCF system architecture''
|
|
37 |
where {\ML} was really The Meta Language for defining theories and
|
|
38 |
conducting proofs. Instead, {\ML} now only serves as the
|
|
39 |
implementation language for the system (and user extensions), while
|
|
40 |
the specific Isar toplevel supports the concepts of theory and proof
|
|
41 |
development natively. This includes the graph structure of theories
|
|
42 |
and the block structure of proofs, support for unlimited undo,
|
|
43 |
facilities for tracing, debugging, timing, profiling etc.
|
|
44 |
|
|
45 |
\medskip The toplevel maintains an implicit state, which is
|
|
46 |
transformed by a sequence of transitions -- either interactively or
|
|
47 |
in batch-mode. In interactive mode, Isar state transitions are
|
|
48 |
encapsulated as safe transactions, such that both failure and undo
|
|
49 |
are handled conveniently without destroying the underlying draft
|
|
50 |
theory (cf.~\secref{sec:context-theory}). In batch mode,
|
|
51 |
transitions operate in a linear (destructive) fashion, such that
|
|
52 |
error conditions abort the present attempt to construct a theory or
|
|
53 |
proof altogether.
|
|
54 |
|
|
55 |
The toplevel state is a disjoint sum of empty \isa{toplevel}, or
|
|
56 |
\isa{theory}, or \isa{proof}. On entering the main Isar loop we
|
|
57 |
start with an empty toplevel. A theory is commenced by giving a
|
|
58 |
\isa{{\isasymTHEORY}} header; within a theory we may issue theory
|
|
59 |
commands such as \isa{{\isasymDEFINITION}}, or state a \isa{{\isasymTHEOREM}} to be proven. Now we are within a proof state, with a
|
|
60 |
rich collection of Isar proof commands for structured proof
|
|
61 |
composition, or unstructured proof scripts. When the proof is
|
|
62 |
concluded we get back to the theory, which is then updated by
|
|
63 |
storing the resulting fact. Further theory declarations or theorem
|
|
64 |
statements with proofs may follow, until we eventually conclude the
|
|
65 |
theory development by issuing \isa{{\isasymEND}}. The resulting theory
|
|
66 |
is then stored within the theory database and we are back to the
|
|
67 |
empty toplevel.
|
|
68 |
|
|
69 |
In addition to these proper state transformations, there are also
|
|
70 |
some diagnostic commands for peeking at the toplevel state without
|
|
71 |
modifying it (e.g.\ \isakeyword{thm}, \isakeyword{term},
|
|
72 |
\isakeyword{print-cases}).%
|
|
73 |
\end{isamarkuptext}%
|
|
74 |
\isamarkuptrue%
|
|
75 |
%
|
|
76 |
\isadelimmlref
|
|
77 |
%
|
|
78 |
\endisadelimmlref
|
|
79 |
%
|
|
80 |
\isatagmlref
|
|
81 |
%
|
|
82 |
\begin{isamarkuptext}%
|
|
83 |
\begin{mldecls}
|
|
84 |
\indexdef{}{ML type}{Toplevel.state}\verb|type Toplevel.state| \\
|
|
85 |
\indexdef{}{ML}{Toplevel.UNDEF}\verb|Toplevel.UNDEF: exn| \\
|
|
86 |
\indexdef{}{ML}{Toplevel.is\_toplevel}\verb|Toplevel.is_toplevel: Toplevel.state -> bool| \\
|
|
87 |
\indexdef{}{ML}{Toplevel.theory\_of}\verb|Toplevel.theory_of: Toplevel.state -> theory| \\
|
|
88 |
\indexdef{}{ML}{Toplevel.proof\_of}\verb|Toplevel.proof_of: Toplevel.state -> Proof.state| \\
|
32836
|
89 |
\indexdef{}{ML}{Toplevel.debug}\verb|Toplevel.debug: bool Unsynchronized.ref| \\
|
|
90 |
\indexdef{}{ML}{Toplevel.timing}\verb|Toplevel.timing: bool Unsynchronized.ref| \\
|
|
91 |
\indexdef{}{ML}{Toplevel.profiling}\verb|Toplevel.profiling: int Unsynchronized.ref| \\
|
30296
|
92 |
\end{mldecls}
|
|
93 |
|
|
94 |
\begin{description}
|
|
95 |
|
|
96 |
\item \verb|Toplevel.state| represents Isar toplevel states,
|
|
97 |
which are normally manipulated through the concept of toplevel
|
|
98 |
transitions only (\secref{sec:toplevel-transition}). Also note that
|
|
99 |
a raw toplevel state is subject to the same linearity restrictions
|
|
100 |
as a theory context (cf.~\secref{sec:context-theory}).
|
|
101 |
|
|
102 |
\item \verb|Toplevel.UNDEF| is raised for undefined toplevel
|
|
103 |
operations. Many operations work only partially for certain cases,
|
|
104 |
since \verb|Toplevel.state| is a sum type.
|
|
105 |
|
|
106 |
\item \verb|Toplevel.is_toplevel|~\isa{state} checks for an empty
|
|
107 |
toplevel state.
|
|
108 |
|
|
109 |
\item \verb|Toplevel.theory_of|~\isa{state} selects the theory of
|
|
110 |
a theory or proof (!), otherwise raises \verb|Toplevel.UNDEF|.
|
|
111 |
|
|
112 |
\item \verb|Toplevel.proof_of|~\isa{state} selects the Isar proof
|
|
113 |
state if available, otherwise raises \verb|Toplevel.UNDEF|.
|
|
114 |
|
32836
|
115 |
\item \verb|Toplevel.debug := true| makes the toplevel print further
|
30296
|
116 |
details about internal error conditions, exceptions being raised
|
|
117 |
etc.
|
|
118 |
|
32836
|
119 |
\item \verb|Toplevel.timing := true| makes the toplevel print timing
|
30296
|
120 |
information for each Isar command being executed.
|
|
121 |
|
|
122 |
\item \verb|Toplevel.profiling|~\verb|:=|~\isa{n} controls
|
|
123 |
low-level profiling of the underlying {\ML} runtime system. For
|
|
124 |
Poly/ML, \isa{n\ {\isacharequal}\ {\isadigit{1}}} means time and \isa{n\ {\isacharequal}\ {\isadigit{2}}} space
|
|
125 |
profiling.
|
|
126 |
|
|
127 |
\end{description}%
|
|
128 |
\end{isamarkuptext}%
|
|
129 |
\isamarkuptrue%
|
|
130 |
%
|
|
131 |
\endisatagmlref
|
|
132 |
{\isafoldmlref}%
|
|
133 |
%
|
|
134 |
\isadelimmlref
|
|
135 |
%
|
|
136 |
\endisadelimmlref
|
|
137 |
%
|
|
138 |
\isamarkupsubsection{Toplevel transitions \label{sec:toplevel-transition}%
|
|
139 |
}
|
|
140 |
\isamarkuptrue%
|
|
141 |
%
|
|
142 |
\begin{isamarkuptext}%
|
|
143 |
An Isar toplevel transition consists of a partial function on the
|
|
144 |
toplevel state, with additional information for diagnostics and
|
|
145 |
error reporting: there are fields for command name, source position,
|
|
146 |
optional source text, as well as flags for interactive-only commands
|
|
147 |
(which issue a warning in batch-mode), printing of result state,
|
|
148 |
etc.
|
|
149 |
|
|
150 |
The operational part is represented as the sequential union of a
|
|
151 |
list of partial functions, which are tried in turn until the first
|
|
152 |
one succeeds. This acts like an outer case-expression for various
|
|
153 |
alternative state transitions. For example, \isakeyword{qed} acts
|
|
154 |
differently for a local proofs vs.\ the global ending of the main
|
|
155 |
proof.
|
|
156 |
|
|
157 |
Toplevel transitions are composed via transition transformers.
|
|
158 |
Internally, Isar commands are put together from an empty transition
|
|
159 |
extended by name and source position (and optional source text). It
|
|
160 |
is then left to the individual command parser to turn the given
|
|
161 |
concrete syntax into a suitable transition transformer that adjoins
|
|
162 |
actual operations on a theory or proof state etc.%
|
|
163 |
\end{isamarkuptext}%
|
|
164 |
\isamarkuptrue%
|
|
165 |
%
|
|
166 |
\isadelimmlref
|
|
167 |
%
|
|
168 |
\endisadelimmlref
|
|
169 |
%
|
|
170 |
\isatagmlref
|
|
171 |
%
|
|
172 |
\begin{isamarkuptext}%
|
|
173 |
\begin{mldecls}
|
|
174 |
\indexdef{}{ML}{Toplevel.print}\verb|Toplevel.print: Toplevel.transition -> Toplevel.transition| \\
|
|
175 |
\indexdef{}{ML}{Toplevel.no\_timing}\verb|Toplevel.no_timing: Toplevel.transition -> Toplevel.transition| \\
|
|
176 |
\indexdef{}{ML}{Toplevel.keep}\verb|Toplevel.keep: (Toplevel.state -> unit) ->|\isasep\isanewline%
|
|
177 |
\verb| Toplevel.transition -> Toplevel.transition| \\
|
|
178 |
\indexdef{}{ML}{Toplevel.theory}\verb|Toplevel.theory: (theory -> theory) ->|\isasep\isanewline%
|
|
179 |
\verb| Toplevel.transition -> Toplevel.transition| \\
|
|
180 |
\indexdef{}{ML}{Toplevel.theory\_to\_proof}\verb|Toplevel.theory_to_proof: (theory -> Proof.state) ->|\isasep\isanewline%
|
|
181 |
\verb| Toplevel.transition -> Toplevel.transition| \\
|
|
182 |
\indexdef{}{ML}{Toplevel.proof}\verb|Toplevel.proof: (Proof.state -> Proof.state) ->|\isasep\isanewline%
|
|
183 |
\verb| Toplevel.transition -> Toplevel.transition| \\
|
|
184 |
\indexdef{}{ML}{Toplevel.proofs}\verb|Toplevel.proofs: (Proof.state -> Proof.state Seq.seq) ->|\isasep\isanewline%
|
|
185 |
\verb| Toplevel.transition -> Toplevel.transition| \\
|
|
186 |
\indexdef{}{ML}{Toplevel.end\_proof}\verb|Toplevel.end_proof: (bool -> Proof.state -> Proof.context) ->|\isasep\isanewline%
|
|
187 |
\verb| Toplevel.transition -> Toplevel.transition| \\
|
|
188 |
\end{mldecls}
|
|
189 |
|
|
190 |
\begin{description}
|
|
191 |
|
|
192 |
\item \verb|Toplevel.print|~\isa{tr} sets the print flag, which
|
|
193 |
causes the toplevel loop to echo the result state (in interactive
|
|
194 |
mode).
|
|
195 |
|
|
196 |
\item \verb|Toplevel.no_timing|~\isa{tr} indicates that the
|
|
197 |
transition should never show timing information, e.g.\ because it is
|
|
198 |
a diagnostic command.
|
|
199 |
|
|
200 |
\item \verb|Toplevel.keep|~\isa{tr} adjoins a diagnostic
|
|
201 |
function.
|
|
202 |
|
|
203 |
\item \verb|Toplevel.theory|~\isa{tr} adjoins a theory
|
|
204 |
transformer.
|
|
205 |
|
|
206 |
\item \verb|Toplevel.theory_to_proof|~\isa{tr} adjoins a global
|
|
207 |
goal function, which turns a theory into a proof state. The theory
|
|
208 |
may be changed before entering the proof; the generic Isar goal
|
|
209 |
setup includes an argument that specifies how to apply the proven
|
|
210 |
result to the theory, when the proof is finished.
|
|
211 |
|
|
212 |
\item \verb|Toplevel.proof|~\isa{tr} adjoins a deterministic
|
|
213 |
proof command, with a singleton result.
|
|
214 |
|
|
215 |
\item \verb|Toplevel.proofs|~\isa{tr} adjoins a general proof
|
|
216 |
command, with zero or more result states (represented as a lazy
|
|
217 |
list).
|
|
218 |
|
|
219 |
\item \verb|Toplevel.end_proof|~\isa{tr} adjoins a concluding
|
|
220 |
proof command, that returns the resulting theory, after storing the
|
|
221 |
resulting facts in the context etc.
|
|
222 |
|
|
223 |
\end{description}%
|
|
224 |
\end{isamarkuptext}%
|
|
225 |
\isamarkuptrue%
|
|
226 |
%
|
|
227 |
\endisatagmlref
|
|
228 |
{\isafoldmlref}%
|
|
229 |
%
|
|
230 |
\isadelimmlref
|
|
231 |
%
|
|
232 |
\endisadelimmlref
|
|
233 |
%
|
|
234 |
\isamarkupsubsection{Toplevel control%
|
|
235 |
}
|
|
236 |
\isamarkuptrue%
|
|
237 |
%
|
|
238 |
\begin{isamarkuptext}%
|
|
239 |
There are a few special control commands that modify the behavior
|
|
240 |
the toplevel itself, and only make sense in interactive mode. Under
|
|
241 |
normal circumstances, the user encounters these only implicitly as
|
|
242 |
part of the protocol between the Isabelle/Isar system and a
|
|
243 |
user-interface such as ProofGeneral.
|
|
244 |
|
|
245 |
\begin{description}
|
|
246 |
|
|
247 |
\item \isacommand{undo} follows the three-level hierarchy of empty
|
|
248 |
toplevel vs.\ theory vs.\ proof: undo within a proof reverts to the
|
|
249 |
previous proof context, undo after a proof reverts to the theory
|
|
250 |
before the initial goal statement, undo of a theory command reverts
|
|
251 |
to the previous theory value, undo of a theory header discontinues
|
|
252 |
the current theory development and removes it from the theory
|
|
253 |
database (\secref{sec:theory-database}).
|
|
254 |
|
|
255 |
\item \isacommand{kill} aborts the current level of development:
|
|
256 |
kill in a proof context reverts to the theory before the initial
|
|
257 |
goal statement, kill in a theory context aborts the current theory
|
|
258 |
development, removing it from the database.
|
|
259 |
|
|
260 |
\item \isacommand{exit} drops out of the Isar toplevel into the
|
|
261 |
underlying {\ML} toplevel (\secref{sec:ML-toplevel}). The Isar
|
|
262 |
toplevel state is preserved and may be continued later.
|
|
263 |
|
|
264 |
\item \isacommand{quit} terminates the Isabelle/Isar process without
|
|
265 |
saving.
|
|
266 |
|
|
267 |
\end{description}%
|
|
268 |
\end{isamarkuptext}%
|
|
269 |
\isamarkuptrue%
|
|
270 |
%
|
|
271 |
\isamarkupsection{ML toplevel \label{sec:ML-toplevel}%
|
|
272 |
}
|
|
273 |
\isamarkuptrue%
|
|
274 |
%
|
|
275 |
\begin{isamarkuptext}%
|
|
276 |
The {\ML} toplevel provides a read-compile-eval-print loop for {\ML}
|
|
277 |
values, types, structures, and functors. {\ML} declarations operate
|
|
278 |
on the global system state, which consists of the compiler
|
|
279 |
environment plus the values of {\ML} reference variables. There is
|
|
280 |
no clean way to undo {\ML} declarations, except for reverting to a
|
|
281 |
previously saved state of the whole Isabelle process. {\ML} input
|
|
282 |
is either read interactively from a TTY, or from a string (usually
|
|
283 |
within a theory text), or from a source file (usually loaded from a
|
|
284 |
theory).
|
|
285 |
|
|
286 |
Whenever the {\ML} toplevel is active, the current Isabelle theory
|
|
287 |
context is passed as an internal reference variable. Thus {\ML}
|
|
288 |
code may access the theory context during compilation, it may even
|
|
289 |
change the value of a theory being under construction --- while
|
|
290 |
observing the usual linearity restrictions
|
|
291 |
(cf.~\secref{sec:context-theory}).%
|
|
292 |
\end{isamarkuptext}%
|
|
293 |
\isamarkuptrue%
|
|
294 |
%
|
|
295 |
\isadelimmlref
|
|
296 |
%
|
|
297 |
\endisadelimmlref
|
|
298 |
%
|
|
299 |
\isatagmlref
|
|
300 |
%
|
|
301 |
\begin{isamarkuptext}%
|
|
302 |
\begin{mldecls}
|
32189
|
303 |
\indexdef{}{ML}{ML\_Context.the\_generic\_context}\verb|ML_Context.the_generic_context: unit -> Context.generic| \\
|
30296
|
304 |
\indexdef{}{ML}{Context.$>$$>$ }\verb|Context.>> : (Context.generic -> Context.generic) -> unit| \\
|
|
305 |
\end{mldecls}
|
|
306 |
|
|
307 |
\begin{description}
|
|
308 |
|
32189
|
309 |
\item \verb|ML_Context.the_generic_context ()| refers to the theory
|
|
310 |
context of the {\ML} toplevel --- at compile time! {\ML} code needs
|
|
311 |
to take care to refer to \verb|ML_Context.the_generic_context ()|
|
|
312 |
correctly. Recall that evaluation of a function body is delayed
|
|
313 |
until actual runtime. Moreover, persistent {\ML} toplevel bindings
|
|
314 |
to an unfinished theory should be avoided: code should either
|
|
315 |
project out the desired information immediately, or produce an
|
|
316 |
explicit \verb|theory_ref| (cf.\ \secref{sec:context-theory}).
|
30296
|
317 |
|
|
318 |
\item \verb|Context.>>|~\isa{f} applies context transformation
|
|
319 |
\isa{f} to the implicit context of the {\ML} toplevel.
|
|
320 |
|
|
321 |
\end{description}
|
|
322 |
|
|
323 |
It is very important to note that the above functions are really
|
|
324 |
restricted to the compile time, even though the {\ML} compiler is
|
|
325 |
invoked at runtime! The majority of {\ML} code uses explicit
|
|
326 |
functional arguments of a theory or proof context instead. Thus it
|
|
327 |
may be invoked for an arbitrary context later on, without having to
|
|
328 |
worry about any operational details.
|
|
329 |
|
|
330 |
\bigskip
|
|
331 |
|
|
332 |
\begin{mldecls}
|
|
333 |
\indexdef{}{ML}{Isar.main}\verb|Isar.main: unit -> unit| \\
|
|
334 |
\indexdef{}{ML}{Isar.loop}\verb|Isar.loop: unit -> unit| \\
|
|
335 |
\indexdef{}{ML}{Isar.state}\verb|Isar.state: unit -> Toplevel.state| \\
|
|
336 |
\indexdef{}{ML}{Isar.exn}\verb|Isar.exn: unit -> (exn * string) option| \\
|
|
337 |
\indexdef{}{ML}{Isar.context}\verb|Isar.context: unit -> Proof.context| \\
|
|
338 |
\indexdef{}{ML}{Isar.goal}\verb|Isar.goal: unit -> thm| \\
|
|
339 |
\end{mldecls}
|
|
340 |
|
|
341 |
\begin{description}
|
|
342 |
|
|
343 |
\item \verb|Isar.main ()| invokes the Isar toplevel from {\ML},
|
|
344 |
initializing an empty toplevel state.
|
|
345 |
|
|
346 |
\item \verb|Isar.loop ()| continues the Isar toplevel with the
|
|
347 |
current state, after having dropped out of the Isar toplevel loop.
|
|
348 |
|
|
349 |
\item \verb|Isar.state ()| and \verb|Isar.exn ()| get current
|
|
350 |
toplevel state and error condition, respectively. This only works
|
|
351 |
after having dropped out of the Isar toplevel loop.
|
|
352 |
|
|
353 |
\item \verb|Isar.context ()| produces the proof context from \verb|Isar.state ()|, analogous to \verb|Context.proof_of|
|
|
354 |
(\secref{sec:generic-context}).
|
|
355 |
|
|
356 |
\item \verb|Isar.goal ()| picks the tactical goal from \verb|Isar.state ()|, represented as a theorem according to
|
|
357 |
\secref{sec:tactical-goals}.
|
|
358 |
|
|
359 |
\end{description}%
|
|
360 |
\end{isamarkuptext}%
|
|
361 |
\isamarkuptrue%
|
|
362 |
%
|
|
363 |
\endisatagmlref
|
|
364 |
{\isafoldmlref}%
|
|
365 |
%
|
|
366 |
\isadelimmlref
|
|
367 |
%
|
|
368 |
\endisadelimmlref
|
|
369 |
%
|
|
370 |
\isamarkupsection{Theory database \label{sec:theory-database}%
|
|
371 |
}
|
|
372 |
\isamarkuptrue%
|
|
373 |
%
|
|
374 |
\begin{isamarkuptext}%
|
|
375 |
The theory database maintains a collection of theories, together
|
|
376 |
with some administrative information about their original sources,
|
|
377 |
which are held in an external store (i.e.\ some directory within the
|
|
378 |
regular file system).
|
|
379 |
|
|
380 |
The theory database is organized as a directed acyclic graph;
|
|
381 |
entries are referenced by theory name. Although some additional
|
|
382 |
interfaces allow to include a directory specification as well, this
|
|
383 |
is only a hint to the underlying theory loader. The internal theory
|
|
384 |
name space is flat!
|
|
385 |
|
|
386 |
Theory \isa{A} is associated with the main theory file \isa{A}\verb,.thy,, which needs to be accessible through the theory
|
|
387 |
loader path. Any number of additional {\ML} source files may be
|
|
388 |
associated with each theory, by declaring these dependencies in the
|
|
389 |
theory header as \isa{{\isasymUSES}}, and loading them consecutively
|
|
390 |
within the theory context. The system keeps track of incoming {\ML}
|
|
391 |
sources and associates them with the current theory. The file
|
|
392 |
\isa{A}\verb,.ML, is loaded after a theory has been concluded, in
|
|
393 |
order to support legacy proof {\ML} proof scripts.
|
|
394 |
|
|
395 |
The basic internal actions of the theory database are \isa{update}, \isa{outdate}, and \isa{remove}:
|
|
396 |
|
|
397 |
\begin{itemize}
|
|
398 |
|
|
399 |
\item \isa{update\ A} introduces a link of \isa{A} with a
|
|
400 |
\isa{theory} value of the same name; it asserts that the theory
|
|
401 |
sources are now consistent with that value;
|
|
402 |
|
|
403 |
\item \isa{outdate\ A} invalidates the link of a theory database
|
|
404 |
entry to its sources, but retains the present theory value;
|
|
405 |
|
|
406 |
\item \isa{remove\ A} deletes entry \isa{A} from the theory
|
|
407 |
database.
|
|
408 |
|
|
409 |
\end{itemize}
|
|
410 |
|
|
411 |
These actions are propagated to sub- or super-graphs of a theory
|
|
412 |
entry as expected, in order to preserve global consistency of the
|
|
413 |
state of all loaded theories with the sources of the external store.
|
|
414 |
This implies certain causalities between actions: \isa{update}
|
|
415 |
or \isa{outdate} of an entry will \isa{outdate} all
|
|
416 |
descendants; \isa{remove} will \isa{remove} all descendants.
|
|
417 |
|
|
418 |
\medskip There are separate user-level interfaces to operate on the
|
|
419 |
theory database directly or indirectly. The primitive actions then
|
|
420 |
just happen automatically while working with the system. In
|
|
421 |
particular, processing a theory header \isa{{\isasymTHEORY}\ A\ {\isasymIMPORTS}\ B\isactrlsub {\isadigit{1}}\ {\isasymdots}\ B\isactrlsub n\ {\isasymBEGIN}} ensures that the
|
|
422 |
sub-graph of the collective imports \isa{B\isactrlsub {\isadigit{1}}\ {\isasymdots}\ B\isactrlsub n}
|
|
423 |
is up-to-date, too. Earlier theories are reloaded as required, with
|
|
424 |
\isa{update} actions proceeding in topological order according to
|
|
425 |
theory dependencies. There may be also a wave of implied \isa{outdate} actions for derived theory nodes until a stable situation
|
|
426 |
is achieved eventually.%
|
|
427 |
\end{isamarkuptext}%
|
|
428 |
\isamarkuptrue%
|
|
429 |
%
|
|
430 |
\isadelimmlref
|
|
431 |
%
|
|
432 |
\endisadelimmlref
|
|
433 |
%
|
|
434 |
\isatagmlref
|
|
435 |
%
|
|
436 |
\begin{isamarkuptext}%
|
|
437 |
\begin{mldecls}
|
|
438 |
\indexdef{}{ML}{theory}\verb|theory: string -> theory| \\
|
|
439 |
\indexdef{}{ML}{use\_thy}\verb|use_thy: string -> unit| \\
|
|
440 |
\indexdef{}{ML}{use\_thys}\verb|use_thys: string list -> unit| \\
|
|
441 |
\indexdef{}{ML}{ThyInfo.touch\_thy}\verb|ThyInfo.touch_thy: string -> unit| \\
|
|
442 |
\indexdef{}{ML}{ThyInfo.remove\_thy}\verb|ThyInfo.remove_thy: string -> unit| \\[1ex]
|
|
443 |
\indexdef{}{ML}{ThyInfo.begin\_theory}\verb|ThyInfo.begin_theory|\verb|: ... -> bool -> theory| \\
|
|
444 |
\indexdef{}{ML}{ThyInfo.end\_theory}\verb|ThyInfo.end_theory: theory -> unit| \\
|
|
445 |
\indexdef{}{ML}{ThyInfo.register\_theory}\verb|ThyInfo.register_theory: theory -> unit| \\[1ex]
|
|
446 |
\verb|datatype action = Update |\verb,|,\verb| Outdate |\verb,|,\verb| Remove| \\
|
|
447 |
\indexdef{}{ML}{ThyInfo.add\_hook}\verb|ThyInfo.add_hook: (ThyInfo.action -> string -> unit) -> unit| \\
|
|
448 |
\end{mldecls}
|
|
449 |
|
|
450 |
\begin{description}
|
|
451 |
|
|
452 |
\item \verb|theory|~\isa{A} retrieves the theory value presently
|
|
453 |
associated with name \isa{A}. Note that the result might be
|
|
454 |
outdated.
|
|
455 |
|
|
456 |
\item \verb|use_thy|~\isa{A} ensures that theory \isa{A} is fully
|
|
457 |
up-to-date wrt.\ the external file store, reloading outdated
|
|
458 |
ancestors as required.
|
|
459 |
|
|
460 |
\item \verb|use_thys| is similar to \verb|use_thy|, but handles
|
|
461 |
several theories simultaneously. Thus it acts like processing the
|
|
462 |
import header of a theory, without performing the merge of the
|
|
463 |
result, though.
|
|
464 |
|
|
465 |
\item \verb|ThyInfo.touch_thy|~\isa{A} performs and \isa{outdate} action
|
|
466 |
on theory \isa{A} and all descendants.
|
|
467 |
|
|
468 |
\item \verb|ThyInfo.remove_thy|~\isa{A} deletes theory \isa{A} and all
|
|
469 |
descendants from the theory database.
|
|
470 |
|
|
471 |
\item \verb|ThyInfo.begin_theory| is the basic operation behind a
|
|
472 |
\isa{{\isasymTHEORY}} header declaration. This is {\ML} functions is
|
|
473 |
normally not invoked directly.
|
|
474 |
|
|
475 |
\item \verb|ThyInfo.end_theory| concludes the loading of a theory
|
|
476 |
proper and stores the result in the theory database.
|
|
477 |
|
|
478 |
\item \verb|ThyInfo.register_theory|~\isa{text\ thy} registers an
|
|
479 |
existing theory value with the theory loader database. There is no
|
|
480 |
management of associated sources.
|
|
481 |
|
|
482 |
\item \verb|ThyInfo.add_hook|~\isa{f} registers function \isa{f} as a hook for theory database actions. The function will be
|
|
483 |
invoked with the action and theory name being involved; thus derived
|
|
484 |
actions may be performed in associated system components, e.g.\
|
|
485 |
maintaining the state of an editor for the theory sources.
|
|
486 |
|
|
487 |
The kind and order of actions occurring in practice depends both on
|
|
488 |
user interactions and the internal process of resolving theory
|
|
489 |
imports. Hooks should not rely on a particular policy here! Any
|
|
490 |
exceptions raised by the hook are ignored.
|
|
491 |
|
|
492 |
\end{description}%
|
|
493 |
\end{isamarkuptext}%
|
|
494 |
\isamarkuptrue%
|
|
495 |
%
|
|
496 |
\endisatagmlref
|
|
497 |
{\isafoldmlref}%
|
|
498 |
%
|
|
499 |
\isadelimmlref
|
|
500 |
%
|
|
501 |
\endisadelimmlref
|
|
502 |
%
|
|
503 |
\isadelimtheory
|
|
504 |
%
|
|
505 |
\endisadelimtheory
|
|
506 |
%
|
|
507 |
\isatagtheory
|
|
508 |
\isacommand{end}\isamarkupfalse%
|
|
509 |
%
|
|
510 |
\endisatagtheory
|
|
511 |
{\isafoldtheory}%
|
|
512 |
%
|
|
513 |
\isadelimtheory
|
|
514 |
%
|
|
515 |
\endisadelimtheory
|
|
516 |
\isanewline
|
|
517 |
\end{isabellebody}%
|
|
518 |
%%% Local Variables:
|
|
519 |
%%% mode: latex
|
|
520 |
%%% TeX-master: "root"
|
|
521 |
%%% End:
|