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