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}%
|
|
7 |
\isacommand{lemma}~hd\_Cons\_tl[simp]:~{"}xs~{\isasymnoteq}~[]~~{\isasymLongrightarrow}~~hd~xs~\#~tl~xs~=~xs{"}\isanewline
|
|
8 |
\isacommand{apply}(case\_tac~xs,~simp,~simp)\isacommand{.}%
|
|
9 |
\begin{isamarkuptext}%
|
|
10 |
\noindent
|
|
11 |
Note the use of ``\ttindexboldpos{,}{$Isar}'' to string together a
|
|
12 |
sequence of methods. Assuming that the simplification rule%
|
|
13 |
\end{isamarkuptext}%
|
|
14 |
~{"}(rev~xs~=~[])~=~(xs~=~[]){"}%
|
|
15 |
\begin{isamarkuptext}%
|
|
16 |
\noindent
|
|
17 |
is present as well,%
|
|
18 |
\end{isamarkuptext}%
|
|
19 |
\isacommand{lemma}~{"}xs~{\isasymnoteq}~[]~{\isasymLongrightarrow}~hd(rev~xs)~\#~tl(rev~xs)~=~rev~xs{"}%
|
|
20 |
\begin{isamarkuptext}%
|
|
21 |
\noindent
|
8771
|
22 |
is proved by plain simplification:
|
8749
|
23 |
the conditional equation \isa{hd_Cons_tl} above
|
|
24 |
can simplify \isa{hd(rev~xs)~\#~tl(rev~xs)} to \isa{rev xs}
|
|
25 |
because the corresponding precondition \isa{rev xs \isasymnoteq\ []}
|
|
26 |
simplifies to \isa{xs \isasymnoteq\ []}, which is exactly the local
|
|
27 |
assumption of the subgoal.%
|
|
28 |
\end{isamarkuptext}%
|
|
29 |
\end{isabelle}%
|