doc-src/TutorialI/Inductive/advanced-examples.tex
author paulson
Fri, 20 Apr 2001 11:11:40 +0200
changeset 11261 51bcafc7bfca
parent 11216 279004936bb0
child 11411 c315dda16748
permissions -rw-r--r--
suggestions from OHeimb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10879
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
     1
% $Id$
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
     2
The premises of introduction rules may contain universal quantifiers and
11173
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
     3
monotone functions.  A universal quantifier lets the rule 
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
     4
refer to any number of instances of 
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
     5
the inductively defined set.  A monotone function lets the rule refer
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
     6
to existing constructions (such as ``list of'') over the inductively defined
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
     7
set.  The examples below show how to use the additional expressiveness
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
     8
and how to reason from the resulting definitions.
10879
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
     9
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    10
\subsection{Universal Quantifiers in Introduction Rules}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    11
\label{sec:gterm-datatype}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    12
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    13
As a running example, this section develops the theory of \textbf{ground
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    14
terms}: terms constructed from constant and function 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    15
symbols but not variables. To simplify matters further, we regard a
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    16
constant as a function applied to the null argument  list.  Let us declare a
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    17
datatype \isa{gterm} for the type of ground  terms. It is a type constructor
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    18
whose argument is a type of  function symbols. 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    19
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    20
\isacommand{datatype}\ 'f\ gterm\ =\ Apply\ 'f\ "'f\ gterm\ list"
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    21
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    22
To try it out, we declare a datatype of some integer operations: 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    23
integer constants, the unary minus operator and the addition 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    24
operator. 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    25
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    26
\isacommand{datatype}\ integer_op\ =\ Number\ int\ |\ UnaryMinus\ |\ Plus
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    27
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    28
Now the type \isa{integer\_op gterm} denotes the ground 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    29
terms built over those symbols.
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    30
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    31
The type constructor \texttt{gterm} can be generalized to a function 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    32
over sets.  It returns 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    33
the set of ground terms that can be formed over a set \isa{F} of function symbols. For
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    34
example,  we could consider the set of ground terms formed from the finite 
10889
aed0a0450797 wrong font for braces
paulson
parents: 10879
diff changeset
    35
set \isa{\isacharbraceleft Number 2, UnaryMinus,
aed0a0450797 wrong font for braces
paulson
parents: 10879
diff changeset
    36
Plus\isacharbraceright}.
10879
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    37
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    38
This concept is inductive. If we have a list \isa{args} of ground terms 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    39
over~\isa{F} and a function symbol \isa{f} in \isa{F}, then we 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    40
can apply \isa{f} to  \isa{args} to obtain another ground term. 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    41
The only difficulty is that the argument list may be of any length. Hitherto, 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    42
each rule in an inductive definition referred to the inductively 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    43
defined set a fixed number of times, typically once or twice. 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    44
A universal quantifier in the premise of the introduction rule 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    45
expresses that every element of \isa{args} belongs
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    46
to our inductively defined set: is a ground term 
11173
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
    47
over~\isa{F}.  The function \isa{set} denotes the set of elements in a given 
10879
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    48
list. 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    49
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    50
\isacommand{consts}\ gterms\ ::\ "'f\ set\ \isasymRightarrow \ 'f\ gterm\ set"\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    51
\isacommand{inductive}\ "gterms\ F"\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    52
\isakeyword{intros}\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    53
step[intro!]:\ "\isasymlbrakk \isasymforall t\ \isasymin \ set\ args.\ t\ \isasymin \ gterms\ F;\ \ f\ \isasymin \ F\isasymrbrakk \isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    54
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \isasymLongrightarrow \ (Apply\ f\ args)\ \isasymin \ gterms\
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    55
F"
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    56
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    57
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    58
To demonstrate a proof from this definition, let us 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    59
show that the function \isa{gterms}
11173
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
    60
is \textbf{monotone}.  We shall need this concept shortly.
10879
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    61
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    62
\isacommand{lemma}\ gterms_mono:\ "F\isasymsubseteq G\ \isasymLongrightarrow \ gterms\ F\ \isasymsubseteq \ gterms\ G"\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    63
\isacommand{apply}\ clarify\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    64
\isacommand{apply}\ (erule\ gterms.induct)\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    65
\isacommand{apply}\ blast\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    66
\isacommand{done}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    67
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    68
Intuitively, this theorem says that
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    69
enlarging the set of function symbols enlarges the set of ground 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    70
terms. The proof is a trivial rule induction.
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    71
First we use the \isa{clarify} method to assume the existence of an element of
11147
d848c6693185 *** empty log message ***
nipkow
parents: 10978
diff changeset
    72
\isa{gterms~F}.  (We could have used \isa{intro subsetI}.)  We then
10879
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    73
apply rule induction. Here is the resulting subgoal: 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    74
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    75
\ 1.\ \isasymAnd x\ args\ f.\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    76
\ \ \ \ \ \ \ \isasymlbrakk F\ \isasymsubseteq \ G;\ \isasymforall t\isasymin set\ args.\ t\ \isasymin \ gterms\ F\ \isasymand \ t\ \isasymin \ gterms\ G;\ f\ \isasymin \ F\isasymrbrakk \isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    77
\ \ \ \ \ \ \ \isasymLongrightarrow \ Apply\ f\ args\ \isasymin \ gterms\ G%
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    78
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    79
%
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    80
The assumptions state that \isa{f} belongs 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    81
to~\isa{F}, which is included in~\isa{G}, and that every element of the list \isa{args} is
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    82
a ground term over~\isa{G}.  The \isa{blast} method finds this chain of reasoning easily.  
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    83
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    84
\begin{warn}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    85
Why do we call this function \isa{gterms} instead 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    86
of {\isa{gterm}}?  A constant may have the same name as a type.  However,
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    87
name  clashes could arise in the theorems that Isabelle generates. 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    88
Our choice of names keeps {\isa{gterms.induct}} separate from 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    89
{\isa{gterm.induct}}.
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    90
\end{warn}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
    91
11173
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
    92
Call a term \textbf{well-formed} if each symbol occurring in it is applied
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
    93
to the correct number of arguments.  (This number is called the symbol's
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
    94
\textbf{arity}.)  We can express well-formedness by
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
    95
generalizing the inductive definition of
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
    96
\isa{gterms}.
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
    97
Suppose we are given a function called \isa{arity}, specifying the arities
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
    98
of all symbols.  In the inductive step, we have a list \isa{args} of such
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
    99
terms and a function  symbol~\isa{f}. If the length of the list matches the
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   100
function's arity  then applying \isa{f} to \isa{args} yields a well-formed
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   101
term. 
10879
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   102
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   103
\isacommand{consts}\ well_formed_gterm\ ::\ "('f\ \isasymRightarrow \ nat)\ \isasymRightarrow \ 'f\ gterm\ set"\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   104
\isacommand{inductive}\ "well_formed_gterm\ arity"\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   105
\isakeyword{intros}\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   106
step[intro!]:\ "\isasymlbrakk \isasymforall t\ \isasymin \ set\ args.\ t\ \isasymin \ well_formed_gterm\ arity;\ \ \isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   107
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ length\ args\ =\ arity\ f\isasymrbrakk \isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   108
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \isasymLongrightarrow \ (Apply\ f\ args)\ \isasymin \ well_formed_gterm\
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   109
arity"
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   110
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   111
%
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   112
The inductive definition neatly captures the reasoning above.
11173
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   113
The universal quantification over the
10879
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   114
\isa{set} of arguments expresses that all of them are well-formed.
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   115
11173
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   116
11216
279004936bb0 *** empty log message ***
nipkow
parents: 11173
diff changeset
   117
\subsection{Alternative Definition Using a Monotone Function}
10879
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   118
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   119
An inductive definition may refer to the inductively defined 
11173
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   120
set through an arbitrary monotone function.  To demonstrate this
10879
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   121
powerful feature, let us
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   122
change the  inductive definition above, replacing the
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   123
quantifier by a use of the function \isa{lists}. This
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   124
function, from the Isabelle theory of lists, is analogous to the
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   125
function \isa{gterms} declared above: if \isa{A} is a set then
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   126
{\isa{lists A}} is the set of lists whose elements belong to
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   127
\isa{A}.  
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   128
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   129
In the inductive definition of well-formed terms, examine the one
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   130
introduction rule.  The first premise states that \isa{args} belongs to
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   131
the \isa{lists} of well-formed terms.  This formulation is more
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   132
direct, if more obscure, than using a universal quantifier.
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   133
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   134
\isacommand{consts}\ well_formed_gterm'\ ::\ "('f\ \isasymRightarrow \ nat)\ \isasymRightarrow \ 'f\ gterm\ set"\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   135
\isacommand{inductive}\ "well_formed_gterm'\ arity"\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   136
\isakeyword{intros}\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   137
step[intro!]:\ "\isasymlbrakk args\ \isasymin \ lists\ (well_formed_gterm'\ arity);\ \ \isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   138
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ length\ args\ =\ arity\ f\isasymrbrakk \isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   139
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \isasymLongrightarrow \ (Apply\ f\ args)\ \isasymin \ well_formed_gterm'\ arity"\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   140
\isakeyword{monos}\ lists_mono
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   141
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   142
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   143
We must cite the theorem \isa{lists_mono} in order to justify 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   144
using the function \isa{lists}. 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   145
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   146
A\ \isasymsubseteq\ B\ \isasymLongrightarrow \ lists\ A\ \isasymsubseteq
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   147
\ lists\ B\rulename{lists_mono}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   148
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   149
%
11173
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   150
Why must the function be monotone?  An inductive definition describes
10879
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   151
an iterative construction: each element of the set is constructed by a
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   152
finite number of introduction rule applications.  For example, the
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   153
elements of \isa{even} are constructed by finitely many applications of
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   154
the rules 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   155
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   156
0\ \isasymin \ even\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   157
n\ \isasymin \ even\ \isasymLongrightarrow \ (Suc\ (Suc\ n))\ \isasymin
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   158
\ even
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   159
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   160
All references to a set in its
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   161
inductive definition must be positive.  Applications of an
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   162
introduction rule cannot invalidate previous applications, allowing the
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   163
construction process to converge.
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   164
The following pair of rules do not constitute an inductive definition:
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   165
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   166
0\ \isasymin \ even\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   167
n\ \isasymnotin \ even\ \isasymLongrightarrow \ (Suc\ n)\ \isasymin
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   168
\ even
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   169
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   170
%
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   171
Showing that 4 is even using these rules requires showing that 3 is not
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   172
even.  It is far from trivial to show that this set of rules
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   173
characterizes the even numbers.  
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   174
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   175
Even with its use of the function \isa{lists}, the premise of our
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   176
introduction rule is positive:
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   177
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   178
args\ \isasymin \ lists\ (well_formed_gterm'\ arity)
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   179
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   180
To apply the rule we construct a list \isa{args} of previously
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   181
constructed well-formed terms.  We obtain a
11173
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   182
new term, \isa{Apply\ f\ args}.  Because \isa{lists} is monotone,
10879
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   183
applications of the rule remain valid as new terms are constructed.
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   184
Further lists of well-formed
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   185
terms become available and none are taken away.
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   186
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   187
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   188
\subsection{A Proof of Equivalence}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   189
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   190
We naturally hope that these two inductive definitions of ``well-formed'' 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   191
coincide.  The equality can be proved by separate inclusions in 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   192
each direction.  Each is a trivial rule induction. 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   193
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   194
\isacommand{lemma}\ "well_formed_gterm\ arity\ \isasymsubseteq \ well_formed_gterm'\ arity"\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   195
\isacommand{apply}\ clarify\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   196
\isacommand{apply}\ (erule\ well_formed_gterm.induct)\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   197
\isacommand{apply}\ auto\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   198
\isacommand{done}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   199
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   200
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   201
The \isa{clarify} method gives
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   202
us an element of \isa{well_formed_gterm\ arity} on which to perform 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   203
induction.  The resulting subgoal can be proved automatically:
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   204
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   205
{\isadigit{1}}{\isachardot}\ {\isasymAnd}x\ args\ f{\isachardot}\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   206
\ \ \ \ \ \ {\isasymlbrakk}{\isasymforall}t{\isasymin}set\ args{\isachardot}\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   207
\ \ \ \ \ \ \ \ \ \ t\ {\isasymin}\ well{\isacharunderscore}formed{\isacharunderscore}gterm\ arity\ {\isasymand}\ t\ {\isasymin}\ well{\isacharunderscore}formed{\isacharunderscore}gterm{\isacharprime}\ arity{\isacharsemicolon}\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   208
\ \ \ \ \ \ \ length\ args\ {\isacharequal}\ arity\ f{\isasymrbrakk}\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   209
\ \ \ \ \ \ {\isasymLongrightarrow}\ Apply\ f\ args\ {\isasymin}\ well{\isacharunderscore}formed{\isacharunderscore}gterm{\isacharprime}\ arity%
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   210
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   211
%
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   212
This proof resembles the one given in
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   213
{\S}\ref{sec:gterm-datatype} above, especially in the form of the
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   214
induction hypothesis.  Next, we consider the opposite inclusion:
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   215
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   216
\isacommand{lemma}\ "well_formed_gterm'\ arity\ \isasymsubseteq \ well_formed_gterm\ arity"\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   217
\isacommand{apply}\ clarify\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   218
\isacommand{apply}\ (erule\ well_formed_gterm'.induct)\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   219
\isacommand{apply}\ auto\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   220
\isacommand{done}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   221
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   222
%
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   223
The proof script is identical, but the subgoal after applying induction may
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   224
be surprising:
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   225
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   226
1.\ \isasymAnd x\ args\ f.\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   227
\ \ \ \ \ \ \isasymlbrakk args\ \isasymin \ lists\ (well_formed_gterm'\ arity\ \isasyminter\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   228
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \isacharbraceleft u.\ u\ \isasymin \ well_formed_gterm\ arity\isacharbraceright );\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   229
\ \ \ \ \ \ \ length\ args\ =\ arity\ f\isasymrbrakk \isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   230
\ \ \ \ \ \ \isasymLongrightarrow \ Apply\ f\ args\ \isasymin \ well_formed_gterm\ arity%
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   231
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   232
The induction hypothesis contains an application of \isa{lists}.  Using a
11173
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   233
monotone function in the inductive definition always has this effect.  The
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   234
subgoal may look uninviting, but fortunately 
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   235
\isa{lists} distributes over intersection:
10879
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   236
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   237
lists\ (A\ \isasyminter \ B)\ =\ lists\ A\ \isasyminter \ lists\ B
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   238
\rulename{lists_Int_eq}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   239
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   240
%
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   241
Thanks to this default simplification rule, the induction hypothesis 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   242
is quickly replaced by its two parts:
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   243
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   244
\ \ \ \ \ \ \ args\ \isasymin \ lists\ (well_formed_gterm'\ arity)\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   245
\ \ \ \ \ \ \ args\ \isasymin \ lists\ (well_formed_gterm\ arity)
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   246
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   247
Invoking the rule \isa{well_formed_gterm.step} completes the proof.  The
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   248
call to
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   249
\isa{auto} does all this work.
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   250
11173
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   251
This example is typical of how monotone functions can be used.  In
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   252
particular, many of them distribute over intersection.  Monotonicity
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   253
implies one direction of this set equality; we have this theorem:
10879
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   254
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   255
mono\ f\ \isasymLongrightarrow \ f\ (A\ \isasyminter \ B)\ \isasymsubseteq \
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   256
f\ A\ \isasyminter \ f\ B%
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   257
\rulename{mono_Int}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   258
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   259
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   260
11173
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   261
\subsection{Another Example of Rule Inversion}
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   262
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   263
Does \isa{gterms} distribute over intersection?  We have proved that this
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   264
function is monotone, so \isa{mono_Int} gives one of the inclusions.  The
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   265
opposite inclusion asserts that if \isa{t} is a ground term over both of the
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   266
sets
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   267
\isa{F} and~\isa{G} then it is also a ground term over their intersection,
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   268
\isa{F\isasyminter G}.
11261
51bcafc7bfca suggestions from OHeimb
paulson
parents: 11216
diff changeset
   269
\begin{isabelle}
51bcafc7bfca suggestions from OHeimb
paulson
parents: 11216
diff changeset
   270
\isacommand{lemma}\ gterms_IntI:\isanewline
51bcafc7bfca suggestions from OHeimb
paulson
parents: 11216
diff changeset
   271
\ \ \ \ \ "t\ \isasymin \ gterms\ F\ \isasymLongrightarrow \ t\ \isasymin \ gterms\ G\ \isasymlongrightarrow \ t\ \isasymin \ gterms\ (F\isasyminter
51bcafc7bfca suggestions from OHeimb
paulson
parents: 11216
diff changeset
   272
G)"
51bcafc7bfca suggestions from OHeimb
paulson
parents: 11216
diff changeset
   273
\end{isabelle}
11173
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   274
Attempting this proof, we get the assumption 
11261
51bcafc7bfca suggestions from OHeimb
paulson
parents: 11216
diff changeset
   275
\isa{Apply\ f\ args\ \isasymin\ gterms\ G}, which cannot be broken down. 
11173
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   276
It looks like a job for rule inversion:
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   277
\begin{isabelle}
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   278
\isacommand{inductive\_cases}\ gterm_Apply_elim\ [elim!]:\ "Apply\ f\ args\
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   279
\isasymin\ gterms\ F"
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   280
\end{isabelle}
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   281
%
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   282
Here is the result.
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   283
\begin{isabelle}
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   284
\isasymlbrakk Apply\ f\ args\ \isasymin \ gterms\ F;\isanewline
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   285
\ \isasymlbrakk
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   286
\isasymforall t\isasymin set\ args.\ t\ \isasymin \ gterms\ F;\ f\ \isasymin
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   287
\ F\isasymrbrakk \ \isasymLongrightarrow \ P\isasymrbrakk\isanewline
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   288
\isasymLongrightarrow \ P%
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   289
\rulename{gterm_Apply_elim}
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   290
\end{isabelle}
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   291
This rule replaces an assumption about \isa{Apply\ f\ args} by 
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   292
assumptions about \isa{f} and~\isa{args}.  
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   293
No cases are discarded (there was only one to begin
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   294
with) but the rule applies specifically to the pattern \isa{Apply\ f\ args}.
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   295
It can be applied repeatedly as an elimination rule without looping, so we
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   296
have given the
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   297
\isa{elim!}\ attribute. 
10879
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   298
11173
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   299
Now we can prove the other half of that distributive law.
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   300
\begin{isabelle}
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   301
\isacommand{lemma}\ gterms_IntI\ [rule_format,\ intro!]:\isanewline
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   302
\ \ \ \ \ "t\ \isasymin \ gterms\ F\ \isasymLongrightarrow \ t\ \isasymin \ gterms\ G\ \isasymlongrightarrow \ t\ \isasymin \ gterms\ (F\isasyminter G)"\isanewline
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   303
\isacommand{apply}\ (erule\ gterms.induct)\isanewline
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   304
\isacommand{apply}\ blast\isanewline
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   305
\isacommand{done}
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   306
\end{isabelle}
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   307
%
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   308
The proof begins with rule induction over the definition of
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   309
\isa{gterms}, which leaves a single subgoal:  
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   310
\begin{isabelle}
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   311
1.\ \isasymAnd args\ f.\isanewline
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   312
\ \ \ \ \ \ \isasymlbrakk \isasymforall t\isasymin set\ args.\ t\ \isasymin \ gterms\ F\ \isasymand\isanewline
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   313
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (t\ \isasymin \ gterms\ G\ \isasymlongrightarrow \ t\ \isasymin \ gterms\ (F\ \isasyminter \ G));\isanewline
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   314
\ \ \ \ \ \ \ f\ \isasymin \ F\isasymrbrakk \isanewline
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   315
\ \ \ \ \ \ \isasymLongrightarrow \ Apply\ f\ args\ \isasymin \ gterms\ G\ \isasymlongrightarrow \ Apply\ f\ args\ \isasymin \ gterms\ (F\ \isasyminter \ G)
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   316
\end{isabelle}
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   317
%
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   318
To prove this, we assume \isa{Apply\ f\ args\ \isasymin \
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   319
gterms\ G}.  Rule inversion, in the form of \isa{gterm_Apply_elim}, infers
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   320
that every element of \isa{args} belongs to 
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   321
\isa{gterms~G}; hence (by the induction hypothesis) it belongs
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   322
to \isa{gterms\ (F\ \isasyminter \ G)}.  Rule inversion also yields
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   323
\isa{f\ \isasymin\ G} and hence \isa{f\ \isasymin \ F\ \isasyminter \ G}. 
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   324
All of this reasoning is done by \isa{blast}.
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   325
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   326
\smallskip
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   327
Our distributive law is a trivial consequence of previously-proved results:
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   328
\begin{isabelle}
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   329
\isacommand{theorem}\ gterms_Int_eq\ [simp]:\isanewline
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   330
\ \ \ \ \ "gterms\ (F\isasyminter G)\ =\ gterms\ F\ \isasyminter \ gterms\ G"\isanewline
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   331
\isacommand{by}\ (blast\ intro!:\ mono_Int\ monoI\ gterms_mono)
094b76968484 revisions in response to comments by Tobias
paulson
parents: 11147
diff changeset
   332
\end{isabelle}
10879
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   333
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   334
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   335
\begin{exercise}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   336
A function mapping function symbols to their 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   337
types is called a \textbf{signature}.  Given a type 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   338
ranging over type symbols, we can represent a function's type by a
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   339
list of argument types paired with the result type. 
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   340
Complete this inductive definition:
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   341
\begin{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   342
\isacommand{consts}\ well_typed_gterm::\ "('f\ \isasymRightarrow \ 't\ list\ *\ 't)\ \isasymRightarrow \ ('f\ gterm\ *\ 't)set"\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   343
\isacommand{inductive}\ "well_typed_gterm\ sig"\isanewline
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   344
\end{isabelle}
ca2b00c4bba7 renaming to avoid clashes
paulson
parents:
diff changeset
   345
\end{exercise}