theory HOL_Specific
imports Main
begin
chapter {* Isabelle/HOL \label{ch:hol} *}
section {* Primitive types \label{sec:hol-typedef} *}
text {*
\begin{matharray}{rcl}
@{command_def (HOL) "typedecl"} & : & @{text "theory \ theory"} \\
@{command_def (HOL) "typedef"} & : & @{text "theory \ proof(prove)"} \\
\end{matharray}
\begin{rail}
'typedecl' typespec mixfix?
;
'typedef' altname? abstype '=' repset
;
altname: '(' (name | 'open' | 'open' name) ')'
;
abstype: typespec mixfix?
;
repset: term ('morphisms' name name)?
;
\end{rail}
\begin{description}
\item @{command (HOL) "typedecl"}~@{text "(\\<^sub>1, \, \\<^sub>n) t"} is similar
to the original @{command "typedecl"} of Isabelle/Pure (see
\secref{sec:types-pure}), but also declares type arity @{text "t ::
(type, \, type) type"}, making @{text t} an actual HOL type
constructor. %FIXME check, update
\item @{command (HOL) "typedef"}~@{text "(\\<^sub>1, \, \\<^sub>n) t = A"} sets up
a goal stating non-emptiness of the set @{text A}. After finishing
the proof, the theory will be augmented by a Gordon/HOL-style type
definition, which establishes a bijection between the representing
set @{text A} and the new type @{text t}.
Technically, @{command (HOL) "typedef"} defines both a type @{text
t} and a set (term constant) of the same name (an alternative base
name may be given in parentheses). The injection from type to set
is called @{text Rep_t}, its inverse @{text Abs_t} (this may be
changed via an explicit @{keyword (HOL) "morphisms"} declaration).
Theorems @{text Rep_t}, @{text Rep_t_inverse}, and @{text
Abs_t_inverse} provide the most basic characterization as a
corresponding injection/surjection pair (in both directions). Rules
@{text Rep_t_inject} and @{text Abs_t_inject} provide a slightly
more convenient view on the injectivity part, suitable for automated
proof tools (e.g.\ in @{attribute simp} or @{attribute iff}
declarations). Rules @{text Rep_t_cases}/@{text Rep_t_induct}, and
@{text Abs_t_cases}/@{text Abs_t_induct} provide alternative views
on surjectivity; these are already declared as set or type rules for
the generic @{method cases} and @{method induct} methods.
An alternative name may be specified in parentheses; the default is
to use @{text t} as indicated before. The ``@{text "(open)"}''
declaration suppresses a separate constant definition for the
representing set.
\end{description}
Note that raw type declarations are rarely used in practice; the
main application is with experimental (or even axiomatic!) theory
fragments. Instead of primitive HOL type definitions, user-level
theories usually refer to higher-level packages such as @{command
(HOL) "record"} (see \secref{sec:hol-record}) or @{command (HOL)
"datatype"} (see \secref{sec:hol-datatype}).
*}
section {* Adhoc tuples *}
text {*
\begin{matharray}{rcl}
@{attribute (HOL) split_format}@{text "\<^sup>*"} & : & @{text attribute} \\
\end{matharray}
\begin{rail}
'split\_format' ((( name * ) + 'and') | ('(' 'complete' ')'))
;
\end{rail}
\begin{description}
\item @{attribute (HOL) split_format}~@{text "p\<^sub>1 \ p\<^sub>m \ \
\ q\<^sub>1 \ q\<^sub>n"} puts expressions of low-level tuple types into
canonical form as specified by the arguments given; the @{text i}-th
collection of arguments refers to occurrences in premise @{text i}
of the rule. The ``@{text "(complete)"}'' option causes \emph{all}
arguments in function applications to be represented canonically
according to their tuple type structure.
Note that these operations tend to invent funny names for new local
parameters to be introduced.
\end{description}
*}
section {* Records \label{sec:hol-record} *}
text {*
In principle, records merely generalize the concept of tuples, where
components may be addressed by labels instead of just position. The
logical infrastructure of records in Isabelle/HOL is slightly more
advanced, though, supporting truly extensible record schemes. This
admits operations that are polymorphic with respect to record
extension, yielding ``object-oriented'' effects like (single)
inheritance. See also \cite{NaraschewskiW-TPHOLs98} for more
details on object-oriented verification and record subtyping in HOL.
*}
subsection {* Basic concepts *}
text {*
Isabelle/HOL supports both \emph{fixed} and \emph{schematic} records
at the level of terms and types. The notation is as follows:
\begin{center}
\begin{tabular}{l|l|l}
& record terms & record types \\ \hline
fixed & @{text "\x = a, y = b\"} & @{text "\x :: A, y :: B\"} \\
schematic & @{text "\x = a, y = b, \ = m\"} &
@{text "\x :: A, y :: B, \ :: M\"} \\
\end{tabular}
\end{center}
\noindent The ASCII representation of @{text "\x = a\"} is @{text
"(| x = a |)"}.
A fixed record @{text "\x = a, y = b\"} has field @{text x} of value
@{text a} and field @{text y} of value @{text b}. The corresponding
type is @{text "\x :: A, y :: B\"}, assuming that @{text "a :: A"}
and @{text "b :: B"}.
A record scheme like @{text "\x = a, y = b, \ = m\"} contains fields
@{text x} and @{text y} as before, but also possibly further fields
as indicated by the ``@{text "\"}'' notation (which is actually part
of the syntax). The improper field ``@{text "\"}'' of a record
scheme is called the \emph{more part}. Logically it is just a free
variable, which is occasionally referred to as ``row variable'' in
the literature. The more part of a record scheme may be
instantiated by zero or more further components. For example, the
previous scheme may get instantiated to @{text "\x = a, y = b, z =
c, \ = m'\"}, where @{text m'} refers to a different more part.
Fixed records are special instances of record schemes, where
``@{text "\"}'' is properly terminated by the @{text "() :: unit"}
element. In fact, @{text "\x = a, y = b\"} is just an abbreviation
for @{text "\x = a, y = b, \ = ()\"}.
\medskip Two key observations make extensible records in a simply
typed language like HOL work out:
\begin{enumerate}
\item the more part is internalized, as a free term or type
variable,
\item field names are externalized, they cannot be accessed within
the logic as first-class values.
\end{enumerate}
\medskip In Isabelle/HOL record types have to be defined explicitly,
fixing their field names and types, and their (optional) parent
record. Afterwards, records may be formed using above syntax, while
obeying the canonical order of fields as given by their declaration.
The record package provides several standard operations like
selectors and updates. The common setup for various generic proof
tools enable succinct reasoning patterns. See also the Isabelle/HOL
tutorial \cite{isabelle-hol-book} for further instructions on using
records in practice.
*}
subsection {* Record specifications *}
text {*
\begin{matharray}{rcl}
@{command_def (HOL) "record"} & : & @{text "theory \ theory"} \\
\end{matharray}
\begin{rail}
'record' typespec '=' (type '+')? (constdecl +)
;
\end{rail}
\begin{description}
\item @{command (HOL) "record"}~@{text "(\\<^sub>1, \, \\<^sub>m) t = \ + c\<^sub>1 :: \\<^sub>1
\ c\<^sub>n :: \\<^sub>n"} defines extensible record type @{text "(\\<^sub>1, \, \\<^sub>m) t"},
derived from the optional parent record @{text "\"} by adding new
field components @{text "c\<^sub>i :: \\<^sub>i"} etc.
The type variables of @{text "\"} and @{text "\\<^sub>i"} need to be
covered by the (distinct) parameters @{text "\\<^sub>1, \,
\\<^sub>m"}. Type constructor @{text t} has to be new, while @{text
\} needs to specify an instance of an existing record type. At
least one new field @{text "c\<^sub>i"} has to be specified.
Basically, field names need to belong to a unique record. This is
not a real restriction in practice, since fields are qualified by
the record name internally.
The parent record specification @{text \} is optional; if omitted
@{text t} becomes a root record. The hierarchy of all records
declared within a theory context forms a forest structure, i.e.\ a
set of trees starting with a root record each. There is no way to
merge multiple parent records!
For convenience, @{text "(\\<^sub>1, \, \\<^sub>m) t"} is made a
type abbreviation for the fixed record type @{text "\c\<^sub>1 ::
\\<^sub>1, \, c\<^sub>n :: \\<^sub>n\"}, likewise is @{text
"(\\<^sub>1, \, \\<^sub>m, \) t_scheme"} made an abbreviation for
@{text "\c\<^sub>1 :: \\<^sub>1, \, c\<^sub>n :: \\<^sub>n, \ ::
\\"}.
\end{description}
*}
subsection {* Record operations *}
text {*
Any record definition of the form presented above produces certain
standard operations. Selectors and updates are provided for any
field, including the improper one ``@{text more}''. There are also
cumulative record constructor functions. To simplify the
presentation below, we assume for now that @{text "(\\<^sub>1, \,
\\<^sub>m) t"} is a root record with fields @{text "c\<^sub>1 ::
\\<^sub>1, \, c\<^sub>n :: \\<^sub>n"}.
\medskip \textbf{Selectors} and \textbf{updates} are available for
any field (including ``@{text more}''):
\begin{matharray}{lll}
@{text "c\<^sub>i"} & @{text "::"} & @{text "\\<^vec>c :: \<^vec>\, \ :: \\ \ \\<^sub>i"} \\
@{text "c\<^sub>i_update"} & @{text "::"} & @{text "\\<^sub>i \ \\<^vec>c :: \<^vec>\, \ :: \\ \ \\<^vec>c :: \<^vec>\, \ :: \\"} \\
\end{matharray}
There is special syntax for application of updates: @{text "r\x :=
a\"} abbreviates term @{text "x_update a r"}. Further notation for
repeated updates is also available: @{text "r\x := a\\y := b\\z :=
c\"} may be written @{text "r\x := a, y := b, z := c\"}. Note that
because of postfix notation the order of fields shown here is
reverse than in the actual term. Since repeated updates are just
function applications, fields may be freely permuted in @{text "\x
:= a, y := b, z := c\"}, as far as logical equality is concerned.
Thus commutativity of independent updates can be proven within the
logic for any two fields, but not as a general theorem.
\medskip The \textbf{make} operation provides a cumulative record
constructor function:
\begin{matharray}{lll}
@{text "t.make"} & @{text "::"} & @{text "\\<^sub>1 \ \ \\<^sub>n \ \\<^vec>c :: \<^vec>\\"} \\
\end{matharray}
\medskip We now reconsider the case of non-root records, which are
derived of some parent. In general, the latter may depend on
another parent as well, resulting in a list of \emph{ancestor
records}. Appending the lists of fields of all ancestors results in
a certain field prefix. The record package automatically takes care
of this by lifting operations over this context of ancestor fields.
Assuming that @{text "(\\<^sub>1, \, \\<^sub>m) t"} has ancestor
fields @{text "b\<^sub>1 :: \\<^sub>1, \, b\<^sub>k :: \\<^sub>k"},
the above record operations will get the following types:
\medskip
\begin{tabular}{lll}
@{text "c\<^sub>i"} & @{text "::"} & @{text "\\<^vec>b :: \<^vec>\, \<^vec>c :: \<^vec>\, \ :: \\ \ \\<^sub>i"} \\
@{text "c\<^sub>i_update"} & @{text "::"} & @{text "\\<^sub>i \
\\<^vec>b :: \<^vec>\, \<^vec>c :: \<^vec>\, \ :: \\ \
\\<^vec>b :: \<^vec>\, \<^vec>c :: \<^vec>\, \ :: \\"} \\
@{text "t.make"} & @{text "::"} & @{text "\\<^sub>1 \ \ \\<^sub>k \ \\<^sub>1 \ \ \\<^sub>n \
\\<^vec>b :: \<^vec>\, \<^vec>c :: \<^vec>\\"} \\
\end{tabular}
\medskip
\noindent Some further operations address the extension aspect of a
derived record scheme specifically: @{text "t.fields"} produces a
record fragment consisting of exactly the new fields introduced here
(the result may serve as a more part elsewhere); @{text "t.extend"}
takes a fixed record and adds a given more part; @{text
"t.truncate"} restricts a record scheme to a fixed record.
\medskip
\begin{tabular}{lll}
@{text "t.fields"} & @{text "::"} & @{text "\\<^sub>1 \ \ \\<^sub>n \ \\<^vec>c :: \<^vec>\\"} \\
@{text "t.extend"} & @{text "::"} & @{text "\\<^vec>b :: \<^vec>\, \<^vec>c :: \<^vec>\\ \
\ \ \\<^vec>b :: \<^vec>\, \<^vec>c :: \<^vec>\, \ :: \\"} \\
@{text "t.truncate"} & @{text "::"} & @{text "\\<^vec>b :: \<^vec>\, \<^vec>c :: \<^vec>\, \ :: \\ \ \\<^vec>b :: \<^vec>\, \<^vec>c :: \<^vec>\\"} \\
\end{tabular}
\medskip
\noindent Note that @{text "t.make"} and @{text "t.fields"} coincide
for root records.
*}
subsection {* Derived rules and proof tools *}
text {*
The record package proves several results internally, declaring
these facts to appropriate proof tools. This enables users to
reason about record structures quite conveniently. Assume that
@{text t} is a record type as specified above.
\begin{enumerate}
\item Standard conversions for selectors or updates applied to
record constructor terms are made part of the default Simplifier
context; thus proofs by reduction of basic operations merely require
the @{method simp} method without further arguments. These rules
are available as @{text "t.simps"}, too.
\item Selectors applied to updated records are automatically reduced
by an internal simplification procedure, which is also part of the
standard Simplifier setup.
\item Inject equations of a form analogous to @{prop "(x, y) = (x',
y') \ x = x' \ y = y'"} are declared to the Simplifier and Classical
Reasoner as @{attribute iff} rules. These rules are available as
@{text "t.iffs"}.
\item The introduction rule for record equality analogous to @{text
"x r = x r' \ y r = y r' \ \ r = r'"} is declared to the Simplifier,
and as the basic rule context as ``@{attribute intro}@{text "?"}''.
The rule is called @{text "t.equality"}.
\item Representations of arbitrary record expressions as canonical
constructor terms are provided both in @{method cases} and @{method
induct} format (cf.\ the generic proof methods of the same name,
\secref{sec:cases-induct}). Several variations are available, for
fixed records, record schemes, more parts etc.
The generic proof methods are sufficiently smart to pick the most
sensible rule according to the type of the indicated record
expression: users just need to apply something like ``@{text "(cases
r)"}'' to a certain proof problem.
\item The derived record operations @{text "t.make"}, @{text
"t.fields"}, @{text "t.extend"}, @{text "t.truncate"} are \emph{not}
treated automatically, but usually need to be expanded by hand,
using the collective fact @{text "t.defs"}.
\end{enumerate}
*}
section {* Datatypes \label{sec:hol-datatype} *}
text {*
\begin{matharray}{rcl}
@{command_def (HOL) "datatype"} & : & @{text "theory \ theory"} \\
@{command_def (HOL) "rep_datatype"} & : & @{text "theory \ proof(prove)"} \\
\end{matharray}
\begin{rail}
'datatype' (dtspec + 'and')
;
'rep\_datatype' ('(' (name +) ')')? (term +)
;
dtspec: parname? typespec mixfix? '=' (cons + '|')
;
cons: name ( type * ) mixfix?
\end{rail}
\begin{description}
\item @{command (HOL) "datatype"} defines inductive datatypes in
HOL.
\item @{command (HOL) "rep_datatype"} represents existing types as
inductive ones, generating the standard infrastructure of derived
concepts (primitive recursion etc.).
\end{description}
The induction and exhaustion theorems generated provide case names
according to the constructors involved, while parameters are named
after the types (see also \secref{sec:cases-induct}).
See \cite{isabelle-HOL} for more details on datatypes, but beware of
the old-style theory syntax being used there! Apart from proper
proof methods for case-analysis and induction, there are also
emulations of ML tactics @{method (HOL) case_tac} and @{method (HOL)
induct_tac} available, see \secref{sec:hol-induct-tac}; these admit
to refer directly to the internal structure of subgoals (including
internally bound parameters).
*}
section {* Recursive functions \label{sec:recursion} *}
text {*
\begin{matharray}{rcl}
@{command_def (HOL) "primrec"} & : & @{text "local_theory \ local_theory"} \\
@{command_def (HOL) "fun"} & : & @{text "local_theory \ local_theory"} \\
@{command_def (HOL) "function"} & : & @{text "local_theory \ proof(prove)"} \\
@{command_def (HOL) "termination"} & : & @{text "local_theory \ proof(prove)"} \\
\end{matharray}
\begin{rail}
'primrec' target? fixes 'where' equations
;
equations: (thmdecl? prop + '|')
;
('fun' | 'function') target? functionopts? fixes 'where' clauses
;
clauses: (thmdecl? prop ('(' 'otherwise' ')')? + '|')
;
functionopts: '(' (('sequential' | 'domintros' | 'tailrec' | 'default' term) + ',') ')'
;
'termination' ( term )?
\end{rail}
\begin{description}
\item @{command (HOL) "primrec"} defines primitive recursive
functions over datatypes, see also \cite{isabelle-HOL}.
\item @{command (HOL) "function"} defines functions by general
wellfounded recursion. A detailed description with examples can be
found in \cite{isabelle-function}. The function is specified by a
set of (possibly conditional) recursive equations with arbitrary
pattern matching. The command generates proof obligations for the
completeness and the compatibility of patterns.
The defined function is considered partial, and the resulting
simplification rules (named @{text "f.psimps"}) and induction rule
(named @{text "f.pinduct"}) are guarded by a generated domain
predicate @{text "f_dom"}. The @{command (HOL) "termination"}
command can then be used to establish that the function is total.
\item @{command (HOL) "fun"} is a shorthand notation for ``@{command
(HOL) "function"}~@{text "(sequential)"}, followed by automated
proof attempts regarding pattern matching and termination. See
\cite{isabelle-function} for further details.
\item @{command (HOL) "termination"}~@{text f} commences a
termination proof for the previously defined function @{text f}. If
this is omitted, the command refers to the most recent function
definition. After the proof is closed, the recursive equations and
the induction principle is established.
\end{description}
Recursive definitions introduced by the @{command (HOL) "function"}
command accommodate
reasoning by induction (cf.\ \secref{sec:cases-induct}): rule @{text
"c.induct"} (where @{text c} is the name of the function definition)
refers to a specific induction rule, with parameters named according
to the user-specified equations. Cases are numbered (starting from 1).
For @{command (HOL) "primrec"}, the induction principle coincides
with structural recursion on the datatype the recursion is carried
out.
The equations provided by these packages may be referred later as
theorem list @{text "f.simps"}, where @{text f} is the (collective)
name of the functions defined. Individual equations may be named
explicitly as well.
The @{command (HOL) "function"} command accepts the following
options.
\begin{description}
\item @{text sequential} enables a preprocessor which disambiguates
overlapping patterns by making them mutually disjoint. Earlier
equations take precedence over later ones. This allows to give the
specification in a format very similar to functional programming.
Note that the resulting simplification and induction rules
correspond to the transformed specification, not the one given
originally. This usually means that each equation given by the user
may result in several theroems. Also note that this automatic
transformation only works for ML-style datatype patterns.
\item @{text domintros} enables the automated generation of
introduction rules for the domain predicate. While mostly not
needed, they can be helpful in some proofs about partial functions.
\item @{text tailrec} generates the unconstrained recursive
equations even without a termination proof, provided that the
function is tail-recursive. This currently only works
\item @{text "default d"} allows to specify a default value for a
(partial) function, which will ensure that @{text "f x = d x"}
whenever @{text "x \ f_dom"}.
\end{description}
*}
subsection {* Proof methods related to recursive definitions *}
text {*
\begin{matharray}{rcl}
@{method_def (HOL) pat_completeness} & : & @{text method} \\
@{method_def (HOL) relation} & : & @{text method} \\
@{method_def (HOL) lexicographic_order} & : & @{text method} \\
@{method_def (HOL) size_change} & : & @{text method} \\
\end{matharray}
\begin{rail}
'relation' term
;
'lexicographic\_order' ( clasimpmod * )
;
'size\_change' ( orders ( clasimpmod * ) )
;
orders: ( 'max' | 'min' | 'ms' ) *
\end{rail}
\begin{description}
\item @{method (HOL) pat_completeness} is a specialized method to
solve goals regarding the completeness of pattern matching, as
required by the @{command (HOL) "function"} package (cf.\
\cite{isabelle-function}).
\item @{method (HOL) relation}~@{text R} introduces a termination
proof using the relation @{text R}. The resulting proof state will
contain goals expressing that @{text R} is wellfounded, and that the
arguments of recursive calls decrease with respect to @{text R}.
Usually, this method is used as the initial proof step of manual
termination proofs.
\item @{method (HOL) "lexicographic_order"} attempts a fully
automated termination proof by searching for a lexicographic
combination of size measures on the arguments of the function. The
method accepts the same arguments as the @{method auto} method,
which it uses internally to prove local descents. The same context
modifiers as for @{method auto} are accepted, see
\secref{sec:clasimp}.
In case of failure, extensive information is printed, which can help
to analyse the situation (cf.\ \cite{isabelle-function}).
\item @{method (HOL) "size_change"} also works on termination goals,
using a variation of the size-change principle, together with a
graph decomposition technique (see \cite{krauss_phd} for details).
Three kinds of orders are used internally: @{text max}, @{text min},
and @{text ms} (multiset), which is only available when the theory
@{text Multiset} is loaded. When no order kinds are given, they are
tried in order. The search for a termination proof uses SAT solving
internally.
For local descent proofs, the same context modifiers as for @{method
auto} are accepted, see \secref{sec:clasimp}.
\end{description}
*}
subsection {* Old-style recursive function definitions (TFL) *}
text {*
The old TFL commands @{command (HOL) "recdef"} and @{command (HOL)
"recdef_tc"} for defining recursive are mostly obsolete; @{command
(HOL) "function"} or @{command (HOL) "fun"} should be used instead.
\begin{matharray}{rcl}
@{command_def (HOL) "recdef"} & : & @{text "theory \ theory)"} \\
@{command_def (HOL) "recdef_tc"}@{text "\<^sup>*"} & : & @{text "theory \ proof(prove)"} \\
\end{matharray}
\begin{rail}
'recdef' ('(' 'permissive' ')')? \\ name term (prop +) hints?
;
recdeftc thmdecl? tc
;
hints: '(' 'hints' ( recdefmod * ) ')'
;
recdefmod: (('recdef\_simp' | 'recdef\_cong' | 'recdef\_wf') (() | 'add' | 'del') ':' thmrefs) | clasimpmod
;
tc: nameref ('(' nat ')')?
;
\end{rail}
\begin{description}
\item @{command (HOL) "recdef"} defines general well-founded
recursive functions (using the TFL package), see also
\cite{isabelle-HOL}. The ``@{text "(permissive)"}'' option tells
TFL to recover from failed proof attempts, returning unfinished
results. The @{text recdef_simp}, @{text recdef_cong}, and @{text
recdef_wf} hints refer to auxiliary rules to be used in the internal
automated proof process of TFL. Additional @{syntax clasimpmod}
declarations (cf.\ \secref{sec:clasimp}) may be given to tune the
context of the Simplifier (cf.\ \secref{sec:simplifier}) and
Classical reasoner (cf.\ \secref{sec:classical}).
\item @{command (HOL) "recdef_tc"}~@{text "c (i)"} recommences the
proof for leftover termination condition number @{text i} (default
1) as generated by a @{command (HOL) "recdef"} definition of
constant @{text c}.
Note that in most cases, @{command (HOL) "recdef"} is able to finish
its internal proofs without manual intervention.
\end{description}
\medskip Hints for @{command (HOL) "recdef"} may be also declared
globally, using the following attributes.
\begin{matharray}{rcl}
@{attribute_def (HOL) recdef_simp} & : & @{text attribute} \\
@{attribute_def (HOL) recdef_cong} & : & @{text attribute} \\
@{attribute_def (HOL) recdef_wf} & : & @{text attribute} \\
\end{matharray}
\begin{rail}
('recdef\_simp' | 'recdef\_cong' | 'recdef\_wf') (() | 'add' | 'del')
;
\end{rail}
*}
section {* Inductive and coinductive definitions \label{sec:hol-inductive} *}
text {*
An \textbf{inductive definition} specifies the least predicate (or
set) @{text R} closed under given rules: applying a rule to elements
of @{text R} yields a result within @{text R}. For example, a
structural operational semantics is an inductive definition of an
evaluation relation.
Dually, a \textbf{coinductive definition} specifies the greatest
predicate~/ set @{text R} that is consistent with given rules: every
element of @{text R} can be seen as arising by applying a rule to
elements of @{text R}. An important example is using bisimulation
relations to formalise equivalence of processes and infinite data
structures.
\medskip The HOL package is related to the ZF one, which is
described in a separate paper,\footnote{It appeared in CADE
\cite{paulson-CADE}; a longer version is distributed with Isabelle.}
which you should refer to in case of difficulties. The package is
simpler than that of ZF thanks to implicit type-checking in HOL.
The types of the (co)inductive predicates (or sets) determine the
domain of the fixedpoint definition, and the package does not have
to use inference rules for type-checking.
\begin{matharray}{rcl}
@{command_def (HOL) "inductive"} & : & @{text "local_theory \ local_theory"} \\
@{command_def (HOL) "inductive_set"} & : & @{text "local_theory \ local_theory"} \\
@{command_def (HOL) "coinductive"} & : & @{text "local_theory \ local_theory"} \\
@{command_def (HOL) "coinductive_set"} & : & @{text "local_theory \ local_theory"} \\
@{attribute_def (HOL) mono} & : & @{text attribute} \\
\end{matharray}
\begin{rail}
('inductive' | 'inductive\_set' | 'coinductive' | 'coinductive\_set') target? fixes ('for' fixes)? \\
('where' clauses)? ('monos' thmrefs)?
;
clauses: (thmdecl? prop + '|')
;
'mono' (() | 'add' | 'del')
;
\end{rail}
\begin{description}
\item @{command (HOL) "inductive"} and @{command (HOL)
"coinductive"} define (co)inductive predicates from the
introduction rules given in the @{keyword "where"} part. The
optional @{keyword "for"} part contains a list of parameters of the
(co)inductive predicates that remain fixed throughout the
definition. The optional @{keyword "monos"} section contains
\emph{monotonicity theorems}, which are required for each operator
applied to a recursive set in the introduction rules. There
\emph{must} be a theorem of the form @{text "A \ B \ M A \ M B"},
for each premise @{text "M R\<^sub>i t"} in an introduction rule!
\item @{command (HOL) "inductive_set"} and @{command (HOL)
"coinductive_set"} are wrappers for to the previous commands,
allowing the definition of (co)inductive sets.
\item @{attribute (HOL) mono} declares monotonicity rules. These
rule are involved in the automated monotonicity proof of @{command
(HOL) "inductive"}.
\end{description}
*}
subsection {* Derived rules *}
text {*
Each (co)inductive definition @{text R} adds definitions to the
theory and also proves some theorems:
\begin{description}
\item @{text R.intros} is the list of introduction rules as proven
theorems, for the recursive predicates (or sets). The rules are
also available individually, using the names given them in the
theory file;
\item @{text R.cases} is the case analysis (or elimination) rule;
\item @{text R.induct} or @{text R.coinduct} is the (co)induction
rule.
\end{description}
When several predicates @{text "R\<^sub>1, \, R\<^sub>n"} are
defined simultaneously, the list of introduction rules is called
@{text "R\<^sub>1_\_R\<^sub>n.intros"}, the case analysis rules are
called @{text "R\<^sub>1.cases, \, R\<^sub>n.cases"}, and the list
of mutual induction rules is called @{text
"R\<^sub>1_\_R\<^sub>n.inducts"}.
*}
subsection {* Monotonicity theorems *}
text {*
Each theory contains a default set of theorems that are used in
monotonicity proofs. New rules can be added to this set via the
@{attribute (HOL) mono} attribute. The HOL theory @{text Inductive}
shows how this is done. In general, the following monotonicity
theorems may be added:
\begin{itemize}
\item Theorems of the form @{text "A \ B \ M A \ M B"}, for proving
monotonicity of inductive definitions whose introduction rules have
premises involving terms such as @{text "M R\<^sub>i t"}.
\item Monotonicity theorems for logical operators, which are of the
general form @{text "(\ \ \) \ \ (\ \ \) \ \ \ \"}. For example, in
the case of the operator @{text "\"}, the corresponding theorem is
\[
\infer{@{text "P\<^sub>1 \ P\<^sub>2 \ Q\<^sub>1 \ Q\<^sub>2"}}{@{text "P\<^sub>1 \ Q\<^sub>1"} & @{text "P\<^sub>2 \ Q\<^sub>2"}}
\]
\item De Morgan style equations for reasoning about the ``polarity''
of expressions, e.g.
\[
@{prop "\ \ P \ P"} \qquad\qquad
@{prop "\ (P \ Q) \