# HG changeset patch # User nipkow # Date 1052496030 -7200 # Node ID a994b92ab1eac014caa84b97fd19004e5629a9bd # Parent ab988a7a8a3b9416b5aa3092f844cb7161b1b429 *** empty log message *** diff -r ab988a7a8a3b -r a994b92ab1ea doc-src/TutorialI/Misc/document/natsum.tex --- a/doc-src/TutorialI/Misc/document/natsum.tex Fri May 09 17:19:58 2003 +0200 +++ b/doc-src/TutorialI/Misc/document/natsum.tex Fri May 09 18:00:30 2003 +0200 @@ -92,15 +92,13 @@ \isamarkupfalse% % \begin{isamarkuptext}% -\noindent -The method \methdx{arith} is more general. It attempts to prove -the first subgoal provided it is a quantifier-free \textbf{linear arithmetic} -formula. Such formulas may involve the -usual logical connectives (\isa{{\isasymnot}}, \isa{{\isasymand}}, \isa{{\isasymor}}, -\isa{{\isasymlongrightarrow}}), the relations \isa{{\isacharequal}}, \isa{{\isasymle}} and \isa{{\isacharless}}, -and the operations -\isa{{\isacharplus}}, \isa{{\isacharminus}}, \isa{min} and \isa{max}. -For example,% +\noindent The method \methdx{arith} is more general. It attempts to +prove the first subgoal provided it is a \textbf{linear arithmetic} formula. +Such formulas may involve the usual logical connectives (\isa{{\isasymnot}}, +\isa{{\isasymand}}, \isa{{\isasymor}}, \isa{{\isasymlongrightarrow}}, \isa{{\isacharequal}}, +\isa{{\isasymforall}}, \isa{{\isasymexists}}), the relations \isa{{\isacharequal}}, +\isa{{\isasymle}} and \isa{{\isacharless}}, and the operations \isa{{\isacharplus}}, \isa{{\isacharminus}}, +\isa{min} and \isa{max}. For example,% \end{isamarkuptext}% \isamarkuptrue% \isacommand{lemma}\ {\isachardoublequote}min\ i\ {\isacharparenleft}max\ j\ {\isacharparenleft}k{\isacharasterisk}k{\isacharparenright}{\isacharparenright}\ {\isacharequal}\ max\ {\isacharparenleft}min\ {\isacharparenleft}k{\isacharasterisk}k{\isacharparenright}\ i{\isacharparenright}\ {\isacharparenleft}min\ i\ {\isacharparenleft}j{\isacharcolon}{\isacharcolon}nat{\isacharparenright}{\isacharparenright}{\isachardoublequote}\isanewline @@ -119,16 +117,19 @@ \begin{isamarkuptext}% \noindent is not proved even by \isa{arith} because the proof relies -on properties of multiplication. +on properties of multiplication. Only multiplication by numerals (which is +the same as iterated addition) is allowed. -\begin{warn} - The running time of \isa{arith} is exponential in the number of occurrences - of \ttindexboldpos{-}{$HOL2arithfun}, \cdx{min} and +\begin{warn} The running time of \isa{arith} is exponential in the number + of occurrences of \ttindexboldpos{-}{$HOL2arithfun}, \cdx{min} and \cdx{max} because they are first eliminated by case distinctions. - Even for linear arithmetic formulae, \isa{arith} is incomplete. If divisibility plays a - role, it may fail to prove a valid formula, for example - \isa{m{\isacharplus}m\ {\isasymnoteq}\ n{\isacharplus}n{\isacharplus}{\isacharparenleft}{\isadigit{1}}{\isacharcolon}{\isacharcolon}nat{\isacharparenright}}. Fortunately, such examples are rare. +If \isa{k} is a numeral, \sdx{div}~\isa{k}, \sdx{mod}~\isa{k} and +\isa{k}~\sdx{dvd} are also supported, where the former two are eliminated +by case distinctions, again blowing up the running time. + +If the formula involves explicit quantifiers, \isa{arith} may take +super-exponential time and space. \end{warn}% \end{isamarkuptext}% \isamarkuptrue% diff -r ab988a7a8a3b -r a994b92ab1ea doc-src/TutorialI/Misc/natsum.thy --- a/doc-src/TutorialI/Misc/natsum.thy Fri May 09 17:19:58 2003 +0200 +++ b/doc-src/TutorialI/Misc/natsum.thy Fri May 09 18:00:30 2003 +0200 @@ -81,16 +81,13 @@ lemma "m \ (n::nat) \ m < n \ n < m" (*<*)by(arith)(*>*) -text{*\noindent -The method \methdx{arith} is more general. It attempts to prove -the first subgoal provided it is a quantifier-free \textbf{linear arithmetic} -formula. Such formulas may involve the -usual logical connectives (@{text"\"}, @{text"\"}, @{text"\"}, -@{text"\"}), the relations @{text"="}, @{text"\"} and @{text"<"}, -and the operations -@{text"+"}, @{text"-"}, @{term min} and @{term max}. -For example, -*} +text{*\noindent The method \methdx{arith} is more general. It attempts to +prove the first subgoal provided it is a \textbf{linear arithmetic} formula. +Such formulas may involve the usual logical connectives (@{text"\"}, +@{text"\"}, @{text"\"}, @{text"\"}, @{text"="}, +@{text"\"}, @{text"\"}), the relations @{text"="}, +@{text"\"} and @{text"<"}, and the operations @{text"+"}, @{text"-"}, +@{term min} and @{term max}. For example, *} lemma "min i (max j (k*k)) = max (min (k*k) i) (min i (j::nat))"; apply(arith) @@ -105,16 +102,19 @@ text{*\noindent is not proved even by @{text arith} because the proof relies -on properties of multiplication. +on properties of multiplication. Only multiplication by numerals (which is +the same as iterated addition) is allowed. -\begin{warn} - The running time of @{text arith} is exponential in the number of occurrences - of \ttindexboldpos{-}{$HOL2arithfun}, \cdx{min} and +\begin{warn} The running time of @{text arith} is exponential in the number + of occurrences of \ttindexboldpos{-}{$HOL2arithfun}, \cdx{min} and \cdx{max} because they are first eliminated by case distinctions. - Even for linear arithmetic formulae, \isa{arith} is incomplete. If divisibility plays a - role, it may fail to prove a valid formula, for example - @{text"m+m \ n+n+(1::nat)"}. Fortunately, such examples are rare. +If @{text k} is a numeral, \sdx{div}~@{text k}, \sdx{mod}~@{text k} and +@{text k}~\sdx{dvd} are also supported, where the former two are eliminated +by case distinctions, again blowing up the running time. + +If the formula involves explicit quantifiers, @{text arith} may take +super-exponential time and space. \end{warn} *} diff -r ab988a7a8a3b -r a994b92ab1ea doc-src/TutorialI/Types/numerics.tex --- a/doc-src/TutorialI/Types/numerics.tex Fri May 09 17:19:58 2003 +0200 +++ b/doc-src/TutorialI/Types/numerics.tex Fri May 09 18:00:30 2003 +0200 @@ -28,7 +28,9 @@ and multiplication by constant factors; subterms involving other operators are regarded as variables. The procedure can be slow, especially if the subgoal to be proved involves subtraction over type \isa{nat}, which -causes case splits. +causes case splits. On types \isa{nat} and \isa{int}, \methdx{arith} +can deal with quantifiers (this is known as ``Presburger Arithmetic''), +whereas on type \isa{real} it cannot. The simplifier reduces arithmetic expressions in other ways, such as dividing through by common factors. For problems that lie @@ -480,4 +482,4 @@ Theory \isa{Hyperreal} also defines transcendental functions such as sine, cosine, exponential and logarithm --- even the versions for type \isa{real}, because they are defined using nonstandard limits.% -\index{numbers|)} \ No newline at end of file +\index{numbers|)}