9924
|
1 |
%
|
|
2 |
\begin{isabellebody}%
|
|
3 |
\def\isabellecontext{simp}%
|
11866
|
4 |
\isamarkupfalse%
|
9933
|
5 |
%
|
11214
|
6 |
\isamarkupsubsection{Simplification Rules%
|
10397
|
7 |
}
|
11866
|
8 |
\isamarkuptrue%
|
9933
|
9 |
%
|
|
10 |
\begin{isamarkuptext}%
|
11458
|
11 |
\index{simplification rules}
|
|
12 |
To facilitate simplification,
|
|
13 |
the attribute \isa{{\isacharbrackleft}simp{\isacharbrackright}}\index{*simp (attribute)}
|
|
14 |
declares theorems to be simplification rules, which the simplifier
|
|
15 |
will use automatically. In addition, \isacommand{datatype} and
|
|
16 |
\isacommand{primrec} declarations (and a few others)
|
|
17 |
implicitly declare some simplification rules.
|
|
18 |
Explicit definitions are \emph{not} declared as
|
9933
|
19 |
simplification rules automatically!
|
|
20 |
|
11458
|
21 |
Nearly any theorem can become a simplification
|
|
22 |
rule. The simplifier will try to transform it into an equation.
|
|
23 |
For example, the theorem
|
|
24 |
\isa{{\isasymnot}\ P} is turned into \isa{P\ {\isacharequal}\ False}. The details
|
9933
|
25 |
are explained in \S\ref{sec:SimpHow}.
|
|
26 |
|
11458
|
27 |
The simplification attribute of theorems can be turned on and off:%
|
12489
|
28 |
\index{*simp del (attribute)}
|
9933
|
29 |
\begin{quote}
|
|
30 |
\isacommand{declare} \textit{theorem-name}\isa{{\isacharbrackleft}simp{\isacharbrackright}}\\
|
|
31 |
\isacommand{declare} \textit{theorem-name}\isa{{\isacharbrackleft}simp\ del{\isacharbrackright}}
|
|
32 |
\end{quote}
|
11309
|
33 |
Only equations that really simplify, like \isa{rev\
|
|
34 |
{\isacharparenleft}rev\ xs{\isacharparenright}\ {\isacharequal}\ xs} and
|
|
35 |
\isa{xs\ {\isacharat}\ {\isacharbrackleft}{\isacharbrackright}\
|
|
36 |
{\isacharequal}\ xs}, should be declared as default simplification rules.
|
|
37 |
More specific ones should only be used selectively and should
|
|
38 |
not be made default. Distributivity laws, for example, alter
|
|
39 |
the structure of terms and can produce an exponential blow-up instead of
|
|
40 |
simplification. A default simplification rule may
|
|
41 |
need to be disabled in certain proofs. Frequent changes in the simplification
|
|
42 |
status of a theorem may indicate an unwise use of defaults.
|
9933
|
43 |
\begin{warn}
|
11458
|
44 |
Simplification can run forever, for example if both $f(x) = g(x)$ and
|
9933
|
45 |
$g(x) = f(x)$ are simplification rules. It is the user's responsibility not
|
|
46 |
to include simplification rules that can lead to nontermination, either on
|
|
47 |
their own or in combination with other simplification rules.
|
12332
|
48 |
\end{warn}
|
|
49 |
\begin{warn}
|
|
50 |
It is inadvisable to toggle the simplification attribute of a
|
12333
|
51 |
theorem from a parent theory $A$ in a child theory $B$ for good.
|
12332
|
52 |
The reason is that if some theory $C$ is based both on $B$ and (via a
|
13814
|
53 |
different path) on $A$, it is not defined what the simplification attribute
|
12332
|
54 |
of that theorem will be in $C$: it could be either.
|
9933
|
55 |
\end{warn}%
|
|
56 |
\end{isamarkuptext}%
|
11866
|
57 |
\isamarkuptrue%
|
9933
|
58 |
%
|
11458
|
59 |
\isamarkupsubsection{The {\tt\slshape simp} Method%
|
10397
|
60 |
}
|
11866
|
61 |
\isamarkuptrue%
|
9933
|
62 |
%
|
|
63 |
\begin{isamarkuptext}%
|
|
64 |
\index{*simp (method)|bold}
|
|
65 |
The general format of the simplification method is
|
|
66 |
\begin{quote}
|
|
67 |
\isa{simp} \textit{list of modifiers}
|
|
68 |
\end{quote}
|
10795
|
69 |
where the list of \emph{modifiers} fine tunes the behaviour and may
|
11309
|
70 |
be empty. Specific modifiers are discussed below. Most if not all of the
|
|
71 |
proofs seen so far could have been performed
|
9933
|
72 |
with \isa{simp} instead of \isa{auto}, except that \isa{simp} attacks
|
10971
|
73 |
only the first subgoal and may thus need to be repeated --- use
|
11428
|
74 |
\methdx{simp_all} to simplify all subgoals.
|
11458
|
75 |
If nothing changes, \isa{simp} fails.%
|
9933
|
76 |
\end{isamarkuptext}%
|
11866
|
77 |
\isamarkuptrue%
|
9933
|
78 |
%
|
11214
|
79 |
\isamarkupsubsection{Adding and Deleting Simplification Rules%
|
10397
|
80 |
}
|
11866
|
81 |
\isamarkuptrue%
|
9933
|
82 |
%
|
|
83 |
\begin{isamarkuptext}%
|
11458
|
84 |
\index{simplification rules!adding and deleting}%
|
9933
|
85 |
If a certain theorem is merely needed in a few proofs by simplification,
|
|
86 |
we do not need to make it a global simplification rule. Instead we can modify
|
|
87 |
the set of simplification rules used in a simplification step by adding rules
|
|
88 |
to it and/or deleting rules from it. The two modifiers for this are
|
|
89 |
\begin{quote}
|
11458
|
90 |
\isa{add{\isacharcolon}} \textit{list of theorem names}\index{*add (modifier)}\\
|
|
91 |
\isa{del{\isacharcolon}} \textit{list of theorem names}\index{*del (modifier)}
|
9933
|
92 |
\end{quote}
|
11458
|
93 |
Or you can use a specific list of theorems and omit all others:
|
9933
|
94 |
\begin{quote}
|
11458
|
95 |
\isa{only{\isacharcolon}} \textit{list of theorem names}\index{*only (modifier)}
|
11309
|
96 |
\end{quote}
|
|
97 |
In this example, we invoke the simplifier, adding two distributive
|
|
98 |
laws:
|
|
99 |
\begin{quote}
|
|
100 |
\isacommand{apply}\isa{{\isacharparenleft}simp\ add{\isacharcolon}\ mod{\isacharunderscore}mult{\isacharunderscore}distrib\ add{\isacharunderscore}mult{\isacharunderscore}distrib{\isacharparenright}}
|
9933
|
101 |
\end{quote}%
|
|
102 |
\end{isamarkuptext}%
|
11866
|
103 |
\isamarkuptrue%
|
9933
|
104 |
%
|
11214
|
105 |
\isamarkupsubsection{Assumptions%
|
10397
|
106 |
}
|
11866
|
107 |
\isamarkuptrue%
|
9933
|
108 |
%
|
|
109 |
\begin{isamarkuptext}%
|
|
110 |
\index{simplification!with/of assumptions}
|
|
111 |
By default, assumptions are part of the simplification process: they are used
|
|
112 |
as simplification rules and are simplified themselves. For example:%
|
|
113 |
\end{isamarkuptext}%
|
11866
|
114 |
\isamarkuptrue%
|
9933
|
115 |
\isacommand{lemma}\ {\isachardoublequote}{\isasymlbrakk}\ xs\ {\isacharat}\ zs\ {\isacharequal}\ ys\ {\isacharat}\ xs{\isacharsemicolon}\ {\isacharbrackleft}{\isacharbrackright}\ {\isacharat}\ xs\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}\ {\isacharat}\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymrbrakk}\ {\isasymLongrightarrow}\ ys\ {\isacharequal}\ zs{\isachardoublequote}\isanewline
|
11866
|
116 |
\isamarkupfalse%
|
|
117 |
\isamarkupfalse%
|
15481
|
118 |
\isamarkupfalse%
|
11866
|
119 |
%
|
9933
|
120 |
\begin{isamarkuptext}%
|
|
121 |
\noindent
|
|
122 |
The second assumption simplifies to \isa{xs\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}}, which in turn
|
|
123 |
simplifies the first assumption to \isa{zs\ {\isacharequal}\ ys}, thus reducing the
|
|
124 |
conclusion to \isa{ys\ {\isacharequal}\ ys} and hence to \isa{True}.
|
|
125 |
|
11458
|
126 |
In some cases, using the assumptions can lead to nontermination:%
|
9933
|
127 |
\end{isamarkuptext}%
|
11866
|
128 |
\isamarkuptrue%
|
|
129 |
\isacommand{lemma}\ {\isachardoublequote}{\isasymforall}x{\isachardot}\ f\ x\ {\isacharequal}\ g\ {\isacharparenleft}f\ {\isacharparenleft}g\ x{\isacharparenright}{\isacharparenright}\ {\isasymLongrightarrow}\ f\ {\isacharbrackleft}{\isacharbrackright}\ {\isacharequal}\ f\ {\isacharbrackleft}{\isacharbrackright}\ {\isacharat}\ {\isacharbrackleft}{\isacharbrackright}{\isachardoublequote}\isamarkupfalse%
|
|
130 |
\isamarkuptrue%
|
|
131 |
\isamarkupfalse%
|
15481
|
132 |
\isamarkupfalse%
|
11866
|
133 |
%
|
9933
|
134 |
\begin{isamarkuptext}%
|
|
135 |
\noindent
|
11458
|
136 |
Three modifiers influence the treatment of assumptions:
|
9933
|
137 |
\begin{description}
|
11458
|
138 |
\item[\isa{{\isacharparenleft}no{\isacharunderscore}asm{\isacharparenright}}]\index{*no_asm (modifier)}
|
9933
|
139 |
means that assumptions are completely ignored.
|
11458
|
140 |
\item[\isa{{\isacharparenleft}no{\isacharunderscore}asm{\isacharunderscore}simp{\isacharparenright}}]\index{*no_asm_simp (modifier)}
|
9933
|
141 |
means that the assumptions are not simplified but
|
|
142 |
are used in the simplification of the conclusion.
|
11458
|
143 |
\item[\isa{{\isacharparenleft}no{\isacharunderscore}asm{\isacharunderscore}use{\isacharparenright}}]\index{*no_asm_use (modifier)}
|
9933
|
144 |
means that the assumptions are simplified but are not
|
|
145 |
used in the simplification of each other or the conclusion.
|
|
146 |
\end{description}
|
10795
|
147 |
Both \isa{{\isacharparenleft}no{\isacharunderscore}asm{\isacharunderscore}simp{\isacharparenright}} and \isa{{\isacharparenleft}no{\isacharunderscore}asm{\isacharunderscore}use{\isacharparenright}} run forever on
|
|
148 |
the problematic subgoal above.
|
11458
|
149 |
Only one of the modifiers is allowed, and it must precede all
|
11309
|
150 |
other modifiers.
|
13623
|
151 |
%\begin{warn}
|
|
152 |
%Assumptions are simplified in a left-to-right fashion. If an
|
|
153 |
%assumption can help in simplifying one to the left of it, this may get
|
|
154 |
%overlooked. In such cases you have to rotate the assumptions explicitly:
|
|
155 |
%\isacommand{apply}@ {text"("}\methdx{rotate_tac}~$n$@ {text")"}
|
|
156 |
%causes a cyclic shift by $n$ positions from right to left, if $n$ is
|
|
157 |
%positive, and from left to right, if $n$ is negative.
|
|
158 |
%Beware that such rotations make proofs quite brittle.
|
|
159 |
%\end{warn}%
|
9933
|
160 |
\end{isamarkuptext}%
|
11866
|
161 |
\isamarkuptrue%
|
9933
|
162 |
%
|
11214
|
163 |
\isamarkupsubsection{Rewriting with Definitions%
|
10397
|
164 |
}
|
11866
|
165 |
\isamarkuptrue%
|
9933
|
166 |
%
|
|
167 |
\begin{isamarkuptext}%
|
11215
|
168 |
\label{sec:Simp-with-Defs}\index{simplification!with definitions}
|
11458
|
169 |
Constant definitions (\S\ref{sec:ConstDefinitions}) can be used as
|
|
170 |
simplification rules, but by default they are not: the simplifier does not
|
|
171 |
expand them automatically. Definitions are intended for introducing abstract
|
12584
|
172 |
concepts and not merely as abbreviations. Of course, we need to expand
|
11458
|
173 |
the definition initially, but once we have proved enough abstract properties
|
|
174 |
of the new constant, we can forget its original definition. This style makes
|
|
175 |
proofs more robust: if the definition has to be changed,
|
|
176 |
only the proofs of the abstract properties will be affected.
|
|
177 |
|
|
178 |
For example, given%
|
9933
|
179 |
\end{isamarkuptext}%
|
11866
|
180 |
\isamarkuptrue%
|
10788
|
181 |
\isacommand{constdefs}\ xor\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}bool\ {\isasymRightarrow}\ bool\ {\isasymRightarrow}\ bool{\isachardoublequote}\isanewline
|
11866
|
182 |
\ \ \ \ \ \ \ \ \ {\isachardoublequote}xor\ A\ B\ {\isasymequiv}\ {\isacharparenleft}A\ {\isasymand}\ {\isasymnot}B{\isacharparenright}\ {\isasymor}\ {\isacharparenleft}{\isasymnot}A\ {\isasymand}\ B{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
|
|
183 |
%
|
9933
|
184 |
\begin{isamarkuptext}%
|
|
185 |
\noindent
|
|
186 |
we may want to prove%
|
|
187 |
\end{isamarkuptext}%
|
11866
|
188 |
\isamarkuptrue%
|
|
189 |
\isacommand{lemma}\ {\isachardoublequote}xor\ A\ {\isacharparenleft}{\isasymnot}A{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
|
|
190 |
\isamarkuptrue%
|
15481
|
191 |
\isamarkupfalse%
|
11866
|
192 |
\isamarkuptrue%
|
|
193 |
\isamarkupfalse%
|
|
194 |
\isamarkupfalse%
|
15481
|
195 |
\isamarkupfalse%
|
11866
|
196 |
\isamarkupfalse%
|
|
197 |
%
|
9933
|
198 |
\begin{isamarkuptext}%
|
|
199 |
\noindent
|
|
200 |
Of course we can also unfold definitions in the middle of a proof.
|
|
201 |
|
|
202 |
\begin{warn}
|
10971
|
203 |
If you have defined $f\,x\,y~\isasymequiv~t$ then you can only unfold
|
|
204 |
occurrences of $f$ with at least two arguments. This may be helpful for unfolding
|
|
205 |
$f$ selectively, but it may also get in the way. Defining
|
|
206 |
$f$~\isasymequiv~\isasymlambda$x\,y.\;t$ allows to unfold all occurrences of $f$.
|
12473
|
207 |
\end{warn}
|
|
208 |
|
|
209 |
There is also the special method \isa{unfold}\index{*unfold (method)|bold}
|
|
210 |
which merely unfolds
|
|
211 |
one or several definitions, as in \isacommand{apply}\isa{(unfold xor_def)}.
|
12533
|
212 |
This is can be useful in situations where \isa{simp} does too much.
|
|
213 |
Warning: \isa{unfold} acts on all subgoals!%
|
9933
|
214 |
\end{isamarkuptext}%
|
11866
|
215 |
\isamarkuptrue%
|
9933
|
216 |
%
|
11214
|
217 |
\isamarkupsubsection{Simplifying {\tt\slshape let}-Expressions%
|
10397
|
218 |
}
|
11866
|
219 |
\isamarkuptrue%
|
9933
|
220 |
%
|
|
221 |
\begin{isamarkuptext}%
|
11458
|
222 |
\index{simplification!of \isa{let}-expressions}\index{*let expressions}%
|
|
223 |
Proving a goal containing \isa{let}-expressions almost invariably requires the
|
|
224 |
\isa{let}-con\-structs to be expanded at some point. Since
|
|
225 |
\isa{let}\ldots\isa{=}\ldots\isa{in}{\ldots} is just syntactic sugar for
|
|
226 |
the predefined constant \isa{Let}, expanding \isa{let}-constructs
|
|
227 |
means rewriting with \tdx{Let_def}:%
|
9933
|
228 |
\end{isamarkuptext}%
|
11866
|
229 |
\isamarkuptrue%
|
9933
|
230 |
\isacommand{lemma}\ {\isachardoublequote}{\isacharparenleft}let\ xs\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}\ in\ xs{\isacharat}ys{\isacharat}xs{\isacharparenright}\ {\isacharequal}\ ys{\isachardoublequote}\isanewline
|
11866
|
231 |
\isamarkupfalse%
|
|
232 |
\isamarkupfalse%
|
15481
|
233 |
\isamarkupfalse%
|
11866
|
234 |
%
|
9933
|
235 |
\begin{isamarkuptext}%
|
|
236 |
If, in a particular context, there is no danger of a combinatorial explosion
|
11458
|
237 |
of nested \isa{let}s, you could even simplify with \isa{Let{\isacharunderscore}def} by
|
9933
|
238 |
default:%
|
|
239 |
\end{isamarkuptext}%
|
11866
|
240 |
\isamarkuptrue%
|
|
241 |
\isacommand{declare}\ Let{\isacharunderscore}def\ {\isacharbrackleft}simp{\isacharbrackright}\isamarkupfalse%
|
|
242 |
%
|
11458
|
243 |
\isamarkupsubsection{Conditional Simplification Rules%
|
10397
|
244 |
}
|
11866
|
245 |
\isamarkuptrue%
|
9933
|
246 |
%
|
|
247 |
\begin{isamarkuptext}%
|
11458
|
248 |
\index{conditional simplification rules}%
|
9933
|
249 |
So far all examples of rewrite rules were equations. The simplifier also
|
|
250 |
accepts \emph{conditional} equations, for example%
|
|
251 |
\end{isamarkuptext}%
|
11866
|
252 |
\isamarkuptrue%
|
9933
|
253 |
\isacommand{lemma}\ hd{\isacharunderscore}Cons{\isacharunderscore}tl{\isacharbrackleft}simp{\isacharbrackright}{\isacharcolon}\ {\isachardoublequote}xs\ {\isasymnoteq}\ {\isacharbrackleft}{\isacharbrackright}\ \ {\isasymLongrightarrow}\ \ hd\ xs\ {\isacharhash}\ tl\ xs\ {\isacharequal}\ xs{\isachardoublequote}\isanewline
|
11866
|
254 |
\isamarkupfalse%
|
|
255 |
\isamarkupfalse%
|
15481
|
256 |
\isamarkupfalse%
|
11866
|
257 |
%
|
9933
|
258 |
\begin{isamarkuptext}%
|
|
259 |
\noindent
|
|
260 |
Note the use of ``\ttindexboldpos{,}{$Isar}'' to string together a
|
|
261 |
sequence of methods. Assuming that the simplification rule
|
|
262 |
\isa{{\isacharparenleft}rev\ xs\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}xs\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}{\isacharparenright}}
|
10795
|
263 |
is present as well,
|
|
264 |
the lemma below is proved by plain simplification:%
|
9933
|
265 |
\end{isamarkuptext}%
|
11866
|
266 |
\isamarkuptrue%
|
13791
|
267 |
\isacommand{lemma}\ {\isachardoublequote}xs\ {\isasymnoteq}\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymLongrightarrow}\ hd{\isacharparenleft}rev\ xs{\isacharparenright}\ {\isacharhash}\ tl{\isacharparenleft}rev\ xs{\isacharparenright}\ {\isacharequal}\ rev\ xs{\isachardoublequote}\isamarkupfalse%
|
11866
|
268 |
\isamarkupfalse%
|
|
269 |
%
|
9933
|
270 |
\begin{isamarkuptext}%
|
|
271 |
\noindent
|
10795
|
272 |
The conditional equation \isa{hd{\isacharunderscore}Cons{\isacharunderscore}tl} above
|
9933
|
273 |
can simplify \isa{hd\ {\isacharparenleft}rev\ xs{\isacharparenright}\ {\isacharhash}\ tl\ {\isacharparenleft}rev\ xs{\isacharparenright}} to \isa{rev\ xs}
|
|
274 |
because the corresponding precondition \isa{rev\ xs\ {\isasymnoteq}\ {\isacharbrackleft}{\isacharbrackright}}
|
|
275 |
simplifies to \isa{xs\ {\isasymnoteq}\ {\isacharbrackleft}{\isacharbrackright}}, which is exactly the local
|
|
276 |
assumption of the subgoal.%
|
|
277 |
\end{isamarkuptext}%
|
11866
|
278 |
\isamarkuptrue%
|
9933
|
279 |
%
|
11214
|
280 |
\isamarkupsubsection{Automatic Case Splits%
|
10397
|
281 |
}
|
11866
|
282 |
\isamarkuptrue%
|
9933
|
283 |
%
|
|
284 |
\begin{isamarkuptext}%
|
11458
|
285 |
\label{sec:AutoCaseSplits}\indexbold{case splits}%
|
|
286 |
Goals containing \isa{if}-expressions\index{*if expressions!splitting of}
|
|
287 |
are usually proved by case
|
|
288 |
distinction on the boolean condition. Here is an example:%
|
9933
|
289 |
\end{isamarkuptext}%
|
11866
|
290 |
\isamarkuptrue%
|
|
291 |
\isacommand{lemma}\ {\isachardoublequote}{\isasymforall}xs{\isachardot}\ if\ xs\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}\ then\ rev\ xs\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}\ else\ rev\ xs\ {\isasymnoteq}\ {\isacharbrackleft}{\isacharbrackright}{\isachardoublequote}\isamarkupfalse%
|
|
292 |
\isamarkuptrue%
|
15481
|
293 |
\isamarkupfalse%
|
11866
|
294 |
\isamarkuptrue%
|
|
295 |
\isamarkupfalse%
|
10362
|
296 |
\isacommand{lemma}\ {\isachardoublequote}{\isacharparenleft}case\ xs\ of\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymRightarrow}\ zs\ {\isacharbar}\ y{\isacharhash}ys\ {\isasymRightarrow}\ y{\isacharhash}{\isacharparenleft}ys{\isacharat}zs{\isacharparenright}{\isacharparenright}\ {\isacharequal}\ xs{\isacharat}zs{\isachardoublequote}\isanewline
|
11866
|
297 |
\isamarkupfalse%
|
15481
|
298 |
\isamarkupfalse%
|
11866
|
299 |
\isamarkuptrue%
|
|
300 |
\isamarkupfalse%
|
|
301 |
\isamarkupfalse%
|
15481
|
302 |
\isamarkupfalse%
|
11866
|
303 |
\isamarkupfalse%
|
|
304 |
%
|
9933
|
305 |
\begin{isamarkuptext}%
|
10668
|
306 |
\noindent
|
|
307 |
whereas \isacommand{apply}\isa{{\isacharparenleft}simp{\isacharparenright}} alone will not succeed.
|
9933
|
308 |
|
11458
|
309 |
Every datatype $t$ comes with a theorem
|
9933
|
310 |
$t$\isa{{\isachardot}split} which can be declared to be a \bfindex{split rule} either
|
11458
|
311 |
locally as above, or by giving it the \attrdx{split} attribute globally:%
|
9933
|
312 |
\end{isamarkuptext}%
|
11866
|
313 |
\isamarkuptrue%
|
|
314 |
\isacommand{declare}\ list{\isachardot}split\ {\isacharbrackleft}split{\isacharbrackright}\isamarkupfalse%
|
|
315 |
%
|
9933
|
316 |
\begin{isamarkuptext}%
|
|
317 |
\noindent
|
|
318 |
The \isa{split} attribute can be removed with the \isa{del} modifier,
|
|
319 |
either locally%
|
|
320 |
\end{isamarkuptext}%
|
11866
|
321 |
\isamarkuptrue%
|
|
322 |
\isamarkupfalse%
|
15481
|
323 |
\isamarkupfalse%
|
11866
|
324 |
\isamarkupfalse%
|
|
325 |
%
|
9933
|
326 |
\begin{isamarkuptext}%
|
|
327 |
\noindent
|
|
328 |
or globally:%
|
|
329 |
\end{isamarkuptext}%
|
11866
|
330 |
\isamarkuptrue%
|
|
331 |
\isacommand{declare}\ list{\isachardot}split\ {\isacharbrackleft}split\ del{\isacharbrackright}\isamarkupfalse%
|
|
332 |
%
|
9933
|
333 |
\begin{isamarkuptext}%
|
11458
|
334 |
Polished proofs typically perform splitting within \isa{simp} rather than
|
|
335 |
invoking the \isa{split} method. However, if a goal contains
|
|
336 |
several \isa{if} and \isa{case} expressions,
|
|
337 |
the \isa{split} method can be
|
10668
|
338 |
helpful in selectively exploring the effects of splitting.
|
|
339 |
|
11458
|
340 |
The split rules shown above are intended to affect only the subgoal's
|
|
341 |
conclusion. If you want to split an \isa{if} or \isa{case}-expression
|
|
342 |
in the assumptions, you have to apply \tdx{split_if_asm} or
|
9933
|
343 |
$t$\isa{{\isachardot}split{\isacharunderscore}asm}:%
|
|
344 |
\end{isamarkuptext}%
|
11866
|
345 |
\isamarkuptrue%
|
10668
|
346 |
\isacommand{lemma}\ {\isachardoublequote}if\ xs\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}\ then\ ys\ {\isasymnoteq}\ {\isacharbrackleft}{\isacharbrackright}\ else\ ys\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymLongrightarrow}\ xs\ {\isacharat}\ ys\ {\isasymnoteq}\ {\isacharbrackleft}{\isacharbrackright}{\isachardoublequote}\isanewline
|
11866
|
347 |
\isamarkupfalse%
|
15481
|
348 |
\isamarkupfalse%
|
11866
|
349 |
\isamarkuptrue%
|
|
350 |
\isamarkupfalse%
|
9933
|
351 |
%
|
11214
|
352 |
\isamarkupsubsection{Tracing%
|
10397
|
353 |
}
|
11866
|
354 |
\isamarkuptrue%
|
9933
|
355 |
%
|
|
356 |
\begin{isamarkuptext}%
|
|
357 |
\indexbold{tracing the simplifier}
|
|
358 |
Using the simplifier effectively may take a bit of experimentation. Set the
|
11428
|
359 |
\isa{trace_simp}\index{*trace_simp (flag)} flag\index{flags}
|
|
360 |
to get a better idea of what is going
|
9933
|
361 |
on:%
|
|
362 |
\end{isamarkuptext}%
|
11866
|
363 |
\isamarkuptrue%
|
|
364 |
\isamarkupfalse%
|
9933
|
365 |
\isacommand{lemma}\ {\isachardoublequote}rev\ {\isacharbrackleft}a{\isacharbrackright}\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}{\isachardoublequote}\isanewline
|
11866
|
366 |
\isamarkupfalse%
|
15481
|
367 |
\isamarkupfalse%
|
11866
|
368 |
\isamarkupfalse%
|
|
369 |
%
|
9933
|
370 |
\begin{isamarkuptext}%
|
|
371 |
\noindent
|
|
372 |
produces the trace
|
|
373 |
|
|
374 |
\begin{ttbox}\makeatother
|
|
375 |
Applying instance of rewrite rule:
|
|
376 |
rev (?x1 \# ?xs1) == rev ?xs1 @ [?x1]
|
|
377 |
Rewriting:
|
10971
|
378 |
rev [a] == rev [] @ [a]
|
9933
|
379 |
Applying instance of rewrite rule:
|
|
380 |
rev [] == []
|
|
381 |
Rewriting:
|
|
382 |
rev [] == []
|
|
383 |
Applying instance of rewrite rule:
|
|
384 |
[] @ ?y == ?y
|
|
385 |
Rewriting:
|
10971
|
386 |
[] @ [a] == [a]
|
9933
|
387 |
Applying instance of rewrite rule:
|
|
388 |
?x3 \# ?t3 = ?t3 == False
|
|
389 |
Rewriting:
|
10971
|
390 |
[a] = [] == False
|
9933
|
391 |
\end{ttbox}
|
|
392 |
|
11309
|
393 |
The trace lists each rule being applied, both in its general form and the
|
|
394 |
instance being used. For conditional rules, the trace lists the rule
|
|
395 |
it is trying to rewrite and gives the result of attempting to prove
|
|
396 |
each of the rule's conditions. Many other hints about the simplifier's
|
|
397 |
actions will appear.
|
|
398 |
|
11458
|
399 |
In more complicated cases, the trace can be quite lengthy. Invocations of the
|
|
400 |
simplifier are often nested, for instance when solving conditions of rewrite
|
|
401 |
rules. Thus it is advisable to reset it:%
|
9933
|
402 |
\end{isamarkuptext}%
|
11866
|
403 |
\isamarkuptrue%
|
|
404 |
\isamarkupfalse%
|
|
405 |
\isamarkupfalse%
|
9924
|
406 |
\end{isabellebody}%
|
|
407 |
%%% Local Variables:
|
|
408 |
%%% mode: latex
|
|
409 |
%%% TeX-master: "root"
|
|
410 |
%%% End:
|