author | Christian Urban <urbanc@in.tum.de> |
Mon, 09 Feb 2009 01:12:00 +0000 | |
changeset 105 | f49dc7e96235 |
parent 104 | 5dcad9348e4d |
child 107 | 258ce361ba1b |
permissions | -rw-r--r-- |
93 | 1 |
theory Tactical |
99 | 2 |
imports Base FirstSteps |
93 | 3 |
begin |
4 |
||
5 |
chapter {* Tactical Reasoning\label{chp:tactical} *} |
|
6 |
||
7 |
text {* |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
8 |
The main reason for descending to the ML-level of Isabelle is to be able to |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
9 |
implement automatic proof procedures. Such proof procedures usually lessen |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
10 |
considerably the burden of manual reasoning, for example, when introducing |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
11 |
new definitions. These proof procedures are centred around refining a goal |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
12 |
state using tactics. This is similar to the \isacommand{apply}-style |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
13 |
reasoning at the user level, where goals are modified in a sequence of proof |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
14 |
steps until all of them are solved. However, there are also more structured |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
15 |
operations available on the ML-level that help with the handling of |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
16 |
variables and assumptions. |
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
17 |
|
93 | 18 |
*} |
19 |
||
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
20 |
section {* Basics of Reasoning with Tactics*} |
93 | 21 |
|
22 |
text {* |
|
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
23 |
To see how tactics work, let us first transcribe a simple \isacommand{apply}-style proof |
93 | 24 |
into ML. Consider the following proof. |
25 |
*} |
|
26 |
||
27 |
lemma disj_swap: "P \<or> Q \<Longrightarrow> Q \<or> P" |
|
28 |
apply(erule disjE) |
|
29 |
apply(rule disjI2) |
|
30 |
apply(assumption) |
|
31 |
apply(rule disjI1) |
|
32 |
apply(assumption) |
|
33 |
done |
|
34 |
||
35 |
text {* |
|
36 |
This proof translates to the following ML-code. |
|
37 |
||
38 |
@{ML_response_fake [display,gray] |
|
39 |
"let |
|
40 |
val ctxt = @{context} |
|
41 |
val goal = @{prop \"P \<or> Q \<Longrightarrow> Q \<or> P\"} |
|
42 |
in |
|
43 |
Goal.prove ctxt [\"P\", \"Q\"] [] goal |
|
44 |
(fn _ => |
|
45 |
etac @{thm disjE} 1 |
|
46 |
THEN rtac @{thm disjI2} 1 |
|
47 |
THEN atac 1 |
|
48 |
THEN rtac @{thm disjI1} 1 |
|
49 |
THEN atac 1) |
|
50 |
end" "?P \<or> ?Q \<Longrightarrow> ?Q \<or> ?P"} |
|
51 |
||
52 |
To start the proof, the function @{ML "Goal.prove"}~@{text "ctxt xs As C |
|
99 | 53 |
tac"} sets up a goal state for proving the goal @{text C} |
54 |
(that is @{prop "P \<or> Q \<Longrightarrow> Q \<or> P"} in the proof at hand) under the |
|
55 |
assumptions @{text As} (happens to be empty) with the variables |
|
93 | 56 |
@{text xs} that will be generalised once the goal is proved (in our case |
57 |
@{text P} and @{text Q}). The @{text "tac"} is the tactic that proves the goal; |
|
58 |
it can make use of the local assumptions (there are none in this example). |
|
59 |
The functions @{ML etac}, @{ML rtac} and @{ML atac} correspond to |
|
60 |
@{text erule}, @{text rule} and @{text assumption}, respectively. |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
61 |
The operator @{ML THEN} strings the tactics together. |
93 | 62 |
|
63 |
\begin{readmore} |
|
99 | 64 |
To learn more about the function @{ML Goal.prove} see \isccite{sec:results} |
65 |
and the file @{ML_file "Pure/goal.ML"}. For more information about the |
|
66 |
internals of goals see \isccite{sec:tactical-goals}. See @{ML_file |
|
67 |
"Pure/tactic.ML"} and @{ML_file "Pure/tctical.ML"} for the code of basic |
|
68 |
tactics and tactic combinators; see also Chapters 3 and 4 in the old |
|
69 |
Isabelle Reference Manual. |
|
93 | 70 |
\end{readmore} |
71 |
||
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
72 |
Note that we used antiquotations for referencing the theorems. Many theorems |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
73 |
also have ML-bindings with the same name. Therefore, we could also just have |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
74 |
written @{ML "etac disjE 1"}, or in case there are no ML-binding obtained |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
75 |
the theorem dynamically using the theorem @{ML thm}; for example @{ML "etac |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
76 |
(thm \"disjE\") 1"}. Both ways however are considered bad style. The reason |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
77 |
is that the binding for @{ML disjE} can be re-assigned by the user and thus |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
78 |
one does not have complete control over which theorem is actually |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
79 |
applied. This problem is nicely prevented by using antiquotations, because |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
80 |
then the theorems are fixed statically at compile-time. |
93 | 81 |
|
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
82 |
During the development of automatic proof procedures, you will often find it |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
83 |
necessary to test a tactic on examples. This can be conveniently |
93 | 84 |
done with the command \isacommand{apply}@{text "(tactic \<verbopen> \<dots> \<verbclose>)"}. |
85 |
Consider the following sequence of tactics |
|
86 |
*} |
|
87 |
||
88 |
ML{*val foo_tac = |
|
89 |
(etac @{thm disjE} 1 |
|
90 |
THEN rtac @{thm disjI2} 1 |
|
91 |
THEN atac 1 |
|
92 |
THEN rtac @{thm disjI1} 1 |
|
93 |
THEN atac 1)*} |
|
94 |
||
95 |
text {* and the Isabelle proof: *} |
|
96 |
||
97 |
lemma "P \<or> Q \<Longrightarrow> Q \<or> P" |
|
98 |
apply(tactic {* foo_tac *}) |
|
99 |
done |
|
100 |
||
101 |
text {* |
|
104 | 102 |
By using @{text "tactic \<verbopen> \<dots> \<verbclose>"} you can call from the |
103 |
user level of Isabelle the tactic @{ML foo_tac} or |
|
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
104 |
any other function that returns a tactic. |
93 | 105 |
|
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
106 |
The tactic @{ML foo_tac} is just a sequence of simple tactics stringed |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
107 |
together by @{ML THEN}. As can be seen, each simple tactic in @{ML foo_tac} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
108 |
has a hard-coded number that stands for the subgoal analysed by the |
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
109 |
tactic (@{text "1"} stands for the first, or top-most, subgoal). This hard-coding |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
110 |
of goals is sometimes wanted, but usually it is not. To avoid the explicit numbering, |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
111 |
you can write |
93 | 112 |
*} |
113 |
||
114 |
ML{*val foo_tac' = |
|
115 |
(etac @{thm disjE} |
|
116 |
THEN' rtac @{thm disjI2} |
|
117 |
THEN' atac |
|
118 |
THEN' rtac @{thm disjI1} |
|
119 |
THEN' atac)*} |
|
120 |
||
121 |
text {* |
|
122 |
and then give the number for the subgoal explicitly when the tactic is |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
123 |
called. So in the next proof you can first discharge the second subgoal, and |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
124 |
after that the first. |
93 | 125 |
*} |
126 |
||
127 |
lemma "P1 \<or> Q1 \<Longrightarrow> Q1 \<or> P1" |
|
128 |
and "P2 \<or> Q2 \<Longrightarrow> Q2 \<or> P2" |
|
129 |
apply(tactic {* foo_tac' 2 *}) |
|
130 |
apply(tactic {* foo_tac' 1 *}) |
|
131 |
done |
|
132 |
||
133 |
text {* |
|
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
134 |
This kind of addressing is more difficult to achieve when the goal is |
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
135 |
hard-coded inside the tactic. For every operator that combines tactics |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
136 |
(@{ML THEN} is only one such operator) a ``primed'' version exists. |
99 | 137 |
|
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
138 |
The tactics @{ML foo_tac} and @{ML foo_tac'} are very specific for |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
139 |
analysing goals being only of the form @{prop "P \<or> Q \<Longrightarrow> Q \<or> P"}. If the goal is not |
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
140 |
of this form, then they throw the error message: |
99 | 141 |
|
142 |
\begin{isabelle} |
|
143 |
@{text "*** empty result sequence -- proof command failed"}\\ |
|
144 |
@{text "*** At command \"apply\"."} |
|
145 |
\end{isabelle} |
|
146 |
||
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
147 |
Meaning the tactics failed. The reason for this error message is that tactics |
99 | 148 |
are functions that map a goal state to a (lazy) sequence of successor states, |
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
149 |
hence the type of a tactic is: |
93 | 150 |
|
151 |
@{text [display, gray] "type tactic = thm -> thm Seq.seq"} |
|
152 |
||
99 | 153 |
It is custom that if a tactic fails, it should return the empty sequence: |
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
154 |
therefore your own tactics should not raise exceptions willy-nilly. |
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
155 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
156 |
The simplest tactics are @{ML no_tac} and @{ML all_tac}. The first returns |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
157 |
the empty sequence and is defined as |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
158 |
*} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
159 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
160 |
ML{*fun no_tac thm = Seq.empty*} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
161 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
162 |
text {* |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
163 |
which means @{ML no_tac} always fails. The second returns the given theorem wrapped |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
164 |
as a single member sequence. It is defined as |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
165 |
*} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
166 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
167 |
ML{*fun all_tac thm = Seq.single thm*} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
168 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
169 |
text {* |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
170 |
which means @{ML all_tac} always succeeds (but also does not make any progress |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
171 |
with the proof). |
93 | 172 |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
173 |
The lazy list of possible successor states shows through at the user-level |
99 | 174 |
of Isabelle when using the command \isacommand{back}. For instance in the |
175 |
following proof, there are two possibilities for how to apply |
|
176 |
@{ML foo_tac'}. |
|
93 | 177 |
*} |
178 |
||
179 |
lemma "\<lbrakk>P \<or> Q; P \<or> Q\<rbrakk> \<Longrightarrow> Q \<or> P" |
|
180 |
apply(tactic {* foo_tac' 1 *}) |
|
181 |
back |
|
182 |
done |
|
183 |
||
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
184 |
|
93 | 185 |
text {* |
99 | 186 |
By using \isacommand{back}, we construct the proof that uses the |
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
187 |
second assumption. In more interesting situations, different possibilities |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
188 |
can lead to different proofs and even often need to be explored when |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
189 |
a first proof attempt is unsuccessful. |
99 | 190 |
|
93 | 191 |
\begin{readmore} |
192 |
See @{ML_file "Pure/General/seq.ML"} for the implementation of lazy |
|
193 |
sequences. However in day-to-day Isabelle programming, one rarely |
|
194 |
constructs sequences explicitly, but uses the predefined functions |
|
99 | 195 |
instead. |
93 | 196 |
\end{readmore} |
197 |
||
104 | 198 |
It might be surprising that tactics, which transform |
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
199 |
one proof state to the next, are functions from theorems to theorem |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
200 |
(sequences). The surprise resolves by knowing that every |
104 | 201 |
goal state is indeed a theorem. To shed more light on this, |
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
202 |
let us modify the code of @{ML all_tac} to obtain the following |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
203 |
tactic |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
204 |
*} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
205 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
206 |
ML{*fun my_print_tac ctxt thm = |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
207 |
let |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
208 |
val _ = warning (str_of_thm ctxt thm) |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
209 |
in |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
210 |
Seq.single thm |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
211 |
end*} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
212 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
213 |
text {* |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
214 |
which prints out the given theorem (using the string-function defined |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
215 |
in Section~\ref{sec:printing}) and then behaves like @{ML all_tac}. We |
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
216 |
now can inspect every proof state in a proof. Consider the proof below: on |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
217 |
the left-hand side we show the goal state as shown by Isabelle; on the |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
218 |
right-hand side the print out from @{ML my_print_tac}. |
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
219 |
*} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
220 |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
221 |
lemma shows "\<lbrakk>A; B\<rbrakk> \<Longrightarrow> A \<and> B" |
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
222 |
apply(tactic {* my_print_tac @{context} *}) |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
223 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
224 |
txt{* \small |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
225 |
\begin{tabular}{@ {}l@ {}p{0.7\textwidth}@ {}} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
226 |
\begin{minipage}[t]{0.3\textwidth} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
227 |
@{subgoals [display]} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
228 |
\end{minipage} & |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
229 |
\hfill@{text "(\<lbrakk>A; B\<rbrakk> \<Longrightarrow> A \<and> B) \<Longrightarrow> (\<lbrakk>A; B\<rbrakk> \<Longrightarrow> A \<and> B)"} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
230 |
\end{tabular} |
93 | 231 |
*} |
232 |
||
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
233 |
apply(rule conjI) |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
234 |
apply(tactic {* my_print_tac @{context} *}) |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
235 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
236 |
txt{* \small |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
237 |
\begin{tabular}{@ {}l@ {}p{0.76\textwidth}@ {}} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
238 |
\begin{minipage}[t]{0.26\textwidth} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
239 |
@{subgoals [display]} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
240 |
\end{minipage} & |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
241 |
\hfill@{text "(\<lbrakk>A; B\<rbrakk> \<Longrightarrow> A) \<Longrightarrow> (\<lbrakk>A; B\<rbrakk> \<Longrightarrow> B) \<Longrightarrow> (\<lbrakk>A; B\<rbrakk> \<Longrightarrow> A \<and> B)"} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
242 |
\end{tabular} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
243 |
*} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
244 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
245 |
apply(assumption) |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
246 |
apply(tactic {* my_print_tac @{context} *}) |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
247 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
248 |
txt{* \small |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
249 |
\begin{tabular}{@ {}l@ {}p{0.7\textwidth}@ {}} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
250 |
\begin{minipage}[t]{0.3\textwidth} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
251 |
@{subgoals [display]} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
252 |
\end{minipage} & |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
253 |
\hfill@{text "(\<lbrakk>A; B\<rbrakk> \<Longrightarrow> B) \<Longrightarrow> (\<lbrakk>A; B\<rbrakk> \<Longrightarrow> A \<and> B)"} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
254 |
\end{tabular} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
255 |
*} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
256 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
257 |
apply(assumption) |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
258 |
apply(tactic {* my_print_tac @{context} *}) |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
259 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
260 |
txt{* \small |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
261 |
\begin{tabular}{@ {}l@ {}p{0.7\textwidth}@ {}} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
262 |
\begin{minipage}[t]{0.3\textwidth} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
263 |
@{subgoals [display]} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
264 |
\end{minipage} & |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
265 |
\hfill@{text "\<lbrakk>A; B\<rbrakk> \<Longrightarrow> A \<and> B"} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
266 |
\end{tabular} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
267 |
*} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
268 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
269 |
done |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
270 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
271 |
text {* |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
272 |
As can be seen, internally every goal state is an implication of the form |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
273 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
274 |
@{text[display] "A\<^isub>1 \<Longrightarrow> \<dots> \<Longrightarrow> A\<^isub>n \<Longrightarrow> (C)"} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
275 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
276 |
where @{term C} is the goal to be proved and the @{term "A\<^isub>i"} are the |
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
277 |
subgoals. So after setting up the lemma, the goal state is always of the form |
104 | 278 |
@{text "C \<Longrightarrow> (C)"}. Since the goal @{term C} can potentially be an implication, |
279 |
there is a ``protector'' wrapped around it (in from of an outermost constant |
|
280 |
@{text "Const (\"prop\", bool \<Rightarrow> bool)"} applied to each goal; |
|
281 |
however this constant is invisible in the print out above). This |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
282 |
prevents that premises of @{text C} are misinterpreted as open subgoals. |
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
283 |
While tactics can operate on the subgoals (the @{text "A\<^isub>i"} above), they |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
284 |
are expected to leave the conclusion @{term C} intact, with the |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
285 |
exception of possibly instantiating schematic variables. |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
286 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
287 |
*} |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
288 |
|
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
289 |
section {* Simple Tactics *} |
93 | 290 |
|
99 | 291 |
text {* |
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
292 |
A simple tactic is @{ML print_tac}, which is useful for low-level debugging of tactics. |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
293 |
It just prints out a message and the current goal state. |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
294 |
*} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
295 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
296 |
lemma shows "False \<Longrightarrow> True" |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
297 |
apply(tactic {* print_tac "foo message" *}) |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
298 |
(*<*)oops(*>*) |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
299 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
300 |
text {* |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
301 |
Another simple tactic is the function @{ML atac}, which, as shown in the previous |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
302 |
section, corresponds to the assumption command. |
99 | 303 |
*} |
304 |
||
305 |
lemma shows "P \<Longrightarrow> P" |
|
93 | 306 |
apply(tactic {* atac 1 *}) |
307 |
done |
|
308 |
||
99 | 309 |
text {* |
310 |
Similarly, @{ML rtac}, @{ML dtac}, @{ML etac} and @{ML ftac} correspond |
|
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
311 |
to @{text rule}, @{text drule}, @{text erule} and @{text frule}, |
104 | 312 |
respectively. Each of them takes a theorem as argument. Below are three |
313 |
examples with the resulting goal state. How |
|
314 |
they work should be self-explanatory. |
|
99 | 315 |
*} |
316 |
||
317 |
lemma shows "P \<and> Q" |
|
93 | 318 |
apply(tactic {* rtac @{thm conjI} 1 *}) |
104 | 319 |
txt{*\begin{minipage}{\textwidth} |
320 |
@{subgoals [display]} |
|
321 |
\end{minipage}*} |
|
93 | 322 |
(*<*)oops(*>*) |
323 |
||
99 | 324 |
lemma shows "P \<and> Q \<Longrightarrow> False" |
93 | 325 |
apply(tactic {* etac @{thm conjE} 1 *}) |
104 | 326 |
txt{*\begin{minipage}{\textwidth} |
327 |
@{subgoals [display]} |
|
328 |
\end{minipage}*} |
|
93 | 329 |
(*<*)oops(*>*) |
330 |
||
331 |
lemma shows "False \<and> True \<Longrightarrow> False" |
|
332 |
apply(tactic {* dtac @{thm conjunct2} 1 *}) |
|
104 | 333 |
txt{*\begin{minipage}{\textwidth} |
334 |
@{subgoals [display]} |
|
335 |
\end{minipage}*} |
|
93 | 336 |
(*<*)oops(*>*) |
337 |
||
338 |
text {* |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
339 |
As mentioned in the previous section, most basic tactics take a number as |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
340 |
argument, which addresses the subgoal they are analysing. In the proof below, |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
341 |
we first break up the second subgoal by focusing on this subgoal first. |
99 | 342 |
*} |
343 |
||
344 |
lemma shows "Foo" and "P \<and> Q" |
|
345 |
apply(tactic {* rtac @{thm conjI} 2 *}) |
|
104 | 346 |
txt {*\begin{minipage}{\textwidth} |
347 |
@{subgoals [display]} |
|
348 |
\end{minipage}*} |
|
99 | 349 |
(*<*)oops(*>*) |
350 |
||
351 |
text {* |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
352 |
The function @{ML resolve_tac} is similar to @{ML rtac}, except that it |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
353 |
expects a list of theorems as arguments. From this list it will apply the |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
354 |
first applicable theorem (later theorems that are also applicable can be |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
355 |
explored via the lazy sequences mechanism). Given the code |
93 | 356 |
*} |
357 |
||
99 | 358 |
ML{*val resolve_tac_xmp = resolve_tac [@{thm impI}, @{thm conjI}]*} |
359 |
||
360 |
text {* |
|
361 |
an example for @{ML resolve_tac} is the following proof where first an outermost |
|
362 |
implication is analysed and then an outermost conjunction. |
|
363 |
*} |
|
364 |
||
365 |
lemma shows "C \<longrightarrow> (A \<and> B)" and "(A \<longrightarrow> B) \<and> C" |
|
366 |
apply(tactic {* resolve_tac_xmp 1 *}) |
|
367 |
apply(tactic {* resolve_tac_xmp 2 *}) |
|
104 | 368 |
txt{*\begin{minipage}{\textwidth} |
369 |
@{subgoals [display]} |
|
370 |
\end{minipage}*} |
|
99 | 371 |
(*<*)oops(*>*) |
372 |
||
373 |
text {* |
|
374 |
Similarly versions exists for @{ML atac} (@{ML assume_tac}), @{ML etac} |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
375 |
(@{ML eresolve_tac}) and so on. |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
376 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
377 |
(FIXME: @{ML cut_facts_tac}) |
99 | 378 |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
379 |
Since rules are applied using higher-order unification, an automatic proof |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
380 |
procedure might become too fragile, if it just applies inference rules shown |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
381 |
in the fashion above. More constraints can be introduced by |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
382 |
pre-instantiating theorems with other theorems. You can do this using the |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
383 |
function @{ML RS}. For example |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
384 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
385 |
@{ML_response_fake [display,gray] |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
386 |
"@{thm disjI1} RS @{thm conjI}" "\<lbrakk>?P1; ?Q\<rbrakk> \<Longrightarrow> (?P1 \<or> ?Q1) \<and> ?Q"} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
387 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
388 |
instantiates the first premise of the @{text conjI}-rule with the |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
389 |
rule @{text disjI1}. The function @{ML RSN} is similar, but |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
390 |
takes a number and makes explicit which premise should be instantiated. |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
391 |
To improve readability we are going use the following function |
99 | 392 |
*} |
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
393 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
394 |
ML{*fun no_vars ctxt thm = |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
395 |
let |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
396 |
val ((_, [thm']), _) = Variable.import_thms true [thm] ctxt |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
397 |
in |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
398 |
thm' |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
399 |
end*} |
93 | 400 |
|
99 | 401 |
text {* |
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
402 |
to transform the schematic variables of a theorem into free variables. |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
403 |
This means for the @{ML RS}-expression above: |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
404 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
405 |
@{ML_response_fake [display,gray] |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
406 |
"no_vars @{context} (@{thm disjI1} RS @{thm conjI})" "\<lbrakk>P; Q\<rbrakk> \<Longrightarrow> (P \<or> Qa) \<and> Q"} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
407 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
408 |
If you want to instantiate more than one premise, you can use the function |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
409 |
@{ML MRS}: |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
410 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
411 |
@{ML_response_fake [display,gray] |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
412 |
"no_vars @{context} ([@{thm disjI1}, @{thm disjI2}] MRS @{thm conjI})" |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
413 |
"\<lbrakk>P; Q\<rbrakk> \<Longrightarrow> (P \<or> Qa) \<and> (Pa \<or> Q)"} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
414 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
415 |
If you need to instantiate lists of theorems, you can use the |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
416 |
functions @{ML RL} and @{ML MRL}. For example below every |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
417 |
theorem in the first list is instantiated against every theorem |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
418 |
in the second. |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
419 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
420 |
@{ML_response_fake [display,gray] |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
421 |
"[@{thm impI}, @{thm disjI2}] RL [@{thm conjI}, @{thm disjI1}]" |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
422 |
"[\<lbrakk>P \<Longrightarrow> Q; Qa\<rbrakk> \<Longrightarrow> (P \<longrightarrow> Q) \<and> Qa, |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
423 |
\<lbrakk>Q; Qa\<rbrakk> \<Longrightarrow> (P \<or> Q) \<and> Qa, |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
424 |
(P \<Longrightarrow> Q) \<Longrightarrow> (P \<longrightarrow> Q) \<or> Qa, |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
425 |
Q \<Longrightarrow> (P \<or> Q) \<or> Qa]"} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
426 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
427 |
\begin{readmore} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
428 |
The combinators for instantiating theorems are defined in @{ML_file "Pure/drule.ML"}. |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
429 |
\end{readmore} |
95
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
430 |
|
104 | 431 |
Often proofs involve elaborate operations on assumptions and |
432 |
@{text "\<And>"}-quantified variables. To do such operations on the ML-level |
|
433 |
using the basic tactics is very unwieldy and brittle. Some convenience and |
|
99 | 434 |
safety is provided by the tactic @{ML SUBPROOF}. This tactic fixes the parameters |
435 |
and binds the various components of a proof state into a record. |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
436 |
To see what happens, assume the function defined in Figure~\ref{fig:sptac}, which |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
437 |
takes a record as argument and just prints out the content of this record (using the |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
438 |
string transformation functions defined in Section~\ref{sec:printing}). Consider |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
439 |
now the proof |
95
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
440 |
*} |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
441 |
|
99 | 442 |
text_raw{* |
443 |
\begin{figure} |
|
444 |
\begin{isabelle} |
|
445 |
*} |
|
95
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
446 |
ML{*fun sp_tac {prems, params, asms, concl, context, schematics} = |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
447 |
let |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
448 |
val str_of_params = str_of_cterms context params |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
449 |
val str_of_asms = str_of_cterms context asms |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
450 |
val str_of_concl = str_of_cterm context concl |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
451 |
val str_of_prems = str_of_thms context prems |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
452 |
val str_of_schms = str_of_cterms context (snd schematics) |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
453 |
|
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
454 |
val _ = (warning ("params: " ^ str_of_params); |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
455 |
warning ("schematics: " ^ str_of_schms); |
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
456 |
warning ("assumptions: " ^ str_of_asms); |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
457 |
warning ("conclusion: " ^ str_of_concl); |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
458 |
warning ("premises: " ^ str_of_prems)) |
95
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
459 |
in |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
460 |
no_tac |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
461 |
end*} |
99 | 462 |
text_raw{* |
463 |
\end{isabelle} |
|
464 |
\caption{A function that prints out the various parameters provided by the tactic |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
465 |
@{ML SUBPROOF}. It uses the functions defined in Section~\ref{sec:printing} for |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
466 |
extracting strings from @{ML_type cterm}s and @{ML_type thm}s.\label{fig:sptac}} |
99 | 467 |
\end{figure} |
468 |
*} |
|
95
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
469 |
|
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
470 |
|
99 | 471 |
lemma shows "\<And>x y. A x y \<Longrightarrow> B y x \<longrightarrow> C (?z y) x" |
95
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
472 |
apply(tactic {* SUBPROOF sp_tac @{context} 1 *})? |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
473 |
|
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
474 |
txt {* |
99 | 475 |
which yields the printout: |
95
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
476 |
|
99 | 477 |
\begin{quote}\small |
95
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
478 |
\begin{tabular}{ll} |
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
479 |
params: & @{term x}, @{term y}\\ |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
480 |
schematics: & @{term z}\\ |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
481 |
assumptions: & @{term "A x y"}\\ |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
482 |
conclusion: & @{term "B y x \<longrightarrow> C (z y) x"}\\ |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
483 |
premises: & @{term "A x y"} |
95
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
484 |
\end{tabular} |
99 | 485 |
\end{quote} |
486 |
||
487 |
Note in the actual output the brown colour of the variables @{term x} and |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
488 |
@{term y}. Although they are parameters in the original goal, they are fixed inside |
99 | 489 |
the subproof. Similarly the schematic variable @{term z}. The assumption |
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
490 |
@{prop "A x y"} is bound as @{ML_type cterm} to the record-variable |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
491 |
@{text asms} but also as @{ML_type thm} to @{text prems}. |
95
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
492 |
|
99 | 493 |
Notice also that we had to append @{text "?"} to \isacommand{apply}. The |
494 |
reason is that @{ML SUBPROOF} normally expects that the subgoal is solved completely. |
|
495 |
Since in the function @{ML sp_tac} we returned the tactic @{ML no_tac}, the subproof |
|
496 |
obviously fails. The question-mark allows us to recover from this failure |
|
497 |
in a graceful manner so that the warning messages are not overwritten |
|
104 | 498 |
by an error message. |
99 | 499 |
|
500 |
If we continue the proof script by applying the @{text impI}-rule |
|
95
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
501 |
*} |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
502 |
|
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
503 |
apply(rule impI) |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
504 |
apply(tactic {* SUBPROOF sp_tac @{context} 1 *})? |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
505 |
|
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
506 |
txt {* |
99 | 507 |
then @{ML SUBPROOF} prints out |
95
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
508 |
|
99 | 509 |
\begin{quote}\small |
95
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
510 |
\begin{tabular}{ll} |
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
511 |
params: & @{term x}, @{term y}\\ |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
512 |
schematics: & @{term z}\\ |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
513 |
assumptions: & @{term "A x y"}, @{term "B y x"}\\ |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
514 |
conclusion: & @{term "C (z y) x"}\\ |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
515 |
premises: & @{term "A x y"}, @{term "B y x"} |
95
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
516 |
\end{tabular} |
99 | 517 |
\end{quote} |
95
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
518 |
*} |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
519 |
(*<*)oops(*>*) |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
520 |
|
99 | 521 |
text {* |
104 | 522 |
where we now also have @{term "B y x"} as an assumption. |
99 | 523 |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
524 |
One convenience of @{ML SUBPROOF} is that we can apply the assumptions |
99 | 525 |
using the usual tactics, because the parameter @{text prems} |
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
526 |
contains them as theorems. With this we can easily |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
527 |
implement a tactic that almost behaves like @{ML atac}, namely: |
99 | 528 |
*} |
529 |
||
104 | 530 |
ML{*val atac' = SUBPROOF (fn {prems, ...} => resolve_tac prems 1)*} |
99 | 531 |
lemma shows "\<And>x y. \<lbrakk>B x y; A x y; C x y\<rbrakk> \<Longrightarrow> A x y" |
104 | 532 |
apply(tactic {* atac' @{context} 1 *}) |
99 | 533 |
txt{* yields |
534 |
@{subgoals [display]} *} |
|
535 |
(*<*)oops(*>*) |
|
536 |
||
104 | 537 |
text {* |
538 |
The restriction in this tactic is that it cannot instantiate any |
|
539 |
schematic variables. This might be seen as a defect, but is actually |
|
540 |
an advantage in the situations for which @{ML SUBPROOF} was designed: |
|
541 |
the reason is that instantiation of schematic variables can affect |
|
542 |
several goals and can render them unprovable. @{ML SUBPROOF} is meant |
|
543 |
to avoid this. |
|
544 |
||
545 |
Notice that @{ML atac'} calls @{ML resolve_tac} with the subgoal |
|
546 |
number @{text "1"} and also the ``outer'' call to @{ML SUBPROOF} in |
|
547 |
the \isacommand{apply}-step uses @{text "1"}. Another advantage |
|
548 |
of @{ML SUBGOAL} is that the addressing inside it is completely |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
549 |
local to the subproof inside. It is therefore possible to also apply |
104 | 550 |
@{ML atac'} to the second goal: |
551 |
*} |
|
552 |
||
553 |
lemma shows "True" and "\<And>x y. \<lbrakk>B x y; A x y; C x y\<rbrakk> \<Longrightarrow> A x y" |
|
554 |
apply(tactic {* atac' @{context} 2 *}) |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
555 |
apply(rule TrueI) |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
556 |
done |
104 | 557 |
|
95
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
558 |
|
93 | 559 |
text {* |
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
560 |
\begin{readmore} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
561 |
The function @{ML SUBPROOF} is defined in @{ML_file "Pure/subgoal.ML"} and |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
562 |
also described in \isccite{sec:results}. |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
563 |
\end{readmore} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
564 |
|
104 | 565 |
A similar but less powerful function than @{ML SUBPROOF} is @{ML SUBGOAL}. |
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
566 |
It allows you to inspect a specified subgoal. With this you can implement |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
567 |
a tactic that applies a rule according to its topmost connective (we only |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
568 |
analyse a few connectives). The tactic is as follows: |
93 | 569 |
*} |
570 |
||
99 | 571 |
ML %linenumbers{*fun select_tac (t,i) = |
572 |
case t of |
|
573 |
@{term "Trueprop"} $ t' => select_tac (t',i) |
|
574 |
| @{term "op \<and>"} $ _ $ _ => rtac @{thm conjI} i |
|
575 |
| @{term "op \<longrightarrow>"} $ _ $ _ => rtac @{thm impI} i |
|
576 |
| @{term "Not"} $ _ => rtac @{thm notI} i |
|
577 |
| Const (@{const_name "All"}, _) $ _ => rtac @{thm allI} i |
|
104 | 578 |
| _ => all_tac*} |
99 | 579 |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
580 |
text {* |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
581 |
In line 3 you need to decend under the outermost @{term "Trueprop"} in order |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
582 |
to get to the connective you like to analyse. Otherwise goals @{prop "A \<and> B"} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
583 |
are not bropek up. In line 7, the pattern cannot be constructed using the |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
584 |
@{text "@term"}-antiquotation, because that would fix the type of the |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
585 |
quantified variable. In this case you really have to construct the pattern |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
586 |
by using the term-constructors. The other cases work, because their type |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
587 |
is always bool. In case that the goal does not fall into any of the categorories, |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
588 |
then we chose to just return @{ML all_tac} (i.e., the tactic never fails). |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
589 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
590 |
Let us now see how to apply this tactic. |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
591 |
*} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
592 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
593 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
594 |
lemma shows "A \<and> B" and "A \<longrightarrow> B \<longrightarrow>C" and "\<forall>x. D x" and "E \<Longrightarrow> F" |
104 | 595 |
apply(tactic {* SUBGOAL select_tac 4 *}) |
596 |
apply(tactic {* SUBGOAL select_tac 3 *}) |
|
597 |
apply(tactic {* SUBGOAL select_tac 2 *}) |
|
99 | 598 |
apply(tactic {* SUBGOAL select_tac 1 *}) |
599 |
txt{* @{subgoals [display]} *} |
|
600 |
(*<*)oops(*>*) |
|
601 |
||
602 |
text {* |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
603 |
Note that we applied it in ``reverse'' order. This is a trick in |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
604 |
order to be independent from what subgoals the rule produced. If we had |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
605 |
it applied in the other order |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
606 |
*} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
607 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
608 |
lemma shows "A \<and> B" and "A \<longrightarrow> B \<longrightarrow>C" and "\<forall>x. D x" and "E \<Longrightarrow> F" |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
609 |
apply(tactic {* SUBGOAL select_tac 1 *}) |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
610 |
apply(tactic {* SUBGOAL select_tac 3 *}) |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
611 |
apply(tactic {* SUBGOAL select_tac 4 *}) |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
612 |
apply(tactic {* SUBGOAL select_tac 5 *}) |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
613 |
(*<*)oops(*>*) |
99 | 614 |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
615 |
text {* |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
616 |
then we have to be careful to not apply the tactic to the two subgoals the |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
617 |
first goal produced. This can be messy in an automated proof script. The |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
618 |
reverse application, on the other hand, is easy to implement. |
104 | 619 |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
620 |
However, this example is contrived: there are much simpler ways to implement |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
621 |
such proof procedure that analyses a goal according to its topmost |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
622 |
connective. They will be explained in the next section. |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
623 |
*} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
624 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
625 |
section {* Tactic Combinators *} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
626 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
627 |
text {* |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
628 |
To be able to implement powerful tactics out of smaller component tactics, |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
629 |
Isabelle provides tactic combinators. In the previous section we already |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
630 |
used @{ML THEN} which strings two tactics together in sequence. For example: |
93 | 631 |
*} |
632 |
||
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
633 |
lemma shows "(Foo \<and> Bar) \<and> False" |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
634 |
apply(tactic {* rtac @{thm conjI} 1 THEN rtac @{thm conjI} 1 *}) |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
635 |
txt {* \begin{minipage}{\textwidth} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
636 |
@{subgoals [display]} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
637 |
\end{minipage} *} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
638 |
(*<*)oops(*>*) |
99 | 639 |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
640 |
text {* |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
641 |
If you want to avoid the hard-coded subgoal addressing, then you can use |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
642 |
@{ML THEN'}. For example: |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
643 |
*} |
93 | 644 |
|
99 | 645 |
lemma shows "(Foo \<and> Bar) \<and> False" |
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
646 |
apply(tactic {* (rtac @{thm conjI} THEN' rtac @{thm conjI}) 1 *}) |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
647 |
txt {* \begin{minipage}{\textwidth} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
648 |
@{subgoals [display]} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
649 |
\end{minipage} *} |
93 | 650 |
(*<*)oops(*>*) |
651 |
||
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
652 |
text {* |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
653 |
For most tactic combinators such a ``primed'' version exists. |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
654 |
In what follows we will, whenever appropriate, prefer the primed version of |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
655 |
the tactic combinator and omit to mention the simple one. |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
656 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
657 |
With @{ML THEN} and @{ML THEN'} it must be guaranteed that both tactics |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
658 |
sucessfully apply; otherwise the whole tactic will fail. If you want to |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
659 |
try out either one tactic, then you can use @{ML ORELSE'}. For |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
660 |
example |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
661 |
*} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
662 |
|
99 | 663 |
ML{*val orelse_xmp = (rtac @{thm disjI1} ORELSE' rtac @{thm conjI})*} |
664 |
||
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
665 |
text {* |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
666 |
will first try out rule @{text disjI} and after that @{text conjI}. |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
667 |
*} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
668 |
|
99 | 669 |
lemma shows "True \<and> False" and "Foo \<or> Bar" |
670 |
apply(tactic {* orelse_xmp 1 *}) |
|
671 |
apply(tactic {* orelse_xmp 3 *}) |
|
93 | 672 |
txt {* @{subgoals [display]} *} |
673 |
(*<*)oops(*>*) |
|
674 |
||
675 |
||
676 |
text {* |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
677 |
applies |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
678 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
679 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
680 |
@{ML REPEAT} @{ML DETERM} |
93 | 681 |
|
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
682 |
*} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
683 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
684 |
section {* Rewriting and Simplifier Tactics *} |
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
685 |
|
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
686 |
text {* |
93 | 687 |
@{ML rewrite_goals_tac} |
688 |
@{ML ObjectLogic.full_atomize_tac} |
|
689 |
@{ML ObjectLogic.rulify_tac} |
|
690 |
*} |
|
691 |
||
105
f49dc7e96235
added more to the Tactical section
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
692 |
|
95
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
693 |
section {* Structured Proofs *} |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
694 |
|
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
695 |
lemma True |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
696 |
proof |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
697 |
|
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
698 |
{ |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
699 |
fix A B C |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
700 |
assume r: "A & B \<Longrightarrow> C" |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
701 |
assume A B |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
702 |
then have "A & B" .. |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
703 |
then have C by (rule r) |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
704 |
} |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
705 |
|
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
706 |
{ |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
707 |
fix A B C |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
708 |
assume r: "A & B \<Longrightarrow> C" |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
709 |
assume A B |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
710 |
note conjI [OF this] |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
711 |
note r [OF this] |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
712 |
} |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
713 |
oops |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
714 |
|
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
715 |
ML {* fun prop ctxt s = |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
716 |
Thm.cterm_of (ProofContext.theory_of ctxt) (Syntax.read_prop ctxt s) *} |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
717 |
|
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
718 |
ML {* |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
719 |
val ctxt0 = @{context}; |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
720 |
val ctxt = ctxt0; |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
721 |
val (_, ctxt) = Variable.add_fixes ["A", "B", "C"] ctxt; |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
722 |
val ([r], ctxt) = Assumption.add_assumes [prop ctxt "A & B \<Longrightarrow> C"] ctxt; |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
723 |
val (this, ctxt) = Assumption.add_assumes [prop ctxt "A", prop ctxt "B"] ctxt; |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
724 |
val this = [@{thm conjI} OF this]; |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
725 |
val this = r OF this; |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
726 |
val this = Assumption.export false ctxt ctxt0 this |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
727 |
val this = Variable.export ctxt ctxt0 [this] |
7235374f34c8
added some preliminary notes about SUBPROOF
Christian Urban <urbanc@in.tum.de>
parents:
93
diff
changeset
|
728 |
*} |
93 | 729 |
|
730 |
||
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
99
diff
changeset
|
731 |
|
93 | 732 |
end |