doc-src/IsarRef/logics.tex
author paulson
Tue, 28 May 2002 11:06:06 +0200
changeset 13183 c7290200b3f4
parent 13049 ce180e5b7fa0
child 13443 1c3327c348b3
permissions -rw-r--r--
conversion of IntDiv.thy to Isar format
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
     1
13048
wenzelm
parents: 13042
diff changeset
     2
\chapter{Object-logic specific elements}\label{ch:logics}
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
     3
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
     4
\section{General logic setup}\label{sec:object-logic}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
     5
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
     6
\indexisarcmd{judgment}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
     7
\indexisarmeth{atomize}\indexisaratt{atomize}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
     8
\indexisaratt{rule-format}\indexisaratt{rulify}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
     9
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    10
\begin{matharray}{rcl}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    11
  \isarcmd{judgment} & : & \isartrans{theory}{theory} \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    12
  atomize & : & \isarmeth \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    13
  atomize & : & \isaratt \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    14
  rule_format & : & \isaratt \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    15
  rulify & : & \isaratt \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    16
\end{matharray}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    17
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    18
The very starting point for any Isabelle object-logic is a ``truth judgment''
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    19
that links object-level statements to the meta-logic (with its minimal
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    20
language of $prop$ that covers universal quantification $\Forall$ and
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
    21
implication $\Imp$).
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
    22
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
    23
Common object-logics are sufficiently expressive to internalize rule
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
    24
statements over $\Forall$ and $\Imp$ within their own language.  This is
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
    25
useful in certain situations where a rule needs to be viewed as an atomic
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
    26
statement from the meta-level perspective, e.g.\ $\All x x \in A \Imp P(x)$
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
    27
versus $\forall x \in A. P(x)$.
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    28
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    29
From the following language elements, only the $atomize$ method and
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    30
$rule_format$ attribute are occasionally required by end-users, the rest is
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    31
for those who need to setup their own object-logic.  In the latter case
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    32
existing formulations of Isabelle/FOL or Isabelle/HOL may be taken as
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    33
realistic examples.
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    34
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    35
Generic tools may refer to the information provided by object-logic
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
    36
declarations internally.
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
    37
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
    38
\railalias{ruleformat}{rule\_format}
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
    39
