8749
|
1 |
\begin{isabelle}%
|
|
2 |
%
|
|
3 |
\begin{isamarkuptext}%
|
|
4 |
So far all examples of rewrite rules were equations. The simplifier also
|
|
5 |
accepts \emph{conditional} equations, for example%
|
|
6 |
\end{isamarkuptext}%
|
9673
|
7 |
\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
|
|
8 |
\isacommand{by}{\isacharparenleft}case{\isacharunderscore}tac\ xs{\isacharcomma}\ simp{\isacharcomma}\ simp{\isacharparenright}%
|
8749
|
9 |
\begin{isamarkuptext}%
|
|
10 |
\noindent
|
|
11 |
Note the use of ``\ttindexboldpos{,}{$Isar}'' to string together a
|
9541
|
12 |
sequence of methods. Assuming that the simplification rule
|
9673
|
13 |
\isa{{\isacharparenleft}rev\ \mbox{xs}\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}\mbox{xs}\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}{\isacharparenright}}
|
8749
|
14 |
is present as well,%
|
|
15 |
\end{isamarkuptext}%
|
9673
|
16 |
\isacommand{lemma}\ {\isachardoublequote}xs\ {\isasymnoteq}\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymLongrightarrow}\ hd{\isacharparenleft}rev\ xs{\isacharparenright}\ {\isacharhash}\ tl{\isacharparenleft}rev\ xs{\isacharparenright}\ {\isacharequal}\ rev\ xs{\isachardoublequote}%
|
8749
|
17 |
\begin{isamarkuptext}%
|
|
18 |
\noindent
|
8771
|
19 |
is proved by plain simplification:
|
8749
|
20 |
the conditional equation \isa{hd_Cons_tl} above
|
|
21 |
can simplify \isa{hd(rev~xs)~\#~tl(rev~xs)} to \isa{rev xs}
|
|
22 |
because the corresponding precondition \isa{rev xs \isasymnoteq\ []}
|
|
23 |
simplifies to \isa{xs \isasymnoteq\ []}, which is exactly the local
|
|
24 |
assumption of the subgoal.%
|
|
25 |
\end{isamarkuptext}%
|
|
26 |
\end{isabelle}%
|
9145
|
27 |
%%% Local Variables:
|
|
28 |
%%% mode: latex
|
|
29 |
%%% TeX-master: "root"
|
|
30 |
%%% End:
|