doc-src/Ref/theories.tex
author krauss
Mon, 01 Mar 2010 17:05:57 +0100
changeset 35419 d78659d1723e
parent 30184 37969710e61f
child 39838 eb47307ab930
permissions -rw-r--r--
more recdef (and old primrec) hunting
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
145
422197c5a078 added subsection 'Classes and types';
wenzelm
parents: 141
diff changeset
     1
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     2
\chapter{Theories, Terms and Types} \label{theories}
30184
37969710e61f removed parts of the manual that are clearly obsolete, or covered by
wenzelm
parents: 19627
diff changeset
     3
\index{theories|(}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     4
6568
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
     5
\section{The theory loader}\label{sec:more-theories}
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
     6
\index{theories!reading}\index{files!reading}
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
     7
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
     8
Isabelle's theory loader manages dependencies of the internal graph of theory
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
     9
nodes (the \emph{theory database}) and the external view of the file system.
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    10
See \S\ref{sec:intro-theories} for its most basic commands, such as
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    11
\texttt{use_thy}.  There are a few more operations available.
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    12
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
    13
\begin{ttbox}
6568
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    14
use_thy_only    : string -> unit
7136
71f6eef45713 added update_thy_only;
wenzelm
parents: 6975
diff changeset
    15
update_thy_only : string -> unit
6568
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    16
touch_thy       : string -> unit
6658
b44dd06378cc remove_thy;
wenzelm
parents: 6625
diff changeset
    17
remove_thy      : string -> unit
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7440
diff changeset
    18
delete_tmpfiles : bool ref \hfill\textbf{initially true}
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
    19
\end{ttbox}
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
    20
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
    21
\begin{ttdescription}
6569
wenzelm
parents: 6568
diff changeset
    22
\item[\ttindexbold{use_thy_only} "$name$";] is similar to \texttt{use_thy},
wenzelm
parents: 6568
diff changeset
    23
  but processes the actual theory file $name$\texttt{.thy} only, ignoring
6568
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    24
  $name$\texttt{.ML}.  This might be useful in replaying proof scripts by hand
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    25
  from the very beginning, starting with the fresh theory.
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    26
  
7136
71f6eef45713 added update_thy_only;
wenzelm
parents: 6975
diff changeset
    27
\item[\ttindexbold{update_thy_only} "$name$";] is similar to
71f6eef45713 added update_thy_only;
wenzelm
parents: 6975
diff changeset
    28
  \texttt{update_thy}, but processes the actual theory file
71f6eef45713 added update_thy_only;
wenzelm
parents: 6975
diff changeset
    29
  $name$\texttt{.thy} only, ignoring $name$\texttt{.ML}.
71f6eef45713 added update_thy_only;
wenzelm
parents: 6975
diff changeset
    30
6569
wenzelm
parents: 6568
diff changeset
    31
\item[\ttindexbold{touch_thy} "$name$";] marks theory node $name$ of the
6568
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    32
  internal graph as outdated.  While the theory remains usable, subsequent
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    33
  operations such as \texttt{use_thy} may cause a reload.
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    34
  
6658
b44dd06378cc remove_thy;
wenzelm
parents: 6625
diff changeset
    35
\item[\ttindexbold{remove_thy} "$name$";] deletes theory node $name$,
b44dd06378cc remove_thy;
wenzelm
parents: 6625
diff changeset
    36
  including \emph{all} of its descendants.  Beware!  This is a quick way to
b44dd06378cc remove_thy;
wenzelm
parents: 6625
diff changeset
    37
  dispose a large number of theories at once.  Note that {\ML} bindings to
b44dd06378cc remove_thy;
wenzelm
parents: 6625
diff changeset
    38
  theorems etc.\ of removed theories may still persist.
b44dd06378cc remove_thy;
wenzelm
parents: 6625
diff changeset
    39
  
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
    40
\end{ttdescription}
138
9ba8bff1addc added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents: 104
diff changeset
    41
6568
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    42
\medskip Theory and {\ML} files are located by skimming through the
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    43
directories listed in Isabelle's internal load path, which merely contains the
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    44
current directory ``\texttt{.}'' by default.  The load path may be accessed by
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    45
the following operations.
332
01b87a921967 final Springer copy
lcp
parents: 324
diff changeset
    46
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
    47
\begin{ttbox}
6568
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    48
show_path: unit -> string list
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    49
add_path: string -> unit
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    50
del_path: string -> unit
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    51
reset_path: unit -> unit
7440
c1829208180f added with_path;
wenzelm
parents: 7168
diff changeset
    52
with_path: string -> ('a -> 'b) -> 'a -> 'b
11052
1379e49c0ee9 added no_document;
wenzelm
parents: 9695
diff changeset
    53
no_document: ('a -> 'b) -> 'a -> 'b
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
    54
\end{ttbox}
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
    55
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
    56
\begin{ttdescription}
6568
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    57
\item[\ttindexbold{show_path}();] displays the load path components in
6571
wenzelm
parents: 6569
diff changeset
    58
  canonical string representation (which is always according to Unix rules).
6568
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    59
  
6569
wenzelm
parents: 6568
diff changeset
    60
\item[\ttindexbold{add_path} "$dir$";] adds component $dir$ to the beginning
wenzelm
parents: 6568
diff changeset
    61
  of the load path.
6568
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    62
  
6569
wenzelm
parents: 6568
diff changeset
    63
\item[\ttindexbold{del_path} "$dir$";] removes any occurrences of component
6568
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    64
  $dir$ from the load path.
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    65
  
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    66
\item[\ttindexbold{reset_path}();] resets the load path to ``\texttt{.}''
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 5390
diff changeset
    67
  (current directory) only.
7440
c1829208180f added with_path;
wenzelm
parents: 7168
diff changeset
    68
  
c1829208180f added with_path;
wenzelm
parents: 7168
diff changeset
    69
\item[\ttindexbold{with_path} "$dir$" $f$ $x$;] temporarily adds component
11052
1379e49c0ee9 added no_document;
wenzelm
parents: 9695
diff changeset
    70
  $dir$ to the beginning of the load path while executing $(f~x)$.
1379e49c0ee9 added no_document;
wenzelm
parents: 9695
diff changeset
    71
  
1379e49c0ee9 added no_document;
wenzelm
parents: 9695
diff changeset
    72
\item[\ttindexbold{no_document} $f$ $x$;] temporarily disables {\LaTeX}
1379e49c0ee9 added no_document;
wenzelm
parents: 9695
diff changeset
    73
  document generation while executing $(f~x)$.
7440
c1829208180f added with_path;
wenzelm
parents: 7168
diff changeset
    74
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
    75
\end{ttdescription}
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
    76
7440
c1829208180f added with_path;
wenzelm
parents: 7168
diff changeset
    77
Furthermore, in operations referring indirectly to some file (e.g.\ 
c1829208180f added with_path;
wenzelm
parents: 7168
diff changeset
    78
\texttt{use_dir}) the argument may be prefixed by a directory that will be
c1829208180f added with_path;
wenzelm
parents: 7168
diff changeset
    79
temporarily appended to the load path, too.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    80
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    81
866
2d3d020eef11 added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
clasohm
parents: 864
diff changeset
    82
\section{Basic operations on theories}\label{BasicOperationsOnTheories}
4384
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
    83
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
    84
\subsection{*Theory inclusion}
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
    85
\begin{ttbox}
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
    86
subthy      : theory * theory -> bool
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
    87
eq_thy      : theory * theory -> bool
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
    88
transfer    : theory -> thm -> thm
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
    89
transfer_sg : Sign.sg -> thm -> thm
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
    90
\end{ttbox}
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
    91
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
    92
Inclusion and equality of theories is determined by unique
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
    93
identification stamps that are created when declaring new components.
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
    94
Theorems contain a reference to the theory (actually to its signature)
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
    95
they have been derived in.  Transferring theorems to super theories
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
    96
has no logical significance, but may affect some operations in subtle
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
    97
ways (e.g.\ implicit merges of signatures when applying rules, or
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
    98
pretty printing of theorems).
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
    99
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
   100
\begin{ttdescription}
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
   101
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
   102
\item[\ttindexbold{subthy} ($thy@1$, $thy@2$)] determines if $thy@1$
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
   103
  is included in $thy@2$ wrt.\ identification stamps.
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
   104
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
   105
\item[\ttindexbold{eq_thy} ($thy@1$, $thy@2$)] determines if $thy@1$
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
   106
  is exactly the same as $thy@2$.
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
   107
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
   108
\item[\ttindexbold{transfer} $thy$ $thm$] transfers theorem $thm$ to
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
   109
  theory $thy$, provided the latter includes the theory of $thm$.
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
   110
  
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
   111
\item[\ttindexbold{transfer_sg} $sign$ $thm$] is similar to
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
   112
  \texttt{transfer}, but identifies the super theory via its
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
   113
  signature.
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
   114
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
   115
\end{ttdescription}
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
   116
429cba89b4c8 \subsection{*Theory inclusion};
wenzelm
parents: 4374
diff changeset
   117
6571
wenzelm
parents: 6569
diff changeset
   118
\subsection{*Primitive theories}
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   119
\begin{ttbox}
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   120
ProtoPure.thy  : theory
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 1905
diff changeset
   121
Pure.thy       : theory
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 1905
diff changeset
   122
CPure.thy      : theory
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   123
\end{ttbox}
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 1905
diff changeset
   124
\begin{description}
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   125
\item[\ttindexbold{ProtoPure.thy}, \ttindexbold{Pure.thy},
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   126
  \ttindexbold{CPure.thy}] contain the syntax and signature of the
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   127
  meta-logic.  There are basically no axioms: meta-level inferences
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   128
  are carried out by \ML\ functions.  \texttt{Pure} and \texttt{CPure}
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   129
  just differ in their concrete syntax of prefix function application:
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   130
  $t(u@1, \ldots, u@n)$ in \texttt{Pure} vs.\ $t\,u@1,\ldots\,u@n$ in
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   131
  \texttt{CPure}.  \texttt{ProtoPure} is their common parent,
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   132
  containing no syntax for printing prefix applications at all!
6571
wenzelm
parents: 6569
diff changeset
   133
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   134
%% FIXME
478
838bd766d536 added init_thy_reader and removed extend_theory
nipkow
parents: 332
diff changeset
   135
%\item [\ttindexbold{extend_theory} $thy$ {\tt"}$T${\tt"} $\cdots$] extends
838bd766d536 added init_thy_reader and removed extend_theory
nipkow
parents: 332
diff changeset
   136
%  the theory $thy$ with new types, constants, etc.  $T$ identifies the theory
838bd766d536 added init_thy_reader and removed extend_theory
nipkow
parents: 332
diff changeset
   137
%  internally.  When a theory is redeclared, say to change an incorrect axiom,
838bd766d536 added init_thy_reader and removed extend_theory
nipkow
parents: 332
diff changeset
   138
%  bindings to the old axiom may persist.  Isabelle ensures that the old and
838bd766d536 added init_thy_reader and removed extend_theory
nipkow
parents: 332
diff changeset
   139
%  new theories are not involved in the same proof.  Attempting to combine
838bd766d536 added init_thy_reader and removed extend_theory
nipkow
parents: 332
diff changeset
   140
%  different theories having the same name $T$ yields the fatal error
838bd766d536 added init_thy_reader and removed extend_theory
nipkow
parents: 332
diff changeset
   141
%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
   142
%\begin{ttbox}
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   143
%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
   144
%\end{ttbox}
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 1905
diff changeset
   145
\end{description}
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   146
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   147
%% FIXME
275
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   148
%\item [\ttindexbold{extend_theory} $thy$ {\tt"}$T${\tt"}
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   149
%      ($classes$, $default$, $types$, $arities$, $consts$, $sextopt$) $rules$]
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   150
%\hfill\break   %%% include if line is just too short
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   151
%is the \ML{} equivalent of the following theory definition:
275
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   152
%\begin{ttbox}
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   153
%\(T\) = \(thy\) +
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   154
%classes \(c\) < \(c@1\),\(\dots\),\(c@m\)
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   155
%        \dots
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   156
%default {\(d@1,\dots,d@r\)}
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   157
%types   \(tycon@1\),\dots,\(tycon@i\) \(n\)
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   158
%        \dots
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   159
%arities \(tycon@1'\),\dots,\(tycon@j'\) :: (\(s@1\),\dots,\(s@n\))\(c\)
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   160
%        \dots
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   161
%consts  \(b@1\),\dots,\(b@k\) :: \(\tau\)
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   162
%        \dots
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   163
%rules   \(name\) \(rule\)
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   164
%        \dots
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   165
%end
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   166
%\end{ttbox}
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   167
%where
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   168
%\begin{tabular}[t]{l@{~=~}l}
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   169
%$classes$ & \tt[("$c$",["$c@1$",\dots,"$c@m$"]),\dots] \\
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   170
%$default$ & \tt["$d@1$",\dots,"$d@r$"]\\
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   171
%$types$   & \tt[([$tycon@1$,\dots,$tycon@i$], $n$),\dots] \\
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   172
%$arities$ & \tt[([$tycon'@1$,\dots,$tycon'@j$], ([$s@1$,\dots,$s@n$],$c$)),\dots]
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   173
%\\
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   174
%$consts$  & \tt[([$b@1$,\dots,$b@k$],$\tau$),\dots] \\
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   175
%$rules$   & \tt[("$name$",$rule$),\dots]
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   176
%\end{tabular}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   177
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   178
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   179
\subsection{Inspecting a theory}\label{sec:inspct-thy}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   180
\index{theories!inspecting|bold}
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   181
\begin{ttbox}
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   182
print_syntax        : theory -> unit
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   183
print_theory        : theory -> unit
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   184
parents_of          : theory -> theory list
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   185
ancestors_of        : theory -> theory list
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   186
sign_of             : theory -> Sign.sg
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   187
Sign.stamp_names_of : Sign.sg -> string list
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   188
\end{ttbox}
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   189
These provide means of viewing a theory's components.
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   190
\begin{ttdescription}
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 1905
diff changeset
   191
\item[\ttindexbold{print_syntax} $thy$] prints the syntax of $thy$
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 1905
diff changeset
   192
  (grammar, macros, translation functions etc., see
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 1905
diff changeset
   193
  page~\pageref{pg:print_syn} for more details).
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 1905
diff changeset
   194
  
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 1905
diff changeset
   195
\item[\ttindexbold{print_theory} $thy$] prints the logical parts of
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 1905
diff changeset
   196
  $thy$, excluding the syntax.
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   197
  
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   198
\item[\ttindexbold{parents_of} $thy$] returns the direct ancestors
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   199
  of~$thy$.
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   200
  
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   201
\item[\ttindexbold{ancestors_of} $thy$] returns all ancestors of~$thy$
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   202
  (not including $thy$ itself).
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   203
  
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   204
\item[\ttindexbold{sign_of} $thy$] returns the signature associated
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   205
  with~$thy$.  It is useful with functions like {\tt
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   206
    read_instantiate_sg}, which take a signature as an argument.
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   207
  
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   208
\item[\ttindexbold{Sign.stamp_names_of} $sg$]\index{signatures}
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   209
  returns the names of the identification \rmindex{stamps} of ax
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   210
  signature.  These coincide with the names of its full ancestry
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   211
  including that of $sg$ itself.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   212
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   213
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   214
1369
b82815e61b30 corrected documentation of pseudo theories;
clasohm
parents: 866
diff changeset
   215
11623
9c95b6a76e15 Added label for section on terms.
berghofe
parents: 11052
diff changeset
   216
\section{Terms}\label{sec:terms}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   217
\index{terms|bold}
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   218
Terms belong to the \ML\ type \mltydx{term}, which is a concrete datatype
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 1905
diff changeset
   219
with six constructors:
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   220
\begin{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   221
type indexname = string * int;
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   222
infix 9 $;
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   223
datatype term = Const of string * typ
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   224
              | Free  of string * typ
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   225
              | Var   of indexname * typ
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   226
              | Bound of int
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   227
              | Abs   of string * typ * term
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   228
              | op $  of term * term;
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   229
\end{ttbox}
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   230
\begin{ttdescription}
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   231
\item[\ttindexbold{Const} ($a$, $T$)] \index{constants|bold}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7440
diff changeset
   232
  is the \textbf{constant} with name~$a$ and type~$T$.  Constants include
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   233
  connectives like $\land$ and $\forall$ as well as constants like~0
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   234
  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
   235
  syntax.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   236
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   237
\item[\ttindexbold{Free} ($a$, $T$)] \index{variables!free|bold}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7440
diff changeset
   238
  is the \textbf{free variable} with name~$a$ and type~$T$.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   239
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   240
\item[\ttindexbold{Var} ($v$, $T$)] \index{unknowns|bold}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7440
diff changeset
   241
  is the \textbf{scheme variable} with indexname~$v$ and type~$T$.  An
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   242
  \mltydx{indexname} is a string paired with a non-negative index, or
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   243
  subscript; a term's scheme variables can be systematically renamed by
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   244
  incrementing their subscripts.  Scheme variables are essentially free
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   245
  variables, but may be instantiated during unification.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   246
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   247
\item[\ttindexbold{Bound} $i$] \index{variables!bound|bold}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7440
diff changeset
   248
  is the \textbf{bound variable} with de Bruijn index~$i$, which counts the
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   249
  number of lambdas, starting from zero, between a variable's occurrence
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   250
  and its binding.  The representation prevents capture of variables.  For
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   251
  more information see de Bruijn \cite{debruijn72} or
6592
c120262044b6 Now uses manual.bib; some references updated
paulson
parents: 6571
diff changeset
   252
  Paulson~\cite[page~376]{paulson-ml2}.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   253
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   254
\item[\ttindexbold{Abs} ($a$, $T$, $u$)]
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   255
  \index{lambda abs@$\lambda$-abstractions|bold}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7440
diff changeset
   256
  is the $\lambda$-\textbf{abstraction} with body~$u$, and whose bound
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   257
  variable has name~$a$ and type~$T$.  The name is used only for parsing
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   258
  and printing; it has no logical significance.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   259
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   260
\item[$t$ \$ $u$] \index{$@{\tt\$}|bold} \index{function applications|bold}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7440
diff changeset
   261
is the \textbf{application} of~$t$ to~$u$.
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   262
\end{ttdescription}
9695
ec7d7f877712 proper setup of iman.sty/extra.sty/ttbox.sty;
wenzelm
parents: 8136
diff changeset
   263
Application is written as an infix operator to aid readability.  Here is an
ec7d7f877712 proper setup of iman.sty/extra.sty/ttbox.sty;
wenzelm
parents: 8136
diff changeset
   264
\ML\ pattern to recognize FOL formulae of the form~$A\imp B$, binding the
ec7d7f877712 proper setup of iman.sty/extra.sty/ttbox.sty;
wenzelm
parents: 8136
diff changeset
   265
subformulae to~$A$ and~$B$:
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   266
\begin{ttbox}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   267
Const("Trueprop",_) $ (Const("op -->",_) $ A $ B)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   268
\end{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   269
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   270
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   271
\section{*Variable binding}
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   272
\begin{ttbox}
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   273
loose_bnos     : term -> int list
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   274
incr_boundvars : int -> term -> term
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   275
abstract_over  : term*term -> term
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   276
variant_abs    : string * typ * term -> string * term
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7440
diff changeset
   277
aconv          : term * term -> bool\hfill\textbf{infix}
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   278
\end{ttbox}
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   279
These functions are all concerned with the de Bruijn representation of
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   280
bound variables.
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   281
\begin{ttdescription}
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   282
\item[\ttindexbold{loose_bnos} $t$]
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   283
  returns the list of all dangling bound variable references.  In
6669
5f1ce866c497 locale documentation (from Florian)
paulson
parents: 6658
diff changeset
   284
  particular, \texttt{Bound~0} is loose unless it is enclosed in an
5f1ce866c497 locale documentation (from Florian)
paulson
parents: 6658
diff changeset
   285
  abstraction.  Similarly \texttt{Bound~1} is loose unless it is enclosed in
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   286
  at least two abstractions; if enclosed in just one, the list will contain
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   287
  the number 0.  A well-formed term does not contain any loose variables.
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   288
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   289
\item[\ttindexbold{incr_boundvars} $j$]
332
01b87a921967 final Springer copy
lcp
parents: 324
diff changeset
   290
  increases a term's dangling bound variables by the offset~$j$.  This is
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   291
  required when moving a subterm into a context where it is enclosed by a
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   292
  different number of abstractions.  Bound variables with a matching
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   293
  abstraction are unaffected.
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   294
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   295
\item[\ttindexbold{abstract_over} $(v,t)$]
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   296
  forms the abstraction of~$t$ over~$v$, which may be any well-formed term.
6669
5f1ce866c497 locale documentation (from Florian)
paulson
parents: 6658
diff changeset
   297
  It replaces every occurrence of \(v\) by a \texttt{Bound} variable with the
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   298
  correct index.
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   299
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   300
\item[\ttindexbold{variant_abs} $(a,T,u)$]
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   301
  substitutes into $u$, which should be the body of an abstraction.
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   302
  It replaces each occurrence of the outermost bound variable by a free
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   303
  variable.  The free variable has type~$T$ and its name is a variant
332
01b87a921967 final Springer copy
lcp
parents: 324
diff changeset
   304
  of~$a$ chosen to be distinct from all constants and from all variables
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   305
  free in~$u$.
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   306
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   307
\item[$t$ \ttindexbold{aconv} $u$]
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   308
  tests whether terms~$t$ and~$u$ are \(\alpha\)-convertible: identical up
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   309
  to renaming of bound variables.
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   310
\begin{itemize}
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   311
  \item
6669
5f1ce866c497 locale documentation (from Florian)
paulson
parents: 6658
diff changeset
   312
    Two constants, \texttt{Free}s, or \texttt{Var}s are \(\alpha\)-convertible
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   313
    if their names and types are equal.
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   314
    (Variables having the same name but different types are thus distinct.
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   315
    This confusing situation should be avoided!)
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   316
  \item
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   317
    Two bound variables are \(\alpha\)-convertible
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   318
    if they have the same number.
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   319
  \item
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   320
    Two abstractions are \(\alpha\)-convertible
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   321
    if their bodies are, and their bound variables have the same type.
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   322
  \item
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   323
    Two applications are \(\alpha\)-convertible
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   324
    if the corresponding subterms are.
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   325
\end{itemize}
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   326
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   327
\end{ttdescription}
286
e7efbf03562b first draft of Springer book
lcp
parents: 275
diff changeset
   328
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   329
\section{Certified terms}\index{terms!certified|bold}\index{signatures}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7440
diff changeset
   330
A term $t$ can be \textbf{certified} under a signature to ensure that every type
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   331
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
   332
constant declared in the signature.  The term must be well-typed and its use
6669
5f1ce866c497 locale documentation (from Florian)
paulson
parents: 6658
diff changeset
   333
of bound variables must be well-formed.  Meta-rules such as \texttt{forall_elim}
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   334
take certified terms as arguments.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   335
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   336
Certified terms belong to the abstract type \mltydx{cterm}.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   337
Elements of the type can only be created through the certification process.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   338
In case of error, Isabelle raises exception~\ttindex{TERM}\@.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   339
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   340
\subsection{Printing terms}
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   341
\index{terms!printing of}
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   342
\begin{ttbox}
275
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   343
     string_of_cterm :           cterm -> string
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   344
Sign.string_of_term  : Sign.sg -> term -> string
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   345
\end{ttbox}
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   346
\begin{ttdescription}
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   347
\item[\ttindexbold{string_of_cterm} $ct$]
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   348
displays $ct$ as a string.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   349
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   350
\item[\ttindexbold{Sign.string_of_term} $sign$ $t$]
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   351
displays $t$ as a string, using the syntax of~$sign$.
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   352
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   353
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   354
\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
   355
\begin{ttbox}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7440
diff changeset
   356
cterm_of       : Sign.sg -> term -> cterm
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7440
diff changeset
   357
read_cterm     : Sign.sg -> string * typ -> cterm
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7440
diff changeset
   358
cert_axm       : Sign.sg -> string * term -> string * term
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7440
diff changeset
   359
read_axm       : Sign.sg -> string * string -> string * term
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7440
diff changeset
   360
rep_cterm      : cterm -> \{T:typ, t:term, sign:Sign.sg, maxidx:int\}
4543
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   361
Sign.certify_term : Sign.sg -> term -> term * typ * int
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   362
\end{ttbox}
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   363
\begin{ttdescription}
4543
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   364
  
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   365
\item[\ttindexbold{cterm_of} $sign$ $t$] \index{signatures} certifies
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   366
  $t$ with respect to signature~$sign$.
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   367
  
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   368
\item[\ttindexbold{read_cterm} $sign$ ($s$, $T$)] reads the string~$s$
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   369
  using the syntax of~$sign$, creating a certified term.  The term is
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   370
  checked to have type~$T$; this type also tells the parser what kind
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   371
  of phrase to parse.
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   372
  
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   373
\item[\ttindexbold{cert_axm} $sign$ ($name$, $t$)] certifies $t$ with
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   374
  respect to $sign$ as a meta-proposition and converts all exceptions
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   375
  to an error, including the final message
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   376
\begin{ttbox}
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   377
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
   378
\end{ttbox}
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   379
4543
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   380
\item[\ttindexbold{read_axm} $sign$ ($name$, $s$)] similar to {\tt
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   381
    cert_axm}, but first reads the string $s$ using the syntax of
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   382
  $sign$.
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   383
  
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   384
\item[\ttindexbold{rep_cterm} $ct$] decomposes $ct$ as a record
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   385
  containing its type, the term itself, its signature, and the maximum
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   386
  subscript of its unknowns.  The type and maximum subscript are
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   387
  computed during certification.
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   388
  
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   389
\item[\ttindexbold{Sign.certify_term}] is a more primitive version of
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   390
  \texttt{cterm_of}, returning the internal representation instead of
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   391
  an abstract \texttt{cterm}.
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   392
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   393
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   394
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   395
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   396
\section{Types}\index{types|bold}
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   397
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
   398
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
   399
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
   400
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
   401
represented by a string.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   402
\begin{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   403
type class = string;
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   404
type sort  = class list;
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   405
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   406
datatype typ = Type  of string * typ list
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   407
             | TFree of string * sort
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   408
             | TVar  of indexname * sort;
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   409
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   410
infixr 5 -->;
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   411
fun S --> T = Type ("fun", [S, T]);
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   412
\end{ttbox}
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   413
\begin{ttdescription}
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   414
\item[\ttindexbold{Type} ($a$, $Ts$)] \index{type constructors|bold}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7440
diff changeset
   415
  applies the \textbf{type constructor} named~$a$ to the type operand list~$Ts$.
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   416
  Type constructors include~\tydx{fun}, the binary function space
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   417
  constructor, as well as nullary type constructors such as~\tydx{prop}.
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   418
  Other type constructors may be introduced.  In expressions, but not in
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   419
  patterns, \hbox{\tt$S$-->$T$} is a convenient shorthand for function
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   420
  types.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   421
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   422
\item[\ttindexbold{TFree} ($a$, $s$)] \index{type variables|bold}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7440
diff changeset
   423
  is the \textbf{type variable} with name~$a$ and sort~$s$.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   424
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 3485
diff changeset
   425
\item[\ttindexbold{TVar} ($v$, $s$)] \index{type unknowns|bold}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7440
diff changeset
   426
  is the \textbf{type unknown} with indexname~$v$ and sort~$s$.
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   427
  Type unknowns are essentially free type variables, but may be
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   428
  instantiated during unification.
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   429
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   430
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   431
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   432
\section{Certified types}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   433
\index{types!certified|bold}
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   434
Certified types, which are analogous to certified terms, have type
275
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   435
\ttindexbold{ctyp}.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   436
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   437
\subsection{Printing types}
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   438
\index{types!printing of}
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   439
\begin{ttbox}
275
933ec96c522e update towards LNCS
nipkow
parents: 273
diff changeset
   440
     string_of_ctyp :           ctyp -> string
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   441
Sign.string_of_typ  : Sign.sg -> typ -> string
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   442
\end{ttbox}
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   443
\begin{ttdescription}
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   444
\item[\ttindexbold{string_of_ctyp} $cT$]
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   445
displays $cT$ as a string.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   446
864
d63b111b917a quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents: 478
diff changeset
   447
\item[\ttindexbold{Sign.string_of_typ} $sign$ $T$]
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   448
displays $T$ as a string, using the syntax of~$sign$.
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   449
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   450
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   451
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   452
\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
   453
\begin{ttbox}
4543
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   454
ctyp_of          : Sign.sg -> typ -> ctyp
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7440
diff changeset
   455
rep_ctyp         : ctyp -> \{T: typ, sign: Sign.sg\}
4543
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   456
Sign.certify_typ : Sign.sg -> typ -> typ
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   457
\end{ttbox}
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   458
\begin{ttdescription}
4543
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   459
  
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   460
\item[\ttindexbold{ctyp_of} $sign$ $T$] \index{signatures} certifies
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   461
  $T$ with respect to signature~$sign$.
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   462
  
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   463
\item[\ttindexbold{rep_ctyp} $cT$] decomposes $cT$ as a record
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   464
  containing the type itself and its signature.
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   465
  
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   466
\item[\ttindexbold{Sign.certify_typ}] is a more primitive version of
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   467
  \texttt{ctyp_of}, returning the internal representation instead of
82a45bdd0e80 several minor updates;
wenzelm
parents: 4384
diff changeset
   468
  an abstract \texttt{ctyp}.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   469
324
34bc15b546e6 penultimate Springer draft
lcp
parents: 286
diff changeset
   470
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   471
1846
763f08fb194f Documentation of oracles and their syntax
paulson
parents: 1650
diff changeset
   472
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   473
\index{theories|)}
5369
8384e01b6cf8 added nonterminals, setup;
wenzelm
parents: 4597
diff changeset
   474
8384e01b6cf8 added nonterminals, setup;
wenzelm
parents: 4597
diff changeset
   475
8384e01b6cf8 added nonterminals, setup;
wenzelm
parents: 4597
diff changeset
   476
%%% Local Variables: 
8384e01b6cf8 added nonterminals, setup;
wenzelm
parents: 4597
diff changeset
   477
%%% mode: latex
8384e01b6cf8 added nonterminals, setup;
wenzelm
parents: 4597
diff changeset
   478
%%% TeX-master: "ref"
8384e01b6cf8 added nonterminals, setup;
wenzelm
parents: 4597
diff changeset
   479
%%% End: