doc-src/TutorialI/Inductive/document/Advanced.tex
author nipkow
Thu, 12 Jun 2008 14:20:25 +0200
changeset 27167 a99747ccba87
parent 23848 ca73e86c22bb
child 32836 4c6e3e7ac2bf
permissions -rw-r--r--
typo
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
     1
%
11187
c6e49929e544 auto-update
paulson
parents: 11173
diff changeset
     2
\begin{isabellebody}%
c6e49929e544 auto-update
paulson
parents: 11173
diff changeset
     3
\def\isabellecontext{Advanced}%
17056
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
     4
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
     5
\isadelimtheory
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
     6
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
     7
\endisadelimtheory
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
     8
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
     9
\isatagtheory
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    10
%
17056
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
    11
\endisatagtheory
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
    12
{\isafoldtheory}%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
    13
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
    14
\isadelimtheory
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
    15
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
    16
\endisadelimtheory
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    17
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    18
\begin{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    19
The premises of introduction rules may contain universal quantifiers and
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    20
monotone functions.  A universal quantifier lets the rule 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    21
refer to any number of instances of 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    22
the inductively defined set.  A monotone function lets the rule refer
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    23
to existing constructions (such as ``list of'') over the inductively defined
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    24
set.  The examples below show how to use the additional expressiveness
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    25
and how to reason from the resulting definitions.%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    26
\end{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    27
\isamarkuptrue%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    28
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    29
\isamarkupsubsection{Universal Quantifiers in Introduction Rules \label{sec:gterm-datatype}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    30
}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    31
\isamarkuptrue%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    32
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    33
\begin{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    34
\index{ground terms example|(}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    35
\index{quantifiers!and inductive definitions|(}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    36
As a running example, this section develops the theory of \textbf{ground
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    37
terms}: terms constructed from constant and function 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    38
symbols but not variables. To simplify matters further, we regard a
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    39
constant as a function applied to the null argument  list.  Let us declare a
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    40
datatype \isa{gterm} for the type of ground  terms. It is a type constructor
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    41
whose argument is a type of  function symbols.%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    42
\end{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    43
\isamarkuptrue%
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
    44
\isacommand{datatype}\isamarkupfalse%
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    45
\ {\isacharprime}f\ gterm\ {\isacharequal}\ Apply\ {\isacharprime}f\ {\isachardoublequoteopen}{\isacharprime}f\ gterm\ list{\isachardoublequoteclose}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    46
\begin{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    47
To try it out, we declare a datatype of some integer operations: 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    48
integer constants, the unary minus operator and the addition 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    49
operator.%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    50
\end{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    51
\isamarkuptrue%
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
    52
\isacommand{datatype}\isamarkupfalse%
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    53
\ integer{\isacharunderscore}op\ {\isacharequal}\ Number\ int\ {\isacharbar}\ UnaryMinus\ {\isacharbar}\ Plus%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    54
\begin{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    55
Now the type \isa{integer{\isacharunderscore}op\ gterm} denotes the ground 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    56
terms built over those symbols.
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    57
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    58
The type constructor \isa{gterm} can be generalized to a function 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    59
over sets.  It returns 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    60
the set of ground terms that can be formed over a set \isa{F} of function symbols. For
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    61
example,  we could consider the set of ground terms formed from the finite 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    62
set \isa{{\isacharbraceleft}Number\ {\isadigit{2}}{\isacharcomma}\ UnaryMinus{\isacharcomma}\ Plus{\isacharbraceright}}.
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    63
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    64
This concept is inductive. If we have a list \isa{args} of ground terms 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    65
over~\isa{F} and a function symbol \isa{f} in \isa{F}, then we 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    66
can apply \isa{f} to \isa{args} to obtain another ground term. 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    67
The only difficulty is that the argument list may be of any length. Hitherto, 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    68
each rule in an inductive definition referred to the inductively 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    69
defined set a fixed number of times, typically once or twice. 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    70
A universal quantifier in the premise of the introduction rule 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    71
expresses that every element of \isa{args} belongs
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    72
to our inductively defined set: is a ground term 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    73
over~\isa{F}.  The function \isa{set} denotes the set of elements in a given 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    74
list.%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    75
\end{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    76
\isamarkuptrue%
23733
3f8ad7418e55 Adapted to new inductive definition package.
berghofe
parents: 21261
diff changeset
    77
\isacommand{inductive{\isacharunderscore}set}\isamarkupfalse%
3f8ad7418e55 Adapted to new inductive definition package.
berghofe
parents: 21261
diff changeset
    78
\isanewline
3f8ad7418e55 Adapted to new inductive definition package.
berghofe
parents: 21261
diff changeset
    79
\ \ gterms\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharprime}f\ set\ {\isasymRightarrow}\ {\isacharprime}f\ gterm\ set{\isachardoublequoteclose}\isanewline
3f8ad7418e55 Adapted to new inductive definition package.
berghofe
parents: 21261
diff changeset
    80
\ \ \isakeyword{for}\ F\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharprime}f\ set{\isachardoublequoteclose}\isanewline
3f8ad7418e55 Adapted to new inductive definition package.
berghofe
parents: 21261
diff changeset
    81
\isakeyword{where}\isanewline
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
    82
step{\isacharbrackleft}intro{\isacharbang}{\isacharbrackright}{\isacharcolon}\ {\isachardoublequoteopen}{\isasymlbrakk}{\isasymforall}t\ {\isasymin}\ set\ args{\isachardot}\ t\ {\isasymin}\ gterms\ F{\isacharsemicolon}\ \ f\ {\isasymin}\ F{\isasymrbrakk}\isanewline
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    83
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isasymLongrightarrow}\ {\isacharparenleft}Apply\ f\ args{\isacharparenright}\ {\isasymin}\ gterms\ F{\isachardoublequoteclose}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    84
\begin{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    85
To demonstrate a proof from this definition, let us 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    86
show that the function \isa{gterms}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    87
is \textbf{monotone}.  We shall need this concept shortly.%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    88
\end{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
    89
\isamarkuptrue%
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
    90
\isacommand{lemma}\isamarkupfalse%
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
    91
\ gterms{\isacharunderscore}mono{\isacharcolon}\ {\isachardoublequoteopen}F{\isasymsubseteq}G\ {\isasymLongrightarrow}\ gterms\ F\ {\isasymsubseteq}\ gterms\ G{\isachardoublequoteclose}\isanewline
17056
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
    92
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
    93
\isadelimproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
    94
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
    95
\endisadelimproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
    96
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
    97
\isatagproof
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
    98
\isacommand{apply}\isamarkupfalse%
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
    99
\ clarify\isanewline
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   100
\isacommand{apply}\isamarkupfalse%
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   101
\ {\isacharparenleft}erule\ gterms{\isachardot}induct{\isacharparenright}\isanewline
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   102
\isacommand{apply}\isamarkupfalse%
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   103
\ blast\isanewline
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   104
\isacommand{done}\isamarkupfalse%
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   105
%
17056
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   106
\endisatagproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   107
{\isafoldproof}%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   108
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   109
\isadelimproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   110
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   111
\endisadelimproof
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   112
%
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   113
\isadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   114
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   115
\endisadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   116
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   117
\isatagproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   118
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   119
\begin{isamarkuptxt}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   120
Intuitively, this theorem says that
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   121
enlarging the set of function symbols enlarges the set of ground 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   122
terms. The proof is a trivial rule induction.
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   123
First we use the \isa{clarify} method to assume the existence of an element of
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   124
\isa{gterms\ F}.  (We could have used \isa{intro\ subsetI}.)  We then
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   125
apply rule induction. Here is the resulting subgoal:
11187
c6e49929e544 auto-update
paulson
parents: 11173
diff changeset
   126
\begin{isabelle}%
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   127
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}x\ args\ f{\isachardot}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   128
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ }{\isasymlbrakk}F\ {\isasymsubseteq}\ G{\isacharsemicolon}\ {\isasymforall}t{\isasymin}set\ args{\isachardot}\ t\ {\isasymin}\ gterms\ F\ {\isasymand}\ t\ {\isasymin}\ gterms\ G{\isacharsemicolon}\ f\ {\isasymin}\ F{\isasymrbrakk}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   129
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ }{\isasymLongrightarrow}\ Apply\ f\ args\ {\isasymin}\ gterms\ G%
11173
094b76968484 revisions in response to comments by Tobias
paulson
parents: 10950
diff changeset
   130
\end{isabelle}
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   131
The assumptions state that \isa{f} belongs 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   132
to~\isa{F}, which is included in~\isa{G}, and that every element of the list \isa{args} is
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   133
a ground term over~\isa{G}.  The \isa{blast} method finds this chain of reasoning easily.%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   134
\end{isamarkuptxt}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   135
\isamarkuptrue%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   136
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   137
\endisatagproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   138
{\isafoldproof}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   139
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   140
\isadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   141
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   142
\endisadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   143
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   144
\begin{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   145
\begin{warn}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   146
Why do we call this function \isa{gterms} instead 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   147
of \isa{gterm}?  A constant may have the same name as a type.  However,
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   148
name  clashes could arise in the theorems that Isabelle generates. 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   149
Our choice of names keeps \isa{gterms{\isachardot}induct} separate from 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   150
\isa{gterm{\isachardot}induct}.
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   151
\end{warn}
10469
7813f5ccfb18 auto update
paulson
parents: 10457
diff changeset
   152
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   153
Call a term \textbf{well-formed} if each symbol occurring in it is applied
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   154
to the correct number of arguments.  (This number is called the symbol's
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   155
\textbf{arity}.)  We can express well-formedness by
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   156
generalizing the inductive definition of
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   157
\isa{gterms}.
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   158
Suppose we are given a function called \isa{arity}, specifying the arities
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   159
of all symbols.  In the inductive step, we have a list \isa{args} of such
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   160
terms and a function  symbol~\isa{f}. If the length of the list matches the
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   161
function's arity  then applying \isa{f} to \isa{args} yields a well-formed
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   162
term.%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   163
\end{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   164
\isamarkuptrue%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   165
\isacommand{inductive{\isacharunderscore}set}\isamarkupfalse%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   166
\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   167
\ \ well{\isacharunderscore}formed{\isacharunderscore}gterm\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharparenleft}{\isacharprime}f\ {\isasymRightarrow}\ nat{\isacharparenright}\ {\isasymRightarrow}\ {\isacharprime}f\ gterm\ set{\isachardoublequoteclose}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   168
\ \ \isakeyword{for}\ arity\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharprime}f\ {\isasymRightarrow}\ nat{\isachardoublequoteclose}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   169
\isakeyword{where}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   170
step{\isacharbrackleft}intro{\isacharbang}{\isacharbrackright}{\isacharcolon}\ {\isachardoublequoteopen}{\isasymlbrakk}{\isasymforall}t\ {\isasymin}\ set\ args{\isachardot}\ t\ {\isasymin}\ well{\isacharunderscore}formed{\isacharunderscore}gterm\ arity{\isacharsemicolon}\ \ \isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   171
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ length\ args\ {\isacharequal}\ arity\ f{\isasymrbrakk}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   172
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isasymLongrightarrow}\ {\isacharparenleft}Apply\ f\ args{\isacharparenright}\ {\isasymin}\ well{\isacharunderscore}formed{\isacharunderscore}gterm\ arity{\isachardoublequoteclose}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   173
\begin{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   174
The inductive definition neatly captures the reasoning above.
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   175
The universal quantification over the
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   176
\isa{set} of arguments expresses that all of them are well-formed.%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   177
\index{quantifiers!and inductive definitions|)}%
11187
c6e49929e544 auto-update
paulson
parents: 11173
diff changeset
   178
\end{isamarkuptext}%
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   179
\isamarkuptrue%
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   180
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   181
\isamarkupsubsection{Alternative Definition Using a Monotone Function%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   182
}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   183
\isamarkuptrue%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   184
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   185
\begin{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   186
\index{monotone functions!and inductive definitions|(}% 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   187
An inductive definition may refer to the
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   188
inductively defined  set through an arbitrary monotone function.  To
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   189
demonstrate this powerful feature, let us
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   190
change the  inductive definition above, replacing the
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   191
quantifier by a use of the function \isa{lists}. This
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   192
function, from the Isabelle theory of lists, is analogous to the
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   193
function \isa{gterms} declared above: if \isa{A} is a set then
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   194
\isa{lists\ A} is the set of lists whose elements belong to
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   195
\isa{A}.  
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   196
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   197
In the inductive definition of well-formed terms, examine the one
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   198
introduction rule.  The first premise states that \isa{args} belongs to
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   199
the \isa{lists} of well-formed terms.  This formulation is more
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   200
direct, if more obscure, than using a universal quantifier.%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   201
\end{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   202
\isamarkuptrue%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   203
\isacommand{inductive{\isacharunderscore}set}\isamarkupfalse%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
   204
\isanewline
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   205
\ \ well{\isacharunderscore}formed{\isacharunderscore}gterm{\isacharprime}\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharparenleft}{\isacharprime}f\ {\isasymRightarrow}\ nat{\isacharparenright}\ {\isasymRightarrow}\ {\isacharprime}f\ gterm\ set{\isachardoublequoteclose}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   206
\ \ \isakeyword{for}\ arity\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharprime}f\ {\isasymRightarrow}\ nat{\isachardoublequoteclose}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   207
\isakeyword{where}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   208
step{\isacharbrackleft}intro{\isacharbang}{\isacharbrackright}{\isacharcolon}\ {\isachardoublequoteopen}{\isasymlbrakk}args\ {\isasymin}\ lists\ {\isacharparenleft}well{\isacharunderscore}formed{\isacharunderscore}gterm{\isacharprime}\ arity{\isacharparenright}{\isacharsemicolon}\ \ \isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   209
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ length\ args\ {\isacharequal}\ arity\ f{\isasymrbrakk}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   210
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isasymLongrightarrow}\ {\isacharparenleft}Apply\ f\ args{\isacharparenright}\ {\isasymin}\ well{\isacharunderscore}formed{\isacharunderscore}gterm{\isacharprime}\ arity{\isachardoublequoteclose}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   211
\isakeyword{monos}\ lists{\isacharunderscore}mono%
11187
c6e49929e544 auto-update
paulson
parents: 11173
diff changeset
   212
\begin{isamarkuptext}%
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   213
We cite the theorem \isa{lists{\isacharunderscore}mono} to justify 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   214
using the function \isa{lists}.%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   215
\footnote{This particular theorem is installed by default already, but we
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   216
include the \isakeyword{monos} declaration in order to illustrate its syntax.}
11187
c6e49929e544 auto-update
paulson
parents: 11173
diff changeset
   217
\begin{isabelle}%
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   218
A\ {\isasymsubseteq}\ B\ {\isasymLongrightarrow}\ lists\ A\ {\isasymsubseteq}\ lists\ B\rulename{lists{\isacharunderscore}mono}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   219
\end{isabelle}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   220
Why must the function be monotone?  An inductive definition describes
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   221
an iterative construction: each element of the set is constructed by a
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   222
finite number of introduction rule applications.  For example, the
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   223
elements of \isa{even} are constructed by finitely many applications of
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   224
the rules
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   225
\begin{isabelle}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   226
{\isadigit{0}}\ {\isasymin}\ even\isasep\isanewline%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   227
n\ {\isasymin}\ even\ {\isasymLongrightarrow}\ Suc\ {\isacharparenleft}Suc\ n{\isacharparenright}\ {\isasymin}\ even%
11187
c6e49929e544 auto-update
paulson
parents: 11173
diff changeset
   228
\end{isabelle}
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   229
All references to a set in its
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   230
inductive definition must be positive.  Applications of an
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   231
introduction rule cannot invalidate previous applications, allowing the
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   232
construction process to converge.
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   233
The following pair of rules do not constitute an inductive definition:
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   234
\begin{trivlist}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   235
\item \isa{{\isadigit{0}}\ {\isasymin}\ even}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   236
\item \isa{n\ {\isasymnotin}\ even\ {\isasymLongrightarrow}\ Suc\ n\ {\isasymin}\ even}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   237
\end{trivlist}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   238
Showing that 4 is even using these rules requires showing that 3 is not
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   239
even.  It is far from trivial to show that this set of rules
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   240
characterizes the even numbers.  
10469
7813f5ccfb18 auto update
paulson
parents: 10457
diff changeset
   241
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   242
Even with its use of the function \isa{lists}, the premise of our
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   243
introduction rule is positive:
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   244
\begin{isabelle}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   245
args\ {\isasymin}\ lists\ {\isacharparenleft}well{\isacharunderscore}formed{\isacharunderscore}gterm{\isacharprime}\ arity{\isacharparenright}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   246
\end{isabelle}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   247
To apply the rule we construct a list \isa{args} of previously
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   248
constructed well-formed terms.  We obtain a
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   249
new term, \isa{Apply\ f\ args}.  Because \isa{lists} is monotone,
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   250
applications of the rule remain valid as new terms are constructed.
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   251
Further lists of well-formed
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   252
terms become available and none are taken away.%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   253
\index{monotone functions!and inductive definitions|)}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   254
\end{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   255
\isamarkuptrue%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   256
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   257
\isamarkupsubsection{A Proof of Equivalence%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   258
}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   259
\isamarkuptrue%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   260
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   261
\begin{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   262
We naturally hope that these two inductive definitions of ``well-formed'' 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   263
coincide.  The equality can be proved by separate inclusions in 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   264
each direction.  Each is a trivial rule induction.%
11187
c6e49929e544 auto-update
paulson
parents: 11173
diff changeset
   265
\end{isamarkuptext}%
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   266
\isamarkuptrue%
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   267
\isacommand{lemma}\isamarkupfalse%
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   268
\ {\isachardoublequoteopen}well{\isacharunderscore}formed{\isacharunderscore}gterm\ arity\ {\isasymsubseteq}\ well{\isacharunderscore}formed{\isacharunderscore}gterm{\isacharprime}\ arity{\isachardoublequoteclose}\isanewline
17056
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   269
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   270
\isadelimproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   271
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   272
\endisadelimproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   273
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   274
\isatagproof
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   275
\isacommand{apply}\isamarkupfalse%
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   276
\ clarify\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   277
\isacommand{apply}\isamarkupfalse%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   278
\ {\isacharparenleft}erule\ well{\isacharunderscore}formed{\isacharunderscore}gterm{\isachardot}induct{\isacharparenright}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   279
\isacommand{apply}\isamarkupfalse%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   280
\ auto\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   281
\isacommand{done}\isamarkupfalse%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   282
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   283
\endisatagproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   284
{\isafoldproof}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   285
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   286
\isadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   287
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   288
\endisadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   289
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   290
\isadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   291
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   292
\endisadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   293
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   294
\isatagproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   295
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   296
\begin{isamarkuptxt}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   297
The \isa{clarify} method gives
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   298
us an element of \isa{well{\isacharunderscore}formed{\isacharunderscore}gterm\ arity} on which to perform 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   299
induction.  The resulting subgoal can be proved automatically:
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   300
\begin{isabelle}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   301
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}x\ args\ f{\isachardot}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   302
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ }{\isasymlbrakk}{\isasymforall}t{\isasymin}set\ args{\isachardot}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   303
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ {\isasymlbrakk}\ \ \ }t\ {\isasymin}\ well{\isacharunderscore}formed{\isacharunderscore}gterm\ arity\ {\isasymand}\ t\ {\isasymin}\ well{\isacharunderscore}formed{\isacharunderscore}gterm{\isacharprime}\ arity{\isacharsemicolon}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   304
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ \ }length\ args\ {\isacharequal}\ arity\ f{\isasymrbrakk}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   305
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ }{\isasymLongrightarrow}\ Apply\ f\ args\ {\isasymin}\ well{\isacharunderscore}formed{\isacharunderscore}gterm{\isacharprime}\ arity%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   306
\end{isabelle}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   307
This proof resembles the one given in
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   308
{\S}\ref{sec:gterm-datatype} above, especially in the form of the
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   309
induction hypothesis.  Next, we consider the opposite inclusion:%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   310
\end{isamarkuptxt}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   311
\isamarkuptrue%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   312
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   313
\endisatagproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   314
{\isafoldproof}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   315
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   316
\isadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   317
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   318
\endisadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   319
\isacommand{lemma}\isamarkupfalse%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   320
\ {\isachardoublequoteopen}well{\isacharunderscore}formed{\isacharunderscore}gterm{\isacharprime}\ arity\ {\isasymsubseteq}\ well{\isacharunderscore}formed{\isacharunderscore}gterm\ arity{\isachardoublequoteclose}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   321
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   322
\isadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   323
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   324
\endisadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   325
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   326
\isatagproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   327
\isacommand{apply}\isamarkupfalse%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   328
\ clarify\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   329
\isacommand{apply}\isamarkupfalse%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   330
\ {\isacharparenleft}erule\ well{\isacharunderscore}formed{\isacharunderscore}gterm{\isacharprime}{\isachardot}induct{\isacharparenright}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   331
\isacommand{apply}\isamarkupfalse%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   332
\ auto\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   333
\isacommand{done}\isamarkupfalse%
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   334
%
17056
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   335
\endisatagproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   336
{\isafoldproof}%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   337
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   338
\isadelimproof
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   339
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   340
\endisadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   341
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   342
\isadelimproof
17056
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   343
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   344
\endisadelimproof
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   345
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   346
\isatagproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   347
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   348
\begin{isamarkuptxt}%
27167
nipkow
parents: 23848
diff changeset
   349
The proof script is virtually identical,
nipkow
parents: 23848
diff changeset
   350
but the subgoal after applying induction may be surprising:
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   351
\begin{isabelle}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   352
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}x\ args\ f{\isachardot}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   353
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ }{\isasymlbrakk}args\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   354
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ {\isasymlbrakk}}{\isasymin}\ lists\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   355
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ {\isasymlbrakk}{\isasymin}\ \ }{\isacharparenleft}well{\isacharunderscore}formed{\isacharunderscore}gterm{\isacharprime}\ arity\ {\isasyminter}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   356
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ {\isasymlbrakk}{\isasymin}\ \ {\isacharparenleft}}{\isacharbraceleft}a{\isachardot}\ a\ {\isasymin}\ well{\isacharunderscore}formed{\isacharunderscore}gterm\ arity{\isacharbraceright}{\isacharparenright}{\isacharsemicolon}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   357
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ \ }length\ args\ {\isacharequal}\ arity\ f{\isasymrbrakk}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   358
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ }{\isasymLongrightarrow}\ Apply\ f\ args\ {\isasymin}\ well{\isacharunderscore}formed{\isacharunderscore}gterm\ arity%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   359
\end{isabelle}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   360
The induction hypothesis contains an application of \isa{lists}.  Using a
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   361
monotone function in the inductive definition always has this effect.  The
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   362
subgoal may look uninviting, but fortunately 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   363
\isa{lists} distributes over intersection:
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   364
\begin{isabelle}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   365
lists\ {\isacharparenleft}A\ {\isasyminter}\ B{\isacharparenright}\ {\isacharequal}\ lists\ A\ {\isasyminter}\ lists\ B\rulename{lists{\isacharunderscore}Int{\isacharunderscore}eq}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   366
\end{isabelle}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   367
Thanks to this default simplification rule, the induction hypothesis 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   368
is quickly replaced by its two parts:
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   369
\begin{trivlist}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   370
\item \isa{args\ {\isasymin}\ lists\ {\isacharparenleft}well{\isacharunderscore}formed{\isacharunderscore}gterm{\isacharprime}\ arity{\isacharparenright}}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   371
\item \isa{args\ {\isasymin}\ lists\ {\isacharparenleft}well{\isacharunderscore}formed{\isacharunderscore}gterm\ arity{\isacharparenright}}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   372
\end{trivlist}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   373
Invoking the rule \isa{well{\isacharunderscore}formed{\isacharunderscore}gterm{\isachardot}step} completes the proof.  The
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   374
call to \isa{auto} does all this work.
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   375
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   376
This example is typical of how monotone functions
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   377
\index{monotone functions} can be used.  In particular, many of them
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   378
distribute over intersection.  Monotonicity implies one direction of
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   379
this set equality; we have this theorem:
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   380
\begin{isabelle}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   381
mono\ f\ {\isasymLongrightarrow}\ f\ {\isacharparenleft}A\ {\isasyminter}\ B{\isacharparenright}\ {\isasymsubseteq}\ f\ A\ {\isasyminter}\ f\ B\rulename{mono{\isacharunderscore}Int}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   382
\end{isabelle}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   383
\end{isamarkuptxt}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   384
\isamarkuptrue%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   385
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   386
\endisatagproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   387
{\isafoldproof}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   388
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   389
\isadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   390
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   391
\endisadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   392
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   393
\isamarkupsubsection{Another Example of Rule Inversion%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   394
}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   395
\isamarkuptrue%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   396
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   397
\begin{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   398
\index{rule inversion|(}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   399
Does \isa{gterms} distribute over intersection?  We have proved that this
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   400
function is monotone, so \isa{mono{\isacharunderscore}Int} gives one of the inclusions.  The
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   401
opposite inclusion asserts that if \isa{t} is a ground term over both of the
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   402
sets
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   403
\isa{F} and~\isa{G} then it is also a ground term over their intersection,
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   404
\isa{F\ {\isasyminter}\ G}.%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   405
\end{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   406
\isamarkuptrue%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   407
\isacommand{lemma}\isamarkupfalse%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   408
\ gterms{\isacharunderscore}IntI{\isacharcolon}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   409
\ \ \ \ \ {\isachardoublequoteopen}t\ {\isasymin}\ gterms\ F\ {\isasymLongrightarrow}\ t\ {\isasymin}\ gterms\ G\ {\isasymlongrightarrow}\ t\ {\isasymin}\ gterms\ {\isacharparenleft}F{\isasyminter}G{\isacharparenright}{\isachardoublequoteclose}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   410
\isadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   411
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   412
\endisadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   413
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   414
\isatagproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   415
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   416
\endisatagproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   417
{\isafoldproof}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   418
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   419
\isadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   420
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   421
\endisadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   422
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   423
\begin{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   424
Attempting this proof, we get the assumption 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   425
\isa{Apply\ f\ args\ {\isasymin}\ gterms\ G}, which cannot be broken down. 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   426
It looks like a job for rule inversion:\cmmdx{inductive\protect\_cases}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   427
\end{isamarkuptext}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   428
\isamarkuptrue%
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   429
\isacommand{inductive{\isacharunderscore}cases}\isamarkupfalse%
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   430
\ gterm{\isacharunderscore}Apply{\isacharunderscore}elim\ {\isacharbrackleft}elim{\isacharbang}{\isacharbrackright}{\isacharcolon}\ {\isachardoublequoteopen}Apply\ f\ args\ {\isasymin}\ gterms\ F{\isachardoublequoteclose}%
11187
c6e49929e544 auto-update
paulson
parents: 11173
diff changeset
   431
\begin{isamarkuptext}%
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   432
Here is the result.
11187
c6e49929e544 auto-update
paulson
parents: 11173
diff changeset
   433
\begin{isabelle}%
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   434
{\isasymlbrakk}Apply\ f\ args\ {\isasymin}\ gterms\ F{\isacharsemicolon}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   435
\isaindent{\ }{\isasymlbrakk}{\isasymforall}t{\isasymin}set\ args{\isachardot}\ t\ {\isasymin}\ gterms\ F{\isacharsemicolon}\ f\ {\isasymin}\ F{\isasymrbrakk}\ {\isasymLongrightarrow}\ P{\isasymrbrakk}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   436
{\isasymLongrightarrow}\ P\rulename{gterm{\isacharunderscore}Apply{\isacharunderscore}elim}%
10469
7813f5ccfb18 auto update
paulson
parents: 10457
diff changeset
   437
\end{isabelle}
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   438
This rule replaces an assumption about \isa{Apply\ f\ args} by 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   439
assumptions about \isa{f} and~\isa{args}.  
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   440
No cases are discarded (there was only one to begin
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   441
with) but the rule applies specifically to the pattern \isa{Apply\ f\ args}.
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   442
It can be applied repeatedly as an elimination rule without looping, so we
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   443
have given the \isa{elim{\isacharbang}} attribute. 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   444
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   445
Now we can prove the other half of that distributive law.%
11187
c6e49929e544 auto-update
paulson
parents: 11173
diff changeset
   446
\end{isamarkuptext}%
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   447
\isamarkuptrue%
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   448
\isacommand{lemma}\isamarkupfalse%
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   449
\ gterms{\isacharunderscore}IntI\ {\isacharbrackleft}rule{\isacharunderscore}format{\isacharcomma}\ intro{\isacharbang}{\isacharbrackright}{\isacharcolon}\isanewline
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   450
\ \ \ \ \ {\isachardoublequoteopen}t\ {\isasymin}\ gterms\ F\ {\isasymLongrightarrow}\ t\ {\isasymin}\ gterms\ G\ {\isasymlongrightarrow}\ t\ {\isasymin}\ gterms\ {\isacharparenleft}F{\isasyminter}G{\isacharparenright}{\isachardoublequoteclose}\isanewline
17056
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   451
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   452
\isadelimproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   453
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   454
\endisadelimproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   455
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   456
\isatagproof
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   457
\isacommand{apply}\isamarkupfalse%
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   458
\ {\isacharparenleft}erule\ gterms{\isachardot}induct{\isacharparenright}\isanewline
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   459
\isacommand{apply}\isamarkupfalse%
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   460
\ blast\isanewline
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   461
\isacommand{done}\isamarkupfalse%
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   462
%
17056
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   463
\endisatagproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   464
{\isafoldproof}%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   465
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   466
\isadelimproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   467
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   468
\endisadelimproof
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   469
%
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   470
\isadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   471
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   472
\endisadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   473
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   474
\isatagproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   475
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   476
\begin{isamarkuptxt}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   477
The proof begins with rule induction over the definition of
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   478
\isa{gterms}, which leaves a single subgoal:  
11187
c6e49929e544 auto-update
paulson
parents: 11173
diff changeset
   479
\begin{isabelle}%
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   480
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}args\ f{\isachardot}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   481
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ }{\isasymlbrakk}{\isasymforall}t{\isasymin}set\ args{\isachardot}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   482
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ {\isasymlbrakk}\ \ \ }t\ {\isasymin}\ gterms\ F\ {\isasymand}\ {\isacharparenleft}t\ {\isasymin}\ gterms\ G\ {\isasymlongrightarrow}\ t\ {\isasymin}\ gterms\ {\isacharparenleft}F\ {\isasyminter}\ G{\isacharparenright}{\isacharparenright}{\isacharsemicolon}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   483
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ \ }f\ {\isasymin}\ F{\isasymrbrakk}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   484
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ }{\isasymLongrightarrow}\ Apply\ f\ args\ {\isasymin}\ gterms\ G\ {\isasymlongrightarrow}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   485
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ {\isasymLongrightarrow}\ }Apply\ f\ args\ {\isasymin}\ gterms\ {\isacharparenleft}F\ {\isasyminter}\ G{\isacharparenright}%
11173
094b76968484 revisions in response to comments by Tobias
paulson
parents: 10950
diff changeset
   486
\end{isabelle}
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   487
To prove this, we assume \isa{Apply\ f\ args\ {\isasymin}\ gterms\ G}.  Rule inversion,
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   488
in the form of \isa{gterm{\isacharunderscore}Apply{\isacharunderscore}elim}, infers
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   489
that every element of \isa{args} belongs to 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   490
\isa{gterms\ G}; hence (by the induction hypothesis) it belongs
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   491
to \isa{gterms\ {\isacharparenleft}F\ {\isasyminter}\ G{\isacharparenright}}.  Rule inversion also yields
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   492
\isa{f\ {\isasymin}\ G} and hence \isa{f\ {\isasymin}\ F\ {\isasyminter}\ G}. 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   493
All of this reasoning is done by \isa{blast}.
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   494
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   495
\smallskip
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   496
Our distributive law is a trivial consequence of previously-proved results:%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   497
\end{isamarkuptxt}%
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   498
\isamarkuptrue%
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   499
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   500
\endisatagproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   501
{\isafoldproof}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   502
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   503
\isadelimproof
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   504
%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   505
\endisadelimproof
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   506
\isacommand{lemma}\isamarkupfalse%
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   507
\ gterms{\isacharunderscore}Int{\isacharunderscore}eq\ {\isacharbrackleft}simp{\isacharbrackright}{\isacharcolon}\isanewline
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   508
\ \ \ \ \ {\isachardoublequoteopen}gterms\ {\isacharparenleft}F\ {\isasyminter}\ G{\isacharparenright}\ {\isacharequal}\ gterms\ F\ {\isasyminter}\ gterms\ G{\isachardoublequoteclose}\isanewline
17056
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   509
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   510
\isadelimproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   511
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   512
\endisadelimproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   513
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   514
\isatagproof
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   515
\isacommand{by}\isamarkupfalse%
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   516
\ {\isacharparenleft}blast\ intro{\isacharbang}{\isacharcolon}\ mono{\isacharunderscore}Int\ monoI\ gterms{\isacharunderscore}mono{\isacharparenright}%
17056
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   517
\endisatagproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   518
{\isafoldproof}%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   519
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   520
\isadelimproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   521
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   522
\endisadelimproof
12156
d2758965362e new-style numerals without leading #, along with generic 0 and 1
paulson
parents: 11866
diff changeset
   523
%
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   524
\index{rule inversion|)}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   525
\index{ground terms example|)}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   526
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   527
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   528
\begin{isamarkuptext}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   529
\begin{exercise}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   530
A function mapping function symbols to their 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   531
types is called a \textbf{signature}.  Given a type 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   532
ranging over type symbols, we can represent a function's type by a
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   533
list of argument types paired with the result type. 
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   534
Complete this inductive definition:
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   535
\begin{isabelle}
23733
3f8ad7418e55 Adapted to new inductive definition package.
berghofe
parents: 21261
diff changeset
   536
\isacommand{inductive{\isacharunderscore}set}\isamarkupfalse%
3f8ad7418e55 Adapted to new inductive definition package.
berghofe
parents: 21261
diff changeset
   537
\isanewline
23848
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   538
\ \ well{\isacharunderscore}typed{\isacharunderscore}gterm\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharparenleft}{\isacharprime}f\ {\isasymRightarrow}\ {\isacharprime}t\ list\ {\isacharasterisk}\ {\isacharprime}t{\isacharparenright}\ {\isasymRightarrow}\ {\isacharparenleft}{\isacharprime}f\ gterm\ {\isacharasterisk}\ {\isacharprime}t{\isacharparenright}set{\isachardoublequoteclose}\isanewline
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   539
\ \ \isakeyword{for}\ sig\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharprime}f\ {\isasymRightarrow}\ {\isacharprime}t\ list\ {\isacharasterisk}\ {\isacharprime}t{\isachardoublequoteclose}%
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   540
\end{isabelle}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   541
\end{exercise}
ca73e86c22bb updated
berghofe
parents: 23733
diff changeset
   542
