10365
|
1 |
%
|
|
2 |
\begin{isabellebody}%
|
|
3 |
\def\isabellecontext{Even}%
|
|
4 |
\isanewline
|
10878
|
5 |
\isacommand{theory}\ Even\ {\isacharequal}\ Main{\isacharcolon}\isanewline
|
|
6 |
\isanewline
|
|
7 |
\isanewline
|
11866
|
8 |
\isamarkupfalse%
|
10365
|
9 |
\isacommand{consts}\ even\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}nat\ set{\isachardoublequote}\isanewline
|
11866
|
10 |
\isamarkupfalse%
|
10365
|
11 |
\isacommand{inductive}\ even\isanewline
|
|
12 |
\isakeyword{intros}\isanewline
|
|
13 |
zero{\isacharbrackleft}intro{\isacharbang}{\isacharbrackright}{\isacharcolon}\ {\isachardoublequote}{\isadigit{0}}\ {\isasymin}\ even{\isachardoublequote}\isanewline
|
11866
|
14 |
step{\isacharbrackleft}intro{\isacharbang}{\isacharbrackright}{\isacharcolon}\ {\isachardoublequote}n\ {\isasymin}\ even\ {\isasymLongrightarrow}\ {\isacharparenleft}Suc\ {\isacharparenleft}Suc\ n{\isacharparenright}{\isacharparenright}\ {\isasymin}\ even{\isachardoublequote}\isamarkupfalse%
|
|
15 |
%
|
10365
|
16 |
\begin{isamarkuptext}%
|
10878
|
17 |
An inductive definition consists of introduction rules.
|
10365
|
18 |
|
|
19 |
\begin{isabelle}%
|
14470
|
20 |
\ \ \ \ \ n\ {\isasymin}\ Even{\isachardot}even\ {\isasymLongrightarrow}\ Suc\ {\isacharparenleft}Suc\ n{\isacharparenright}\ {\isasymin}\ Even{\isachardot}even%
|
10365
|
21 |
\end{isabelle}
|
|
22 |
\rulename{even.step}
|
|
23 |
|
|
24 |
\begin{isabelle}%
|
14470
|
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
|
|
26 |
\isaindent{\ \ \ \ \ }{\isasymLongrightarrow}\ P\ xa%
|
10365
|
27 |
\end{isabelle}
|
|
28 |
\rulename{even.induct}
|
|
29 |
|
|
30 |
Attributes can be given to the introduction rules. Here both rules are
|
10878
|
31 |
specified as \isa{intro!}
|
|
32 |
|
|
33 |
Our first lemma states that numbers of the form $2\times k$ are even.%
|
10365
|
34 |
\end{isamarkuptext}%
|
11866
|
35 |
\isamarkuptrue%
|
11708
|
36 |
\isacommand{lemma}\ two{\isacharunderscore}times{\isacharunderscore}even{\isacharbrackleft}intro{\isacharbang}{\isacharbrackright}{\isacharcolon}\ {\isachardoublequote}{\isadigit{2}}{\isacharasterisk}k\ {\isasymin}\ even{\isachardoublequote}\isanewline
|
11866
|
37 |
\isamarkupfalse%
|
|
38 |
\isamarkupfalse%
|
15481
|
39 |
\isamarkuptrue%
|
|
40 |
\isamarkupfalse%
|
|
41 |
\isamarkupfalse%
|
11866
|
42 |
%
|
10365
|
43 |
\begin{isamarkuptext}%
|
|
44 |
Our goal is to prove the equivalence between the traditional definition
|
|
45 |
of even (using the divides relation) and our inductive definition. Half of
|
|
46 |
this equivalence is trivial using the lemma just proved, whose \isa{intro!}
|
|
47 |
attribute ensures it will be applied automatically.%
|
|
48 |
\end{isamarkuptext}%
|
11866
|
49 |
\isamarkuptrue%
|
11708
|
50 |
\isacommand{lemma}\ dvd{\isacharunderscore}imp{\isacharunderscore}even{\isacharcolon}\ {\isachardoublequote}{\isadigit{2}}\ dvd\ n\ {\isasymLongrightarrow}\ n\ {\isasymin}\ even{\isachardoublequote}\isanewline
|
11866
|
51 |
\isamarkupfalse%
|
15481
|
52 |
\isamarkupfalse%
|
11866
|
53 |
%
|
10365
|
54 |
\begin{isamarkuptext}%
|
|
55 |
our first rule induction!%
|
|
56 |
\end{isamarkuptext}%
|
11866
|
57 |
\isamarkuptrue%
|
11708
|
58 |
\isacommand{lemma}\ even{\isacharunderscore}imp{\isacharunderscore}dvd{\isacharcolon}\ {\isachardoublequote}n\ {\isasymin}\ even\ {\isasymLongrightarrow}\ {\isadigit{2}}\ dvd\ n{\isachardoublequote}\isanewline
|
11866
|
59 |
\isamarkupfalse%
|
15481
|
60 |
\isamarkupfalse%
|
|
61 |
\isamarkuptrue%
|
|
62 |
\isamarkupfalse%
|
11866
|
63 |
\isamarkuptrue%
|
15481
|
64 |
\isamarkupfalse%
|
11866
|
65 |
\isamarkuptrue%
|
|
66 |
\isamarkupfalse%
|
15481
|
67 |
\isamarkupfalse%
|
11866
|
68 |
%
|
10365
|
69 |
\begin{isamarkuptext}%
|
|
70 |
no iff-attribute because we don't always want to use it%
|
|
71 |
\end{isamarkuptext}%
|
11866
|
72 |
\isamarkuptrue%
|
11708
|
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
|
74 |
\isamarkupfalse%
|
15481
|
75 |
\isamarkupfalse%
|
11866
|
76 |
%
|
10365
|
77 |
\begin{isamarkuptext}%
|
|
78 |
this result ISN'T inductive...%
|
|
79 |
\end{isamarkuptext}%
|
11866
|
80 |
\isamarkuptrue%
|
10365
|
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
|
82 |
\isamarkupfalse%
|
15481
|
83 |
\isamarkupfalse%
|
11866
|
84 |
\isamarkuptrue%
|
15481
|
85 |
\isamarkupfalse%
|
11866
|
86 |
%
|
10365
|
87 |
\begin{isamarkuptext}%
|
|
88 |
...so we need an inductive lemma...%
|
|
89 |
\end{isamarkuptext}%
|
11866
|
90 |
\isamarkuptrue%
|
11708
|
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
|
92 |
\isamarkupfalse%
|
15481
|
93 |
\isamarkupfalse%
|
11866
|
94 |
\isamarkuptrue%
|
|
95 |
\isamarkupfalse%
|
15481
|
96 |
\isamarkupfalse%
|
11866
|
97 |
%
|
10365
|
98 |
\begin{isamarkuptext}%
|
|
99 |
...and prove it in a separate step%
|
|
100 |
\end{isamarkuptext}%
|
11866
|
101 |
\isamarkuptrue%
|
10365
|
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
|
103 |
\isamarkupfalse%
|
15481
|
104 |
\isanewline
|
10878
|
105 |
\isanewline
|
11866
|
106 |
\isamarkupfalse%
|
10365
|
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
|
108 |
\isamarkupfalse%
|
15481
|
109 |
\isanewline
|
11866
|
110 |
\isamarkupfalse%
|
10365
|
111 |
\isacommand{end}\isanewline
|
|
112 |
\isanewline
|
11866
|
113 |
\isamarkupfalse%
|
10365
|
114 |
\end{isabellebody}%
|
|
115 |
%%% Local Variables:
|
|
116 |
%%% mode: latex
|
|
117 |
%%% TeX-master: "root"
|
|
118 |
%%% End:
|