diff -r 93d5408eb7d9 -r fbd097aec213 doc-src/TutorialI/Recdef/document/termination.tex --- a/doc-src/TutorialI/Recdef/document/termination.tex Sun Oct 21 19:48:19 2001 +0200 +++ b/doc-src/TutorialI/Recdef/document/termination.tex Sun Oct 21 19:49:29 2001 +0200 @@ -1,6 +1,7 @@ % \begin{isabellebody}% \def\isabellecontext{termination}% +\isamarkupfalse% % \begin{isamarkuptext}% When a function~$f$ is defined via \isacommand{recdef}, Isabelle tries to prove @@ -16,9 +17,12 @@ Isabelle may fail to prove the termination condition for some recursive call. Let us try the following artificial function:% \end{isamarkuptext}% +\isamarkuptrue% \isacommand{consts}\ f\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}nat{\isasymtimes}nat\ {\isasymRightarrow}\ nat{\isachardoublequote}\isanewline +\isamarkupfalse% \isacommand{recdef}\ f\ {\isachardoublequote}measure{\isacharparenleft}{\isasymlambda}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}{\isachardot}\ x{\isacharminus}y{\isacharparenright}{\isachardoublequote}\isanewline -\ \ {\isachardoublequote}f{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}if\ x\ {\isasymle}\ y\ then\ x\ else\ f{\isacharparenleft}x{\isacharcomma}y{\isacharplus}{\isadigit{1}}{\isacharparenright}{\isacharparenright}{\isachardoublequote}% +\ \ {\isachardoublequote}f{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}if\ x\ {\isasymle}\ y\ then\ x\ else\ f{\isacharparenleft}x{\isacharcomma}y{\isacharplus}{\isadigit{1}}{\isacharparenright}{\isacharparenright}{\isachardoublequote}\isamarkupfalse% +% \begin{isamarkuptext}% \noindent Isabelle prints a @@ -27,14 +31,19 @@ have to prove it as a separate lemma before you attempt the definition of your function once more. In our case the required lemma is the obvious one:% \end{isamarkuptext}% -\isacommand{lemma}\ termi{\isacharunderscore}lem{\isacharcolon}\ {\isachardoublequote}{\isasymnot}\ x\ {\isasymle}\ y\ {\isasymLongrightarrow}\ x\ {\isacharminus}\ Suc\ y\ {\isacharless}\ x\ {\isacharminus}\ y{\isachardoublequote}% +\isamarkuptrue% +\isacommand{lemma}\ termi{\isacharunderscore}lem{\isacharcolon}\ {\isachardoublequote}{\isasymnot}\ x\ {\isasymle}\ y\ {\isasymLongrightarrow}\ x\ {\isacharminus}\ Suc\ y\ {\isacharless}\ x\ {\isacharminus}\ y{\isachardoublequote}\isamarkupfalse% +% \begin{isamarkuptxt}% \noindent It was not proved automatically because of the awkward behaviour of subtraction on type \isa{nat}. This requires more arithmetic than is tried by default:% \end{isamarkuptxt}% +\isamarkuptrue% \isacommand{apply}{\isacharparenleft}arith{\isacharparenright}\isanewline -\isacommand{done}% +\isamarkupfalse% +\isacommand{done}\isamarkupfalse% +% \begin{isamarkuptext}% \noindent Because \isacommand{recdef}'s termination prover involves simplification, @@ -42,19 +51,26 @@ says to use \isa{termi{\isacharunderscore}lem} as a simplification rule.% \end{isamarkuptext}% +\isamarkuptrue% \isacommand{consts}\ g\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}nat{\isasymtimes}nat\ {\isasymRightarrow}\ nat{\isachardoublequote}\isanewline +\isamarkupfalse% \isacommand{recdef}\ g\ {\isachardoublequote}measure{\isacharparenleft}{\isasymlambda}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}{\isachardot}\ x{\isacharminus}y{\isacharparenright}{\isachardoublequote}\isanewline \ \ {\isachardoublequote}g{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}if\ x\ {\isasymle}\ y\ then\ x\ else\ g{\isacharparenleft}x{\isacharcomma}y{\isacharplus}{\isadigit{1}}{\isacharparenright}{\isacharparenright}{\isachardoublequote}\isanewline -{\isacharparenleft}\isakeyword{hints}\ recdef{\isacharunderscore}simp{\isacharcolon}\ termi{\isacharunderscore}lem{\isacharparenright}% +{\isacharparenleft}\isakeyword{hints}\ recdef{\isacharunderscore}simp{\isacharcolon}\ termi{\isacharunderscore}lem{\isacharparenright}\isamarkupfalse% +% \begin{isamarkuptext}% \noindent This time everything works fine. Now \isa{g{\isachardot}simps} contains precisely the stated recursion equation for \isa{g}, which has been stored as a simplification rule. Thus we can automatically prove results such as this one:% \end{isamarkuptext}% +\isamarkuptrue% \isacommand{theorem}\ {\isachardoublequote}g{\isacharparenleft}{\isadigit{1}}{\isacharcomma}{\isadigit{0}}{\isacharparenright}\ {\isacharequal}\ g{\isacharparenleft}{\isadigit{1}}{\isacharcomma}{\isadigit{1}}{\isacharparenright}{\isachardoublequote}\isanewline +\isamarkupfalse% \isacommand{apply}{\isacharparenleft}simp{\isacharparenright}\isanewline -\isacommand{done}% +\isamarkupfalse% +\isacommand{done}\isamarkupfalse% +% \begin{isamarkuptext}% \noindent More exciting theorems require induction, which is discussed below. @@ -79,6 +95,8 @@ up front. \REMARK{FIXME, with one exception: nested recursion.}% \end{isamarkuptext}% +\isamarkuptrue% +\isamarkupfalse% \end{isabellebody}% %%% Local Variables: %%% mode: latex