author | Christian Urban <urbanc@in.tum.de> |
Tue, 16 Sep 2008 00:43:45 +0200 | |
changeset 6 | 007e09485351 |
parent 5 | e91f54791e14 |
child 10 | df09e49b19bf |
permissions | -rw-r--r-- |
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1 |
theory FirstSteps |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
imports Main |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
3 |
uses "antiquote_setup.ML" |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
("comp_simproc") |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
5 |
begin |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
6 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
7 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
8 |
(*<*) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
9 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
10 |
ML {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
11 |
local structure O = ThyOutput |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
12 |
in |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
13 |
fun check_exists f = |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
14 |
if File.exists (Path.explode ("~~/src/" ^ f)) then () |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
15 |
else error ("Source file " ^ quote f ^ " does not exist.") |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
16 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
17 |
val _ = O.add_commands |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
18 |
[("ML_file", O.args (Scan.lift Args.name) (O.output (fn _ => fn name => |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
19 |
(check_exists name; Pretty.str name))))]; |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
20 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
21 |
end |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
22 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
23 |
(*>*) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
24 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
25 |
chapter {* First Steps *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
26 |
|
5
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
27 |
|
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
28 |
text {* |
6 | 29 |
Isabelle programming is done in Standard ML, however ML-code for Isabelle often |
30 |
includes antiquotations to refer to the logical context of Isabelle. |
|
31 |
Just like lemmas and proofs, code in Isabelle is part of a |
|
32 |
theory. If you want to follow the code written in this chapter, we |
|
33 |
assume you are working inside the theory defined by |
|
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
34 |
|
6 | 35 |
\begin{center} |
5
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
36 |
\begin{tabular}{@ {}l} |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
37 |
\isacommand{theory} CookBook\\ |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
38 |
\isacommand{imports} Main\\ |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
39 |
\isacommand{begin}\\ |
6 | 40 |
\ldots |
5
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
41 |
\end{tabular} |
6 | 42 |
\end{center} |
5
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
43 |
|
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
44 |
The easiest and quickest way to include code in a theory is |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
45 |
by using the \isacommand{ML} command. For example |
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
46 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
47 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
48 |
ML {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
49 |
3 + 4 |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
50 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
51 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
52 |
text {* |
6 | 53 |
The expression inside \isacommand{ML} commands is immediately evaluated, |
54 |
like ``normal'' Isabelle proof scripts, by using the advance and undo buttons of |
|
5
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
55 |
your Isabelle environment. The code inside the \isacommand{ML} command |
6 | 56 |
can also contain value- and function bindings, on which the undo operation |
57 |
does not have any effect. |
|
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
58 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
59 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
60 |
section {* Antiquotations *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
61 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
62 |
text {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
63 |
The main advantage of embedding all code in a theory is that the |
5
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
64 |
code can contain references to entities that are defined on the |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
65 |
logical level of Isabelle. This is done using antiquotations. |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
66 |
For example, one can print out the name of |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
67 |
the current theory by typing |
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
68 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
69 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
70 |
ML {* Context.theory_name @{theory} *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
71 |
|
5
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
72 |
text {* |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
73 |
where @{text "@{theory}"} is an antiquotation that is substituted with the |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
74 |
current theory (remember that we assumed we are inside the theory CookBook). |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
75 |
The name of this theory can be extrated using a the function @{ML "Context.theory_name"}. |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
76 |
So the code above returns the string @{ML "\"CookBook\""}. |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
77 |
|
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
78 |
Note that antiquotations are statically scoped, that is the value is |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
79 |
determined at ``compile-time'' not ``run-time''. For example the function |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
80 |
|
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
81 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
82 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
83 |
ML {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
84 |
fun current_thyname () = Context.theory_name @{theory} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
85 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
86 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
87 |
text {* |
5
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
88 |
does \emph{not} return the name of the current theory, if it is run in a |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
89 |
different theory. Instead, the code above defines the constant function |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
90 |
that always returns the string @{ML "\"CookBook\""}, no matter where the |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
91 |
function is called. Operationally speaking, @{text "@{theory}"} is |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
92 |
\emph{not} replaced with code that will look up the current theory in |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
93 |
some data structure and return it. Instead, it is literally |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
94 |
replaced with the value representing the theory name. |
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
95 |
|
5
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
96 |
In the course of this introduction, we will learn more about |
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
97 |
these antoquotations: they greatly simplify Isabelle programming since one |
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
98 |
can directly access all kinds of logical elements from ML. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
99 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
100 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
101 |
section {* Terms *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
102 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
103 |
text {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
104 |
We can simply quote Isabelle terms from ML using the @{text "@{term \<dots>}"} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
105 |
antiquotation: |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
106 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
107 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
108 |
ML {* @{term "(a::nat) + b = c"} *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
109 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
110 |
text {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
111 |
This shows the term @{term "(a::nat) + b = c"} in the internal |
5
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
112 |
representation with all gory details. Terms are just an ML |
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
113 |
datatype, and they are defined in @{ML_file "Pure/term.ML"}. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
114 |
|
5
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
115 |
The representation of terms uses deBruin indices: bound variables |
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
116 |
are represented by the constructor @{ML Bound}, and the index refers to |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
117 |
the number of lambdas we have to skip until we hit the lambda that |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
118 |
binds the variable. The names of bound variables are kept at the |
5
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
119 |
abstractions, but they should be treated just as comments. |
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
120 |
See \ichcite{ch:logic} for more details. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
121 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
122 |
\begin{readmore} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
123 |
Terms are described in detail in \ichcite{ch:logic}. Their |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
124 |
definition and many useful operations can be found in @{ML_file "Pure/term.ML"}. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
125 |
\end{readmore} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
126 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
127 |
In a similar way we can quote types and theorems: |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
128 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
129 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
130 |
ML {* @{typ "(int * nat) list"} *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
131 |
ML {* @{thm allI} *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
132 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
133 |
text {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
134 |
In the default setup, types and theorems are printed as strings. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
135 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
136 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
137 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
138 |
text {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
139 |
Sometimes the internal representation can be surprisingly different |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
140 |
from what you see at the user level, because the layer of |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
141 |
parsing/type checking/pretty printing can be quite thick. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
142 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
143 |
\begin{exercise} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
144 |
Look at the internal term representation of the following terms, and |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
145 |
find out why they are represented like this. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
146 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
147 |
\begin{itemize} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
148 |
\item @{term "case x of 0 \<Rightarrow> 0 | Suc y \<Rightarrow> y"} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
149 |
\item @{term "\<lambda>(x,y). P y x"} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
150 |
\item @{term "{ [x::int] | x. x \<le> -2 }"} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
151 |
\end{itemize} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
152 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
153 |
Hint: The third term is already quite big, and the pretty printer |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
154 |
may omit parts of it by default. If you want to see all of it, you |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
155 |
can use @{ML "print_depth 50"} to set the limit to a value high enough. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
156 |
\end{exercise} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
157 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
158 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
159 |
section {* Type checking *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
160 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
161 |
text {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
162 |
We can freely construct and manipulate terms, since they are just |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
163 |
arbitrary unchecked trees. However, we eventually want to see if a |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
164 |
term is wellformed in a certain context. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
165 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
166 |
Type checking is done via @{ML cterm_of}, which turns a @{ML_type |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
167 |
term} into a @{ML_type cterm}, a \emph{certified} term. Unlike |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
168 |
@{ML_type term}s, which are just trees, @{ML_type |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
169 |
"cterm"}s are abstract objects that are guaranteed to be |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
170 |
type-correct, and can only be constructed via the official |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
171 |
interfaces. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
172 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
173 |
Type |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
174 |
checking is always relative to a theory context. For now we can use |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
175 |
the @{ML "@{theory}"} antiquotation to get hold of the theory at the current |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
176 |
point: |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
177 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
178 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
179 |
ML {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
180 |
let |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
181 |
val natT = @{typ "nat"} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
182 |
val zero = @{term "0::nat"}(*Const ("HOL.zero_class.zero", natT)*) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
183 |
in |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
184 |
cterm_of @{theory} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
185 |
(Const ("HOL.plus_class.plus", natT --> natT --> natT) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
186 |
$ zero $ zero) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
187 |
end |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
188 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
189 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
190 |
ML {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
191 |
@{const_name plus} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
192 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
193 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
194 |
ML {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
195 |
@{term "{ [x::int] | x. x \<le> -2 }"} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
196 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
197 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
198 |
text {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
199 |
The internal names of constants like @{term "zero"} or @{text "+"} are |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
200 |
often more complex than one first expects. Here, the extra prefixes |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
201 |
@{text zero_class} and @{text plus_class} are present because the |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
202 |
constants are defined within a type class. Guessing such internal |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
203 |
names can be extremely hard, which is why the system provides |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
204 |
another antiquotation: @{ML "@{const_name plus}"} gives just this |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
205 |
name. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
206 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
207 |
\begin{exercise} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
208 |
Write a function @{ML_text "rev_sum : term -> term"} that takes a |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
209 |
term of the form @{text "t\<^isub>1 + t\<^isub>2 + \<dots> + t\<^isub>n"} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
210 |
and returns the reversed sum @{text "t\<^isub>n + \<dots> + t\<^isub>2 + t\<^isub>1"}. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
211 |
Note that @{text "+"} associates to the left. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
212 |
Try your function on some examples, and see if the result typechecks. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
213 |
\end{exercise} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
214 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
215 |
\begin{exercise} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
216 |
Write a function which takes two terms representing natural numbers |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
217 |
in unary (like @{term "Suc (Suc (Suc 0))"}), and produce the unary |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
218 |
number representing their sum. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
219 |
\end{exercise} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
220 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
221 |
\begin{exercise} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
222 |
Look at the functions defined in @{ML_file "Pure/logic.ML"} and |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
223 |
@{ML_file "HOL/hologic.ML"} and see if they can make your life |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
224 |
easier. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
225 |
\end{exercise} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
226 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
227 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
228 |
section {* Theorems *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
229 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
230 |
text {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
231 |
Just like @{ML_type cterm}s, theorems (of type @{ML_type thm}) are |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
232 |
abstract objects that can only be built by going through the kernel |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
233 |
interfaces, which means that all your proofs will be checked. The |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
234 |
basic rules of the Isabelle/Pure logical framework are defined in |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
235 |
@{ML_file "Pure/thm.ML"}. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
236 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
237 |
Using these rules, which are just ML functions, you can do simple |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
238 |
natural deduction proofs on the ML level. For example, the statement |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
239 |
@{prop "(\<And>(x::nat). P x \<Longrightarrow> Q x) \<Longrightarrow> P t \<Longrightarrow> Q t"} can be proved like |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
240 |
this\footnote{Note that @{text "|>"} is just reverse |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
241 |
application. This combinator, and several variants are defined in |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
242 |
@{ML_file "Pure/General/basics.ML"}}: |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
243 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
244 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
245 |
ML {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
246 |
let |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
247 |
val thy = @{theory} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
248 |
val nat = HOLogic.natT |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
249 |
val x = Free ("x", nat) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
250 |
val t = Free ("t", nat) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
251 |
val P = Free ("P", nat --> HOLogic.boolT) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
252 |
val Q = Free ("Q", nat --> HOLogic.boolT) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
253 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
254 |
val A1 = Logic.all x |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
255 |
(Logic.mk_implies (HOLogic.mk_Trueprop (P $ x), |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
256 |
HOLogic.mk_Trueprop (Q $ x))) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
257 |
|> cterm_of thy |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
258 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
259 |
val A2 = HOLogic.mk_Trueprop (P $ t) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
260 |
|> cterm_of thy |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
261 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
262 |
val Pt_implies_Qt = |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
263 |
assume A1 |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
264 |
|> forall_elim (cterm_of thy t) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
265 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
266 |
val Qt = implies_elim Pt_implies_Qt (assume A2) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
267 |
in |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
268 |
Qt |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
269 |
|> implies_intr A2 |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
270 |
|> implies_intr A1 |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
271 |
end |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
272 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
273 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
274 |
section {* Tactical reasoning *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
275 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
276 |
text {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
277 |
The goal-oriented tactical style is similar to the @{text apply} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
278 |
style at the user level. Reasoning is centered around a \emph{goal}, |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
279 |
which is modified in a sequence of proof steps until it is solved. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
280 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
281 |
A goal (or goal state) is a special @{ML_type thm}, which by |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
282 |
convention is an implication: |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
283 |
@{text[display] "A\<^isub>1 \<Longrightarrow> \<dots> \<Longrightarrow> A\<^isub>n \<Longrightarrow> #(C)"} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
284 |
Since the final result @{term C} could again be an implication, there is the |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
285 |
@{text "#"} around the final result, which protects its premises from being |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
286 |
misinterpreted as open subgoals. The protection @{text "# :: prop \<Rightarrow> |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
287 |
prop"} is just the identity and used as a syntactic marker. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
288 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
289 |
Now tactics are just functions that map a goal state to a (lazy) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
290 |
sequence of successor states, hence the type of a tactic is |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
291 |
@{ML_type[display] "thm -> thm Seq.seq"} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
292 |
See @{ML_file "Pure/General/seq.ML"} for the implementation of lazy |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
293 |
sequences. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
294 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
295 |
Of course, tactics are expected to behave nicely and leave the final |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
296 |
conclusion @{term C} intact. In order to start a tactical proof for |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
297 |
@{term A}, we |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
298 |
just set up the trivial goal @{text "A \<Longrightarrow> #(A)"} and run the tactic |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
299 |
on it. When the subgoal is solved, we have just @{text "#(A)"} and |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
300 |
can remove the protection. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
301 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
302 |
The operations in @{ML_file "Pure/goal.ML"} do just that and we can use |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
303 |
them. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
304 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
305 |
Let us transcribe a simple apply style proof from the |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
306 |
tutorial\cite{isa-tutorial} into ML: |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
307 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
308 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
309 |
lemma disj_swap: "P \<or> Q \<Longrightarrow> Q \<or> P" |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
310 |
apply (erule disjE) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
311 |
apply (rule disjI2) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
312 |
apply assumption |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
313 |
apply (rule disjI1) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
314 |
apply assumption |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
315 |
done |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
316 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
317 |
ML {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
318 |
let |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
319 |
val ctxt = @{context} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
320 |
val goal = @{prop "P \<or> Q \<Longrightarrow> Q \<or> P"} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
321 |
in |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
322 |
Goal.prove ctxt ["P", "Q"] [] goal (fn _ => |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
323 |
eresolve_tac [disjE] 1 |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
324 |
THEN resolve_tac [disjI2] 1 |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
325 |
THEN assume_tac 1 |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
326 |
THEN resolve_tac [disjI1] 1 |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
327 |
THEN assume_tac 1) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
328 |
end |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
329 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
330 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
331 |
text {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
332 |
Tactics that affect only a certain subgoal, take a subgoal number as |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
333 |
an integer parameter. Here we always work on the first subgoal, |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
334 |
following exactly the @{text "apply"} script. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
335 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
336 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
337 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
338 |
section {* Case Study: Relation Composition *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
339 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
340 |
text {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
341 |
\emph{Note: This is completely unfinished. I hoped to have a section |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
342 |
with a nontrivial example, but I ran into several problems.} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
343 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
344 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
345 |
Recall that HOL has special syntax for set comprehensions: |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
346 |
@{term "{ f x y |x y. P x y}"} abbreviates |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
347 |
@{term[source] "{u. \<exists>x y. u = f x y \<and> P x y}"}. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
348 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
349 |
We will automatically prove statements of the following form: |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
350 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
351 |
@{lemma[display] "{(l\<^isub>1 x, r\<^isub>1 x) |x. P\<^isub>1 x} O {(l\<^isub>2 x, r\<^isub>2 x) |x. P\<^isub>2 x} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
352 |
= {(l\<^isub>2 x, r\<^isub>1 y) |x y. r\<^isub>2 x = l\<^isub>1 y \<and> |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
353 |
P\<^isub>2 x \<and> P\<^isub>1 y}" by auto} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
354 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
355 |
In Isabelle, relation composition is defined to be consistent with |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
356 |
function composition, that is, the relation applied ``first'' is |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
357 |
written on the right hand side. This different from what many |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
358 |
textbooks do. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
359 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
360 |
The above statement about composition is not proved automatically by |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
361 |
@{method simp}, and it cannot be solved by a fixed set of rewrite |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
362 |
rules, since the number of (implicit) quantifiers may vary. Here, we |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
363 |
only have one bound variable in each comprehension, but in general |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
364 |
there can be more. On the other hand, @{method auto} proves the |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
365 |
above statement quickly, by breaking the equality into two parts and |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
366 |
proving them separately. However, if e.g.\ @{term "P\<^isub>1"} is a |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
367 |
complicated expression, the automated tools may get confused. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
368 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
369 |
Our goal is now to develop a small procedure that can compute (with proof) the |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
370 |
composition of two relation comprehensions, which can be used to |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
371 |
extend the simplifier. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
372 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
373 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
374 |
section {*A tactic *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
375 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
376 |
text {* Let's start with a step-by-step proof of the above statement *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
377 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
378 |
lemma "{(l\<^isub>1 x, r\<^isub>1 x) |x. P\<^isub>1 x} O {(l\<^isub>2 |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
379 |
x, r\<^isub>2 x) |x. P\<^isub>2 x} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
380 |
= {(l\<^isub>2 x, r\<^isub>1 y) |x y. r\<^isub>2 x = l\<^isub>1 y \<and> P\<^isub>2 x \<and> P\<^isub>1 y}" |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
381 |
apply (rule set_ext) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
382 |
apply (rule iffI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
383 |
apply (erule rel_compE) -- {* @{text "\<subseteq>"} *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
384 |
apply (erule CollectE) -- {* eliminate @{text "Collect"}, @{text "\<exists>"}, @{text "\<and>"}, and pairs *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
385 |
apply (erule CollectE) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
386 |
apply (erule exE) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
387 |
apply (erule exE) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
388 |
apply (erule conjE) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
389 |
apply (erule conjE) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
390 |
apply (erule Pair_inject) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
391 |
apply (erule Pair_inject) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
392 |
apply (simp only:) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
393 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
394 |
apply (rule CollectI) -- {* introduce them again *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
395 |
apply (rule exI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
396 |
apply (rule exI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
397 |
apply (rule conjI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
398 |
apply (rule refl) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
399 |
apply (rule conjI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
400 |
apply (rule sym) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
401 |
apply (assumption) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
402 |
apply (rule conjI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
403 |
apply assumption |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
404 |
apply assumption |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
405 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
406 |
apply (erule CollectE) -- {* @{text "\<subseteq>"} *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
407 |
apply (erule exE)+ |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
408 |
apply (erule conjE)+ |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
409 |
apply (simp only:) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
410 |
apply (rule rel_compI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
411 |
apply (rule CollectI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
412 |
apply (rule exI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
413 |
apply (rule conjI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
414 |
apply (rule refl) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
415 |
apply assumption |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
416 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
417 |
apply (rule CollectI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
418 |
apply (rule exI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
419 |
apply (rule conjI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
420 |
apply (subst Pair_eq) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
421 |
apply (rule conjI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
422 |
apply assumption |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
423 |
apply (rule refl) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
424 |
apply assumption |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
425 |
done |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
426 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
427 |
text {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
428 |
The reader will probably need to step through the proof and verify |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
429 |
that there is nothing spectacular going on here. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
430 |
The @{text apply} script just applies the usual elimination and introduction rules in the right order. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
431 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
432 |
This script is of course totally unreadable. But we are not trying |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
433 |
to produce pretty Isar proofs here. We just want to find out which |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
434 |
rules are needed and how they must be applied to complete the |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
435 |
proof. And a detailed apply-style proof can often be turned into a |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
436 |
tactic quite easily. Of course we must resist the temptation to use |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
437 |
@{method auto}, @{method blast} and friends, since their behaviour |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
438 |
is not predictable enough. But the simple @{method rule} and |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
439 |
@{method erule} methods are fine. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
440 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
441 |
Notice that this proof depends only in one detail on the |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
442 |
concrete equation that we want to prove: The number of bound |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
443 |
variables in the comprehension corresponds to the number of |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
444 |
existential quantifiers that we have to eliminate and introduce |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
445 |
again. In fact this is the only reason why the equations that we |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
446 |
want to prove are not just instances of a single rule. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
447 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
448 |
Here is the ML equivalent of the tactic script above: |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
449 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
450 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
451 |
ML {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
452 |
val compr_compose_tac = |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
453 |
rtac @{thm set_ext} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
454 |
THEN' rtac @{thm iffI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
455 |
THEN' etac @{thm rel_compE} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
456 |
THEN' etac @{thm CollectE} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
457 |
THEN' etac @{thm CollectE} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
458 |
THEN' (fn i => REPEAT (etac @{thm exE} i)) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
459 |
THEN' etac @{thm conjE} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
460 |
THEN' etac @{thm conjE} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
461 |
THEN' etac @{thm Pair_inject} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
462 |
THEN' etac @{thm Pair_inject} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
463 |
THEN' asm_full_simp_tac HOL_basic_ss |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
464 |
THEN' rtac @{thm CollectI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
465 |
THEN' (fn i => REPEAT (rtac @{thm exI} i)) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
466 |
THEN' rtac @{thm conjI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
467 |
THEN' rtac @{thm refl} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
468 |
THEN' rtac @{thm conjI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
469 |
THEN' rtac @{thm sym} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
470 |
THEN' assume_tac |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
471 |
THEN' rtac @{thm conjI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
472 |
THEN' assume_tac |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
473 |
THEN' assume_tac |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
474 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
475 |
THEN' etac @{thm CollectE} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
476 |
THEN' (fn i => REPEAT (etac @{thm exE} i)) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
477 |
THEN' etac @{thm conjE} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
478 |
THEN' etac @{thm conjE} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
479 |
THEN' etac @{thm conjE} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
480 |
THEN' asm_full_simp_tac HOL_basic_ss |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
481 |
THEN' rtac @{thm rel_compI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
482 |
THEN' rtac @{thm CollectI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
483 |
THEN' (fn i => REPEAT (rtac @{thm exI} i)) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
484 |
THEN' rtac @{thm conjI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
485 |
THEN' rtac @{thm refl} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
486 |
THEN' assume_tac |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
487 |
THEN' rtac @{thm CollectI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
488 |
THEN' (fn i => REPEAT (rtac @{thm exI} i)) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
489 |
THEN' rtac @{thm conjI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
490 |
THEN' simp_tac (HOL_basic_ss addsimps [@{thm Pair_eq}]) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
491 |
THEN' rtac @{thm conjI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
492 |
THEN' assume_tac |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
493 |
THEN' rtac @{thm refl} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
494 |
THEN' assume_tac |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
495 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
496 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
497 |
lemma test1: "{(l\<^isub>1 x, r\<^isub>1 x) |x. P\<^isub>1 x} O {(l\<^isub>2 |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
498 |
x, r\<^isub>2 x) |x. P\<^isub>2 x} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
499 |
= {(l\<^isub>2 x, r\<^isub>1 y) |x y. r\<^isub>2 x = l\<^isub>1 y \<and> P\<^isub>2 x \<and> P\<^isub>1 y}" |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
500 |
by (tactic "compr_compose_tac 1") |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
501 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
502 |
lemma test3: "{(l\<^isub>1 x, r\<^isub>1 x) |x. P\<^isub>1 x} O {(l\<^isub>2 x z, r\<^isub>2 x z) |x z. P\<^isub>2 x z} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
503 |
= {(l\<^isub>2 x z, r\<^isub>1 y) |x y z. r\<^isub>2 x z = l\<^isub>1 y \<and> P\<^isub>2 x z \<and> P\<^isub>1 y}" |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
504 |
by (tactic "compr_compose_tac 1") |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
505 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
506 |
text {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
507 |
So we have a tactic that works on at least two examples. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
508 |
Getting it really right requires some more effort. Consider the goal |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
509 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
510 |
lemma "{(n, Suc n) |n. n > 0} O {(n, Suc n) |n. P n} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
511 |
= {(n, Suc m)|n m. Suc n = m \<and> P n \<and> m > 0}" |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
512 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
513 |
(*lemma "{(l\<^isub>1 x, r\<^isub>1 x) |x. P\<^isub>1 x} O {(l\<^isub>2 |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
514 |
x, r\<^isub>2 x) |x. P\<^isub>2 x} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
515 |
= {(l\<^isub>2 x, r\<^isub>1 y) |x y. r\<^isub>2 x = l\<^isub>1 y \<and> P\<^isub>2 x \<and> P\<^isub>1 y}"*) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
516 |
txt {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
517 |
This is exactly an instance of @{fact test1}, but our tactic fails |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
518 |
on it with the usual uninformative |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
519 |
\emph{empty result requence}. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
520 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
521 |
We are now in the frequent situation that we need to debug. One simple instrument for this is @{ML "print_tac"}, |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
522 |
which is the same as @{ML all_tac} (the identity for @{ML_text "THEN"}), |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
523 |
i.e.\ it does nothing, but it prints the current goal state as a |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
524 |
side effect. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
525 |
Another debugging option is of course to step through the interactive apply script. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
526 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
527 |
Finding the problem could be taken as an exercise for the patient |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
528 |
reader, and we will go ahead with the solution. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
529 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
530 |
The problem is that in this instance the simplifier does more than it did in the general version |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
531 |
of lemma @{fact test1}. Since @{text "l\<^isub>1"} and @{text "l\<^isub>2"} are just the identity function, |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
532 |
the equation corresponding to @{text "l\<^isub>1 y = r\<^isub>2 x "} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
533 |
becomes @{text "m = Suc n"}. Then the simplifier eagerly replaces |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
534 |
all occurences of @{term "m"} by @{term "Suc n"} which destroys the |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
535 |
structure of the proof. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
536 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
537 |
This is perhaps the most important lesson to learn, when writing tactics: |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
538 |
\textbf{Avoid automation at all cost!!!}. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
539 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
540 |
Let us look at the proof state at the point where the simplifier is |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
541 |
invoked: |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
542 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
543 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
544 |
(*<*) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
545 |
apply (rule set_ext) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
546 |
apply (rule iffI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
547 |
apply (erule rel_compE) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
548 |
apply (erule CollectE) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
549 |
apply (erule CollectE) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
550 |
apply (erule exE) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
551 |
apply (erule exE) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
552 |
apply (erule conjE) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
553 |
apply (erule conjE) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
554 |
apply (erule Pair_inject) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
555 |
apply (erule Pair_inject)(*>*) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
556 |
txt {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
557 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
558 |
@{subgoals[display]} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
559 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
560 |
Like in the apply proof, we now want to eliminate the equations that |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
561 |
``define'' @{term x}, @{term xa} and @{term z}. The other equations |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
562 |
are just there by coincidence, and we must not touch them. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
563 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
564 |
For such purposes, there is the internal tactic @{text "hyp_subst_single"}. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
565 |
Its job is to take exactly one premise of the form @{term "v = t"}, |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
566 |
where @{term v} is a variable, and replace @{term "v"} in the whole |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
567 |
subgoal. The hypothesis to eliminate is given by its position. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
568 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
569 |
We can use this tactic to eliminate @{term x}: |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
570 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
571 |
apply (tactic "single_hyp_subst_tac 0 1") |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
572 |
txt {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
573 |
@{subgoals[display]} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
574 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
575 |
apply (tactic "single_hyp_subst_tac 2 1") |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
576 |
apply (tactic "single_hyp_subst_tac 2 1") |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
577 |
apply (tactic "single_hyp_subst_tac 3 1") |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
578 |
apply (rule CollectI) -- {* introduce them again *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
579 |
apply (rule exI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
580 |
apply (rule exI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
581 |
apply (rule conjI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
582 |
apply (rule refl) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
583 |
apply (rule conjI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
584 |
apply (assumption) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
585 |
apply (rule conjI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
586 |
apply assumption |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
587 |
apply assumption |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
588 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
589 |
apply (erule CollectE) -- {* @{text "\<subseteq>"} *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
590 |
apply (erule exE)+ |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
591 |
apply (erule conjE)+ |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
592 |
apply (tactic "single_hyp_subst_tac 0 1") |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
593 |
apply (rule rel_compI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
594 |
apply (rule CollectI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
595 |
apply (rule exI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
596 |
apply (rule conjI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
597 |
apply (rule refl) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
598 |
apply assumption |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
599 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
600 |
apply (rule CollectI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
601 |
apply (rule exI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
602 |
apply (rule conjI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
603 |
apply (subst Pair_eq) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
604 |
apply (rule conjI) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
605 |
apply assumption |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
606 |
apply (rule refl) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
607 |
apply assumption |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
608 |
done |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
609 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
610 |
ML {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
611 |
val compr_compose_tac = |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
612 |
rtac @{thm set_ext} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
613 |
THEN' rtac @{thm iffI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
614 |
THEN' etac @{thm rel_compE} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
615 |
THEN' etac @{thm CollectE} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
616 |
THEN' etac @{thm CollectE} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
617 |
THEN' (fn i => REPEAT (etac @{thm exE} i)) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
618 |
THEN' etac @{thm conjE} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
619 |
THEN' etac @{thm conjE} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
620 |
THEN' etac @{thm Pair_inject} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
621 |
THEN' etac @{thm Pair_inject} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
622 |
THEN' single_hyp_subst_tac 0 |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
623 |
THEN' single_hyp_subst_tac 2 |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
624 |
THEN' single_hyp_subst_tac 2 |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
625 |
THEN' single_hyp_subst_tac 3 |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
626 |
THEN' rtac @{thm CollectI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
627 |
THEN' (fn i => REPEAT (rtac @{thm exI} i)) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
628 |
THEN' rtac @{thm conjI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
629 |
THEN' rtac @{thm refl} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
630 |
THEN' rtac @{thm conjI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
631 |
THEN' assume_tac |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
632 |
THEN' rtac @{thm conjI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
633 |
THEN' assume_tac |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
634 |
THEN' assume_tac |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
635 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
636 |
THEN' etac @{thm CollectE} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
637 |
THEN' (fn i => REPEAT (etac @{thm exE} i)) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
638 |
THEN' etac @{thm conjE} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
639 |
THEN' etac @{thm conjE} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
640 |
THEN' etac @{thm conjE} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
641 |
THEN' single_hyp_subst_tac 0 |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
642 |
THEN' rtac @{thm rel_compI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
643 |
THEN' rtac @{thm CollectI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
644 |
THEN' (fn i => REPEAT (rtac @{thm exI} i)) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
645 |
THEN' rtac @{thm conjI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
646 |
THEN' rtac @{thm refl} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
647 |
THEN' assume_tac |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
648 |
THEN' rtac @{thm CollectI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
649 |
THEN' (fn i => REPEAT (rtac @{thm exI} i)) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
650 |
THEN' rtac @{thm conjI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
651 |
THEN' stac @{thm Pair_eq} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
652 |
THEN' rtac @{thm conjI} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
653 |
THEN' assume_tac |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
654 |
THEN' rtac @{thm refl} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
655 |
THEN' assume_tac |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
656 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
657 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
658 |
lemma "{(n, Suc n) |n. n > 0 \<and> A} O {(n, Suc n) |n m. P m n} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
659 |
= {(n, Suc m)|n m' m. Suc n = m \<and> P m' n \<and> (m > 0 \<and> A)}" |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
660 |
apply (tactic "compr_compose_tac 1") |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
661 |
done |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
662 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
663 |
text {* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
664 |
The next step is now to turn this tactic into a simplification |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
665 |
procedure. This just means that we need some code that builds the |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
666 |
term of the composed relation. |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
667 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
668 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
669 |
use "comp_simproc" |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
670 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
671 |
(*<*) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
672 |
(*simproc_setup mysp ("x O y") = {* compose_simproc *}*) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
673 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
674 |
lemma "{(n, Suc n) |n. n > 0 \<and> A} O {(n, Suc n) |n m. P m n} = x" |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
675 |
(*apply (simp del:ex_simps)*) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
676 |
oops |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
677 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
678 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
679 |
lemma "({(g m, k) | m k. Q m k} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
680 |
O {(h j, f j) | j. R j}) = x" |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
681 |
(*apply (simp del:ex_simps) *) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
682 |
oops |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
683 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
684 |
lemma "{uu. \<exists>j m k. uu = (h j, k) \<and> f j = g m \<and> R j \<and> Q m k} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
685 |
O {(h j, f j) | j. R j} = x" |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
686 |
(*apply (simp del:ex_simps)*) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
687 |
oops |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
688 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
689 |
lemma " |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
690 |
{ (l x, r x) | x. P x \<and> Q x \<and> Q' x } |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
691 |
O { (l1 x, r1 x) | x. P1 x \<and> Q1 x \<and> Q1' x } |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
692 |
= A" |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
693 |
(*apply (simp del:ex_simps)*) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
694 |
oops |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
695 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
696 |
lemma " |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
697 |
{ (l x, r x) | x. P x } |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
698 |
O { (l1 x, r1 x) | x. P1 x } |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
699 |
O { (l2 x, r2 x) | x. P2 x } |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
700 |
= A" |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
701 |
(* |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
702 |
apply (simp del:ex_simps)*) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
703 |
oops |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
704 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
705 |
lemma "{(f n, m) |n m. P n m} O ({(g m, k) | m k. Q m k} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
706 |
O {(h j, f j) | j. R j}) = x" |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
707 |
(*apply (simp del:ex_simps)*) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
708 |
oops |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
709 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
710 |
lemma "{u. \<exists>n. u=(f n, g n)} O {u. \<exists>n. u=(h n, j n)} = A" |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
711 |
oops |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
712 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
713 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
714 |
(*>*) |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
715 |
end |