doc-src/IsarRef/hol.tex
author wenzelm
Tue, 07 Sep 1999 18:08:51 +0200
changeset 7507 e70255cb1035
parent 7466 7df66ce6508a
child 7987 d9aef93c0e32
permissions -rw-r--r--
induct method: rule option;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
     1
7167
wenzelm
parents: 7141
diff changeset
     2
\chapter{Isabelle/HOL Tools and Packages}\label{ch:hol-tools}
7135
wenzelm
parents: 7134
diff changeset
     3
wenzelm
parents: 7134
diff changeset
     4
\section{Primitive types}
wenzelm
parents: 7134
diff changeset
     5
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
     6
\indexisarcmd{typedecl}\indexisarcmd{typedef}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
     7
\begin{matharray}{rcl}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
     8
  \isarcmd{typedecl} & : & \isartrans{theory}{theory} \\
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
     9
  \isarcmd{typedef} & : & \isartrans{theory}{proof(prove)} \\
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    10
\end{matharray}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    11
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    12
\begin{rail}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    13
  'typedecl' typespec infix? comment?
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    14
  ;
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    15
  'typedef' parname? typespec infix? \\ '=' term comment?
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    16
  ;
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    17
\end{rail}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    18
7167
wenzelm
parents: 7141
diff changeset
    19
\begin{descr}
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    20
\item [$\isarkeyword{typedecl}~(\vec\alpha)t$] is similar to the original
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    21
  $\isarkeyword{typedecl}$ of Isabelle/Pure (see \S\ref{sec:types-pure}), but
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    22
  also declares type arity $t :: (term, \dots, term) term$, making $t$ an
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    23
  actual HOL type constructor.
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    24
\item [$\isarkeyword{typedef}~(\vec\alpha)t = A$] sets up a goal stating
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    25
  non-emptiness of the set $A$.  After finishing the proof, the theory will be
7175
wenzelm
parents: 7167
diff changeset
    26
  augmented by a Gordon/HOL-style type definition.  See \cite{isabelle-HOL}
7335
abba35b98892 draft release;
wenzelm
parents: 7319
diff changeset
    27
  for more information.  Note that user-level theories usually do not directly
abba35b98892 draft release;
wenzelm
parents: 7319
diff changeset
    28
  refer to the HOL $\isarkeyword{typedef}$ primitive, but use more advanced
abba35b98892 draft release;
wenzelm
parents: 7319
diff changeset
    29
  packages such as $\isarkeyword{record}$ (see \S\ref{sec:record}) and
7175
wenzelm
parents: 7167
diff changeset
    30
  $\isarkeyword{datatype}$ (see \S\ref{sec:datatype}).
7167
wenzelm
parents: 7141
diff changeset
    31
\end{descr}
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    32
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    33
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    34
\section{Records}\label{sec:record}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    35
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    36
%FIXME record_split method
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    37
\indexisarcmd{record}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    38
\begin{matharray}{rcl}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    39
  \isarcmd{record} & : & \isartrans{theory}{theory} \\
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    40
\end{matharray}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    41
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    42
\begin{rail}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    43
  'record' typespec '=' (type '+')? (field +)
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    44
  ;
7135
wenzelm
parents: 7134
diff changeset
    45
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    46
  field: name '::' type comment?
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    47
  ;
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    48
\end{rail}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    49
7167
wenzelm
parents: 7141
diff changeset
    50
\begin{descr}
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    51
\item [$\isarkeyword{record}~(\vec\alpha)t = \tau + \vec c :: \vec\sigma$]
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    52
  defines extensible record type $(\vec\alpha)t$, derived from the optional
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    53
  parent record $\tau$ by adding new field components $\vec c :: \vec\sigma$.
7335
abba35b98892 draft release;
wenzelm
parents: 7319
diff changeset
    54
  See \cite{isabelle-HOL,NaraschewskiW-TPHOLs98} for more information only
abba35b98892 draft release;
wenzelm
parents: 7319
diff changeset
    55
  simply-typed extensible records.
7167
wenzelm
parents: 7141
diff changeset
    56
\end{descr}
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    57
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    58
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    59
\section{Datatypes}\label{sec:datatype}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    60
7167
wenzelm
parents: 7141
diff changeset
    61
\indexisarcmd{datatype}\indexisarcmd{rep-datatype}
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    62
\begin{matharray}{rcl}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    63
  \isarcmd{datatype} & : & \isartrans{theory}{theory} \\
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    64
  \isarcmd{rep_datatype} & : & \isartrans{theory}{theory} \\
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    65
\end{matharray}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    66
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    67
\railalias{repdatatype}{rep\_datatype}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    68
\railterm{repdatatype}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    69
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    70
\begin{rail}
7175
wenzelm
parents: 7167
diff changeset
    71
  'datatype' (parname? typespec infix? \\ '=' (constructor + '|') + 'and')
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    72
  ;
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    73
  repdatatype (name * ) \\ 'distinct' thmrefs 'inject' thmrefs 'induction' thmrefs
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    74
  ;
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    75
7175
wenzelm
parents: 7167
diff changeset
    76
  constructor: name (type * ) mixfix? comment?
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    77
  ;
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    78
\end{rail}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    79
7167
wenzelm
parents: 7141
diff changeset
    80
