doc-src/TutorialI/Inductive/document/Even.tex
author haftmann
Mon, 02 May 2005 10:56:13 +0200
changeset 15904 a6fb4ddc05c7
parent 15614 b098158a3f39
child 16069 3f2a9f400168
permissions -rw-r--r--
introduced @{const ...} antiquotation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
     1
%
a17cf465d29a auto generated
paulson
parents:
diff changeset
     2
\begin{isabellebody}%
a17cf465d29a auto generated
paulson
parents:
diff changeset
     3
\def\isabellecontext{Even}%
a17cf465d29a auto generated
paulson
parents:
diff changeset
     4
\isanewline
10878
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
     5
\isacommand{theory}\ Even\ {\isacharequal}\ Main{\isacharcolon}\isanewline
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
     6
\isanewline
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
     7
\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
     8
\isamarkupfalse%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
     9
\isacommand{consts}\ even\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}nat\ set{\isachardoublequote}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    10
\isamarkupfalse%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
    11
\isacommand{inductive}\ even\isanewline
a17cf465d29a auto generated
paulson
parents:
diff changeset
    12
\isakeyword{intros}\isanewline
a17cf465d29a auto generated
paulson
parents:
diff changeset
    13
zero{\isacharbrackleft}intro{\isacharbang}{\isacharbrackright}{\isacharcolon}\ {\isachardoublequote}{\isadigit{0}}\ {\isasymin}\ even{\isachardoublequote}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    14
step{\isacharbrackleft}intro{\isacharbang}{\isacharbrackright}{\isacharcolon}\ {\isachardoublequote}n\ {\isasymin}\ even\ {\isasymLongrightarrow}\ {\isacharparenleft}Suc\ {\isacharparenleft}Suc\ n{\isacharparenright}{\isacharparenright}\ {\isasymin}\ even{\isachardoublequote}\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    15
%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
    16
\begin{isamarkuptext}%
10878
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
    17
An inductive definition consists of introduction rules. 
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
    18
a17cf465d29a auto generated
paulson
parents:
diff changeset
    19
\begin{isabelle}%
14470
1ffe42cfaefe auto update
paulson
parents: 12328
diff changeset
    20
\ \ \ \ \ n\ {\isasymin}\ Even{\isachardot}even\ {\isasymLongrightarrow}\ Suc\ {\isacharparenleft}Suc\ n{\isacharparenright}\ {\isasymin}\ Even{\isachardot}even%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
    21
\end{isabelle}
a17cf465d29a auto generated
paulson
parents:
diff changeset
    22
\rulename{even.step}
a17cf465d29a auto generated
paulson
parents:
diff changeset
    23
a17cf465d29a auto generated
paulson
parents:
diff changeset
    24
\begin{isabelle}%
14470
1ffe42cfaefe auto update
paulson
parents: 12328
diff changeset
    25
\ \ \ \ \ {\isasymlbrakk}xa\ {\isasymin}\ Even{\isachardot}even{\isacharsemicolon}\ P\ {\isadigit{0}}{\isacharsemicolon}\ {\isasymAnd}n{\isachardot}\ {\isasymlbrakk}n\ {\isasymin}\ Even{\isachardot}even{\isacharsemicolon}\ P\ n{\isasymrbrakk}\ {\isasymLongrightarrow}\ P\ {\isacharparenleft}Suc\ {\isacharparenleft}Suc\ n{\isacharparenright}{\isacharparenright}{\isasymrbrakk}\isanewline
1ffe42cfaefe auto update
paulson
parents: 12328
diff changeset
    26
\isaindent{\ \ \ \ \ }{\isasymLongrightarrow}\ P\ xa%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
    27
\end{isabelle}
a17cf465d29a auto generated
paulson
parents:
diff changeset
    28
\rulename{even.induct}
a17cf465d29a auto generated
paulson
parents:
diff changeset
    29
a17cf465d29a auto generated
paulson
parents:
diff changeset
    30
Attributes can be given to the introduction rules.  Here both rules are
10878
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
    31
specified as \isa{intro!}
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
    32
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
    33
Our first lemma states that numbers of the form $2\times k$ are even.%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
    34
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    35
\isamarkuptrue%
11708
d27253c4594f *** empty log message ***
wenzelm
parents: 10878
diff changeset
    36
\isacommand{lemma}\ two{\isacharunderscore}times{\isacharunderscore}even{\isacharbrackleft}intro{\isacharbang}{\isacharbrackright}{\isacharcolon}\ {\isachardoublequote}{\isadigit{2}}{\isacharasterisk}k\ {\isasymin}\ even{\isachardoublequote}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    37
\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    38
\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14470
diff changeset
    39
\isamarkuptrue%
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14470
diff changeset
    40
\isamarkupfalse%
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14470
diff changeset
    41
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    42
%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
    43
\begin{isamarkuptext}%
a17cf465d29a auto generated
paulson
parents:
diff changeset
    44
Our goal is to prove the equivalence between the traditional definition
a17cf465d29a auto generated
paulson
parents:
diff changeset
    45
of even (using the divides relation) and our inductive definition.  Half of
a17cf465d29a auto generated
paulson
parents:
diff changeset
    46
this equivalence is trivial using the lemma just proved, whose \isa{intro!}
a17cf465d29a auto generated
paulson
parents:
diff changeset
    47
attribute ensures it will be applied automatically.%
a17cf465d29a auto generated
paulson
parents:
diff changeset
    48
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    49
\isamarkuptrue%
11708
d27253c4594f *** empty log message ***
wenzelm
parents: 10878
diff changeset
    50
\isacommand{lemma}\ dvd{\isacharunderscore}imp{\isacharunderscore}even{\isacharcolon}\ {\isachardoublequote}{\isadigit{2}}\ dvd\ n\ {\isasymLongrightarrow}\ n\ {\isasymin}\ even{\isachardoublequote}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    51
\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14470
diff changeset
    52
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    53
%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
    54
\begin{isamarkuptext}%
a17cf465d29a auto generated
paulson
parents:
diff changeset
    55
our first rule induction!%
a17cf465d29a auto generated
paulson
parents:
diff changeset
    56
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    57
\isamarkuptrue%
11708
d27253c4594f *** empty log message ***
wenzelm
parents: 10878
diff changeset
    58
\isacommand{lemma}\ even{\isacharunderscore}imp{\isacharunderscore}dvd{\isacharcolon}\ {\isachardoublequote}n\ {\isasymin}\ even\ {\isasymLongrightarrow}\ {\isadigit{2}}\ dvd\ n{\isachardoublequote}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    59
\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14470
diff changeset
    60
\isamarkupfalse%
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14470
diff changeset
    61
\isamarkuptrue%
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14470
diff changeset
    62
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    63
\isamarkuptrue%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14470
diff changeset
    64
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    65
\isamarkuptrue%
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    66
\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14470
diff changeset
    67
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    68
%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
    69
\begin{isamarkuptext}%
a17cf465d29a auto generated
paulson
parents:
diff changeset
    70
no iff-attribute because we don't always want to use it%
a17cf465d29a auto generated
paulson
parents:
diff changeset
    71
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    72
\isamarkuptrue%
11708
d27253c4594f *** empty log message ***
wenzelm
parents: 10878
diff changeset
    73
\isacommand{theorem}\ even{\isacharunderscore}iff{\isacharunderscore}dvd{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}n\ {\isasymin}\ even{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}{\isadigit{2}}\ dvd\ n{\isacharparenright}{\isachardoublequote}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    74
\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14470
diff changeset
    75
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    76
%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
    77
\begin{isamarkuptext}%
a17cf465d29a auto generated
paulson
parents:
diff changeset
    78
this result ISN'T inductive...%
a17cf465d29a auto generated
paulson
parents:
diff changeset
    79
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    80
\isamarkuptrue%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
    81
\isacommand{lemma}\ Suc{\isacharunderscore}Suc{\isacharunderscore}even{\isacharunderscore}imp{\isacharunderscore}even{\isacharcolon}\ {\isachardoublequote}Suc\ {\isacharparenleft}Suc\ n{\isacharparenright}\ {\isasymin}\ even\ {\isasymLongrightarrow}\ n\ {\isasymin}\ even{\isachardoublequote}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    82
\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14470
diff changeset
    83
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    84
\isamarkuptrue%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14470
diff changeset
    85
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    86
%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
    87
\begin{isamarkuptext}%
a17cf465d29a auto generated
paulson
parents:
diff changeset
    88
...so we need an inductive lemma...%
a17cf465d29a auto generated
paulson
parents:
diff changeset
    89
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    90
\isamarkuptrue%
11708
d27253c4594f *** empty log message ***
wenzelm
parents: 10878
diff changeset
    91
\isacommand{lemma}\ even{\isacharunderscore}imp{\isacharunderscore}even{\isacharunderscore}minus{\isacharunderscore}{\isadigit{2}}{\isacharcolon}\ {\isachardoublequote}n\ {\isasymin}\ even\ {\isasymLongrightarrow}\ n\ {\isacharminus}\ {\isadigit{2}}\ {\isasymin}\ even{\isachardoublequote}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    92
\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14470
diff changeset
    93
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    94
\isamarkuptrue%
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    95
\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14470
diff changeset
    96
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    97
%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
    98
\begin{isamarkuptext}%
a17cf465d29a auto generated
paulson
parents:
diff changeset
    99
...and prove it in a separate step%
a17cf465d29a auto generated
paulson
parents:
diff changeset
   100
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   101
\isamarkuptrue%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
   102
\isacommand{lemma}\ Suc{\isacharunderscore}Suc{\isacharunderscore}even{\isacharunderscore}imp{\isacharunderscore}even{\isacharcolon}\ {\isachardoublequote}Suc\ {\isacharparenleft}Suc\ n{\isacharparenright}\ {\isasymin}\ even\ {\isasymLongrightarrow}\ n\ {\isasymin}\ even{\isachardoublequote}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   103
\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14470
diff changeset
   104
\isanewline
10878
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
   105
\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   106
\isamarkupfalse%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
   107
\isacommand{lemma}\ {\isacharbrackleft}iff{\isacharbrackright}{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}{\isacharparenleft}Suc\ {\isacharparenleft}Suc\ n{\isacharparenright}{\isacharparenright}\ {\isasymin}\ even{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}n\ {\isasymin}\ even{\isacharparenright}{\isachardoublequote}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   108
\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14470
diff changeset
   109
\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   110
\isamarkupfalse%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
   111
\isacommand{end}\isanewline
a17cf465d29a auto generated
paulson
parents:
diff changeset
   112
\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   113
\isamarkupfalse%
10365
a17cf465d29a auto generated
paulson
parents:
diff changeset
   114
\end{isabellebody}%
a17cf465d29a auto generated
paulson
parents:
diff changeset
   115
%%% Local Variables:
a17cf465d29a auto generated
paulson
parents:
diff changeset
   116
%%% mode: latex
a17cf465d29a auto generated
paulson
parents:
diff changeset
   117
%%% TeX-master: "root"
a17cf465d29a auto generated
paulson
parents:
diff changeset
   118
%%% End: