1.1 --- a/doc-src/TutorialI/Recdef/document/Nested2.tex Tue Aug 29 12:28:48 2000 +0200
1.2 +++ b/doc-src/TutorialI/Recdef/document/Nested2.tex Tue Aug 29 15:13:10 2000 +0200
1.3 @@ -1,5 +1,4 @@
1.4 -%
1.5 -\begin{isabellebody}%
1.6 +\begin{isabelle}%
1.7 %
1.8 \begin{isamarkuptext}%
1.9 \noindent
1.10 @@ -32,10 +31,21 @@
1.11 \end{quote}
1.12 both of which are solved by simplification:%
1.13 \end{isamarkuptxt}%
1.14 -\isacommand{by}{\isacharparenleft}simp{\isacharunderscore}all\ del{\isacharcolon}map{\isacharunderscore}compose\ add{\isacharcolon}sym{\isacharbrackleft}OF\ map{\isacharunderscore}compose{\isacharbrackright}\ rev{\isacharunderscore}map{\isacharparenright}%
1.15 +\isacommand{by}{\isacharparenleft}simp{\isacharunderscore}all\ add{\isacharcolon}rev{\isacharunderscore}map\ sym{\isacharbrackleft}OF\ map{\isacharunderscore}compose{\isacharbrackright}{\isacharparenright}%
1.16 \begin{isamarkuptext}%
1.17 \noindent
1.18 -If this surprises you, see Datatype/Nested2......
1.19 +If the proof of the induction step mystifies you, we recommend to go through
1.20 +the chain of simplification steps in detail, probably with the help of
1.21 +\isa{trace\_simp}.
1.22 +%\begin{quote}
1.23 +%{term[display]"trev(trev(App f ts))"}\\
1.24 +%{term[display]"App f (rev(map trev (rev(map trev ts))))"}\\
1.25 +%{term[display]"App f (map trev (rev(rev(map trev ts))))"}\\
1.26 +%{term[display]"App f (map trev (map trev ts))"}\\
1.27 +%{term[display]"App f (map (trev o trev) ts)"}\\
1.28 +%{term[display]"App f (map (%x. x) ts)"}\\
1.29 +%{term[display]"App f ts"}
1.30 +%\end{quote}
1.31
1.32 The above definition of \isa{trev} is superior to the one in \S\ref{sec:nested-datatype}
1.33 because it brings \isa{rev} into play, about which already know a lot, in particular
1.34 @@ -46,12 +56,13 @@
1.35 because they determine the complexity of your proofs.}
1.36 \end{quote}
1.37
1.38 -Let us now return to the question of how \isacommand{recdef} can come up with sensible termination
1.39 -conditions in the presence of higher-order functions like \isa{map}. For a start, if nothing
1.40 -were known about \isa{map}, \isa{map\ trev\ \mbox{ts}} might apply \isa{trev} to arbitrary terms,
1.41 -and thus \isacommand{recdef} would try to prove the unprovable
1.42 -\isa{size\ \mbox{t}\ {\isacharless}\ Suc\ {\isacharparenleft}term{\isacharunderscore}size\ \mbox{ts}{\isacharparenright}}, without any assumption about \isa{t}.
1.43 -Therefore \isacommand{recdef} has been supplied with the congruence theorem \isa{map\_cong}:
1.44 +Let us now return to the question of how \isacommand{recdef} can come up with
1.45 +sensible termination conditions in the presence of higher-order functions
1.46 +like \isa{map}. For a start, if nothing were known about \isa{map},
1.47 +\isa{map\ trev\ \mbox{ts}} might apply \isa{trev} to arbitrary terms, and thus
1.48 +\isacommand{recdef} would try to prove the unprovable \isa{size\ \mbox{t}\ {\isacharless}\ Suc\ {\isacharparenleft}term{\isacharunderscore}size\ \mbox{ts}{\isacharparenright}}, without any assumption about \isa{t}. Therefore
1.49 +\isacommand{recdef} has been supplied with the congruence theorem
1.50 +\isa{map\_cong}:
1.51 \begin{quote}
1.52
1.53 \begin{isabelle}%
1.54 @@ -60,10 +71,11 @@
1.55 \end{isabelle}%
1.56
1.57 \end{quote}
1.58 -Its second premise expresses (indirectly) that the second argument of \isa{map} is only applied
1.59 -to elements of its third argument. Congruence rules for other higher-order functions on lists would
1.60 -look very similar but have not been proved yet because they were never needed.
1.61 -If you get into a situation where you need to supply \isacommand{recdef} with new congruence
1.62 +Its second premise expresses (indirectly) that the second argument of
1.63 +\isa{map} is only applied to elements of its third argument. Congruence
1.64 +rules for other higher-order functions on lists would look very similar but
1.65 +have not been proved yet because they were never needed. If you get into a
1.66 +situation where you need to supply \isacommand{recdef} with new congruence
1.67 rules, you can either append the line
1.68 \begin{ttbox}
1.69 congs <congruence rules>
1.70 @@ -78,7 +90,7 @@
1.71 declaring a congruence rule for the simplifier does not make it
1.72 available to \isacommand{recdef}, and vice versa. This is intentional.%
1.73 \end{isamarkuptext}%
1.74 -\end{isabellebody}%
1.75 +\end{isabelle}%
1.76 %%% Local Variables:
1.77 %%% mode: latex
1.78 %%% TeX-master: "root"