\end{isamarkuptext}
17056
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   543
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   544
\isadelimproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   545
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   546
\endisadelimproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   547
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   548
\isatagproof
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   549
%
17056
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   550
\endisatagproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   551
{\isafoldproof}%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   552
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   553
\isadelimproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   554
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   555
\endisadelimproof
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   556
%
17056
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   557
\isadelimproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   558
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   559
\endisadelimproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   560
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   561
\isatagproof
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   562
%
17056
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   563
\endisatagproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   564
{\isafoldproof}%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   565
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   566
\isadelimproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   567
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   568
\endisadelimproof
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   569
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   570
\isadelimtheory
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   571
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   572
\endisadelimtheory
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   573
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   574
\isatagtheory
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
   575
%
17056
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   576
\endisatagtheory
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   577
{\isafoldtheory}%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   578
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   579
\isadelimtheory
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   580
%
05fc32a23b8b updated;
wenzelm
parents: 16523
diff changeset
   581
\endisadelimtheory
11187
c6e49929e544 auto-update
paulson
parents: 11173
diff changeset
   582
\end{isabellebody}%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
   583
%%% Local Variables:
a17cf465d29a auto generated
paulson
parents:
diff changeset
   584
%%% mode: latex
a17cf465d29a auto generated
paulson
parents:
diff changeset
   585
%%% TeX-master: "root"
a17cf465d29a auto generated
paulson
parents:
diff changeset
   586
%%% End: