nipkow@10560
|
1 |
%
|
nipkow@10560
|
2 |
\begin{isabellebody}%
|
nipkow@10560
|
3 |
\def\isabellecontext{Pairs}%
|
wenzelm@17056
|
4 |
%
|
wenzelm@17056
|
5 |
\isadelimtheory
|
wenzelm@17056
|
6 |
%
|
wenzelm@17056
|
7 |
\endisadelimtheory
|
wenzelm@17056
|
8 |
%
|
wenzelm@17056
|
9 |
\isatagtheory
|
wenzelm@17056
|
10 |
%
|
wenzelm@17056
|
11 |
\endisatagtheory
|
wenzelm@17056
|
12 |
{\isafoldtheory}%
|
wenzelm@17056
|
13 |
%
|
wenzelm@17056
|
14 |
\isadelimtheory
|
wenzelm@17056
|
15 |
%
|
wenzelm@17056
|
16 |
\endisadelimtheory
|
nipkow@10560
|
17 |
%
|
paulson@11428
|
18 |
\isamarkupsection{Pairs and Tuples%
|
nipkow@10560
|
19 |
}
|
wenzelm@11866
|
20 |
\isamarkuptrue%
|
nipkow@10560
|
21 |
%
|
nipkow@10560
|
22 |
\begin{isamarkuptext}%
|
nipkow@10560
|
23 |
\label{sec:products}
|
paulson@11428
|
24 |
Ordered pairs were already introduced in \S\ref{sec:pairs}, but only with a minimal
|
nipkow@10560
|
25 |
repertoire of operations: pairing and the two projections \isa{fst} and
|
nipkow@11149
|
26 |
\isa{snd}. In any non-trivial application of pairs you will find that this
|
paulson@11494
|
27 |
quickly leads to unreadable nests of projections. This
|
paulson@11494
|
28 |
section introduces syntactic sugar to overcome this
|
nipkow@10560
|
29 |
problem: pattern matching with tuples.%
|
nipkow@10560
|
30 |
\end{isamarkuptext}%
|
wenzelm@11866
|
31 |
\isamarkuptrue%
|
nipkow@10560
|
32 |
%
|
paulson@10878
|
33 |
\isamarkupsubsection{Pattern Matching with Tuples%
|
nipkow@10560
|
34 |
}
|
wenzelm@11866
|
35 |
\isamarkuptrue%
|
nipkow@10560
|
36 |
%
|
nipkow@10560
|
37 |
\begin{isamarkuptext}%
|
paulson@10878
|
38 |
Tuples may be used as patterns in $\lambda$-abstractions,
|
nipkow@10560
|
39 |
for example \isa{{\isasymlambda}{\isacharparenleft}x{\isacharcomma}y{\isacharcomma}z{\isacharparenright}{\isachardot}x{\isacharplus}y{\isacharplus}z} and \isa{{\isasymlambda}{\isacharparenleft}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}{\isacharcomma}z{\isacharparenright}{\isachardot}x{\isacharplus}y{\isacharplus}z}. In fact,
|
paulson@10878
|
40 |
tuple patterns can be used in most variable binding constructs,
|
paulson@10878
|
41 |
and they can be nested. Here are
|
nipkow@10560
|
42 |
some typical examples:
|
nipkow@10560
|
43 |
\begin{quote}
|
nipkow@10560
|
44 |
\isa{let\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isacharequal}\ f\ z\ in\ {\isacharparenleft}y{\isacharcomma}\ x{\isacharparenright}}\\
|
nipkow@12699
|
45 |
\isa{case\ xs\ of\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymRightarrow}\ {\isadigit{0}}\ {\isacharbar}\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isacharhash}\ zs\ {\isasymRightarrow}\ x\ {\isacharplus}\ y}\\
|
nipkow@10560
|
46 |
\isa{{\isasymforall}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}{\isasymin}A{\isachardot}\ x{\isacharequal}y}\\
|
paulson@10878
|
47 |
\isa{{\isacharbraceleft}{\isacharparenleft}x{\isacharcomma}y{\isacharcomma}z{\isacharparenright}{\isachardot}\ x{\isacharequal}z{\isacharbraceright}}\\
|
paulson@14387
|
48 |
\isa{{\isasymUnion}\isactrlbsub {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}{\isasymin}A\isactrlesub \ {\isacharbraceleft}x\ {\isacharplus}\ y{\isacharbraceright}}
|
nipkow@11149
|
49 |
\end{quote}
|
paulson@10878
|
50 |
The intuitive meanings of these expressions should be obvious.
|
nipkow@10560
|
51 |
Unfortunately, we need to know in more detail what the notation really stands
|
paulson@10878
|
52 |
for once we have to reason about it. Abstraction
|
nipkow@10560
|
53 |
over pairs and tuples is merely a convenient shorthand for a more complex
|
nipkow@10560
|
54 |
internal representation. Thus the internal and external form of a term may
|
nipkow@10560
|
55 |
differ, which can affect proofs. If you want to avoid this complication,
|
nipkow@10560
|
56 |
stick to \isa{fst} and \isa{snd} and write \isa{{\isasymlambda}p{\isachardot}\ fst\ p\ {\isacharplus}\ snd\ p}
|
paulson@11494
|
57 |
instead of \isa{{\isasymlambda}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}{\isachardot}\ x{\isacharplus}y}. These terms are distinct even though they
|
paulson@11494
|
58 |
denote the same function.
|
nipkow@10560
|
59 |
|
nipkow@10560
|
60 |
Internally, \isa{{\isasymlambda}{\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}{\isachardot}\ t} becomes \isa{split\ {\isacharparenleft}{\isasymlambda}x\ y{\isachardot}\ t{\isacharparenright}}, where
|
paulson@11494
|
61 |
\cdx{split} is the uncurrying function of type \isa{{\isacharparenleft}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}b\ {\isasymRightarrow}\ {\isacharprime}c{\isacharparenright}\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymtimes}\ {\isacharprime}b\ {\isasymRightarrow}\ {\isacharprime}c} defined as
|
nipkow@10560
|
62 |
\begin{center}
|
wenzelm@37216
|
63 |
\isa{split\ {\isacharequal}\ {\isacharparenleft}{\isasymlambda}c\ p{\isachardot}\ c\ {\isacharparenleft}fst\ p{\isacharparenright}\ {\isacharparenleft}snd\ p{\isacharparenright}{\isacharparenright}}
|
nipkow@10560
|
64 |
\hfill(\isa{split{\isacharunderscore}def})
|
nipkow@10560
|
65 |
\end{center}
|
nipkow@10560
|
66 |
Pattern matching in
|
nipkow@10560
|
67 |
other variable binding constructs is translated similarly. Thus we need to
|
nipkow@10560
|
68 |
understand how to reason about such constructs.%
|
nipkow@10560
|
69 |
\end{isamarkuptext}%
|
wenzelm@11866
|
70 |
\isamarkuptrue%
|
nipkow@10560
|
71 |
%
|
paulson@10878
|
72 |
\isamarkupsubsection{Theorem Proving%
|
nipkow@10560
|
73 |
}
|
wenzelm@11866
|
74 |
\isamarkuptrue%
|
nipkow@10560
|
75 |
%
|
nipkow@10560
|
76 |
\begin{isamarkuptext}%
|
nipkow@10560
|
77 |
The most obvious approach is the brute force expansion of \isa{split}:%
|
nipkow@10560
|
78 |
\end{isamarkuptext}%
|
wenzelm@17175
|
79 |
\isamarkuptrue%
|
wenzelm@17175
|
80 |
\isacommand{lemma}\isamarkupfalse%
|
wenzelm@17175
|
81 |
\ {\isachardoublequoteopen}{\isacharparenleft}{\isasymlambda}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}{\isachardot}x{\isacharparenright}\ p\ {\isacharequal}\ fst\ p{\isachardoublequoteclose}\isanewline
|
wenzelm@17056
|
82 |
%
|
wenzelm@17056
|
83 |
\isadelimproof
|
wenzelm@17056
|
84 |
%
|
wenzelm@17056
|
85 |
\endisadelimproof
|
wenzelm@17056
|
86 |
%
|
wenzelm@17056
|
87 |
\isatagproof
|
wenzelm@17175
|
88 |
\isacommand{by}\isamarkupfalse%
|
wenzelm@17175
|
89 |
{\isacharparenleft}simp\ add{\isacharcolon}\ split{\isacharunderscore}def{\isacharparenright}%
|
wenzelm@17056
|
90 |
\endisatagproof
|
wenzelm@17056
|
91 |
{\isafoldproof}%
|
wenzelm@17056
|
92 |
%
|
wenzelm@17056
|
93 |
\isadelimproof
|
wenzelm@17056
|
94 |
%
|
wenzelm@17056
|
95 |
\endisadelimproof
|
wenzelm@11866
|
96 |
%
|
nipkow@10560
|
97 |
\begin{isamarkuptext}%
|
nipkow@27027
|
98 |
\noindent
|
nipkow@10560
|
99 |
This works well if rewriting with \isa{split{\isacharunderscore}def} finishes the
|
nipkow@11149
|
100 |
proof, as it does above. But if it does not, you end up with exactly what
|
nipkow@10560
|
101 |
we are trying to avoid: nests of \isa{fst} and \isa{snd}. Thus this
|
nipkow@10560
|
102 |
approach is neither elegant nor very practical in large examples, although it
|
nipkow@10560
|
103 |
can be effective in small ones.
|
nipkow@10560
|
104 |
|
paulson@11494
|
105 |
If we consider why this lemma presents a problem,
|
nipkow@27027
|
106 |
we realize that we need to replace variable~\isa{p} by some pair \isa{{\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}}. Then both sides of the
|
paulson@11494
|
107 |
equation would simplify to \isa{a} by the simplification rules
|
wenzelm@26698
|
108 |
\isa{split\ f\ {\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}\ {\isacharequal}\ f\ a\ b} and \isa{fst\ {\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}\ {\isacharequal}\ a}.
|
paulson@11494
|
109 |
To reason about tuple patterns requires some way of
|
paulson@11494
|
110 |
converting a variable of product type into a pair.
|
nipkow@10560
|
111 |
In case of a subterm of the form \isa{split\ f\ p} this is easy: the split
|
nipkow@10560
|
112 |
rule \isa{split{\isacharunderscore}split} replaces \isa{p} by a pair:%
|
paulson@11494
|
113 |
\index{*split (method)}%
|
nipkow@10560
|
114 |
\end{isamarkuptext}%
|
wenzelm@17175
|
115 |
\isamarkuptrue%
|
wenzelm@17175
|
116 |
\isacommand{lemma}\isamarkupfalse%
|
wenzelm@17175
|
117 |
\ {\isachardoublequoteopen}{\isacharparenleft}{\isasymlambda}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}{\isachardot}y{\isacharparenright}\ p\ {\isacharequal}\ snd\ p{\isachardoublequoteclose}\isanewline
|
wenzelm@17056
|
118 |
%
|
wenzelm@17056
|
119 |
\isadelimproof
|
wenzelm@17056
|
120 |
%
|
wenzelm@17056
|
121 |
\endisadelimproof
|
wenzelm@17056
|
122 |
%
|
wenzelm@17056
|
123 |
\isatagproof
|
wenzelm@17175
|
124 |
\isacommand{apply}\isamarkupfalse%
|
wenzelm@17175
|
125 |
{\isacharparenleft}split\ split{\isacharunderscore}split{\isacharparenright}%
|
wenzelm@16353
|
126 |
\begin{isamarkuptxt}%
|
wenzelm@16353
|
127 |
\begin{isabelle}%
|
wenzelm@16353
|
128 |
\ {\isadigit{1}}{\isachardot}\ {\isasymforall}x\ y{\isachardot}\ p\ {\isacharequal}\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isasymlongrightarrow}\ y\ {\isacharequal}\ snd\ p%
|
wenzelm@16353
|
129 |
\end{isabelle}
|
wenzelm@16353
|
130 |
This subgoal is easily proved by simplification. Thus we could have combined
|
wenzelm@16353
|
131 |
simplification and splitting in one command that proves the goal outright:%
|
wenzelm@16353
|
132 |
\end{isamarkuptxt}%
|
wenzelm@17175
|
133 |
\isamarkuptrue%
|
wenzelm@17056
|
134 |
%
|
wenzelm@17056
|
135 |
\endisatagproof
|
wenzelm@17056
|
136 |
{\isafoldproof}%
|
wenzelm@17056
|
137 |
%
|
wenzelm@17056
|
138 |
\isadelimproof
|
wenzelm@17056
|
139 |
%
|
wenzelm@17056
|
140 |
\endisadelimproof
|
wenzelm@17056
|
141 |
%
|
wenzelm@17056
|
142 |
\isadelimproof
|
wenzelm@17056
|
143 |
%
|
wenzelm@17056
|
144 |
\endisadelimproof
|
wenzelm@17056
|
145 |
%
|
wenzelm@17056
|
146 |
\isatagproof
|
wenzelm@17175
|
147 |
\isacommand{by}\isamarkupfalse%
|
wenzelm@17175
|
148 |
{\isacharparenleft}simp\ split{\isacharcolon}\ split{\isacharunderscore}split{\isacharparenright}%
|
wenzelm@17175
|
149 |
\endisatagproof
|
wenzelm@17175
|
150 |
{\isafoldproof}%
|
wenzelm@17175
|
151 |
%
|
wenzelm@17175
|
152 |
\isadelimproof
|
wenzelm@17175
|
153 |
%
|
wenzelm@17175
|
154 |
\endisadelimproof
|
wenzelm@17175
|
155 |
%
|
wenzelm@17175
|
156 |
\begin{isamarkuptext}%
|
wenzelm@17175
|
157 |
Let us look at a second example:%
|
wenzelm@17175
|
158 |
\end{isamarkuptext}%
|
wenzelm@17175
|
159 |
\isamarkuptrue%
|
wenzelm@17175
|
160 |
\isacommand{lemma}\isamarkupfalse%
|
wenzelm@17175
|
161 |
\ {\isachardoublequoteopen}let\ {\isacharparenleft}x{\isacharcomma}y{\isacharparenright}\ {\isacharequal}\ p\ in\ fst\ p\ {\isacharequal}\ x{\isachardoublequoteclose}\isanewline
|
wenzelm@17175
|
162 |
%
|
wenzelm@17175
|
163 |
\isadelimproof
|
wenzelm@17175
|
164 |
%
|
wenzelm@17175
|
165 |
\endisadelimproof
|
wenzelm@17175
|
166 |
%
|
wenzelm@17175
|
167 |
\isatagproof
|
wenzelm@17175
|
168 |
\isacommand{apply}\isamarkupfalse%
|
wenzelm@17175
|
169 |
{\isacharparenleft}simp\ only{\isacharcolon}\ Let{\isacharunderscore}def{\isacharparenright}%
|
wenzelm@17175
|
170 |
\begin{isamarkuptxt}%
|
wenzelm@17175
|
171 |
\begin{isabelle}%
|
wenzelm@17175
|
172 |
\ {\isadigit{1}}{\isachardot}\ {\isacharparenleft}{\isasymlambda}{\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}{\isachardot}\ fst\ p\ {\isacharequal}\ x{\isacharparenright}\ p%
|
wenzelm@17175
|
173 |
\end{isabelle}
|
wenzelm@17175
|
174 |
A paired \isa{let} reduces to a paired $\lambda$-abstraction, which
|
wenzelm@17175
|
175 |
can be split as above. The same is true for paired set comprehension:%
|
wenzelm@17175
|
176 |
\end{isamarkuptxt}%
|
wenzelm@17175
|
177 |
\isamarkuptrue%
|
wenzelm@16353
|
178 |
%
|
wenzelm@17175
|
179 |
\endisatagproof
|
wenzelm@17175
|
180 |
{\isafoldproof}%
|
wenzelm@17175
|
181 |
%
|
wenzelm@17175
|
182 |
\isadelimproof
|
wenzelm@17175
|
183 |
%
|
wenzelm@17175
|
184 |
\endisadelimproof
|
wenzelm@17175
|
185 |
\isacommand{lemma}\isamarkupfalse%
|
wenzelm@17175
|
186 |
\ {\isachardoublequoteopen}p\ {\isasymin}\ {\isacharbraceleft}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}{\isachardot}\ x{\isacharequal}y{\isacharbraceright}\ {\isasymlongrightarrow}\ fst\ p\ {\isacharequal}\ snd\ p{\isachardoublequoteclose}\isanewline
|
wenzelm@17175
|
187 |
%
|
wenzelm@17175
|
188 |
\isadelimproof
|
wenzelm@17175
|
189 |
%
|
wenzelm@17175
|
190 |
\endisadelimproof
|
wenzelm@17175
|
191 |
%
|
wenzelm@17175
|
192 |
\isatagproof
|
wenzelm@17175
|
193 |
\isacommand{apply}\isamarkupfalse%
|
wenzelm@17175
|
194 |
\ simp%
|
wenzelm@16353
|
195 |
\begin{isamarkuptxt}%
|
wenzelm@16353
|
196 |
\begin{isabelle}%
|
wenzelm@16353
|
197 |
\ {\isadigit{1}}{\isachardot}\ split\ op\ {\isacharequal}\ p\ {\isasymlongrightarrow}\ fst\ p\ {\isacharequal}\ snd\ p%
|
wenzelm@16353
|
198 |
\end{isabelle}
|
wenzelm@16353
|
199 |
Again, simplification produces a term suitable for \isa{split{\isacharunderscore}split}
|
wenzelm@16353
|
200 |
as above. If you are worried about the strange form of the premise:
|
nipkow@27169
|
201 |
\isa{split\ {\isacharparenleft}op\ {\isacharequal}{\isacharparenright}} is short for \isa{{\isasymlambda}{\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}{\isachardot}\ x\ {\isacharequal}\ y}.
|
wenzelm@16353
|
202 |
The same proof procedure works for%
|
wenzelm@16353
|
203 |
\end{isamarkuptxt}%
|
wenzelm@17175
|
204 |
\isamarkuptrue%
|
wenzelm@17056
|
205 |
%
|
wenzelm@17056
|
206 |
\endisatagproof
|
wenzelm@17056
|
207 |
{\isafoldproof}%
|
wenzelm@17056
|
208 |
%
|
wenzelm@17056
|
209 |
\isadelimproof
|
wenzelm@17056
|
210 |
%
|
wenzelm@17056
|
211 |
\endisadelimproof
|
wenzelm@17175
|
212 |
\isacommand{lemma}\isamarkupfalse%
|
wenzelm@17175
|
213 |
\ {\isachardoublequoteopen}p\ {\isasymin}\ {\isacharbraceleft}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}{\isachardot}\ x{\isacharequal}y{\isacharbraceright}\ {\isasymLongrightarrow}\ fst\ p\ {\isacharequal}\ snd\ p{\isachardoublequoteclose}%
|
wenzelm@17056
|
214 |
\isadelimproof
|
wenzelm@17056
|
215 |
%
|
wenzelm@17056
|
216 |
\endisadelimproof
|
wenzelm@17056
|
217 |
%
|
wenzelm@17056
|
218 |
\isatagproof
|
wenzelm@16353
|
219 |
%
|
wenzelm@16353
|
220 |
\begin{isamarkuptxt}%
|
wenzelm@16353
|
221 |
\noindent
|
wenzelm@16353
|
222 |
except that we now have to use \isa{split{\isacharunderscore}split{\isacharunderscore}asm}, because
|
wenzelm@16353
|
223 |
\isa{split} occurs in the assumptions.
|
wenzelm@16353
|
224 |
|
wenzelm@16353
|
225 |
However, splitting \isa{split} is not always a solution, as no \isa{split}
|
wenzelm@16353
|
226 |
may be present in the goal. Consider the following function:%
|
wenzelm@16353
|
227 |
\end{isamarkuptxt}%
|
wenzelm@17175
|
228 |
\isamarkuptrue%
|
wenzelm@17056
|
229 |
%
|
wenzelm@17056
|
230 |
\endisatagproof
|
wenzelm@17056
|
231 |
{\isafoldproof}%
|
wenzelm@17056
|
232 |
%
|
wenzelm@17056
|
233 |
\isadelimproof
|
wenzelm@17056
|
234 |
%
|
wenzelm@17056
|
235 |
\endisadelimproof
|
wenzelm@17175
|
236 |
\isacommand{primrec}\isamarkupfalse%
|
nipkow@27027
|
237 |
\ swap\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharprime}a\ {\isasymtimes}\ {\isacharprime}b\ {\isasymRightarrow}\ {\isacharprime}b\ {\isasymtimes}\ {\isacharprime}a{\isachardoublequoteclose}\ \isakeyword{where}\ {\isachardoublequoteopen}swap\ {\isacharparenleft}x{\isacharcomma}y{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}y{\isacharcomma}x{\isacharparenright}{\isachardoublequoteclose}%
|
nipkow@10560
|
238 |
\begin{isamarkuptext}%
|
nipkow@10560
|
239 |
\noindent
|
nipkow@10560
|
240 |
Note that the above \isacommand{primrec} definition is admissible
|
nipkow@10560
|
241 |
because \isa{{\isasymtimes}} is a datatype. When we now try to prove%
|
nipkow@10560
|
242 |
\end{isamarkuptext}%
|
wenzelm@17175
|
243 |
\isamarkuptrue%
|
wenzelm@17175
|
244 |
\isacommand{lemma}\isamarkupfalse%
|
wenzelm@17175
|
245 |
\ {\isachardoublequoteopen}swap{\isacharparenleft}swap\ p{\isacharparenright}\ {\isacharequal}\ p{\isachardoublequoteclose}%
|
wenzelm@17056
|
246 |
\isadelimproof
|
wenzelm@17056
|
247 |
%
|
wenzelm@17056
|
248 |
\endisadelimproof
|
wenzelm@17056
|
249 |
%
|
wenzelm@17056
|
250 |
\isatagproof
|
wenzelm@16353
|
251 |
%
|
wenzelm@16353
|
252 |
\begin{isamarkuptxt}%
|
wenzelm@16353
|
253 |
\noindent
|
nipkow@27027
|
254 |
simplification will do nothing, because the defining equation for
|
nipkow@27027
|
255 |
\isa{swap} expects a pair. Again, we need to turn \isa{p}
|
nipkow@27027
|
256 |
into a pair first, but this time there is no \isa{split} in sight.
|
nipkow@27027
|
257 |
The only thing we can do is to split the term by hand:%
|
wenzelm@16353
|
258 |
\end{isamarkuptxt}%
|
wenzelm@17175
|
259 |
\isamarkuptrue%
|
wenzelm@17175
|
260 |
\isacommand{apply}\isamarkupfalse%
|
wenzelm@17175
|
261 |
{\isacharparenleft}case{\isacharunderscore}tac\ p{\isacharparenright}%
|
wenzelm@16353
|
262 |
\begin{isamarkuptxt}%
|
wenzelm@16353
|
263 |
\noindent
|
wenzelm@16353
|
264 |
\begin{isabelle}%
|
nipkow@27027
|
265 |
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}a\ b{\isachardot}\ p\ {\isacharequal}\ {\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}\ {\isasymLongrightarrow}\ swap\ {\isacharparenleft}swap\ p{\isacharparenright}\ {\isacharequal}\ p%
|
wenzelm@16353
|
266 |
\end{isabelle}
|
wenzelm@16353
|
267 |
Again, \methdx{case_tac} is applicable because \isa{{\isasymtimes}} is a datatype.
|
wenzelm@16353
|
268 |
The subgoal is easily proved by \isa{simp}.
|
wenzelm@16353
|
269 |
|
wenzelm@16353
|
270 |
Splitting by \isa{case{\isacharunderscore}tac} also solves the previous examples and may thus
|
wenzelm@16353
|
271 |
appear preferable to the more arcane methods introduced first. However, see
|
wenzelm@16353
|
272 |
the warning about \isa{case{\isacharunderscore}tac} in \S\ref{sec:struct-ind-case}.
|
wenzelm@16353
|
273 |
|
nipkow@27027
|
274 |
Alternatively, you can split \emph{all} \isa{{\isasymAnd}}-quantified variables
|
nipkow@27027
|
275 |
in a goal with the rewrite rule \isa{split{\isacharunderscore}paired{\isacharunderscore}all}:%
|
wenzelm@16353
|
276 |
\end{isamarkuptxt}%
|
wenzelm@17175
|
277 |
\isamarkuptrue%
|
wenzelm@17056
|
278 |
%
|
wenzelm@17056
|
279 |
\endisatagproof
|
wenzelm@17056
|
280 |
{\isafoldproof}%
|
wenzelm@17056
|
281 |
%
|
wenzelm@17056
|
282 |
\isadelimproof
|
wenzelm@17056
|
283 |
%
|
wenzelm@17056
|
284 |
\endisadelimproof
|
wenzelm@17175
|
285 |
\isacommand{lemma}\isamarkupfalse%
|
wenzelm@17175
|
286 |
\ {\isachardoublequoteopen}{\isasymAnd}p\ q{\isachardot}\ swap{\isacharparenleft}swap\ p{\isacharparenright}\ {\isacharequal}\ q\ {\isasymlongrightarrow}\ p\ {\isacharequal}\ q{\isachardoublequoteclose}\isanewline
|
wenzelm@17056
|
287 |
%
|
wenzelm@17056
|
288 |
\isadelimproof
|
wenzelm@17056
|
289 |
%
|
wenzelm@17056
|
290 |
\endisadelimproof
|
wenzelm@17056
|
291 |
%
|
wenzelm@17056
|
292 |
\isatagproof
|
wenzelm@17175
|
293 |
\isacommand{apply}\isamarkupfalse%
|
wenzelm@17175
|
294 |
{\isacharparenleft}simp\ only{\isacharcolon}\ split{\isacharunderscore}paired{\isacharunderscore}all{\isacharparenright}%
|
wenzelm@16353
|
295 |
\begin{isamarkuptxt}%
|
wenzelm@16353
|
296 |
\noindent
|
wenzelm@16353
|
297 |
\begin{isabelle}%
|
nipkow@27027
|
298 |
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}a\ b\ aa\ ba{\isachardot}\ swap\ {\isacharparenleft}swap\ {\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}aa{\isacharcomma}\ ba{\isacharparenright}\ {\isasymlongrightarrow}\ {\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}aa{\isacharcomma}\ ba{\isacharparenright}%
|
wenzelm@16353
|
299 |
\end{isabelle}%
|
wenzelm@16353
|
300 |
\end{isamarkuptxt}%
|
wenzelm@17175
|
301 |
\isamarkuptrue%
|
wenzelm@17175
|
302 |
\isacommand{apply}\isamarkupfalse%
|
wenzelm@17175
|
303 |
\ simp\isanewline
|
wenzelm@17175
|
304 |
\isacommand{done}\isamarkupfalse%
|
wenzelm@17175
|
305 |
%
|
wenzelm@17056
|
306 |
\endisatagproof
|
wenzelm@17056
|
307 |
{\isafoldproof}%
|
wenzelm@17056
|
308 |
%
|
wenzelm@17056
|
309 |
\isadelimproof
|
wenzelm@17056
|
310 |
%
|
wenzelm@17056
|
311 |
\endisadelimproof
|
wenzelm@11866
|
312 |
%
|
nipkow@10560
|
313 |
\begin{isamarkuptext}%
|
nipkow@10560
|
314 |
\noindent
|
nipkow@10560
|
315 |
Note that we have intentionally included only \isa{split{\isacharunderscore}paired{\isacharunderscore}all}
|
paulson@11494
|
316 |
in the first simplification step, and then we simplify again.
|
paulson@11494
|
317 |
This time the reason was not merely
|
nipkow@10560
|
318 |
pedagogical:
|
paulson@11494
|
319 |
\isa{split{\isacharunderscore}paired{\isacharunderscore}all} may interfere with other functions
|
paulson@11494
|
320 |
of the simplifier.
|
paulson@11494
|
321 |
The following command could fail (here it does not)
|
paulson@11494
|
322 |
where two separate \isa{simp} applications succeed.%
|
nipkow@10560
|
323 |
\end{isamarkuptext}%
|
wenzelm@17175
|
324 |
\isamarkuptrue%
|
wenzelm@17056
|
325 |
%
|
wenzelm@17056
|
326 |
\isadelimproof
|
wenzelm@17056
|
327 |
%
|
wenzelm@17056
|
328 |
\endisadelimproof
|
wenzelm@17056
|
329 |
%
|
wenzelm@17056
|
330 |
\isatagproof
|
wenzelm@17175
|
331 |
\isacommand{apply}\isamarkupfalse%
|
wenzelm@17181
|
332 |
{\isacharparenleft}simp\ add{\isacharcolon}\ split{\isacharunderscore}paired{\isacharunderscore}all{\isacharparenright}%
|
wenzelm@17056
|
333 |
\endisatagproof
|
wenzelm@17056
|
334 |
{\isafoldproof}%
|
wenzelm@17056
|
335 |
%
|
wenzelm@17056
|
336 |
\isadelimproof
|
wenzelm@17056
|
337 |
%
|
wenzelm@17056
|
338 |
\endisadelimproof
|
wenzelm@11866
|
339 |
%
|
nipkow@10560
|
340 |
\begin{isamarkuptext}%
|
nipkow@10560
|
341 |
\noindent
|
paulson@11494
|
342 |
Finally, the simplifier automatically splits all \isa{{\isasymforall}} and
|
paulson@11494
|
343 |
\isa{{\isasymexists}}-quantified variables:%
|
nipkow@10560
|
344 |
\end{isamarkuptext}%
|
wenzelm@17175
|
345 |
\isamarkuptrue%
|
wenzelm@17175
|
346 |
\isacommand{lemma}\isamarkupfalse%
|
wenzelm@17175
|
347 |
\ {\isachardoublequoteopen}{\isasymforall}p{\isachardot}\ {\isasymexists}q{\isachardot}\ swap\ p\ {\isacharequal}\ swap\ q{\isachardoublequoteclose}\isanewline
|
wenzelm@17056
|
348 |
%
|
wenzelm@17056
|
349 |
\isadelimproof
|
wenzelm@17056
|
350 |
%
|
wenzelm@17056
|
351 |
\endisadelimproof
|
wenzelm@17056
|
352 |
%
|
wenzelm@17056
|
353 |
\isatagproof
|
wenzelm@17175
|
354 |
\isacommand{by}\isamarkupfalse%
|
wenzelm@17175
|
355 |
\ simp%
|
wenzelm@17056
|
356 |
\endisatagproof
|
wenzelm@17056
|
357 |
{\isafoldproof}%
|
wenzelm@17056
|
358 |
%
|
wenzelm@17056
|
359 |
\isadelimproof
|
wenzelm@17056
|
360 |
%
|
wenzelm@17056
|
361 |
\endisadelimproof
|
wenzelm@11866
|
362 |
%
|
nipkow@10560
|
363 |
\begin{isamarkuptext}%
|
nipkow@10560
|
364 |
\noindent
|
nipkow@27027
|
365 |
To turn off this automatic splitting, disable the
|
nipkow@10560
|
366 |
responsible simplification rules:
|
nipkow@10560
|
367 |
\begin{center}
|
nipkow@10654
|
368 |
\isa{{\isacharparenleft}{\isasymforall}x{\isachardot}\ P\ x{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}{\isasymforall}a\ b{\isachardot}\ P\ {\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}{\isacharparenright}}
|
nipkow@10560
|
369 |
\hfill
|
nipkow@10560
|
370 |
(\isa{split{\isacharunderscore}paired{\isacharunderscore}All})\\
|
nipkow@10654
|
371 |
\isa{{\isacharparenleft}{\isasymexists}x{\isachardot}\ P\ x{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}{\isasymexists}a\ b{\isachardot}\ P\ {\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}{\isacharparenright}}
|
nipkow@10560
|
372 |
\hfill
|
nipkow@10560
|
373 |
(\isa{split{\isacharunderscore}paired{\isacharunderscore}Ex})
|
nipkow@10560
|
374 |
\end{center}%
|
nipkow@10560
|
375 |
\end{isamarkuptext}%
|
wenzelm@17175
|
376 |
\isamarkuptrue%
|
wenzelm@17056
|
377 |
%
|
wenzelm@17056
|
378 |
\isadelimtheory
|
wenzelm@17056
|
379 |
%
|
wenzelm@17056
|
380 |
\endisadelimtheory
|
wenzelm@17056
|
381 |
%
|
wenzelm@17056
|
382 |
\isatagtheory
|
wenzelm@17056
|
383 |
%
|
wenzelm@17056
|
384 |
\endisatagtheory
|
wenzelm@17056
|
385 |
{\isafoldtheory}%
|
wenzelm@17056
|
386 |
%
|
wenzelm@17056
|
387 |
\isadelimtheory
|
wenzelm@17056
|
388 |
%
|
wenzelm@17056
|
389 |
\endisadelimtheory
|
nipkow@10560
|
390 |
\end{isabellebody}%
|
nipkow@10560
|
391 |
%%% Local Variables:
|
nipkow@10560
|
392 |
%%% mode: latex
|
nipkow@10560
|
393 |
%%% TeX-master: "root"
|
nipkow@10560
|
394 |
%%% End:
|