equal
deleted
inserted
replaced
6 So far all examples of rewrite rules were equations. The simplifier also |
6 So far all examples of rewrite rules were equations. The simplifier also |
7 accepts \emph{conditional} equations, for example |
7 accepts \emph{conditional} equations, for example |
8 *} |
8 *} |
9 |
9 |
10 lemma hd_Cons_tl[simp]: "xs \\<noteq> [] \\<Longrightarrow> hd xs # tl xs = xs"; |
10 lemma hd_Cons_tl[simp]: "xs \\<noteq> [] \\<Longrightarrow> hd xs # tl xs = xs"; |
11 apply(case_tac xs, simp, simp).; |
11 by(case_tac xs, simp, simp); |
12 |
12 |
13 text{*\noindent |
13 text{*\noindent |
14 Note the use of ``\ttindexboldpos{,}{$Isar}'' to string together a |
14 Note the use of ``\ttindexboldpos{,}{$Isar}'' to string together a |
15 sequence of methods. Assuming that the simplification rule |
15 sequence of methods. Assuming that the simplification rule |
16 *}(*<*)term(*>*) "(rev xs = []) = (xs = [])"; |
16 *}(*<*)term(*>*) "(rev xs = []) = (xs = [])"; |
18 is present as well, |
18 is present as well, |
19 *} |
19 *} |
20 |
20 |
21 lemma "xs \\<noteq> [] \\<Longrightarrow> hd(rev xs) # tl(rev xs) = rev xs"; |
21 lemma "xs \\<noteq> [] \\<Longrightarrow> hd(rev xs) # tl(rev xs) = rev xs"; |
22 (*<*) |
22 (*<*) |
23 apply(simp). |
23 by(simp); |
24 (*>*) |
24 (*>*) |
25 text{*\noindent |
25 text{*\noindent |
26 is proved by plain simplification: |
26 is proved by plain simplification: |
27 the conditional equation \isa{hd_Cons_tl} above |
27 the conditional equation \isa{hd_Cons_tl} above |
28 can simplify \isa{hd(rev~xs)~\#~tl(rev~xs)} to \isa{rev xs} |
28 can simplify \isa{hd(rev~xs)~\#~tl(rev~xs)} to \isa{rev xs} |