\railterm{ruleformat}
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    40
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    41
\begin{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    42
  'judgment' constdecl
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    43
  ;
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
    44
  'atomize' ('(' 'full' ')')?
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
    45
  ;
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
    46
  ruleformat ('(' 'noasm' ')')?
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    47
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    48
\end{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    49
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    50
\begin{descr}
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
    51
  
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
    52
\item [$\isarkeyword{judgment}~c::\sigma~~(mx)$] declares constant $c$ as the
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    53
  truth judgment of the current object-logic.  Its type $\sigma$ should
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    54
  specify a coercion of the category of object-level propositions to $prop$ of
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
    55
  the Pure meta-logic; the mixfix annotation $(mx)$ would typically just link
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    56
  the object language (internally of syntactic category $logic$) with that of
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    57
  $prop$.  Only one $\isarkeyword{judgment}$ declaration may be given in any
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    58
  theory development.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
    59
  
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    60
\item [$atomize$] (as a method) rewrites any non-atomic premises of a
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    61
  sub-goal, using the meta-level equations declared via $atomize$ (as an
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    62
  attribute) beforehand.  As a result, heavily nested goals become amenable to
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    63
  fundamental operations such as resolution (cf.\ the $rule$ method) and
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
    64
  proof-by-assumption (cf.\ $assumption$).  Giving the ``$(full)$'' option
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
    65
  here means to turn the whole subgoal into an object-statement (if possible),
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
    66
  including the outermost parameters and assumptions as well.
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
    67
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    68
  A typical collection of $atomize$ rules for a particular object-logic would
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    69
  provide an internalization for each of the connectives of $\Forall$, $\Imp$,
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    70
  and $\equiv$.  Meta-level conjunction expressed in the manner of minimal
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    71
  higher-order logic as $\All{\PROP\,C} (A \Imp B \Imp \PROP\,C) \Imp PROP\,C$
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    72
  should be covered as well (this is particularly important for locales, see
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    73
  \S\ref{sec:locale}).
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
    74
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    75
\item [$rule_format$] rewrites a theorem by the equalities declared as
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    76
  $rulify$ rules in the current object-logic.  By default, the result is fully
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    77
  normalized, including assumptions and conclusions at any depth.  The
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    78
  $no_asm$ option restricts the transformation to the conclusion of a rule.
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
    79
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    80
  In common object-logics (HOL, FOL, ZF), the effect of $rule_format$ is to
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    81
  replace (bounded) universal quantification ($\forall$) and implication
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    82
  ($\imp$) by the corresponding rule statements over $\Forall$ and $\Imp$.
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    83
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    84
\end{descr}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    85
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    86
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    87
\section{HOL}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    88
13039
wenzelm
parents: 13027
diff changeset
    89
\subsection{Primitive types}\label{sec:hol-typedef}
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    90
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    91
\indexisarcmdof{HOL}{typedecl}\indexisarcmdof{HOL}{typedef}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    92
\begin{matharray}{rcl}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    93
  \isarcmd{typedecl} & : & \isartrans{theory}{theory} \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    94
  \isarcmd{typedef} & : & \isartrans{theory}{proof(prove)} \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    95
\end{matharray}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    96
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    97
\begin{rail}
12879
wenzelm
parents: 12621
diff changeset
    98
  'typedecl' typespec infix?
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
    99
  ;
13016
wenzelm
parents: 13014
diff changeset
   100
  'typedef' parname? abstype '=' repset
wenzelm
parents: 13014
diff changeset
   101
  ;
wenzelm
parents: 13014
diff changeset
   102
wenzelm
parents: 13014
diff changeset
   103
  abstype: typespec infix?
wenzelm
parents: 13014
diff changeset
   104
  ;
wenzelm
parents: 13014
diff changeset
   105
  repset: term ('morphisms' name name)?
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   106
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   107
\end{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   108
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   109
\begin{descr}
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   110
  
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   111
\item [$\isarkeyword{typedecl}~(\vec\alpha)t$] is similar to the original
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   112
  $\isarkeyword{typedecl}$ of Isabelle/Pure (see \S\ref{sec:types-pure}), but
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   113
  also declares type arity $t :: (type, \dots, type) type$, making $t$ an
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   114
  actual HOL type constructor.
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   115
  
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   116
\item [$\isarkeyword{typedef}~(\vec\alpha)t = A$] sets up a goal stating
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   117
  non-emptiness of the set $A$.  After finishing the proof, the theory will be
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   118
  augmented by a Gordon/HOL-style type definition, which establishes a
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   119
  bijection between the representing set $A$ and the new type $t$.
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   120
  
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   121
  Technically, $\isarkeyword{typedef}$ defines both a type $t$ and a set (term
13016
wenzelm
parents: 13014
diff changeset
   122
  constant) of the same name (an alternative base name may be given in
wenzelm
parents: 13014
diff changeset
   123
  parentheses).  The injection from type to set is called $Rep_t$, its inverse
wenzelm
parents: 13014
diff changeset
   124
  $Abs_t$ (this may be changed via an explicit $\isarkeyword{morphisms}$
wenzelm
parents: 13014
diff changeset
   125
  declaration).
wenzelm
parents: 13014
diff changeset
   126
  
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   127
  Theorems $Rep_t$, $Rep_t_inverse$, and $Abs_t_inverse$ provide the most
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   128
  basic characterization as a corresponding injection/surjection pair (in both
13016
wenzelm
parents: 13014
diff changeset
   129
  directions).  Rules $Rep_t_inject$ and $Abs_t_inject$ provide a slightly
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   130
  more convenient view on the injectivity part, suitable for automated proof
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   131
  tools (e.g.\ in $simp$ or $iff$ declarations).  Rules
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   132
  $Rep_t_cases/Rep_t_induct$, and $Abs_t_cases/Abs_t_induct$ provide
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   133
  alternative views on surjectivity; these are already declared as set or type
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   134
  rules for the generic $cases$ and $induct$ methods.
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   135
\end{descr}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   136
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   137
Note that raw type declarations are rarely used in practice; the main
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   138
application is with experimental (or even axiomatic!) theory fragments.
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   139
Instead of primitive HOL type definitions, user-level theories usually refer
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   140
to higher-level packages such as $\isarkeyword{record}$ (see
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   141
\S\ref{sec:hol-record}) or $\isarkeyword{datatype}$ (see
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   142
\S\ref{sec:hol-datatype}).
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   143
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   144
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   145
\subsection{Adhoc tuples}
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   146
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   147
\indexisarattof{HOL}{split-format}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   148
\begin{matharray}{rcl}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   149
  split_format^* & : & \isaratt \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   150
\end{matharray}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   151
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   152
\railalias{splitformat}{split\_format}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   153
\railterm{splitformat}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   154
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   155
\begin{rail}
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   156
  splitformat (((name *) + 'and') | ('(' 'complete' ')'))
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   157
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   158
\end{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   159
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   160
\begin{descr}
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   161
  
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   162
\item [$split_format~\vec p@1 \dots \vec p@n$] puts expressions of low-level
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   163
  tuple types into canonical form as specified by the arguments given; $\vec
13049
wenzelm
parents: 13048
diff changeset
   164
  p@i$ refers to occurrences in premise $i$ of the rule.  The ``$(complete)$''
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   165
  option causes \emph{all} arguments in function applications to be
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   166
  represented canonically according to their tuple type structure.
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   167
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   168
  Note that these operations tend to invent funny names for new local
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   169
  parameters to be introduced.
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   170
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   171
\end{descr}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   172
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   173
13039
wenzelm
parents: 13027
diff changeset
   174
\subsection{Records}\label{sec:hol-record}
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   175
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   176
In principle, records merely generalize the concept of tuples, where
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   177
components may be addressed by labels instead of just position.  The logical
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   178
infrastructure of records in Isabelle/HOL is slightly more advanced, though,
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   179
supporting truly extensible record schemes.  This admits operations that are
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   180
polymorphic with respect to record extension, yielding ``object-oriented''
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   181
effects like (single) inheritance.  See also \cite{NaraschewskiW-TPHOLs98} for
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   182
more details on object-oriented verification and record subtyping in HOL.
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   183
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   184
13039
wenzelm
parents: 13027
diff changeset
   185
\subsubsection{Basic concepts}
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   186
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   187
Isabelle/HOL supports both \emph{fixed} and \emph{schematic} records at the
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   188
level of terms and types.  The notation is as follows:
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   189
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   190
\begin{center}
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   191
\begin{tabular}{l|l|l}
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   192
  & record terms & record types \\ \hline
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   193
  fixed & $\record{x = a\fs y = b}$ & $\record{x \ty A\fs y \ty B}$ \\
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   194
  schematic & $\record{x = a\fs y = b\fs \more = m}$ &
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   195
    $\record{x \ty A\fs y \ty B\fs \more \ty M}$ \\
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   196
\end{tabular}
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   197
\end{center}
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   198
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   199
\noindent The ASCII representation of $\record{x = a}$ is \texttt{(| x = a |)}.
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   200
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   201
A fixed record $\record{x = a\fs y = b}$ has field $x$ of value $a$ and field
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   202
$y$ of value $b$.  The corresponding type is $\record{x \ty A\fs y \ty B}$,
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   203
assuming that $a \ty A$ and $b \ty B$.
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   204
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   205
A record scheme like $\record{x = a\fs y = b\fs \more = m}$ contains fields
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   206
$x$ and $y$ as before, but also possibly further fields as indicated by the
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   207
``$\more$'' notation (which is actually part of the syntax).  The improper
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   208
field ``$\more$'' of a record scheme is called the \emph{more part}.
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   209
Logically it is just a free variable, which is occasionally referred to as
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   210
``row variable'' in the literature.  The more part of a record scheme may be
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   211
instantiated by zero or more further components.  For example, the previous
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   212
scheme may get instantiated to $\record{x = a\fs y = b\fs z = c\fs \more =
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   213
  m'}$, where $m'$ refers to a different more part.  Fixed records are special
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   214
instances of record schemes, where ``$\more$'' is properly terminated by the
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   215
$() :: unit$ element.  Actually, $\record{x = a\fs y = b}$ is just an
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   216
abbreviation for $\record{x = a\fs y = b\fs \more = ()}$.
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   217
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   218
\medskip
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   219
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   220
Two key observations make extensible records in a simply typed language like
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   221
HOL feasible:
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   222
\begin{enumerate}
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   223
\item the more part is internalized, as a free term or type variable,
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   224
\item field names are externalized, they cannot be accessed within the logic
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   225
  as first-class values.
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   226
\end{enumerate}
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   227
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   228
\medskip
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   229
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   230
In Isabelle/HOL record types have to be defined explicitly, fixing their field
13042
wenzelm
parents: 13041
diff changeset
   231
names and types, and their (optional) parent record.  Afterwards, records may
wenzelm
parents: 13041
diff changeset
   232
be formed using above syntax, while obeying the canonical order of fields as
wenzelm
parents: 13041
diff changeset
   233
given by their declaration.  The record package provides several standard
wenzelm
parents: 13041
diff changeset
   234
operations like selectors and updates.  The common setup for various generic
wenzelm
parents: 13041
diff changeset
   235
proof tools enable succinct reasoning patterns.  See also the Isabelle/HOL
wenzelm
parents: 13041
diff changeset
   236
tutorial \cite{isabelle-hol-book} for further instructions on using records in
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   237
practice.
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   238
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   239
13042
wenzelm
parents: 13041
diff changeset
   240
\subsubsection{Record specifications}
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   241
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   242
\indexisarcmdof{HOL}{record}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   243
\begin{matharray}{rcl}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   244
  \isarcmd{record} & : & \isartrans{theory}{theory} \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   245
\end{matharray}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   246
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   247
\begin{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   248
  'record' typespec '=' (type '+')? (constdecl +)
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   249
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   250
\end{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   251
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   252
\begin{descr}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   253
\item [$\isarkeyword{record}~(\vec\alpha)t = \tau + \vec c :: \vec\sigma$]
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   254
  defines extensible record type $(\vec\alpha)t$, derived from the optional
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   255
  parent record $\tau$ by adding new field components $\vec c :: \vec\sigma$.
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   256
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   257
  The type variables of $\tau$ and $\vec\sigma$ need to be covered by the
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   258
  (distinct) parameters $\vec\alpha$.  Type constructor $t$ has to be new,
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   259
  while $\tau$ needs to specify an instance of an existing record type.  At
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   260
  least one new field $\vec c$ has to be specified.  Basically, field names
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   261
  need to belong to a unique record.  This is not a real restriction in
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   262
  practice, since fields are qualified by the record name internally.
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   263
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   264
  The parent record specification $\tau$ is optional; if omitted $t$ becomes a
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   265
  root record.  The hierarchy of all records declared within a theory context
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   266
  forms a forest structure, i.e.\ a set of trees starting with a root record
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   267
  each.  There is no way to merge multiple parent records!
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   268
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   269
  For convenience, $(\vec\alpha) \, t$ is made a type abbreviation for the
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   270
  fixed record type $\record{\vec c \ty \vec\sigma}$, likewise is
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   271
  $(\vec\alpha, \zeta) \, t_scheme$ made an abbreviation for $\record{\vec c
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   272
    \ty \vec\sigma\fs \more \ty \zeta}$.
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   273
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   274
\end{descr}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   275
13042
wenzelm
parents: 13041
diff changeset
   276
\subsubsection{Record operations}
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   277
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   278
Any record definition of the form presented above produces certain standard
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   279
operations.  Selectors and updates are provided for any field, including the
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   280
improper one ``$more$''.  There are also cumulative record constructor
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   281
functions.  To simplify the presentation below, we assume for now that
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   282
$(\vec\alpha) \, t$ is a root record with fields $\vec c \ty \vec\sigma$.
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   283
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   284
\medskip \textbf{Selectors} and \textbf{updates} are available for any field
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   285
(including ``$more$''):
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   286
\begin{matharray}{lll}
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   287
  c@i & \ty & \record{\vec c \ty \vec \sigma, \more \ty \zeta} \To \sigma@i \\
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   288
  c@i_update & \ty & \sigma@i \To \record{\vec c \ty \vec\sigma, \more \ty \zeta} \To
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   289
    \record{\vec c \ty \vec\sigma, \more \ty \zeta}
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   290
\end{matharray}
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   291
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   292
There is special syntax for application of updates: $r \, \record{x \asn a}$
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   293
abbreviates term $x_update \, a \, r$.  Further notation for repeated updates
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   294
is also available: $r \, \record{x \asn a} \, \record{y \asn b} \, \record{z
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   295
  \asn c}$ may be written $r \, \record{x \asn a\fs y \asn b\fs z \asn c}$.
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   296
Note that because of postfix notation the order of fields shown here is
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   297
reverse than in the actual term.  Since repeated updates are just function
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   298
applications, fields may be freely permuted in $\record{x \asn a\fs y \asn
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   299
  b\fs z \asn c}$, as far as logical equality is concerned.  Thus
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   300
commutativity of independent updates can be proven within the logic for any
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   301
two fields, but not as a general theorem.
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   302
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   303
\medskip The \textbf{make} operation provides a cumulative record constructor
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   304
function:
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   305
\begin{matharray}{lll}
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   306
  t{\dtt}make & \ty & \vec\sigma \To \record{\vec c \ty \vec \sigma} \\
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   307
\end{matharray}
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   308
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   309
\medskip We now reconsider the case of non-root records, which are derived of
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   310
some parent.  In general, the latter may depend on another parent as well,
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   311
resulting in a list of \emph{ancestor records}.  Appending the lists of fields
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   312
of all ancestors results in a certain field prefix.  The record package
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   313
automatically takes care of this by lifting operations over this context of
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   314
ancestor fields.  Assuming that $(\vec\alpha) \, t$ has ancestor fields $\vec
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   315
b \ty \vec\rho$, the above record operations will get the following types:
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   316
\begin{matharray}{lll}
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   317
  c@i & \ty & \record{\vec b \ty \vec\rho, \vec c \ty \vec\sigma, \more \ty
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   318
    \zeta} \To \sigma@i \\
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   319
  c@i_update & \ty & \sigma@i \To
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   320
    \record{\vec b \ty \vec\rho, \vec c \ty \vec\sigma, \more \ty \zeta} \To
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   321
    \record{\vec b \ty \vec\rho, \vec c \ty \vec\sigma, \more \ty \zeta} \\
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   322
  t{\dtt}make & \ty & \vec\rho \To \vec\sigma \To
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   323
    \record{\vec b \ty \vec\rho, \vec c \ty \vec \sigma} \\
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   324
\end{matharray}
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   325
\noindent
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   326
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   327
\medskip Some further operations address the extension aspect of a derived
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   328
record scheme specifically: $fields$ produces a record fragment consisting of
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   329
exactly the new fields introduced here (the result may serve as a more part
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   330
elsewhere); $extend$ takes a fixed record and adds a given more part;
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   331
$truncate$ restricts a record scheme to a fixed record.
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   332
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   333
\begin{matharray}{lll}
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   334
  t{\dtt}fields & \ty & \vec\sigma \To \record{\vec c \ty \vec \sigma} \\
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   335
  t{\dtt}extend & \ty & \record{\vec d \ty \vec \rho, \vec c \ty \vec\sigma} \To
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   336
    \zeta \To \record{\vec d \ty \vec \rho, \vec c \ty \vec\sigma, \more \ty \zeta} \\
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   337
  t{\dtt}truncate & \ty & \record{\vec d \ty \vec \rho, \vec c \ty \vec\sigma, \more \ty \zeta} \To
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   338
    \record{\vec d \ty \vec \rho, \vec c \ty \vec\sigma} \\
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   339
\end{matharray}
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   340
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   341
\noindent Note that $t{\dtt}make$ and $t{\dtt}fields$ actually coincide for root records.
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   342
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   343
13042
wenzelm
parents: 13041
diff changeset
   344
\subsubsection{Derived rules and proof tools}
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   345
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   346
The record package proves several results internally, declaring these facts to
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   347
appropriate proof tools.  This enables users to reason about record structures
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   348
quite conveniently.  Assume that $t$ is a record type as specified above.
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   349
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   350
\begin{enumerate}
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   351
  
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   352
\item Standard conversions for selectors or updates applied to record
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   353
  constructor terms are made part of the default Simplifier context; thus
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   354
  proofs by reduction of basic operations merely require the $simp$ method
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   355
  without further arguments.  These rules are available as $t{\dtt}simps$,
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   356
  too.
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   357
  
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   358
\item Selectors applied to updated records are automatically reduced by an
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   359
  internal simplification procedure, which is also part of the standard
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   360
  Simplifier setup.
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   361
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   362
\item Inject equations of a form analogous to $((x, y) = (x', y')) \equiv x=x'
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   363
  \conj y=y'$ are declared to the Simplifier and Classical Reasoner as $iff$
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   364
  rules.  These rules are available as $t{\dtt}iffs$.
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   365
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   366
\item The introduction rule for record equality analogous to $x~r = x~r' \Imp
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   367
  y~r = y~r' \Imp \dots \Imp r = r'$ is declared to the Simplifier, and as the
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   368
  basic rule context as ``$intro?$''.  The rule is called $t{\dtt}equality$.
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   369
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   370
\item Representations of arbitrary record expressions as canonical constructor
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   371
  terms are provided both in $cases$ and $induct$ format (cf.\ the generic
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   372
  proof methods of the same name, \S\ref{sec:cases-induct}).  Several
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   373
  variations are available, for fixed records, record schemes, more parts etc.
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   374
  
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   375
  The generic proof methods are sufficiently smart to pick the most sensible
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   376
  rule according to the type of the indicated record expression: users just
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   377
  need to apply something like ``$(cases~r)$'' to a certain proof problem.
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   378
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   379
\item The derived record operations $t{\dtt}make$, $t{\dtt}fields$,
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   380
  $t{\dtt}extend$, $t{\dtt}truncate$ are \emph{not} treated automatically, but
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   381
  usually need to be expanded by hand, using the collective fact
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   382
  $t{\dtt}defs$.
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   383
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   384
\end{enumerate}
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   385
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   386
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   387
\subsection{Datatypes}\label{sec:hol-datatype}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   388
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   389
\indexisarcmdof{HOL}{datatype}\indexisarcmdof{HOL}{rep-datatype}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   390
\begin{matharray}{rcl}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   391
  \isarcmd{datatype} & : & \isartrans{theory}{theory} \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   392
  \isarcmd{rep_datatype} & : & \isartrans{theory}{theory} \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   393
\end{matharray}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   394
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   395
\railalias{repdatatype}{rep\_datatype}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   396
\railterm{repdatatype}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   397
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   398
\begin{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   399
  'datatype' (dtspec + 'and')
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   400
  ;
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   401
  repdatatype (name *) dtrules
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   402
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   403
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   404
  dtspec: parname? typespec infix? '=' (cons + '|')
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   405
  ;
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   406
  cons: name (type *) mixfix?
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   407
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   408
  dtrules: 'distinct' thmrefs 'inject' thmrefs 'induction' thmrefs
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   409
\end{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   410
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   411
\begin{descr}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   412
\item [$\isarkeyword{datatype}$] defines inductive datatypes in HOL.
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   413
\item [$\isarkeyword{rep_datatype}$] represents existing types as inductive
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   414
  ones, generating the standard infrastructure of derived concepts (primitive
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   415
  recursion etc.).
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   416
\end{descr}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   417
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   418
The induction and exhaustion theorems generated provide case names according
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   419
to the constructors involved, while parameters are named after the types (see
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   420
also \S\ref{sec:cases-induct}).
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   421
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   422
See \cite{isabelle-HOL} for more details on datatypes, but beware of the
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   423
old-style theory syntax being used there!  Apart from proper proof methods for
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   424
case-analysis and induction, there are also emulations of ML tactics
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   425
\texttt{case_tac} and \texttt{induct_tac} available, see
13042
wenzelm
parents: 13041
diff changeset
   426
\S\ref{sec:hol-induct-tac}; these admit to refer directly to the internal
wenzelm
parents: 13041
diff changeset
   427
structure of subgoals (including internally bound parameters).
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   428
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   429
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   430
\subsection{Recursive functions}\label{sec:recursion}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   431
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   432
\indexisarcmdof{HOL}{primrec}\indexisarcmdof{HOL}{recdef}\indexisarcmdof{HOL}{recdef-tc}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   433
\begin{matharray}{rcl}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   434
  \isarcmd{primrec} & : & \isartrans{theory}{theory} \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   435
  \isarcmd{recdef} & : & \isartrans{theory}{theory} \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   436
  \isarcmd{recdef_tc}^* & : & \isartrans{theory}{proof(prove)} \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   437
\end{matharray}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   438
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   439
\railalias{recdefsimp}{recdef\_simp}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   440
\railterm{recdefsimp}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   441
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   442
\railalias{recdefcong}{recdef\_cong}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   443
\railterm{recdefcong}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   444
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   445
\railalias{recdefwf}{recdef\_wf}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   446
\railterm{recdefwf}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   447
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   448
\railalias{recdeftc}{recdef\_tc}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   449
\railterm{recdeftc}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   450
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   451
\begin{rail}
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   452
  'primrec' parname? (equation +)
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   453
  ;
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   454
  'recdef' ('(' 'permissive' ')')? \\ name term (prop +) hints?
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   455
  ;
12879
wenzelm
parents: 12621
diff changeset
   456
  recdeftc thmdecl? tc
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   457
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   458
12879
wenzelm
parents: 12621
diff changeset
   459
  equation: thmdecl? prop
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   460
  ;
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   461
  hints: '(' 'hints' (recdefmod *) ')'
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   462
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   463
  recdefmod: ((recdefsimp | recdefcong | recdefwf) (() | 'add' | 'del') ':' thmrefs) | clasimpmod
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   464
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   465
  tc: nameref ('(' nat ')')?
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   466
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   467
\end{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   468
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   469
\begin{descr}
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   470
  
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   471
\item [$\isarkeyword{primrec}$] defines primitive recursive functions over
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   472
  datatypes, see also \cite{isabelle-HOL}.
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   473
  
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   474
\item [$\isarkeyword{recdef}$] defines general well-founded recursive
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   475
  functions (using the TFL package), see also \cite{isabelle-HOL}.  The
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   476
  ``$(permissive)$'' option tells TFL to recover from failed proof attempts,
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   477
  returning unfinished results.  The $recdef_simp$, $recdef_cong$, and
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   478
  $recdef_wf$ hints refer to auxiliary rules to be used in the internal
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   479
  automated proof process of TFL.  Additional $clasimpmod$ declarations (cf.\ 
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   480
  \S\ref{sec:clasimp}) may be given to tune the context of the Simplifier
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   481
  (cf.\ \S\ref{sec:simplifier}) and Classical reasoner (cf.\ 
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   482
  \S\ref{sec:classical}).
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   483
  
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   484
\item [$\isarkeyword{recdef_tc}~c~(i)$] recommences the proof for leftover
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   485
  termination condition number $i$ (default $1$) as generated by a
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   486
  $\isarkeyword{recdef}$ definition of constant $c$.
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   487
  
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   488
  Note that in most cases, $\isarkeyword{recdef}$ is able to finish its
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   489
  internal proofs without manual intervention.
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   490
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   491
\end{descr}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   492
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   493
Both kinds of recursive definitions accommodate reasoning by induction (cf.\
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   494
\S\ref{sec:cases-induct}): rule $c\mathord{.}induct$ (where $c$ is the name of
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   495
the function definition) refers to a specific induction rule, with parameters
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   496
named according to the user-specified equations.  Case names of
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   497
$\isarkeyword{primrec}$ are that of the datatypes involved, while those of
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   498
$\isarkeyword{recdef}$ are numbered (starting from $1$).
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   499
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   500
The equations provided by these packages may be referred later as theorem list
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   501
$f{\dtt}simps$, where $f$ is the (collective) name of the functions defined.
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   502
Individual equations may be named explicitly as well; note that for
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   503
$\isarkeyword{recdef}$ each specification given by the user may result in
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   504
several theorems.
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   505
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   506
\medskip Hints for $\isarkeyword{recdef}$ may be also declared globally, using
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   507
the following attributes.
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   508
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   509
\indexisarattof{HOL}{recdef-simp}\indexisarattof{HOL}{recdef-cong}\indexisarattof{HOL}{recdef-wf}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   510
\begin{matharray}{rcl}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   511
  recdef_simp & : & \isaratt \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   512
  recdef_cong & : & \isaratt \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   513
  recdef_wf & : & \isaratt \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   514
\end{matharray}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   515
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   516
\railalias{recdefsimp}{recdef\_simp}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   517
\railterm{recdefsimp}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   518
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   519
\railalias{recdefcong}{recdef\_cong}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   520
\railterm{recdefcong}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   521
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   522
\railalias{recdefwf}{recdef\_wf}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   523
\railterm{recdefwf}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   524
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   525
\begin{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   526
  (recdefsimp | recdefcong | recdefwf) (() | 'add' | 'del')
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   527
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   528
\end{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   529
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   530
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   531
\subsection{(Co)Inductive sets}\label{sec:hol-inductive}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   532
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   533
\indexisarcmdof{HOL}{inductive}\indexisarcmdof{HOL}{coinductive}\indexisarattof{HOL}{mono}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   534
\begin{matharray}{rcl}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   535
  \isarcmd{inductive} & : & \isartrans{theory}{theory} \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   536
  \isarcmd{coinductive} & : & \isartrans{theory}{theory} \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   537
  mono & : & \isaratt \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   538
\end{matharray}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   539
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   540
\begin{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   541
  ('inductive' | 'coinductive') sets intros monos?
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   542
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   543
  'mono' (() | 'add' | 'del')
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   544
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   545
12879
wenzelm
parents: 12621
diff changeset
   546
  sets: (term +)
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   547
  ;
12879
wenzelm
parents: 12621
diff changeset
   548
  intros: 'intros' (thmdecl? prop +)
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   549
  ;
12879
wenzelm
parents: 12621
diff changeset
   550
  monos: 'monos' thmrefs
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   551
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   552
\end{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   553
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   554
\begin{descr}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   555
\item [$\isarkeyword{inductive}$ and $\isarkeyword{coinductive}$] define
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   556
  (co)inductive sets from the given introduction rules.
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   557
\item [$mono$] declares monotonicity rules.  These rule are involved in the
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   558
  automated monotonicity proof of $\isarkeyword{inductive}$.
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   559
\end{descr}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   560
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   561
See \cite{isabelle-HOL} for further information on inductive definitions in
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   562
HOL, but note that this covers the old-style theory format.
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   563
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   564
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   565
\subsection{Arithmetic proof support}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   566
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   567
\indexisarmethof{HOL}{arith}\indexisarattof{HOL}{arith-split}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   568
\begin{matharray}{rcl}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   569
  arith & : & \isarmeth \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   570
  arith_split & : & \isaratt \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   571
\end{matharray}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   572
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   573
\begin{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   574
  'arith' '!'?
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   575
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   576
\end{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   577
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   578
The $arith$ method decides linear arithmetic problems (on types $nat$, $int$,
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   579
$real$).  Any current facts are inserted into the goal before running the
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   580
procedure.  The ``!''~argument causes the full context of assumptions to be
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   581
included.  The $arith_split$ attribute declares case split rules to be
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   582
expanded before the arithmetic procedure is invoked.
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   583
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   584
Note that a simpler (but faster) version of arithmetic reasoning is already
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   585
performed by the Simplifier.
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   586
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   587
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   588
\subsection{Cases and induction: emulating tactic scripts}\label{sec:hol-induct-tac}
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   589
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   590
The following important tactical tools of Isabelle/HOL have been ported to
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   591
Isar.  These should be never used in proper proof texts!
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   592
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   593
\indexisarmethof{HOL}{case-tac}\indexisarmethof{HOL}{induct-tac}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   594
\indexisarmethof{HOL}{ind-cases}\indexisarcmdof{HOL}{inductive-cases}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   595
\begin{matharray}{rcl}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   596
  case_tac^* & : & \isarmeth \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   597
  induct_tac^* & : & \isarmeth \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   598
  ind_cases^* & : & \isarmeth \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   599
  \isarcmd{inductive_cases} & : & \isartrans{theory}{theory} \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   600
\end{matharray}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   601
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   602
\railalias{casetac}{case\_tac}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   603
\railterm{casetac}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   604
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   605
\railalias{inducttac}{induct\_tac}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   606
\railterm{inducttac}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   607
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   608
\railalias{indcases}{ind\_cases}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   609
\railterm{indcases}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   610
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   611
\railalias{inductivecases}{inductive\_cases}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   612
\railterm{inductivecases}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   613
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   614
\begin{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   615
  casetac goalspec? term rule?
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   616
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   617
  inducttac goalspec? (insts * 'and') rule?
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   618
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   619
  indcases (prop +)
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   620
  ;
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   621
  inductivecases (thmdecl? (prop +) + 'and')
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   622
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   623
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   624
  rule: ('rule' ':' thmref)
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   625
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   626
\end{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   627
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   628
\begin{descr}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   629
\item [$case_tac$ and $induct_tac$] admit to reason about inductive datatypes
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   630
  only (unless an alternative rule is given explicitly).  Furthermore,
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   631
  $case_tac$ does a classical case split on booleans; $induct_tac$ allows only
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   632
  variables to be given as instantiation.  These tactic emulations feature
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   633
  both goal addressing and dynamic instantiation.  Note that named rule cases
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   634
  are \emph{not} provided as would be by the proper $induct$ and $cases$ proof
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   635
  methods (see \S\ref{sec:cases-induct}).
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   636
  
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   637
\item [$ind_cases$ and $\isarkeyword{inductive_cases}$] provide an interface
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   638
  to the internal \texttt{mk_cases} operation.  Rules are simplified in an
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   639
  unrestricted forward manner.
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   640
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   641
  While $ind_cases$ is a proof method to apply the result immediately as
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   642
  elimination rules, $\isarkeyword{inductive_cases}$ provides case split
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   643
  theorems at the theory level for later use,
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   644
\end{descr}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   645
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   646
13039
wenzelm
parents: 13027
diff changeset
   647
\subsection{Executable code}
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   648
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   649
Isabelle/Pure provides a generic infrastructure to support code generation
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   650
from executable specifications, both functional and relational programs.
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   651
Isabelle/HOL instantiates these mechanisms in a way that is amenable to
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   652
end-user applications.  See \cite{isabelle-HOL} for further information (this
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   653
actually covers the new-style theory format as well).
13027
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   654
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   655
\indexisarcmd{generate-code}\indexisarcmd{consts-code}\indexisarcmd{types-code}
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   656
\indexisaratt{code}
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   657
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   658
\begin{matharray}{rcl}
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   659
  \isarcmd{generate_code} & : & \isartrans{theory}{theory} \\
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   660
  \isarcmd{consts_code} & : & \isartrans{theory}{theory} \\
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   661
  \isarcmd{types_code} & : & \isartrans{theory}{theory} \\  
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   662
  code & : & \isaratt \\
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   663
\end{matharray}
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   664
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   665
\railalias{generatecode}{generate\_code}
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   666
\railterm{generatecode}
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   667
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   668
\railalias{constscode}{consts\_code}
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   669
\railterm{constscode}
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   670
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   671
\railalias{typescode}{types\_code}
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   672
\railterm{typescode}
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   673
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   674
\begin{rail}
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   675
  generatecode ( () | '(' name ')') ((name '=' term) +)
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   676
  ;
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   677
  constscode (name ('::' type)? template +)
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   678
  ;
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   679
  typescode (name template +)
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   680
  ;
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   681
  template: '(' string ')'
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   682
  ;
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   683
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   684
  'code' (name)?
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   685
  ;
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   686
\end{rail}
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   687
ddf235f2384a some more stuff;
wenzelm
parents: 13024
diff changeset
   688
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   689
\section{HOLCF}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   690
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   691
\subsection{Mixfix syntax for continuous operations}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   692
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   693
\indexisarcmdof{HOLCF}{consts}\indexisarcmdof{HOLCF}{constdefs}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   694
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   695
\begin{matharray}{rcl}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   696
  \isarcmd{consts} & : & \isartrans{theory}{theory} \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   697
  \isarcmd{constdefs} & : & \isartrans{theory}{theory} \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   698
\end{matharray}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   699
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   700
HOLCF provides a separate type for continuous functions $\alpha \rightarrow
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   701
\beta$, with an explicit application operator $f \cdot x$.  Isabelle mixfix
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   702
syntax normally refers directly to the pure meta-level function type $\alpha
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   703
\To \beta$, with application $f\,x$.
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   704
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   705
The HOLCF variants of $\CONSTS$ and $\CONSTDEFS$ have the same outer syntax as
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   706
the pure versions (cf.\ \S\ref{sec:consts}).  Internally, declarations
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   707
involving continuous function types are treated specifically, transforming the
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   708
syntax template accordingly and generating syntax translation rules for the
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   709
abstract and concrete representation of application.
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   710
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   711
The behavior for plain meta-level function types is unchanged.  Mixed
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   712
continuous and meta-level application is \emph{not} supported.
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   713
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   714
\subsection{Recursive domains}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   715
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   716
\indexisarcmdof{HOLCF}{domain}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   717
\begin{matharray}{rcl}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   718
  \isarcmd{domain} & : & \isartrans{theory}{theory} \\
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   719
\end{matharray}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   720
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   721
\begin{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   722
  'domain' parname? (dmspec + 'and')
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   723
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   724
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   725
  dmspec: typespec '=' (cons + '|')
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   726
  ;
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   727
  cons: name (type *) mixfix?
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   728
  ;
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   729
  dtrules: 'distinct' thmrefs 'inject' thmrefs 'induction' thmrefs
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   730
\end{rail}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   731
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   732
Recursive domains in HOLCF are analogous to datatypes in classical HOL (cf.\ 
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   733
\S\ref{sec:hol-datatype}).  Mutual recursion is supported, but no nesting nor
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   734
arbitrary branching.  Domain constructors may be strict (default) or lazy, the
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   735
latter admits to introduce infinitary objects in the typical LCF manner (e.g.\ 
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   736
lazy lists).  See also \cite{MuellerNvOS99} for a general discussion of HOLCF
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   737
domains.
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   738
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   739
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   740
\section{ZF}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   741
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   742
\subsection{Type checking}
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   743
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   744
The ZF logic is essentially untyped, so the concept of ``type checking'' is
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   745
performed as logical reasoning about set-membership statements.  A special
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   746
method assists users in this task; a version of this is already declared as a
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   747
``solver'' in the standard Simplifier setup.
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   748
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   749
\indexisarcmd{print-tcset}\indexisaratt{typecheck}\indexisaratt{TC}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   750
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   751
\begin{matharray}{rcl}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   752
  \isarcmd{print_tcset}^* & : & \isarkeep{theory~|~proof} \\
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   753
  typecheck & : & \isarmeth \\
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   754
  TC & : & \isaratt \\
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   755
\end{matharray}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   756
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   757
\begin{rail}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   758
  'TC' (() | 'add' | 'del')
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   759
  ;
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   760
\end{rail}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   761
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   762
\begin{descr}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   763
  
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   764
\item [$\isarcmd{print_tcset}$] prints the collection of typechecking rules of
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   765
  the current context.
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   766
  
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   767
  Note that the component built into the Simplifier only knows about those
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   768
  rules being declared globally in the theory!
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   769
  
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   770
\item [$typecheck$] attempts to solve any pending type-checking problems in
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   771
  subgoals.
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   772
  
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   773
\item [$TC$] adds or deletes type-checking rules from the context.
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   774
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   775
\end{descr}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   776
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   777
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   778
\subsection{(Co)Inductive sets and datatypes}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   779
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   780
\subsubsection{Set definitions}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   781
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   782
In ZF everything is a set.  The generic inductive package also provides a
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   783
specific view for ``datatype'' specifications.  Coinductive definitions are
13041
6faccf7d0f25 *** empty log message ***
wenzelm
parents: 13039
diff changeset
   784
available in both cases, too.
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   785
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   786
\indexisarcmdof{ZF}{inductive}\indexisarcmdof{ZF}{coinductive}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   787
\indexisarcmdof{ZF}{datatype}\indexisarcmdof{ZF}{codatatype}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   788
\begin{matharray}{rcl}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   789
  \isarcmd{inductive} & : & \isartrans{theory}{theory} \\
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   790
  \isarcmd{coinductive} & : & \isartrans{theory}{theory} \\
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   791
  \isarcmd{datatype} & : & \isartrans{theory}{theory} \\
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   792
  \isarcmd{codatatype} & : & \isartrans{theory}{theory} \\
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   793
\end{matharray}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   794
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   795
\railalias{CONDEFS}{con\_defs}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   796
\railterm{CONDEFS}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   797
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   798
\railalias{TYPEINTROS}{type\_intros}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   799
\railterm{TYPEINTROS}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   800
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   801
\railalias{TYPEELIMS}{type\_elims}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   802
\railterm{TYPEELIMS}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   803
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   804
\begin{rail}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   805
  ('inductive' | 'coinductive') domains intros hints
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   806
  ;
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   807
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   808
  domains: 'domains' (term + '+') ('<=' | subseteq) term
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   809
  ;
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   810
  intros: 'intros' (thmdecl? prop +)
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   811
  ;
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   812
  hints: monos? condefs? typeintros? typeelims?
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   813
  ;
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   814
  monos: ('monos' thmrefs)?
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   815
  ;
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   816
  condefs: (CONDEFS thmrefs)?
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   817
  ;
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   818
  typeintros: (TYPEINTROS thmrefs)?
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   819
  ;
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   820
  typeelims: (TYPEELIMS thmrefs)?
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   821
  ;
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   822
\end{rail}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   823
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   824
In the following diagram $monos$, $typeintros$, and $typeelims$ are the same
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   825
as above.
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   826
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   827
\begin{rail}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   828
  ('datatype' | 'codatatype') domain? (dtspec + 'and') hints
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   829
  ;
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   830
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   831
  domain: ('<=' | subseteq) term
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   832
  ;
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   833
  dtspec: term '=' (con + '|')
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   834
  ;
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   835
  con: name ('(' (term ',' +) ')')?  
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   836
  ;
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   837
  hints: monos? typeintros? typeelims?
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   838
  ;
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   839
\end{rail}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   840
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   841
See \cite{isabelle-ZF} for further information on inductive definitions in
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   842
HOL, but note that this covers the old-style theory format.
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   843
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   844
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   845
\subsubsection{Primitive recursive functions}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   846
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   847
\indexisarcmdof{ZF}{primrec}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   848
\begin{matharray}{rcl}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   849
  \isarcmd{primrec} & : & \isartrans{theory}{theory} \\
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   850
\end{matharray}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   851
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   852
\begin{rail}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   853
  'primrec' (thmdecl? prop +)
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   854
  ;
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   855
\end{rail}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   856
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   857
13042
wenzelm
parents: 13041
diff changeset
   858
\subsubsection{Cases and induction: emulating tactic scripts}
13024
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   859
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   860
The following important tactical tools of Isabelle/ZF have been ported to
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   861
Isar.  These should be never used in proper proof texts!
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   862
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   863
\indexisarmethof{ZF}{case-tac}\indexisarmethof{ZF}{induct-tac}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   864
\indexisarmethof{ZF}{ind-cases}\indexisarcmdof{ZF}{inductive-cases}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   865
\begin{matharray}{rcl}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   866
  case_tac^* & : & \isarmeth \\
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   867
  induct_tac^* & : & \isarmeth \\
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   868
  ind_cases^* & : & \isarmeth \\
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   869
  \isarcmd{inductive_cases} & : & \isartrans{theory}{theory} \\
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   870
\end{matharray}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   871
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   872
\begin{rail}
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   873
  (casetac | inducttac) goalspec? name
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   874
  ;
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   875
  indcases (prop +)
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   876
  ;
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   877
  inductivecases (thmdecl? (prop +) + 'and')
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   878
  ;
0461b281c2b5 more stuff;
wenzelm
parents: 13016
diff changeset
   879
\end{rail}
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   880
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   881
%%% Local Variables:
12621
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   882
%%% mode: latex
48cafea0684b next round of updates;
wenzelm
parents:
diff changeset
   883
%%% TeX-master: "isar-ref"
13014
3c1c493e6d93 records from logics-HOL;
wenzelm
parents: 12879
diff changeset
   884
%%% End: