author | Cezary Kaliszyk <kaliszyk@in.tum.de> |
Tue, 25 Jan 2011 02:46:05 +0900 | |
changeset 2705 | 67451725fb41 |
parent 2692 | da9bed7baf23 |
child 2706 | 8ae1c2e6369e |
permissions | -rw-r--r-- |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
header {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
3 |
|
2687
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
4 |
Nominal Isabelle Tutorial at POPL'11 |
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
5 |
==================================== |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
6 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
7 |
Nominal Isabelle is a definitional extension of Isabelle/HOL, which |
2689 | 8 |
means it does not add any new axioms to higher-order logic. It just |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
9 |
adds new definitions and an infrastructure for 'nominal resoning'. |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
10 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
11 |
|
2687
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
12 |
The jEdit Interface |
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
13 |
------------------- |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
14 |
|
2689 | 15 |
The Isabelle theorem prover comes with an interface for jEdit. |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
16 |
Unlike many other theorem prover interfaces (e.g. ProofGeneral) where you |
2689 | 17 |
advance a 'checked' region in a proof script, this interface immediately |
18 |
checks the whole buffer. The text you type is also immediately checked. |
|
19 |
Malformed text or unfinished proofs are highlighted in red with a little |
|
20 |
red 'stop' signal on the left-hand side. If you drag the 'red-box' cursor |
|
21 |
over a line, the Output window gives further feedback. |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
22 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
23 |
Note: If a section is not parsed correctly, the work-around is to cut it |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
24 |
out and paste it back into the text (cut-out: Ctrl + X; paste in: Ctrl + V; |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
25 |
Cmd is Ctrl on the Mac) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
26 |
|
2689 | 27 |
Nominal Isabelle and jEdit can be started by typing on the command line |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
28 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
29 |
isabelle jedit -l HOL-Nominal2 |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
30 |
isabelle jedit -l HOL-Nominal2 A.thy B.thy ... |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
31 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
32 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
33 |
Symbols |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
34 |
------- |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
35 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
36 |
Symbols can considerably improve the readability of your statements and proofs. |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
37 |
They can be input by just typing 'name-of-symbol' where 'name-of-symbol' is the |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
38 |
usual latex name of that symbol. A little window will then appear in which |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
39 |
you can select the symbol. With `Escape' you can ignore any suggestion. |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
40 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
41 |
There are some handy short-cuts for frequently used symbols. |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
42 |
For example |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
43 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
44 |
short-cut symbol |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
45 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
46 |
=> \<Rightarrow> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
47 |
==> \<Longrightarrow> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
48 |
--> \<longrightarrow> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
49 |
! \<forall> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
50 |
? \<exists> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
51 |
/\ \<and> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
52 |
\/ \<or> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
53 |
~ \<not> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
54 |
~= \<noteq> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
55 |
: \<in> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
56 |
~: \<notin> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
57 |
|
2689 | 58 |
For nominal the following two symbols have a special meaning |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
59 |
|
2689 | 60 |
\<sharp> sharp (freshness) |
61 |
\<bullet> bullet (permutation application) |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
62 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
63 |
|
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
64 |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
65 |
theory Tutorial1 |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
66 |
imports Lambda |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
67 |
begin |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
68 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
69 |
section {* Theories *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
70 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
71 |
text {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
72 |
All formal developments in Isabelle are part of a theory. A theory |
2687
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
73 |
needs to have a name and must import some pre-existing theory. The |
2689 | 74 |
imported theory will normally be Nominal2 (which provides many useful |
75 |
concepts like set-theory, lists, nominal things etc). For the purpose |
|
76 |
of this tutorial we import the theory Lambda.thy, which contains |
|
77 |
already some useful definitions for (alpha-equated) lambda terms. |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
78 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
79 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
80 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
81 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
82 |
section {* Types *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
83 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
84 |
text {* |
2687
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
85 |
Isabelle is based on simple types including some polymorphism. It also |
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
86 |
includes overloading, which means that sometimes explicit type annotations |
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
87 |
need to be given. |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
88 |
|
2687
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
89 |
- Base types include: nat, bool, string, lam (defined in the Lambda theory) |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
90 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
91 |
- Type formers include: 'a list, ('a \<times> 'b), 'c set |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
92 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
93 |
- Type variables are written like in ML with an apostrophe: 'a, 'b, \<dots> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
94 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
95 |
Types known to Isabelle can be queried using the command "typ". |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
96 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
97 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
98 |
typ nat |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
99 |
typ bool |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
100 |
typ string |
2687
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
101 |
typ lam -- {* alpha-equated lambda terms defined in Lambda.thy *} |
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
102 |
typ name -- {* type of (object) variables defined in Lambda.thy *} |
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
103 |
typ "('a \<times> 'b)" -- {* pair type *} |
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
104 |
typ "'c set" -- {* set type *} |
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
105 |
typ "'a list" -- {* list type *} |
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
106 |
typ "lam \<Rightarrow> nat" -- {* type of functions from lambda terms to natural numbers *} |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
107 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
108 |
|
2687
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
109 |
text {* Some malformed types - note the "stop" signal on the left margin *} |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
110 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
111 |
(* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
112 |
typ boolean -- {* undeclared type *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
113 |
typ set -- {* type argument missing *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
114 |
*) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
115 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
116 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
117 |
section {* Terms *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
118 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
119 |
text {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
120 |
Every term in Isabelle needs to be well-typed. However they can have |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
121 |
polymorphic type. Whether a term is accepted can be queried using |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
122 |
the command "term". |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
123 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
124 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
125 |
term c -- {* a variable of polymorphic type *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
126 |
term "1::nat" -- {* the constant 1 in natural numbers *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
127 |
term 1 -- {* the constant 1 with polymorphic type *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
128 |
term "{1, 2, 3::nat}" -- {* the set containing natural numbers 1, 2 and 3 *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
129 |
term "[1, 2, 3]" -- {* the list containing the polymorphic numbers 1, 2 and 3 *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
130 |
term "(True, ''c'')" -- {* a pair consisting of the boolean true and the string "c" *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
131 |
term "Suc 0" -- {* successor of 0, in other words 1::nat *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
132 |
term "Lam [x].Var x" -- {* a lambda-term *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
133 |
term "App t1 t2" -- {* another lambda-term *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
134 |
term "x::name" -- {* an (object) variable of type name *} |
2705 | 135 |
term "atom (x::name)" -- {* atom is an overloaded function *} |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
136 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
137 |
text {* |
2689 | 138 |
Lam [x].Var is the syntax we made up for lambda abstractions. If you |
139 |
prefer, you can have your own syntax (but \<lambda> is already taken up for |
|
140 |
Isabelle's functions). We also came up with the type "name" for variables. |
|
141 |
You can introduce your own types of object variables using the |
|
142 |
command atom_decl: |
|
143 |
*} |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
144 |
|
2689 | 145 |
atom_decl ident |
146 |
atom_decl ty_var |
|
147 |
||
148 |
text {* |
|
2687
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
149 |
Isabelle provides some useful colour feedback about its constants (black), |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
150 |
free variables (blue) and bound variables (green). |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
151 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
152 |
|
2689 | 153 |
term "True" -- {* a constant defined somewhere...written in black *} |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
154 |
term "true" -- {* not recognised as a constant, therefore it is interpreted |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
155 |
as a free variable, written in blue *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
156 |
term "\<forall>x. P x" -- {* x is bound (green), P is free (blue) *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
157 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
158 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
159 |
text {* Formulae in Isabelle/HOL are terms of type bool *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
160 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
161 |
term "True" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
162 |
term "True \<and> False" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
163 |
term "True \<or> B" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
164 |
term "{1,2,3} = {3,2,1}" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
165 |
term "\<forall>x. P x" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
166 |
term "A \<longrightarrow> B" |
2687
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
167 |
term "atom a \<sharp> t" -- {* freshness in Nominal *} |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
168 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
169 |
text {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
170 |
When working with Isabelle, one deals with an object logic (that is HOL) and |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
171 |
Isabelle's rule framework (called Pure). Occasionally one has to pay attention |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
172 |
to this fact. But for the moment we ignore this completely. |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
173 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
174 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
175 |
term "A \<longrightarrow> B" -- {* versus *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
176 |
term "A \<Longrightarrow> B" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
177 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
178 |
term "\<forall>x. P x" -- {* versus *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
179 |
term "\<And>x. P x" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
180 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
181 |
|
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
182 |
section {* Inductive Definitions: Evaluation Relation *} |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
183 |
|
2687
d0fb94035969
first split of tutorrial theory
Christian Urban <urbanc@in.tum.de>
parents:
2686
diff
changeset
|
184 |
text {* |
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
185 |
In this section we want to define inductively the evaluation |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
186 |
relation for lambda terms. |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
187 |
|
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
188 |
Inductive definitions in Isabelle start with the keyword "inductive" |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
189 |
and a predicate name. One can optionally provide a type for the predicate. |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
190 |
Clauses of the inductive predicate are introduced by "where" and more than |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
191 |
two clauses need to be separated by "|". One can also give a name to each |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
192 |
clause and indicate that it should be added to the hints database ("[intro]"). |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
193 |
A typical clause has some premises and a conclusion. This is written in |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
194 |
Isabelle as: |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
195 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
196 |
"premise \<Longrightarrow> conclusion" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
197 |
"premise1 \<Longrightarrow> premise2 \<Longrightarrow> \<dots> premisen \<Longrightarrow> conclusion" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
198 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
199 |
There is an alternative way of writing the latter clause as |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
200 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
201 |
"\<lbrakk>premise1; premise2; \<dots> premisen\<rbrakk> \<Longrightarrow> conclusion" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
202 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
203 |
If no premise is present, then one just writes |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
204 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
205 |
"conclusion" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
206 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
207 |
Below we give two definitions for the transitive closure |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
208 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
209 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
210 |
inductive |
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
211 |
eval :: "lam \<Rightarrow> lam \<Rightarrow> bool" ("_ \<Down> _" [60, 60] 60) |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
212 |
where |
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
213 |
e_Lam[intro]: "Lam [x].t \<Down> Lam [x].t" |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
214 |
| e_App[intro]: "\<lbrakk>t1 \<Down> Lam [x].t; t2 \<Down> v'; t[x::=v'] \<Down> v\<rbrakk> \<Longrightarrow> App t1 t2 \<Down> v" |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
215 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
216 |
|
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
217 |
text {* |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
218 |
Values are also defined using inductive. In our case values |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
219 |
are just lambda-abstractions. |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
220 |
*} |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
221 |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
222 |
inductive |
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
223 |
val :: "lam \<Rightarrow> bool" |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
224 |
where |
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
225 |
v_Lam[intro]: "val (Lam [x].t)" |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
226 |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
227 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
228 |
section {* Theorems *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
229 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
230 |
text {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
231 |
A central concept in Isabelle is that of theorems. Isabelle's theorem |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
232 |
database can be queried using |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
233 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
234 |
|
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
235 |
thm e_App |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
236 |
thm e_Lam |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
237 |
thm conjI |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
238 |
thm conjunct1 |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
239 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
240 |
text {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
241 |
Notice that theorems usually contain schematic variables (e.g. ?P, ?Q, \<dots>). |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
242 |
These schematic variables can be substituted with any term (of the right type |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
243 |
of course). |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
244 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
245 |
When defining the predicates beta_star, Isabelle provides us automatically |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
246 |
with the following theorems that state how they can be introduced and what |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
247 |
constitutes an induction over them. |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
248 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
249 |
|
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
250 |
thm eval.intros |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
251 |
thm eval.induct |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
252 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
253 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
254 |
section {* Lemmas / Theorems / Corollaries *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
255 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
256 |
text {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
257 |
Whether to use lemma, theorem or corollary makes no semantic difference |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
258 |
in Isabelle. |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
259 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
260 |
A lemma starts with "lemma" and consists of a statement ("shows \<dots>") and |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
261 |
optionally a lemma name, some type-information for variables ("fixes \<dots>") |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
262 |
and some assumptions ("assumes \<dots>"). |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
263 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
264 |
Lemmas also need to have a proof, but ignore this 'detail' for the moment. |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
265 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
266 |
Examples are |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
267 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
268 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
269 |
lemma alpha_equ: |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
270 |
shows "Lam [x].Var x = Lam [y].Var y" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
271 |
by (simp add: lam.eq_iff Abs1_eq_iff lam.fresh fresh_at_base) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
272 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
273 |
lemma Lam_freshness: |
2689 | 274 |
assumes a: "atom y \<sharp> Lam [x].t" |
275 |
shows "(y = x) \<or> (y \<noteq> x \<and> atom y \<sharp> t)" |
|
276 |
using a by (auto simp add: lam.fresh Abs_fresh_iff) |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
277 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
278 |
lemma neutral_element: |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
279 |
fixes x::"nat" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
280 |
shows "x + 0 = x" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
281 |
by simp |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
282 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
283 |
text {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
284 |
Note that in the last statement, the explicit type annotation is important |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
285 |
in order for Isabelle to be able to figure out what 0 stands for (e.g. a |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
286 |
natural number, a vector, etc) and which lemmas to apply. |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
287 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
288 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
289 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
290 |
section {* Isar Proofs *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
291 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
292 |
text {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
293 |
Isar is a language for writing formal proofs that can be understood by humans |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
294 |
and by Isabelle. An Isar proof can be thought of as a sequence of 'stepping stones' |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
295 |
that start with some assumptions and lead to the goal to be established. Every such |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
296 |
stepping stone is introduced by "have" followed by the statement of the stepping |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
297 |
stone. An exception is the goal to be proved, which need to be introduced with "show". |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
298 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
299 |
have "statement" \<dots> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
300 |
show "goal_to_be_proved" \<dots> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
301 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
302 |
Since proofs usually do not proceed in a linear fashion, labels can be given |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
303 |
to every stepping stone and they can be used later to explicitly refer to this |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
304 |
corresponding stepping stone ("using"). |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
305 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
306 |
have label: "statement1" \<dots> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
307 |
\<dots> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
308 |
have "later_statement" using label \<dots> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
309 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
310 |
Each stepping stone (or have-statement) needs to have a justification. The |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
311 |
simplest justification is "sorry" which admits any stepping stone, even false |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
312 |
ones (this is good during the development of proofs). |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
313 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
314 |
have "outrageous_false_statement" sorry |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
315 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
316 |
Assumptions can be 'justified' using "by fact". |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
317 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
318 |
have "assumption" by fact |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
319 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
320 |
Derived facts can be justified using |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
321 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
322 |
have "statement" by simp -- simplification |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
323 |
have "statement" by auto -- proof search and simplification |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
324 |
have "statement" by blast -- only proof search |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
325 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
326 |
If facts or lemmas are needed in order to justify a have-statement, then |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
327 |
one can feed these facts into the proof by using "using label \<dots>" or |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
328 |
"using theorem-name \<dots>". More than one label at a time is allowed. For |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
329 |
example |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
330 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
331 |
have "statement" using label1 label2 theorem_name by auto |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
332 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
333 |
Induction proofs in Isar are set up by indicating over which predicate(s) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
334 |
the induction proceeds ("using a b") followed by the command "proof (induct)". |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
335 |
In this way, Isabelle uses defaults for which induction should be performed. |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
336 |
These defaults can be overridden by giving more information, like the variable |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
337 |
over which a structural induction should proceed, or a specific induction principle, |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
338 |
such as well-founded inductions. |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
339 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
340 |
After the induction is set up, the proof proceeds by cases. In Isar these |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
341 |
cases can be given in any order. Most commonly they are started with "case" and the |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
342 |
name of the case, and optionally some legible names for the variables used inside |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
343 |
the case. |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
344 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
345 |
In each "case", we need to establish a statement introduced by "show". Once |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
346 |
this has been done, the next case can be started using "next". When all cases |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
347 |
are completed, the proof can be finished using "qed". |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
348 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
349 |
This means a typical induction proof has the following pattern |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
350 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
351 |
proof (induct) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
352 |
case \<dots> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
353 |
\<dots> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
354 |
show \<dots> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
355 |
next |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
356 |
case \<dots> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
357 |
\<dots> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
358 |
show \<dots> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
359 |
\<dots> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
360 |
qed |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
361 |
|
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
362 |
Two very simple example proofs are as follows. |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
363 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
364 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
365 |
|
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
366 |
lemma eval_val: |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
367 |
assumes a: "val t" |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
368 |
shows "t \<Down> t" |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
369 |
using a |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
370 |
proof (induct) |
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
371 |
case (v_Lam x t) |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
372 |
show "Lam [x]. t \<Down> Lam [x]. t" sorry |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
373 |
qed |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
374 |
|
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
375 |
lemma eavl_to_val: |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
376 |
assumes a: "t \<Down> t'" |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
377 |
shows "val t'" |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
378 |
using a |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
379 |
proof (induct) |
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
380 |
case (e_Lam x t) |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
381 |
show "val (Lam [x].t)" sorry |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
382 |
next |
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
383 |
case (e_App t1 x t t2 v v') |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
384 |
have "t1 \<Down> Lam [x].t" by fact |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
385 |
have ih1: "val (Lam [x]. t)" by fact |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
386 |
have "t2 \<Down> v" by fact |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
387 |
have ih2: "val v" by fact |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
388 |
have "t [x ::= v] \<Down> v'" by fact |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
389 |
have ih3: "val v'" by fact |
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
390 |
show "val v'" sorry |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
391 |
qed |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
392 |
|
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
393 |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
394 |
text {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
395 |
Just like gotos in the Basic programming language, labels often reduce |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
396 |
the readability of proofs. Therefore one can use in Isar the notation |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
397 |
"then have" in order to feed a have-statement to the proof of |
2705 | 398 |
the next have-statement. This is used in the second case below. |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
399 |
*} |
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
400 |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
401 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
402 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
403 |
text {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
404 |
The label ih2 cannot be got rid of in this way, because it is used |
2705 | 405 |
two lines below and we cannot rearrange them. We can still avoid the |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
406 |
label by feeding a sequence of facts into a proof using the |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
407 |
"moreover"-chaining mechanism: |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
408 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
409 |
have "statement_1" \<dots> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
410 |
moreover |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
411 |
have "statement_2" \<dots> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
412 |
\<dots> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
413 |
moreover |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
414 |
have "statement_n" \<dots> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
415 |
ultimately have "statement" \<dots> |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
416 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
417 |
In this chain, all "statement_i" can be used in the proof of the final |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
418 |
"statement". With this we can simplify our proof further to: |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
419 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
420 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
421 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
422 |
text {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
423 |
While automatic proof procedures in Isabelle are not able to prove statements |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
424 |
like "P = NP" assuming usual definitions for P and NP, they can automatically |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
425 |
discharge the lemmas we just proved. For this we only have to set up the induction |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
426 |
and auto will take care of the rest. This means we can write: |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
427 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
428 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
429 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
430 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
431 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
432 |
section {* Datatypes: Evaluation Contexts *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
433 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
434 |
text {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
435 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
436 |
Datatypes can be defined in Isabelle as follows: we have to provide the name |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
437 |
of the datatype and list its type-constructors. Each type-constructor needs |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
438 |
to have the information about the types of its arguments, and optionally |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
439 |
can also contain some information about pretty syntax. For example, we like |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
440 |
to write "\<box>" for holes. |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
441 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
442 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
443 |
datatype ctx = |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
444 |
Hole ("\<box>") |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
445 |
| CAppL "ctx" "lam" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
446 |
| CAppR "lam" "ctx" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
447 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
448 |
text {* Now Isabelle knows about: *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
449 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
450 |
typ ctx |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
451 |
term "\<box>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
452 |
term "CAppL" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
453 |
term "CAppL \<box> (Var x)" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
454 |
|
2689 | 455 |
subsection {* MINI EXERCISE *} |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
456 |
|
2689 | 457 |
text {* |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
458 |
Try and see what happens if you apply a Hole to a Hole? |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
459 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
460 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
461 |
type_synonym ctxs = "ctx list" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
462 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
463 |
inductive |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
464 |
machine :: "lam \<Rightarrow> ctxs \<Rightarrow>lam \<Rightarrow> ctxs \<Rightarrow> bool" ("<_,_> \<mapsto> <_,_>" [60, 60, 60, 60] 60) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
465 |
where |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
466 |
m1[intro]: "<App t1 t2,Es> \<mapsto> <t1,(CAppL \<box> t2) # Es>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
467 |
| m2[intro]: "val v \<Longrightarrow> <v,(CAppL \<box> t2) # Es> \<mapsto> <t2,(CAppR v \<box>) # Es>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
468 |
| m3[intro]: "val v \<Longrightarrow> <v,(CAppR (Lam [x].t) \<box>) # Es> \<mapsto> <t[x ::= v],Es>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
469 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
470 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
471 |
text {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
472 |
Since the machine defined above only performs a single reduction, |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
473 |
we need to define the transitive closure of this machine. *} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
474 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
475 |
inductive |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
476 |
machines :: "lam \<Rightarrow> ctxs \<Rightarrow> lam \<Rightarrow> ctxs \<Rightarrow> bool" ("<_,_> \<mapsto>* <_,_>" [60, 60, 60, 60] 60) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
477 |
where |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
478 |
ms1[intro]: "<t,Es> \<mapsto>* <t,Es>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
479 |
| ms2[intro]: "\<lbrakk><t1,Es1> \<mapsto> <t2,Es2>; <t2,Es2> \<mapsto>* <t3,Es3>\<rbrakk> \<Longrightarrow> <t1,Es1> \<mapsto>* <t3,Es3>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
480 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
481 |
lemma |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
482 |
assumes a: "<e1, Es1> \<mapsto>* <e2, Es2>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
483 |
and b: "<e2, Es2> \<mapsto>* <e3, Es3>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
484 |
shows "<e1, Es1> \<mapsto>* <e3, Es3>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
485 |
using a b |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
486 |
proof(induct) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
487 |
case (ms1 e1 Es1) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
488 |
have c: "<e1, Es1> \<mapsto>* <e3, Es3>" by fact |
2689 | 489 |
then show "<e1, Es1> \<mapsto>* <e3, Es3>" by simp |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
490 |
next |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
491 |
case (ms2 e1 Es1 e2 Es2 e2' Es2') |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
492 |
have ih: "<e2', Es2'> \<mapsto>* <e3, Es3> \<Longrightarrow> <e2, Es2> \<mapsto>* <e3, Es3>" by fact |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
493 |
have d1: "<e2', Es2'> \<mapsto>* <e3, Es3>" by fact |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
494 |
have d2: "<e1, Es1> \<mapsto> <e2, Es2>" by fact |
2689 | 495 |
show "<e1, Es1> \<mapsto>* <e3, Es3>" using d1 d2 ih by blast |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
496 |
qed |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
497 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
498 |
text {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
499 |
Just like gotos in the Basic programming language, labels can reduce |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
500 |
the readability of proofs. Therefore one can use in Isar the notation |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
501 |
"then have" in order to feed a have-statement to the proof of |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
502 |
the next have-statement. In the proof below this has been used |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
503 |
in order to get rid of the labels c and d1. |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
504 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
505 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
506 |
lemma |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
507 |
assumes a: "<e1, Es1> \<mapsto>* <e2, Es2>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
508 |
and b: "<e2, Es2> \<mapsto>* <e3, Es3>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
509 |
shows "<e1, Es1> \<mapsto>* <e3, Es3>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
510 |
using a b |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
511 |
proof(induct) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
512 |
case (ms1 e1 Es1) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
513 |
show "<e1, Es1> \<mapsto>* <e3, Es3>" by fact |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
514 |
next |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
515 |
case (ms2 e1 Es1 e2 Es2 e2' Es2') |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
516 |
have ih: "<e2', Es2'> \<mapsto>* <e3, Es3> \<Longrightarrow> <e2, Es2> \<mapsto>* <e3, Es3>" by fact |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
517 |
have "<e2', Es2'> \<mapsto>* <e3, Es3>" by fact |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
518 |
then have d3: "<e2, Es2> \<mapsto>* <e3, Es3>" using ih by simp |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
519 |
have d2: "<e1, Es1> \<mapsto> <e2, Es2>" by fact |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
520 |
show "<e1, Es1> \<mapsto>* <e3, Es3>" using d2 d3 by auto |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
521 |
qed |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
522 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
523 |
lemma |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
524 |
assumes a: "<e1, Es1> \<mapsto>* <e2, Es2>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
525 |
and b: "<e2, Es2> \<mapsto>* <e3, Es3>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
526 |
shows "<e1, Es1> \<mapsto>* <e3, Es3>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
527 |
using a b |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
528 |
proof(induct) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
529 |
case (ms1 e1 Es1) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
530 |
show "<e1, Es1> \<mapsto>* <e3, Es3>" by fact |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
531 |
next |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
532 |
case (ms2 e1 Es1 e2 Es2 e2' Es2') |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
533 |
have ih: "<e2', Es2'> \<mapsto>* <e3, Es3> \<Longrightarrow> <e2, Es2> \<mapsto>* <e3, Es3>" by fact |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
534 |
have "<e2', Es2'> \<mapsto>* <e3, Es3>" by fact |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
535 |
then have "<e2, Es2> \<mapsto>* <e3, Es3>" using ih by simp |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
536 |
moreover |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
537 |
have "<e1, Es1> \<mapsto> <e2, Es2>" by fact |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
538 |
ultimately show "<e1, Es1> \<mapsto>* <e3, Es3>" by auto |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
539 |
qed |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
540 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
541 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
542 |
lemma ms3[intro]: |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
543 |
assumes a: "<e1, Es1> \<mapsto>* <e2, Es2>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
544 |
and b: "<e2, Es2> \<mapsto>* <e3, Es3>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
545 |
shows "<e1, Es1> \<mapsto>* <e3, Es3>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
546 |
using a b by (induct) (auto) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
547 |
|
2692
da9bed7baf23
better flow of proofs and definitions and proof
Christian Urban <urbanc@in.tum.de>
parents:
2690
diff
changeset
|
548 |
lemma eval_to_val: (* fixme: done above *) |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
549 |
assumes a: "t \<Down> t'" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
550 |
shows "val t'" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
551 |
using a by (induct) (auto) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
552 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
553 |
theorem |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
554 |
assumes a: "t \<Down> t'" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
555 |
shows "<t, []> \<mapsto>* <t', []>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
556 |
using a |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
557 |
proof (induct) |
2688 | 558 |
case (e_Lam x t) |
559 |
-- {* no assumptions *} |
|
2689 | 560 |
show "<Lam [x].t, []> \<mapsto>* <Lam [x].t, []>" by auto |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
561 |
next |
2688 | 562 |
case (e_App t1 x t t2 v' v) |
563 |
-- {* all assumptions in this case *} |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
564 |
have a1: "t1 \<Down> Lam [x].t" by fact |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
565 |
have ih1: "<t1, []> \<mapsto>* <Lam [x].t, []>" by fact |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
566 |
have a2: "t2 \<Down> v'" by fact |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
567 |
have ih2: "<t2, []> \<mapsto>* <v', []>" by fact |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
568 |
have a3: "t[x::=v'] \<Down> v" by fact |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
569 |
have ih3: "<t[x::=v'], []> \<mapsto>* <v, []>" by fact |
2688 | 570 |
-- {* your reasoning *} |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
571 |
show "<App t1 t2, []> \<mapsto>* <v, []>" sorry |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
572 |
qed |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
573 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
574 |
text {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
575 |
Again the automatic tools in Isabelle can discharge automatically |
2688 | 576 |
of the routine work in these proofs. We can write: |
577 |
*} |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
578 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
579 |
theorem eval_implies_machines_ctx: |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
580 |
assumes a: "t \<Down> t'" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
581 |
shows "<t, Es> \<mapsto>* <t', Es>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
582 |
using a |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
583 |
by (induct arbitrary: Es) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
584 |
(metis eval_to_val machine.intros ms1 ms2 ms3 v_Lam)+ |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
585 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
586 |
corollary eval_implies_machines: |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
587 |
assumes a: "t \<Down> t'" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
588 |
shows "<t, []> \<mapsto>* <t', []>" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
589 |
using a eval_implies_machines_ctx by simp |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
590 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
591 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
592 |
|
2688 | 593 |
section {* Function Definitions: Filling a Lambda-Term into a Context *} |
594 |
||
595 |
text {* |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
596 |
Many functions over datatypes can be defined by recursion on the |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
597 |
structure. For this purpose, Isabelle provides "fun". To use it one needs |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
598 |
to give a name for the function, its type, optionally some pretty-syntax |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
599 |
and then some equations defining the function. Like in "inductive", |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
600 |
"fun" expects that more than one such equation is separated by "|". |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
601 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
602 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
603 |
fun |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
604 |
filling :: "ctx \<Rightarrow> lam \<Rightarrow> lam" ("_\<lbrakk>_\<rbrakk>" [100, 100] 100) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
605 |
where |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
606 |
"\<box>\<lbrakk>t\<rbrakk> = t" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
607 |
| "(CAppL E t')\<lbrakk>t\<rbrakk> = App (E\<lbrakk>t\<rbrakk>) t'" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
608 |
| "(CAppR t' E)\<lbrakk>t\<rbrakk> = App t' (E\<lbrakk>t\<rbrakk>)" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
609 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
610 |
text {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
611 |
After this definition Isabelle will be able to simplify |
2688 | 612 |
statements like: |
613 |
*} |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
614 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
615 |
lemma |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
616 |
shows "(CAppL \<box> (Var x))\<lbrakk>Var y\<rbrakk> = App (Var y) (Var x)" |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
617 |
by simp |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
618 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
619 |
fun |
2688 | 620 |
ctx_compose :: "ctx \<Rightarrow> ctx \<Rightarrow> ctx" ("_ \<odot> _" [99,98] 99) |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
621 |
where |
2688 | 622 |
"\<box> \<odot> E' = E'" |
623 |
| "(CAppL E t') \<odot> E' = CAppL (E \<odot> E') t'" |
|
624 |
| "(CAppR t' E) \<odot> E' = CAppR t' (E \<odot> E')" |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
625 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
626 |
fun |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
627 |
ctx_composes :: "ctxs \<Rightarrow> ctx" ("_\<down>" [110] 110) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
628 |
where |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
629 |
"[]\<down> = \<box>" |
2688 | 630 |
| "(E # Es)\<down> = (Es\<down>) \<odot> E" |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
631 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
632 |
text {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
633 |
Notice that we not just have given a pretty syntax for the functions, but |
2688 | 634 |
also some precedences. The numbers inside the [\<dots>] stand for the precedences |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
635 |
of the arguments; the one next to it the precedence of the whole term. |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
636 |
|
2688 | 637 |
This means we have to write (Es1 \<odot> Es2) \<odot> Es3 otherwise Es1 \<odot> Es2 \<odot> Es3 is |
638 |
interpreted as Es1 \<odot> (Es2 \<odot> Es3). |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
639 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
640 |
|
2688 | 641 |
section {* Structural Inductions over Contexts *} |
642 |
||
643 |
text {* |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
644 |
So far we have had a look at an induction over an inductive predicate. |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
645 |
Another important induction principle is structural inductions for |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
646 |
datatypes. To illustrate structural inductions we prove some facts |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
647 |
about context composition, some of which we will need later on. |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
648 |
*} |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
649 |
|
2688 | 650 |
subsection {* EXERCISE 5 *} |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
651 |
|
2688 | 652 |
text {* Complete the proof and remove the sorries. *} |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
653 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
654 |
lemma ctx_compose: |
2688 | 655 |
shows "(E1 \<odot> E2)\<lbrakk>t\<rbrakk> = E1\<lbrakk>E2\<lbrakk>t\<rbrakk>\<rbrakk>" |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
656 |
proof (induct E1) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
657 |
case Hole |
2688 | 658 |
show "(\<box> \<odot> E2)\<lbrakk>t\<rbrakk> = \<box>\<lbrakk>E2\<lbrakk>t\<rbrakk>\<rbrakk>" sorry |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
659 |
next |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
660 |
case (CAppL E1 t') |
2688 | 661 |
have ih: "(E1 \<odot> E2)\<lbrakk>t\<rbrakk> = E1\<lbrakk>E2\<lbrakk>t\<rbrakk>\<rbrakk>" by fact |
662 |
show "((CAppL E1 t') \<odot> E2)\<lbrakk>t\<rbrakk> = (CAppL E1 t')\<lbrakk>E2\<lbrakk>t\<rbrakk>\<rbrakk>" sorry |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
663 |
next |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
664 |
case (CAppR t' E1) |
2688 | 665 |
have ih: "(E1 \<odot> E2)\<lbrakk>t\<rbrakk> = E1\<lbrakk>E2\<lbrakk>t\<rbrakk>\<rbrakk>" by fact |
666 |
show "((CAppR t' E1) \<odot> E2)\<lbrakk>t\<rbrakk> = (CAppR t' E1)\<lbrakk>E2\<lbrakk>t\<rbrakk>\<rbrakk>" sorry |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
667 |
qed |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
668 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
669 |
lemma neut_hole: |
2688 | 670 |
shows "E \<odot> \<box> = E" |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
671 |
by (induct E) (simp_all) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
672 |
|
2689 | 673 |
lemma odot_assoc: (* fixme call compose *) |
2688 | 674 |
shows "(E1 \<odot> E2) \<odot> E3 = E1 \<odot> (E2 \<odot> E3)" |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
675 |
by (induct E1) (simp_all) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
676 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
677 |
lemma |
2688 | 678 |
shows "(Es1 @ Es2)\<down> = (Es2\<down>) \<odot> (Es1\<down>)" |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
679 |
proof (induct Es1) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
680 |
case Nil |
2688 | 681 |
show "([] @ Es2)\<down> = Es2\<down> \<odot> []\<down>" sorry |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
682 |
next |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
683 |
case (Cons E Es1) |
2688 | 684 |
have ih: "(Es1 @ Es2)\<down> = Es2\<down> \<odot> Es1\<down>" by fact |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
685 |
|
2688 | 686 |
show "((E # Es1) @ Es2)\<down> = Es2\<down> \<odot> (E # Es1)\<down>" sorry |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
687 |
qed |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
688 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
689 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
690 |
text {* |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
691 |
The last proof involves several steps of equational reasoning. |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
692 |
Isar provides some convenient means to express such equational |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
693 |
reasoning in a much cleaner fashion using the "also have" |
2688 | 694 |
construction. |
695 |
*} |
|
696 |
||
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
697 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
698 |
lemma |
2688 | 699 |
shows "(Es1 @ Es2)\<down> = (Es2\<down>) \<odot> (Es1\<down>)" |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
700 |
proof (induct Es1) |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
701 |
case Nil |
2688 | 702 |
show "([] @ Es2)\<down> = Es2\<down> \<odot> []\<down>" using neut_hole by simp |
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
703 |
next |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
704 |
case (Cons E Es1) |
2688 | 705 |
have ih: "(Es1 @ Es2)\<down> = Es2\<down> \<odot> Es1\<down>" by fact |
706 |
have "((E # Es1) @ Es2)\<down> = (Es1 @ Es2)\<down> \<odot> E" by simp |
|
707 |
also have "\<dots> = (Es2\<down> \<odot> Es1\<down>) \<odot> E" using ih by simp |
|
708 |
also have "\<dots> = Es2\<down> \<odot> (Es1\<down> \<odot> E)" using odot_assoc by simp |
|
709 |
also have "\<dots> = Es2\<down> \<odot> (E # Es1)\<down>" by simp |
|
710 |
finally show "((E # Es1) @ Es2)\<down> = Es2\<down> \<odot> (E # Es1)\<down>" by simp |
|
2686
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
711 |
qed |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
712 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
713 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
714 |
|
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
715 |
end |
52e1e98edb34
added a very rough version of the tutorial; all seems to work
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
716 |