\begin{descr}
7319
wenzelm
parents: 7175
diff changeset
    81
\item [$\isarkeyword{datatype}$] defines inductive datatypes in HOL.
wenzelm
parents: 7175
diff changeset
    82
\item [$\isarkeyword{rep_datatype}$] represents existing types as inductive
wenzelm
parents: 7175
diff changeset
    83
  ones, generating the standard infrastructure of derived concepts (primitive
wenzelm
parents: 7175
diff changeset
    84
  recursion etc.).
7167
wenzelm
parents: 7141
diff changeset
    85
\end{descr}
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    86
7319
wenzelm
parents: 7175
diff changeset
    87
See \cite{isabelle-HOL} for more details on datatypes.  Note that the theory
7335
abba35b98892 draft release;
wenzelm
parents: 7319
diff changeset
    88
syntax above has been slightly simplified over the old version, usually
abba35b98892 draft release;
wenzelm
parents: 7319
diff changeset
    89
requiring more quotes and less parentheses.
7319
wenzelm
parents: 7175
diff changeset
    90
7135
wenzelm
parents: 7134
diff changeset
    91
wenzelm
parents: 7134
diff changeset
    92
\section{Recursive functions}
wenzelm
parents: 7134
diff changeset
    93
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    94
\indexisarcmd{primrec}\indexisarcmd{recdef}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    95
\begin{matharray}{rcl}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    96
  \isarcmd{primrec} & : & \isartrans{theory}{theory} \\
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    97
  \isarcmd{recdef} & : & \isartrans{theory}{theory} \\
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    98
%FIXME
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    99
%  \isarcmd{defer_recdef} & : & \isartrans{theory}{theory} \\
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   100
\end{matharray}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   101
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   102
\begin{rail}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   103
  'primrec' parname? (thmdecl? prop comment? + )
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   104
  ;
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   105
  'recdef' name term (term comment? +) \\ ('congs' thmrefs)? ('simpset' name)?
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   106
  ;
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   107
\end{rail}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   108
7167
wenzelm
parents: 7141
diff changeset
   109
\begin{descr}
7319
wenzelm
parents: 7175
diff changeset
   110
\item [$\isarkeyword{primrec}$] defines primitive recursive functions over
wenzelm
parents: 7175
diff changeset
   111
  datatypes.
wenzelm
parents: 7175
diff changeset
   112
\item [$\isarkeyword{recdef}$] defines general well-founded recursive
wenzelm
parents: 7175
diff changeset
   113
  functions (using the TFL package).
7167
wenzelm
parents: 7141
diff changeset
   114
\end{descr}
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   115
7335
abba35b98892 draft release;
wenzelm
parents: 7319
diff changeset
   116
See \cite{isabelle-HOL} for more information on both mechanisms.
7319
wenzelm
parents: 7175
diff changeset
   117
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   118
7135
wenzelm
parents: 7134
diff changeset
   119
\section{(Co)Inductive sets}
wenzelm
parents: 7134
diff changeset
   120
7167
wenzelm
parents: 7141
diff changeset
   121
\indexisarcmd{inductive}\indexisarcmd{coinductive}\indexisarcmd{inductive-cases}
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   122
\begin{matharray}{rcl}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   123
  \isarcmd{inductive} & : & \isartrans{theory}{theory} \\
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   124
  \isarcmd{coinductive} & : & \isartrans{theory}{theory} \\
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   125
  \isarcmd{inductive_cases} & : & \isartrans{theory}{theory} \\
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   126
\end{matharray}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   127
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   128
\railalias{condefs}{con\_defs}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   129
\railalias{indcases}{inductive\_cases}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   130
\railterm{condefs,indcases}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   131
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   132
\begin{rail}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   133
  ('inductive' | 'coinductive') (term comment? +) \\
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   134
    'intrs' attributes? (thmdecl? prop comment? +) \\
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   135
    'monos' thmrefs comment? \\ condefs thmrefs comment?
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   136
  ;
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   137
  indcases thmdef? nameref ':' \\ (prop +) comment?
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   138
  ;
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   139
\end{rail}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   140
7167
wenzelm
parents: 7141
diff changeset
   141
\begin{descr}
7319
wenzelm
parents: 7175
diff changeset
   142
\item [$\isarkeyword{inductive}$ and $\isarkeyword{coinductive}$] define
wenzelm
parents: 7175
diff changeset
   143
  (co)inductive sets from the given introduction rules.
wenzelm
parents: 7175
diff changeset
   144
\item [$\isarkeyword{inductive_cases}$] creates simplified instances of
wenzelm
parents: 7175
diff changeset
   145
  elimination rules of (co)inductive sets.
7167
wenzelm
parents: 7141
diff changeset
   146
\end{descr}
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   147
7319
wenzelm
parents: 7175
diff changeset
   148
See \cite{isabelle-HOL} for more information.  Note that
wenzelm
parents: 7175
diff changeset
   149
$\isarkeyword{inductive_cases}$ corresponds to the ML function
wenzelm
parents: 7175
diff changeset
   150
\texttt{mk_cases}.
wenzelm
parents: 7175
diff changeset
   151
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   152
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   153
\section{Proof by induction}
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   154
7319
wenzelm
parents: 7175
diff changeset
   155
\indexisarmeth{induct}
wenzelm
parents: 7175
diff changeset
   156
\begin{matharray}{rcl}
wenzelm
parents: 7175
diff changeset
   157
  induct & : & \isarmeth \\
wenzelm
parents: 7175
diff changeset
   158
\end{matharray}
wenzelm
parents: 7175
diff changeset
   159
wenzelm
parents: 7175
diff changeset
   160
The $induct$ method provides a uniform interface to induction over datatypes,
7507
e70255cb1035 induct method: rule option;
wenzelm
parents: 7466
diff changeset
   161
inductive sets, recursive functions etc.  Basically, it is just an interface
7319
wenzelm
parents: 7175
diff changeset
   162
to the $rule$ method applied to appropriate instances of the corresponding
wenzelm
parents: 7175
diff changeset
   163
induction rules.
wenzelm
parents: 7175
diff changeset
   164
wenzelm
parents: 7175
diff changeset
   165
\begin{rail}
wenzelm
parents: 7175
diff changeset
   166
  'induct' (inst * 'and') kind?
wenzelm
parents: 7175
diff changeset
   167
  ;
wenzelm
parents: 7175
diff changeset
   168
wenzelm
parents: 7175
diff changeset
   169
  inst: term term?
wenzelm
parents: 7175
diff changeset
   170
  ;
7507
e70255cb1035 induct method: rule option;
wenzelm
parents: 7466
diff changeset
   171
  kind: ('type' | 'set' | 'function' | 'rule') ':' nameref
7319
wenzelm
parents: 7175
diff changeset
   172
  ;
wenzelm
parents: 7175
diff changeset
   173
\end{rail}
wenzelm
parents: 7175
diff changeset
   174
wenzelm
parents: 7175
diff changeset
   175
\begin{descr}
wenzelm
parents: 7175
diff changeset
   176
\item [$induct~insts~kind$] abbreviates method $rule~R$, where $R$ is the
7507
e70255cb1035 induct method: rule option;
wenzelm
parents: 7466
diff changeset
   177
  induction rule specified by $kind$ and instantiated by $insts$.  The rule is
e70255cb1035 induct method: rule option;
wenzelm
parents: 7466
diff changeset
   178
  either that of some type, set, or recursive function (defined via TFL), or
e70255cb1035 induct method: rule option;
wenzelm
parents: 7466
diff changeset
   179
  given explicitly.
e70255cb1035 induct method: rule option;
wenzelm
parents: 7466
diff changeset
   180
  
e70255cb1035 induct method: rule option;
wenzelm
parents: 7466
diff changeset
   181
  The instantiation basically consists of a list of $P$ $x$ (induction
e70255cb1035 induct method: rule option;
wenzelm
parents: 7466
diff changeset
   182
  predicate and variable) specifications, where $P$ is optional.  If $kind$ is
7466
7df66ce6508a updated;
wenzelm
parents: 7390
diff changeset
   183
  omitted, the default is to pick a datatype induction rule according to the
7df66ce6508a updated;
wenzelm
parents: 7390
diff changeset
   184
  type of some induction variable, which may not be omitted that case.
7319
wenzelm
parents: 7175
diff changeset
   185
\end{descr}
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
   186
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   187
7390
f819265e267c 'arith' method;
wenzelm
parents: 7335
diff changeset
   188
\section{Arithmetic}
f819265e267c 'arith' method;
wenzelm
parents: 7335
diff changeset
   189
f819265e267c 'arith' method;
wenzelm
parents: 7335
diff changeset
   190
\indexisarmeth{arith}
f819265e267c 'arith' method;
wenzelm
parents: 7335
diff changeset
   191
\begin{matharray}{rcl}
f819265e267c 'arith' method;
wenzelm
parents: 7335
diff changeset
   192
  arith & : & \isarmeth \\
f819265e267c 'arith' method;
wenzelm
parents: 7335
diff changeset
   193
\end{matharray}
f819265e267c 'arith' method;
wenzelm
parents: 7335
diff changeset
   194
f819265e267c 'arith' method;
wenzelm
parents: 7335
diff changeset
   195
The $arith$ method decides linear arithmetic problems (on types $nat$, $int$,
f819265e267c 'arith' method;
wenzelm
parents: 7335
diff changeset
   196
$real$).  Note that a simpler (but faster) version of arithmetic reasoning is
f819265e267c 'arith' method;
wenzelm
parents: 7335
diff changeset
   197
already performed by the Simplifier.
f819265e267c 'arith' method;
wenzelm
parents: 7335
diff changeset
   198
f819265e267c 'arith' method;
wenzelm
parents: 7335
diff changeset
   199
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   200
%%% Local Variables: 
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   201
%%% mode: latex
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   202
%%% TeX-master: "isar-ref"
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   203
%%% End: