new numerics section using type classes
authorpaulson
Thu Feb 19 17:57:54 2004 +0100 (2004-02-19)
changeset 144006069098854b9
parent 14399 dc677b35e54f
child 14401 477380c74c1d
new numerics section using type classes
doc-src/TutorialI/Types/Numbers.thy
doc-src/TutorialI/Types/document/Numbers.tex
doc-src/TutorialI/Types/numerics.tex
doc-src/TutorialI/Types/types.tex
doc-src/TutorialI/tutorial.sty
doc-src/TutorialI/tutorial.tex
     1.1 --- a/doc-src/TutorialI/Types/Numbers.thy	Thu Feb 19 16:44:21 2004 +0100
     1.2 +++ b/doc-src/TutorialI/Types/Numbers.thy	Thu Feb 19 17:57:54 2004 +0100
     1.3 @@ -60,18 +60,10 @@
     1.4  oops
     1.5  
     1.6  text{*
     1.7 -@{thm[display] mult_le_mono[no_vars]}
     1.8 -\rulename{mult_le_mono}
     1.9 -
    1.10 -@{thm[display] mult_less_mono1[no_vars]}
    1.11 -\rulename{mult_less_mono1}
    1.12  
    1.13  @{thm[display] div_le_mono[no_vars]}
    1.14  \rulename{div_le_mono}
    1.15  
    1.16 -@{thm[display] add_mult_distrib[no_vars]}
    1.17 -\rulename{add_mult_distrib}
    1.18 -
    1.19  @{thm[display] diff_mult_distrib[no_vars]}
    1.20  \rulename{diff_mult_distrib}
    1.21  
    1.22 @@ -168,9 +160,6 @@
    1.23  
    1.24  @{thm[display] zmod_zmult2_eq[no_vars]}
    1.25  \rulename{zmod_zmult2_eq}
    1.26 -
    1.27 -@{thm[display] abs_mult[no_vars]}
    1.28 -\rulename{abs_mult}
    1.29  *}  
    1.30  
    1.31  lemma "abs (x+y) \<le> abs x + abs (y :: int)"
    1.32 @@ -195,14 +184,11 @@
    1.33  \rulename{int_less_induct}
    1.34  *}  
    1.35  
    1.36 -text {*REALS
    1.37 +text {*FIELDS
    1.38  
    1.39  @{thm[display] dense[no_vars]}
    1.40  \rulename{dense}
    1.41  
    1.42 -@{thm[display] power_abs[no_vars]}
    1.43 -\rulename{power_abs}
    1.44 -
    1.45  @{thm[display] times_divide_eq_right[no_vars]}
    1.46  \rulename{times_divide_eq_right}
    1.47  
    1.48 @@ -254,6 +240,59 @@
    1.49  apply simp 
    1.50  oops
    1.51  
    1.52 +text{*
    1.53 +Ring and Field
    1.54 +
    1.55 +Requires a field, or else an ordered ring
    1.56 +
    1.57 +@{thm[display] mult_eq_0_iff[no_vars]}
    1.58 +\rulename{mult_eq_0_iff}
    1.59 +
    1.60 +@{thm[display] field_mult_eq_0_iff[no_vars]}
    1.61 +\rulename{field_mult_eq_0_iff}
    1.62 +
    1.63 +@{thm[display] mult_cancel_right[no_vars]}
    1.64 +\rulename{mult_cancel_right}
    1.65 +
    1.66 +@{thm[display] field_mult_cancel_right[no_vars]}
    1.67 +\rulename{field_mult_cancel_right}
    1.68 +*}
    1.69 +
    1.70 +ML{*set show_sorts*}
    1.71 +
    1.72 +text{*
    1.73 +effect of show sorts on the above
    1.74 +
    1.75 +@{thm[display] field_mult_cancel_right[no_vars]}
    1.76 +\rulename{field_mult_cancel_right}
    1.77 +*}
    1.78 +
    1.79 +ML{*reset show_sorts*}
    1.80 +
    1.81 +
    1.82 +text{*
    1.83 +absolute value
    1.84 +
    1.85 +@{thm[display] abs_mult[no_vars]}
    1.86 +\rulename{abs_mult}
    1.87 +
    1.88 +@{thm[display] abs_le_iff[no_vars]}
    1.89 +\rulename{abs_le_iff}
    1.90 +
    1.91 +@{thm[display] abs_triangle_ineq[no_vars]}
    1.92 +\rulename{abs_triangle_ineq}
    1.93 +
    1.94 +@{thm[display] power_add[no_vars]}
    1.95 +\rulename{power_add}
    1.96 +
    1.97 +@{thm[display] power_mult[no_vars]}
    1.98 +\rulename{power_mult}
    1.99 +
   1.100 +@{thm[display] power_abs[no_vars]}
   1.101 +\rulename{power_abs}
   1.102 +
   1.103 +
   1.104 +*}
   1.105  
   1.106  
   1.107  end
     2.1 --- a/doc-src/TutorialI/Types/document/Numbers.tex	Thu Feb 19 16:44:21 2004 +0100
     2.2 +++ b/doc-src/TutorialI/Types/document/Numbers.tex	Thu Feb 19 17:57:54 2004 +0100
     2.3 @@ -95,26 +95,11 @@
     2.4  %
     2.5  \begin{isamarkuptext}%
     2.6  \begin{isabelle}%
     2.7 -{\isasymlbrakk}i\ {\isasymle}\ j{\isacharsemicolon}\ k\ {\isasymle}\ l{\isasymrbrakk}\ {\isasymLongrightarrow}\ i\ {\isacharasterisk}\ k\ {\isasymle}\ j\ {\isacharasterisk}\ l%
     2.8 -\end{isabelle}
     2.9 -\rulename{mult_le_mono}
    2.10 -
    2.11 -\begin{isabelle}%
    2.12 -{\isasymlbrakk}i\ {\isacharless}\ j{\isacharsemicolon}\ {\isadigit{0}}\ {\isacharless}\ k{\isasymrbrakk}\ {\isasymLongrightarrow}\ i\ {\isacharasterisk}\ k\ {\isacharless}\ j\ {\isacharasterisk}\ k%
    2.13 -\end{isabelle}
    2.14 -\rulename{mult_less_mono1}
    2.15 -
    2.16 -\begin{isabelle}%
    2.17  m\ {\isasymle}\ n\ {\isasymLongrightarrow}\ m\ div\ k\ {\isasymle}\ n\ div\ k%
    2.18  \end{isabelle}
    2.19  \rulename{div_le_mono}
    2.20  
    2.21  \begin{isabelle}%
    2.22 -{\isacharparenleft}m\ {\isacharplus}\ n{\isacharparenright}\ {\isacharasterisk}\ k\ {\isacharequal}\ m\ {\isacharasterisk}\ k\ {\isacharplus}\ n\ {\isacharasterisk}\ k%
    2.23 -\end{isabelle}
    2.24 -\rulename{add_mult_distrib}
    2.25 -
    2.26 -\begin{isabelle}%
    2.27  {\isacharparenleft}m\ {\isacharminus}\ n{\isacharparenright}\ {\isacharasterisk}\ k\ {\isacharequal}\ m\ {\isacharasterisk}\ k\ {\isacharminus}\ n\ {\isacharasterisk}\ k%
    2.28  \end{isabelle}
    2.29  \rulename{diff_mult_distrib}
    2.30 @@ -274,12 +259,7 @@
    2.31  \begin{isabelle}%
    2.32  {\isadigit{0}}\ {\isacharless}\ c\ {\isasymLongrightarrow}\ a\ mod\ {\isacharparenleft}b\ {\isacharasterisk}\ c{\isacharparenright}\ {\isacharequal}\ b\ {\isacharasterisk}\ {\isacharparenleft}a\ div\ b\ mod\ c{\isacharparenright}\ {\isacharplus}\ a\ mod\ b%
    2.33  \end{isabelle}
    2.34 -\rulename{zmod_zmult2_eq}
    2.35 -
    2.36 -\begin{isabelle}%
    2.37 -{\isasymbar}a\ {\isacharasterisk}\ b{\isasymbar}\ {\isacharequal}\ {\isasymbar}a{\isasymbar}\ {\isacharasterisk}\ {\isasymbar}b{\isasymbar}%
    2.38 -\end{isabelle}
    2.39 -\rulename{abs_mult}%
    2.40 +\rulename{zmod_zmult2_eq}%
    2.41  \end{isamarkuptext}%
    2.42  \isamarkuptrue%
    2.43  \isacommand{lemma}\ {\isachardoublequote}abs\ {\isacharparenleft}x{\isacharplus}y{\isacharparenright}\ {\isasymle}\ abs\ x\ {\isacharplus}\ abs\ {\isacharparenleft}y\ {\isacharcolon}{\isacharcolon}\ int{\isacharparenright}{\isachardoublequote}\isanewline
    2.44 @@ -317,7 +297,7 @@
    2.45  \isamarkuptrue%
    2.46  %
    2.47  \begin{isamarkuptext}%
    2.48 -REALS
    2.49 +FIELDS
    2.50  
    2.51  \begin{isabelle}%
    2.52  a\ {\isacharless}\ b\ {\isasymLongrightarrow}\ {\isasymexists}r{\isachardot}\ a\ {\isacharless}\ r\ {\isasymand}\ r\ {\isacharless}\ b%
    2.53 @@ -325,11 +305,6 @@
    2.54  \rulename{dense}
    2.55  
    2.56  \begin{isabelle}%
    2.57 -{\isasymbar}a\ {\isacharcircum}\ n{\isasymbar}\ {\isacharequal}\ {\isasymbar}a{\isasymbar}\ {\isacharcircum}\ n%
    2.58 -\end{isabelle}
    2.59 -\rulename{power_abs}
    2.60 -
    2.61 -\begin{isabelle}%
    2.62  a\ {\isacharasterisk}\ {\isacharparenleft}b\ {\isacharslash}\ c{\isacharparenright}\ {\isacharequal}\ a\ {\isacharasterisk}\ b\ {\isacharslash}\ c%
    2.63  \end{isabelle}
    2.64  \rulename{times_divide_eq_right}
    2.65 @@ -414,11 +389,82 @@
    2.66  \isamarkupfalse%
    2.67  \isacommand{apply}\ simp\ \isanewline
    2.68  \isamarkupfalse%
    2.69 -\isacommand{oops}\isanewline
    2.70 -\isanewline
    2.71 -\isanewline
    2.72 -\isanewline
    2.73 -\isamarkupfalse%
    2.74 +\isacommand{oops}\isamarkupfalse%
    2.75 +%
    2.76 +\begin{isamarkuptext}%
    2.77 +Ring and Field
    2.78 +
    2.79 +Requires a field, or else an ordered ring
    2.80 +
    2.81 +\begin{isabelle}%
    2.82 +{\isacharparenleft}a\ {\isacharasterisk}\ b\ {\isacharequal}\ {\isacharparenleft}{\isadigit{0}}{\isasymColon}{\isacharprime}a{\isacharparenright}{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}a\ {\isacharequal}\ {\isacharparenleft}{\isadigit{0}}{\isasymColon}{\isacharprime}a{\isacharparenright}\ {\isasymor}\ b\ {\isacharequal}\ {\isacharparenleft}{\isadigit{0}}{\isasymColon}{\isacharprime}a{\isacharparenright}{\isacharparenright}%
    2.83 +\end{isabelle}
    2.84 +\rulename{mult_eq_0_iff}
    2.85 +
    2.86 +\begin{isabelle}%
    2.87 +{\isacharparenleft}a\ {\isacharasterisk}\ b\ {\isacharequal}\ {\isacharparenleft}{\isadigit{0}}{\isasymColon}{\isacharprime}a{\isacharparenright}{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}a\ {\isacharequal}\ {\isacharparenleft}{\isadigit{0}}{\isasymColon}{\isacharprime}a{\isacharparenright}\ {\isasymor}\ b\ {\isacharequal}\ {\isacharparenleft}{\isadigit{0}}{\isasymColon}{\isacharprime}a{\isacharparenright}{\isacharparenright}%
    2.88 +\end{isabelle}
    2.89 +\rulename{field_mult_eq_0_iff}
    2.90 +
    2.91 +\begin{isabelle}%
    2.92 +{\isacharparenleft}a\ {\isacharasterisk}\ c\ {\isacharequal}\ b\ {\isacharasterisk}\ c{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}c\ {\isacharequal}\ {\isacharparenleft}{\isadigit{0}}{\isasymColon}{\isacharprime}a{\isacharparenright}\ {\isasymor}\ a\ {\isacharequal}\ b{\isacharparenright}%
    2.93 +\end{isabelle}
    2.94 +\rulename{mult_cancel_right}
    2.95 +
    2.96 +\begin{isabelle}%
    2.97 +{\isacharparenleft}a\ {\isacharasterisk}\ c\ {\isacharequal}\ b\ {\isacharasterisk}\ c{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}c\ {\isacharequal}\ {\isacharparenleft}{\isadigit{0}}{\isasymColon}{\isacharprime}a{\isacharparenright}\ {\isasymor}\ a\ {\isacharequal}\ b{\isacharparenright}%
    2.98 +\end{isabelle}
    2.99 +\rulename{field_mult_cancel_right}%
   2.100 +\end{isamarkuptext}%
   2.101 +\isamarkuptrue%
   2.102 +\isacommand{ML}{\isacharbraceleft}{\isacharasterisk}set\ show{\isacharunderscore}sorts{\isacharasterisk}{\isacharbraceright}\isamarkupfalse%
   2.103 +%
   2.104 +\begin{isamarkuptext}%
   2.105 +effect of show sorts on the above
   2.106 +
   2.107 +\begin{isabelle}%
   2.108 +{\isacharparenleft}{\isacharparenleft}a{\isasymColon}{\isacharprime}a{\isasymColon}field{\isacharparenright}\ {\isacharasterisk}\ {\isacharparenleft}c{\isasymColon}{\isacharprime}a{\isasymColon}field{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}b{\isasymColon}{\isacharprime}a{\isasymColon}field{\isacharparenright}\ {\isacharasterisk}\ c{\isacharparenright}\ {\isacharequal}\isanewline
   2.109 +{\isacharparenleft}c\ {\isacharequal}\ {\isacharparenleft}{\isadigit{0}}{\isasymColon}{\isacharprime}a{\isasymColon}field{\isacharparenright}\ {\isasymor}\ a\ {\isacharequal}\ b{\isacharparenright}%
   2.110 +\end{isabelle}
   2.111 +\rulename{field_mult_cancel_right}%
   2.112 +\end{isamarkuptext}%
   2.113 +\isamarkuptrue%
   2.114 +\isacommand{ML}{\isacharbraceleft}{\isacharasterisk}reset\ show{\isacharunderscore}sorts{\isacharasterisk}{\isacharbraceright}\isamarkupfalse%
   2.115 +%
   2.116 +\begin{isamarkuptext}%
   2.117 +absolute value
   2.118 +
   2.119 +\begin{isabelle}%
   2.120 +{\isasymbar}a\ {\isacharasterisk}\ b{\isasymbar}\ {\isacharequal}\ {\isasymbar}a{\isasymbar}\ {\isacharasterisk}\ {\isasymbar}b{\isasymbar}%
   2.121 +\end{isabelle}
   2.122 +\rulename{abs_mult}
   2.123 +
   2.124 +\begin{isabelle}%
   2.125 +{\isacharparenleft}{\isasymbar}a{\isasymbar}\ {\isasymle}\ b{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}a\ {\isasymle}\ b\ {\isasymand}\ {\isacharminus}\ a\ {\isasymle}\ b{\isacharparenright}%
   2.126 +\end{isabelle}
   2.127 +\rulename{abs_le_iff}
   2.128 +
   2.129 +\begin{isabelle}%
   2.130 +{\isasymbar}a\ {\isacharplus}\ b{\isasymbar}\ {\isasymle}\ {\isasymbar}a{\isasymbar}\ {\isacharplus}\ {\isasymbar}b{\isasymbar}%
   2.131 +\end{isabelle}
   2.132 +\rulename{abs_triangle_ineq}
   2.133 +
   2.134 +\begin{isabelle}%
   2.135 +a\ {\isacharcircum}\ {\isacharparenleft}m\ {\isacharplus}\ n{\isacharparenright}\ {\isacharequal}\ a\ {\isacharcircum}\ m\ {\isacharasterisk}\ a\ {\isacharcircum}\ n%
   2.136 +\end{isabelle}
   2.137 +\rulename{power_add}
   2.138 +
   2.139 +\begin{isabelle}%
   2.140 +a\ {\isacharcircum}\ {\isacharparenleft}m\ {\isacharasterisk}\ n{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}a\ {\isacharcircum}\ m{\isacharparenright}\ {\isacharcircum}\ n%
   2.141 +\end{isabelle}
   2.142 +\rulename{power_mult}
   2.143 +
   2.144 +\begin{isabelle}%
   2.145 +{\isasymbar}a\ {\isacharcircum}\ n{\isasymbar}\ {\isacharequal}\ {\isasymbar}a{\isasymbar}\ {\isacharcircum}\ n%
   2.146 +\end{isabelle}
   2.147 +\rulename{power_abs}%
   2.148 +\end{isamarkuptext}%
   2.149 +\isamarkuptrue%
   2.150  \isacommand{end}\isanewline
   2.151  \isamarkupfalse%
   2.152  \end{isabellebody}%
     3.1 --- a/doc-src/TutorialI/Types/numerics.tex	Thu Feb 19 16:44:21 2004 +0100
     3.2 +++ b/doc-src/TutorialI/Types/numerics.tex	Thu Feb 19 17:57:54 2004 +0100
     3.3 @@ -10,16 +10,19 @@
     3.4  zero  and successor, so it works well with inductive proofs and primitive
     3.5  recursive function definitions.  HOL also provides the type
     3.6  \isa{int} of \textbf{integers}, which lack induction but support true
     3.7 -subtraction.  The integers are preferable to the natural numbers for reasoning about
     3.8 -complicated arithmetic expressions, even for some expressions whose
     3.9 -value is non-negative.  The logic HOL-Complex also has the types
    3.10 -\isa{real} and \isa{complex}: the real and complex numbers.  Isabelle has no 
    3.11 +subtraction.  With subtraction, arithmetic reasoning is easier, which makes
    3.12 +the integers preferable to the natural numbers for
    3.13 +complicated arithmetic expressions, even if they are non-negative.  The logic HOL-Complex also has the types
    3.14 +\isa{rat}, \isa{real} and \isa{complex}: the rational, real and complex numbers.  Isabelle has no 
    3.15  subtyping,  so the numeric
    3.16  types are distinct and there are functions to convert between them.
    3.17 -Fortunately most numeric operations are overloaded: the same symbol can be
    3.18 +Most numeric operations are overloaded: the same symbol can be
    3.19  used at all numeric types. Table~\ref{tab:overloading} in the appendix
    3.20  shows the most important operations, together with the priorities of the
    3.21 -infix symbols.
    3.22 +infix symbols. Algebraic properties are organized using type classes
    3.23 +around algebraic concepts such as rings and fields;
    3.24 +a property such as the commutativity of addition is a single theorem 
    3.25 +(\isa{add_commute}) that applies to all numeric types.
    3.26  
    3.27  \index{linear arithmetic}%
    3.28  Many theorems involving numeric types can be proved automatically by
    3.29 @@ -29,8 +32,7 @@
    3.30  are regarded as variables.  The procedure can be slow, especially if the
    3.31  subgoal to be proved involves subtraction over type \isa{nat}, which 
    3.32  causes case splits.  On types \isa{nat} and \isa{int}, \methdx{arith}
    3.33 -can deal with quantifiers (this is known as ``Presburger Arithmetic''),
    3.34 -whereas on type \isa{real} it cannot.
    3.35 +can deal with quantifiers---this is known as Presburger arithmetic---whereas on type \isa{real} it cannot.
    3.36  
    3.37  The simplifier reduces arithmetic expressions in other
    3.38  ways, such as dividing through by common factors.  For problems that lie
    3.39 @@ -46,16 +48,13 @@
    3.40  \index{numeric literals|(}%
    3.41  The constants \cdx{0} and \cdx{1} are overloaded.  They denote zero and one,
    3.42  respectively, for all numeric types.  Other values are expressed by numeric
    3.43 -literals, which consist of one or more decimal digits optionally preceeded by
    3.44 -a minus sign (\isa{-}).  Examples are \isa{2}, \isa{-3} and
    3.45 -\isa{441223334678}.  Literals are available for the types of natural numbers,
    3.46 -integers and reals; they denote integer values of arbitrary size.
    3.47 +literals, which consist of one or more decimal digits optionally preceeded by a minus sign (\isa{-}).  Examples are \isa{2}, \isa{-3} and
\isa{441223334678}.  Literals are available for the types of natural
numbers, integers, rationals, reals, etc.; they denote integer values of
arbitrary size.
    3.48  
    3.49  Literals look like constants, but they abbreviate 
    3.50  terms representing the number in a two's complement binary notation. 
    3.51  Isabelle performs arithmetic on literals by rewriting rather 
    3.52  than using the hardware arithmetic. In most cases arithmetic 
    3.53 -is fast enough, even for large numbers. The arithmetic operations 
    3.54 +is fast enough, even for numbers in the millions. The arithmetic operations 
    3.55  provided for literals include addition, subtraction, multiplication, 
    3.56  integer division and remainder.  Fractions of literals (expressed using
    3.57  division) are reduced to lowest terms.
    3.58 @@ -98,14 +97,14 @@
    3.59  \end{warn}
    3.60  
    3.61  
    3.62 -
    3.63  \subsection{The Type of Natural Numbers, {\tt\slshape nat}}
    3.64  
    3.65  \index{natural numbers|(}\index{*nat (type)|(}%
    3.66  This type requires no introduction: we have been using it from the
    3.67  beginning.  Hundreds of theorems about the natural numbers are
    3.68 -proved in the theories \isa{Nat}, \isa{NatArith} and \isa{Divides}.  Only
    3.69 -in exceptional circumstances should you resort to induction.
    3.70 +proved in the theories \isa{Nat}, \isa{NatArith} and \isa{Divides}.  
    3.71 +Basic properties of addition and multiplication are available through the
    3.72 +axiomatic type class for semirings (\S\ref{sec:numeric-axclasses}).
    3.73  
    3.74  \subsubsection{Literals}
    3.75  \index{numeric literals!for type \protect\isa{nat}}%
    3.76 @@ -134,30 +133,6 @@
    3.77  the simplifier will normally reverse this transformation.  Novices should
    3.78  express natural numbers using \isa{0} and \isa{Suc} only.
    3.79  
    3.80 -\subsubsection{Typical lemmas}
    3.81 -Inequalities involving addition and subtraction alone can be proved
    3.82 -automatically.  Lemmas such as these can be used to prove inequalities
    3.83 -involving multiplication and division:
    3.84 -\begin{isabelle}
    3.85 -\isasymlbrakk i\ \isasymle \ j;\ k\ \isasymle \ l\isasymrbrakk \ \isasymLongrightarrow \ i\ *\ k\ \isasymle \ j\ *\ l%
    3.86 -\rulename{mult_le_mono}\isanewline
    3.87 -\isasymlbrakk i\ <\ j;\ 0\ <\ k\isasymrbrakk \ \isasymLongrightarrow \ i\
    3.88 -*\ k\ <\ j\ *\ k%
    3.89 -\rulename{mult_less_mono1}\isanewline
    3.90 -m\ \isasymle \ n\ \isasymLongrightarrow \ m\ div\ k\ \isasymle \ n\ div\ k%
    3.91 -\rulename{div_le_mono}
    3.92 -\end{isabelle}
    3.93 -%
    3.94 -Various distributive laws concerning multiplication are available:
    3.95 -\begin{isabelle}
    3.96 -(m\ +\ n)\ *\ k\ =\ m\ *\ k\ +\ n\ *\ k%
    3.97 -\rulenamedx{add_mult_distrib}\isanewline
    3.98 -(m\ -\ n)\ *\ k\ =\ m\ *\ k\ -\ n\ *\ k%
    3.99 -\rulenamedx{diff_mult_distrib}\isanewline
   3.100 -(m\ mod\ n)\ *\ k\ =\ (m\ *\ k)\ mod\ (n\ *\ k)
   3.101 -\rulenamedx{mod_mult_distrib}
   3.102 -\end{isabelle}
   3.103 -
   3.104  \subsubsection{Division}
   3.105  \index{division!for type \protect\isa{nat}}%
   3.106  The infix operators \isa{div} and \isa{mod} are overloaded.
   3.107 @@ -182,7 +157,11 @@
   3.108  a\ mod\ (b*c)\ =\ b * (a\ div\ b\ mod\ c)\ +\ a\ mod\ b%
   3.109  \rulename{mod_mult2_eq}\isanewline
   3.110  0\ <\ c\ \isasymLongrightarrow \ (c\ *\ a)\ div\ (c\ *\ b)\ =\ a\ div\ b%
   3.111 -\rulename{div_mult_mult1}
   3.112 +\rulename{div_mult_mult1}\isanewline
   3.113 +(m\ mod\ n)\ *\ k\ =\ (m\ *\ k)\ mod\ (n\ *\ k)
   3.114 +\rulenamedx{mod_mult_distrib}\isanewline
   3.115 +m\ \isasymle \ n\ \isasymLongrightarrow \ m\ div\ k\ \isasymle \ n\ div\ k%
   3.116 +\rulename{div_le_mono}
   3.117  \end{isabelle}
   3.118  
   3.119  Surprisingly few of these results depend upon the
   3.120 @@ -196,8 +175,7 @@
   3.121  a\ mod\ 0\ =\ a%
   3.122  \rulename{DIVISION_BY_ZERO_MOD}
   3.123  \end{isabelle}
   3.124 -As a concession to convention, these equations are not installed as default
   3.125 -simplification rules.  In \isa{div_mult_mult1} above, one of
   3.126 +In \isa{div_mult_mult1} above, one of
   3.127  the two divisors (namely~\isa{c}) must still be nonzero.
   3.128  
   3.129  The \textbf{divides} relation\index{divides relation}
   3.130 @@ -217,19 +195,26 @@
   3.131  \rulenamedx{dvd_add}
   3.132  \end{isabelle}
   3.133  
   3.134 -\subsubsection{Simplifier Tricks}
   3.135 -The rule \isa{diff_mult_distrib} shown above is one of the few facts
   3.136 +\subsubsection{Subtraction}
   3.137 +
   3.138 +There are no negative natural numbers, so \isa{m\ -\ n} equals zero unless 
   3.139 +\isa{m} exceeds~\isa{n}. The following is one of the few facts
   3.140  about \isa{m\ -\ n} that is not subject to
   3.141 -the condition \isa{n\ \isasymle \  m}.  Natural number subtraction has few
   3.142 +the condition \isa{n\ \isasymle \  m}. 
   3.143 +\begin{isabelle}
   3.144 +(m\ -\ n)\ *\ k\ =\ m\ *\ k\ -\ n\ *\ k%
   3.145 +\rulenamedx{diff_mult_distrib}
   3.146 +\end{isabelle}
   3.147 +Natural number subtraction has few
   3.148  nice properties; often you should remove it by simplifying with this split
   3.149 -rule:
   3.150 +rule.
   3.151  \begin{isabelle}
   3.152  P(a-b)\ =\ ((a<b\ \isasymlongrightarrow \ P\
   3.153  0)\ \isasymand \ (\isasymforall d.\ a\ =\ b+d\ \isasymlongrightarrow \ P\
   3.154  d))
   3.155  \rulename{nat_diff_split}
   3.156  \end{isabelle}
   3.157 -For example, splitting helps to prove the following fact:
   3.158 +For example, splitting helps to prove the following fact.
   3.159  \begin{isabelle}
   3.160  \isacommand{lemma}\ "(n\ -\ 2)\ *\ (n\ +\ 2)\ =\ n\ *\ n\ -\ (4::nat)"\isanewline
   3.161  \isacommand{apply}\ (simp\ split:\ nat_diff_split,\ clarify)\isanewline
   3.162 @@ -241,66 +226,18 @@
   3.163  \begin{isabelle}
   3.164  \isacommand{apply}\ (subgoal_tac\ "n=0\ |\ n=1",\ force,\ arith)\isanewline
   3.165  \isacommand{done}
   3.166 -\end{isabelle}
   3.167 -
   3.168 -Suppose that two expressions are equal, differing only in 
   3.169 -associativity and commutativity of addition.  Simplifying with the
   3.170 -following equations sorts the terms and groups them to the right, making
   3.171 -the two expressions identical:
   3.172 -\begin{isabelle}
   3.173 -m\ +\ n\ +\ k\ =\ m\ +\ (n\ +\ k)
   3.174 -\rulenamedx{add_assoc}\isanewline
   3.175 -m\ +\ n\ =\ n\ +\ m%
   3.176 -\rulenamedx{add_commute}\isanewline
   3.177 -x\ +\ (y\ +\ z)\ =\ y\ +\ (x\
   3.178 -+\ z)
   3.179 -\rulename{add_left_commute}
   3.180 -\end{isabelle}
   3.181 -The name \isa{add_ac}\index{*add_ac (theorems)} 
   3.182 -refers to the list of all three theorems; similarly
   3.183 -there is \isa{mult_ac}.\index{*mult_ac (theorems)} 
   3.184 -Here is an example of the sorting effect.  Start
   3.185 -with this goal:
   3.186 -\begin{isabelle}
   3.187 -\ 1.\ Suc\ (i\ +\ j\ *\ l\ *\ k\ +\ m\ *\ n)\ =\
   3.188 -f\ (n\ *\ m\ +\ i\ +\ k\ *\ j\ *\ l)
   3.189 -\end{isabelle}
   3.190 -%
   3.191 -Simplify using  \isa{add_ac} and \isa{mult_ac}:
   3.192 -\begin{isabelle}
   3.193 -\isacommand{apply}\ (simp\ add:\ add_ac\ mult_ac)
   3.194 -\end{isabelle}
   3.195 -%
   3.196 -Here is the resulting subgoal:
   3.197 -\begin{isabelle}
   3.198 -\ 1.\ Suc\ (i\ +\ (m\ *\ n\ +\ j\ *\ (k\ *\ l)))\
   3.199 -=\ f\ (i\ +\ (m\ *\ n\ +\ j\ *\ (k\ *\ l)))%
   3.200 -\end{isabelle}%
   3.201 +\end{isabelle}%%%%%%
   3.202  \index{natural numbers|)}\index{*nat (type)|)}
   3.203  
   3.204  
   3.205 -
   3.206  \subsection{The Type of Integers, {\tt\slshape int}}
   3.207  
   3.208  \index{integers|(}\index{*int (type)|(}%
   3.209 -Reasoning methods resemble those for the natural numbers, but induction and
   3.210 -the constant \isa{Suc} are not available.  HOL provides many lemmas
   3.211 -for proving inequalities involving integer multiplication and division,
   3.212 -similar to those shown above for type~\isa{nat}.  
   3.213 +Reasoning methods for the integers resemble those for the natural numbers, 
   3.214 +but induction and
the constant \isa{Suc} are not available.  HOL provides many lemmas for
proving inequalities involving integer multiplication and division, similar
to those shown above for type~\isa{nat}. The laws of addition, subtraction
and multiplication are available through the axiomatic type class for rings
(\S\ref{sec:numeric-axclasses}).
   3.215  
   3.216 -The \rmindex{absolute value} function \cdx{abs} is overloaded for the numeric types.
   3.217 -It is defined for the integers; we have for example the obvious law
   3.218 -\begin{isabelle}
   3.219 -\isasymbar x\ *\ y\isasymbar \ =\ \isasymbar x\isasymbar \ *\ \isasymbar y\isasymbar 
   3.220 -\rulename{abs_mult}
   3.221 -\end{isabelle}
   3.222 -
   3.223 -\begin{warn}
   3.224 -The absolute value bars shown above cannot be typed on a keyboard.  They
   3.225 -can be entered using the X-symbol package.  In \textsc{ascii}, type \isa{abs x} to
   3.226 -get \isa{\isasymbar x\isasymbar}.
   3.227 -\end{warn}
   3.228 -
   3.229 +The \rmindex{absolute value} function \cdx{abs} is overloaded, and is 
   3.230 +defined for all types that involve negative numbers, including the integers.
   3.231  The \isa{arith} method can prove facts about \isa{abs} automatically, 
   3.232  though as it does so by case analysis, the cost can be exponential.
   3.233  \begin{isabelle}
   3.234 @@ -308,16 +245,6 @@
   3.235  \isacommand{by}\ arith
   3.236  \end{isabelle}
   3.237  
   3.238 -Concerning simplifier tricks, we have no need to eliminate subtraction: it
   3.239 -is well-behaved.  As with the natural numbers, the simplifier can sort the
   3.240 -operands of sums and products.  The name \isa{zadd_ac}\index{*zadd_ac (theorems)}
   3.241 -refers to the
   3.242 -associativity and commutativity theorems for integer addition, while
   3.243 -\isa{zmult_ac}\index{*zmult_ac (theorems)}
   3.244 -has the analogous theorems for multiplication.  The
   3.245 -prefix~\isa{z} in many theorem names recalls the use of $\mathbb{Z}$ to
   3.246 -denote the set of integers.
   3.247 -
   3.248  For division and remainder,\index{division!by negative numbers}
   3.249  the treatment of negative divisors follows
   3.250  mathematical practice: the sign of the remainder follows that
   3.251 @@ -363,7 +290,9 @@
   3.252  \isa{c} to be zero.  However, \isa{c} cannot be negative: a counterexample
   3.253  is
   3.254  $\isa{a} = 7$, $\isa{b} = 2$ and $\isa{c} = -3$, when the left-hand side of
   3.255 -\isa{zdiv_zmult2_eq} is $-2$ while the right-hand side is~$-1$.%
   3.256 +\isa{zdiv_zmult2_eq} is $-2$ while the right-hand side is~$-1$.
   3.257 +The prefix~\isa{z} in many theorem names recalls the use of $\mathbb{Z}$ to
   3.258 +denote the set of integers.%
   3.259  \index{integers|)}\index{*int (type)|)}
   3.260  
   3.261  Induction is less important for integers than it is for the natural numbers, but it can be valuable if the range of integers has a lower or upper bound.  There are four rules for integer induction, corresponding to the possible relations of the bound ($\geq$, $>$, $\leq$ and $<$):
   3.262 @@ -379,27 +308,147 @@
   3.263  \end{isabelle}
   3.264  
   3.265  
   3.266 -\subsection{The Type of Real Numbers, {\tt\slshape real}}
   3.267 +\subsection{The Types of Rational, Real and Complex Numbers}
   3.268  
   3.269 +\index{rational numbers|(}\index{*rat (type)|(}%
   3.270  \index{real numbers|(}\index{*real (type)|(}%
   3.271 -The real numbers enjoy two significant properties that the integers lack. 
   3.272 -They are
   3.273 -\textbf{dense}: between every two distinct real numbers there lies another.
   3.274 -This property follows from the division laws, since if $x<y$ then between
   3.275 -them lies $(x+y)/2$.  The second property is that they are
   3.276 -\textbf{complete}: every set of reals that is bounded above has a least
   3.277 -upper bound.  Completeness distinguishes the reals from the rationals, for
   3.278 -which the set $\{x\mid x^2<2\}$ has no least upper bound.  (It could only be
   3.279 -$\surd2$, which is irrational.)
   3.280 -The formalization of completeness is complicated; rather than
   3.281 -reproducing it here, we refer you to the theory \texttt{RComplete} in
   3.282 -directory \texttt{Real}.
   3.283 -Density, however, is trivial to express:
   3.284 +\index{complex numbers|(}\index{*complex (type)|(}%
   3.285 +These types provide true division, the overloaded operator \isa{/}, 
   3.286 +which differs from the operator \isa{div} of the 
   3.287 +natural numbers and integers. The rationals and reals are 
   3.288 +\textbf{dense}: between every two distinct numbers lies another.
   3.289 +This property follows from the division laws, since if $x\not=y$ then $(x+y)/2$ lies between them:
   3.290  \begin{isabelle}
   3.291 -x\ <\ y\ \isasymLongrightarrow \ \isasymexists r.\ x\ <\ r\ \isasymand \ r\ <\ y%
   3.292 +a\ <\ b\ \isasymLongrightarrow \ \isasymexists r.\ a\ <\ r\ \isasymand \ r\ <\ b%
   3.293  \rulename{dense}
   3.294  \end{isabelle}
   3.295  
   3.296 +The real numbers are, moreover, \textbf{complete}: every set of reals that
is bounded above has a least upper bound.  Completeness distinguishes the
reals from the rationals, for which the set $\{x\mid x^2<2\}$ has no least
upper bound.  (It could only be $\surd2$, which is irrational. The
formalization of completeness, which is complicated, 
   3.297 +can be found in theory \texttt{RComplete} of directory
\texttt{Real}.
   3.298 +
   3.299 +Numeric literals\index{numeric literals!for type \protect\isa{real}}
   3.300 +for type \isa{real} have the same syntax as those for type
   3.301 +\isa{int} and only express integral values.  Fractions expressed
   3.302 +using the division operator are automatically simplified to lowest terms:
   3.303 +\begin{isabelle}
   3.304 +\ 1.\ P\ ((3\ /\ 4)\ *\ (8\ /\ 15))\isanewline
   3.305 +\isacommand{apply} simp\isanewline
   3.306 +\ 1.\ P\ (2\ /\ 5)
   3.307 +\end{isabelle}
   3.308 +Exponentiation can express floating-point values such as
   3.309 +\isa{2 * 10\isacharcircum6}, but at present no special simplification
   3.310 +is performed.
   3.311 +
   3.312 +\begin{warn}
   3.313 +Type \isa{real} is only available in the logic HOL-Complex, which
   3.314 +is  HOL extended with a definitional development of the real and complex
   3.315 +numbers.  Base your theory upon theory
   3.316 +\thydx{Complex_Main}, not the usual \isa{Main}.%
   3.317 +\index{real numbers|)}\index{*real (type)|)}
   3.318 +Launch Isabelle using the command 
   3.319 +\begin{verbatim}
   3.320 +Isabelle -l HOL-Complex
   3.321 +\end{verbatim}
   3.322 +\end{warn}
   3.323 +
   3.324 +Also available in HOL-Complex is the
   3.325 +theory \isa{Hyperreal}, which define the type \tydx{hypreal} of 
   3.326 +\rmindex{non-standard reals}.  These
   3.327 +\textbf{hyperreals} include infinitesimals, which represent infinitely
   3.328 +small and infinitely large quantities; they facilitate proofs
   3.329 +about limits, differentiation and integration~\cite{fleuriot-jcm}.  The
   3.330 +development defines an infinitely large number, \isa{omega} and an
   3.331 +infinitely small positive number, \isa{epsilon}.  The 
   3.332 +relation $x\approx y$ means ``$x$ is infinitely close to~$y$.''
   3.333 +Theory \isa{Hyperreal} also defines transcendental functions such as sine,
   3.334 +cosine, exponential and logarithm --- even the versions for type
   3.335 +\isa{real}, because they are defined using nonstandard limits.%
   3.336 +\index{rational numbers|)}\index{*rat (type)|)}%
   3.337 +\index{real numbers|)}\index{*real (type)|)}%
   3.338 +\index{complex numbers|)}\index{*complex (type)|)}
   3.339 +
   3.340 +
   3.341 +\subsection{The Numeric Type Classes}\label{sec:numeric-axclasses}
   3.342 +
   3.343 +Isabelle/HOL organises its numeric theories using axiomatic type classes.
   3.344 +Hundreds of basic properties are proved in the theory \isa{Ring_and_Field}.
   3.345 +These lemmas are available (as simprules if they were declared as such)
   3.346 +for all numeric types satisfying the necessary axioms. The theory defines
   3.347 +the following type classes:
   3.348 +\begin{itemize}
   3.349 +\item 
   3.350 +\tcdx{semiring} and \tcdx{ordered_semiring}: a \emph{semiring}
provides the operators \isa{+} and~\isa{*}, which are commutative and
associative, with the usual distributive law and with \isa{0} and~\isa{1}
as their respective identities. An \emph{ordered semiring} is also linearly
ordered, with addition and multiplication respecting the ordering. Type \isa{nat} is an ordered semiring.
   3.351 +\item 
   3.352 +\tcdx{ring} and \tcdx{ordered_ring}: a \emph{ring} extends a semiring
with unary minus (the additive inverse) and subtraction (both
denoted~\isa{-}). An \emph{ordered ring} includes the absolute value
function, \cdx{abs}. Type \isa{int} is an ordered ring.
   3.353 +\item 
   3.354 +\tcdx{field} and \tcdx{ordered_field}: a field extends a ring with the
multiplicative inverse (called simply \cdx{inverse} and division~(\isa{/}).
An ordered field is based on an ordered ring. Type \isa{complex} is a field, while type \isa{real} is an ordered field.
   3.355 +\item 
   3.356 +\tcdx{division_by_zero} includes all types where \isa{inverse 0 = 0}
   3.357 +and \isa{a / 0 = 0}. These include all of Isabelle's standard numeric types.
   3.358 +However, the basic properties of fields are derived without assuming
   3.359 +division by zero.
\end{itemize}
   3.360 +
   3.361 +Theory \thydx{Ring_and_Field} proves over 250 lemmas, each of which
holds for all types in the corresponding type class. In most
cases, it is obvious whether a property is valid for a particular type. All
abstract properties involving subtraction require a ring, and therefore do
not hold for type \isa{nat}, although we have theorems such as
\isa{diff_mult_distrib} proved specifically about subtraction on
type~\isa{nat}. All abstract properties involving division require a field.
Obviously, all properties involving orderings required an ordered
structure.
   3.362 +
   3.363 +The following two theorems are less obvious. Although they
   3.364 +mention no ordering, they require an ordered ring. However, if we have a 
   3.365 +field, then an ordering is no longer required.
   3.366 +\begin{isabelle}
   3.367 +(a\ *\ b\ =\ (0::'a))\ =\ (a\ =\ (0::'a)\ \isasymor \ b\ =\ (0::'a))
   3.368 +\rulename{mult_eq_0_iff}\isanewline
   3.369 +(a\ *\ c\ =\ b\ *\ c)\ =\ (c\ =\ (0::'a)\ \isasymor \ a\ =\ b)
   3.370 +\rulename{mult_cancel_right}
   3.371 +\end{isabelle}
   3.372 +Theorems \isa{field_mult_eq_0_iff} and \isa{field_mult_cancel_right}
   3.373 +express the same properties, only for fields. When working with such
   3.374 +theorems, setting the \texttt{show_sorts}\index{*show_sorts (flag)}
   3.375 +flag will display the type classes of all type variables. Here is how the 
   3.376 +theorem \isa{field_mult_cancel_right} appears with the flag set.
   3.377 +\begin{isabelle}
   3.378 +((a::'a::field)\ *\ (c::'a::field)\ =\ (b::'a::field)\ *\ c)\ =\isanewline
   3.379 +(c\ =\ (0::'a::field)\ \isasymor \ a\ =\ b)
   3.380 +\end{isabelle}
   3.381 +
   3.382 +
   3.383 +\subsubsection{Simplifying with the AC-Laws}
   3.384 +Suppose that two expressions are equal, differing only in 
   3.385 +associativity and commutativity of addition.  Simplifying with the
   3.386 +following equations sorts the terms and groups them to the right, making
   3.387 +the two expressions identical.
   3.388 +\begin{isabelle}
   3.389 +a\ +\ b\ +\ c\ =\ a\ +\ (b\ +\ c)
   3.390 +\rulenamedx{add_assoc}\isanewline
   3.391 +a\ +\ b\ =\ b\ +\ a%
   3.392 +\rulenamedx{add_commute}\isanewline
   3.393 +a\ +\ (b\ +\ c)\ =\ b\ +\ (a\ +\ c)
   3.394 +\rulename{add_left_commute}
   3.395 +\end{isabelle}
   3.396 +The name \isa{add_ac}\index{*add_ac (theorems)} 
   3.397 +refers to the list of all three theorems; similarly
   3.398 +there is \isa{mult_ac}.\index{*mult_ac (theorems)} 
   3.399 +They are all proved for semirings and therefore hold for all numeric types.
   3.400 +
   3.401 +Here is an example of the sorting effect.  Start
   3.402 +with this goal, which involves type \isa{nat}.
   3.403 +\begin{isabelle}
   3.404 +\ 1.\ Suc\ (i\ +\ j\ *\ l\ *\ k\ +\ m\ *\ n)\ =\
   3.405 +f\ (n\ *\ m\ +\ i\ +\ k\ *\ j\ *\ l)
   3.406 +\end{isabelle}
   3.407 +%
   3.408 +Simplify using  \isa{add_ac} and \isa{mult_ac}.
   3.409 +\begin{isabelle}
   3.410 +\isacommand{apply}\ (simp\ add:\ add_ac\ mult_ac)
   3.411 +\end{isabelle}
   3.412 +%
   3.413 +Here is the resulting subgoal.
   3.414 +\begin{isabelle}
   3.415 +\ 1.\ Suc\ (i\ +\ (m\ *\ n\ +\ j\ *\ (k\ *\ l)))\
   3.416 +=\ f\ (i\ +\ (m\ *\ n\ +\ j\ *\ (k\ *\ l)))%
   3.417 +\end{isabelle}
   3.418 +
   3.419 +
   3.420 +\subsubsection{Division Laws for Fields}
   3.421 +
   3.422  Here is a selection of rules about the division operator.  The following
   3.423  are installed as default simplification rules in order to express
   3.424  combinations of products and quotients as rational expressions:
   3.425 @@ -430,56 +479,41 @@
   3.426  \rulename{add_divide_distrib}
   3.427  \end{isabelle}
   3.428  
   3.429 -As with the other numeric types, the simplifier can sort the operands of
   3.430 -addition and multiplication.  The name \isa{real_add_ac} refers to the
   3.431 -associativity and commutativity theorems for addition, while similarly
   3.432 -\isa{real_mult_ac} contains those properties for multiplication. 
   3.433 +
   3.434 +\subsubsection{Absolute Value}
   3.435  
   3.436 -The absolute value function \isa{abs} is
   3.437 -defined for the reals, along with many theorems such as this one about
   3.438 -exponentiation:
   3.439 +The \rmindex{absolute value} function \cdx{abs} is available for all 
   3.440 +ordered rings, including types \isa{int}, \isa{rat} and \isa{real}.
   3.441 +It satisfies many properties,
   3.442 +such as the following:
   3.443  \begin{isabelle}
   3.444 -\isasymbar a\ \isacharcircum \ n\isasymbar\ =\ 
   3.445 -\isasymbar a\isasymbar \ \isacharcircum \ n
   3.446 -\rulename{power_abs}
   3.447 +\isasymbar x\ *\ y\isasymbar \ =\ \isasymbar x\isasymbar \ *\ \isasymbar y\isasymbar 
   3.448 +\rulename{abs_mult}\isanewline
   3.449 +(\isasymbar a\isasymbar \ \isasymle \ b)\ =\ (a\ \isasymle \ b\ \isasymand \ -\ a\ \isasymle \ b)
   3.450 +\rulename{abs_le_iff}\isanewline
   3.451 +\isasymbar a\ +\ b\isasymbar \ \isasymle \ \isasymbar a\isasymbar \ +\ \isasymbar b\isasymbar 
   3.452 +\rulename{abs_triangle_ineq}
   3.453  \end{isabelle}
   3.454  
   3.455 -Numeric literals\index{numeric literals!for type \protect\isa{real}}
   3.456 -for type \isa{real} have the same syntax as those for type
   3.457 -\isa{int} and only express integral values.  Fractions expressed
   3.458 -using the division operator are automatically simplified to lowest terms:
   3.459 -\begin{isabelle}
   3.460 -\ 1.\ P\ ((3\ /\ 4)\ *\ (8\ /\ 15))\isanewline
   3.461 -\isacommand{apply} simp\isanewline
   3.462 -\ 1.\ P\ (2\ /\ 5)
   3.463 -\end{isabelle}
   3.464 -Exponentiation can express floating-point values such as
   3.465 -\isa{2 * 10\isacharcircum6}, but at present no special simplification
   3.466 -is performed.
   3.467 +\begin{warn}
   3.468 +The absolute value bars shown above cannot be typed on a keyboard.  They
   3.469 +can be entered using the X-symbol package.  In \textsc{ascii}, type \isa{abs x} to
   3.470 +get \isa{\isasymbar x\isasymbar}.
   3.471 +\end{warn}
   3.472  
   3.473  
   3.474 -\begin{warn}
   3.475 -Type \isa{real} is only available in the logic HOL-Complex, which
   3.476 -is  HOL extended with a definitional development of the real and complex
   3.477 -numbers.  Base your theory upon theory
   3.478 -\thydx{Complex_Main}, not the usual \isa{Main}.%
   3.479 -\index{real numbers|)}\index{*real (type)|)}
   3.480 -Launch Isabelle using the command 
   3.481 -\begin{verbatim}
   3.482 -Isabelle -l HOL-Complex
   3.483 -\end{verbatim}
   3.484 -\end{warn}
   3.485 +\subsubsection{Raising to a Power}
   3.486  
   3.487 -Also available in HOL-Complex is the
   3.488 -theory \isa{Hyperreal}, which define the type \tydx{hypreal} of 
   3.489 -\rmindex{non-standard reals}.  These
   3.490 -\textbf{hyperreals} include infinitesimals, which represent infinitely
   3.491 -small and infinitely large quantities; they facilitate proofs
   3.492 -about limits, differentiation and integration~\cite{fleuriot-jcm}.  The
   3.493 -development defines an infinitely large number, \isa{omega} and an
   3.494 -infinitely small positive number, \isa{epsilon}.  The 
   3.495 -relation $x\approx y$ means ``$x$ is infinitely close to~$y$.''
   3.496 -Theory \isa{Hyperreal} also defines transcendental functions such as sine,
   3.497 -cosine, exponential and logarithm --- even the versions for type
   3.498 -\isa{real}, because they are defined using nonstandard limits.%
   3.499 +Another type class, \tcdx{ringppower}, specifies rings that also have 
   3.500 +exponentation to a natural number power, defined using the obvious primitive
   3.501 +recursion. Theory \thydx{Power} proves various theorems, such as the 
   3.502 +following.
   3.503 +\begin{isabelle}
   3.504 +a\ \isacharcircum \ (m\ +\ n)\ =\ a\ \isacharcircum \ m\ *\ a\ \isacharcircum \ n%
   3.505 +\rulename{power_add}\isanewline
   3.506 +a\ \isacharcircum \ (m\ *\ n)\ =\ (a\ \isacharcircum \ m)\ \isacharcircum \ n%
   3.507 +\rulename{power_mult}\isanewline
   3.508 +\isasymbar a\ \isacharcircum \ n\isasymbar \ =\ \isasymbar a\isasymbar \ \isacharcircum \ n%
   3.509 +\rulename{power_abs}
   3.510 +\end{isabelle}%%%%%%%%%%%%%%%%%%%%%%%%%
   3.511  \index{numbers|)}
     4.1 --- a/doc-src/TutorialI/Types/types.tex	Thu Feb 19 16:44:21 2004 +0100
     4.2 +++ b/doc-src/TutorialI/Types/types.tex	Thu Feb 19 17:57:54 2004 +0100
     4.3 @@ -6,37 +6,29 @@
     4.4  (\isacommand{datatype}). This chapter will introduce more
     4.5  advanced material:
     4.6  \begin{itemize}
     4.7 -\item More about basic types: numbers ({\S}\ref{sec:numbers}), pairs
     4.8 -  ({\S}\ref{sec:products}) and records ({\S}\ref{sec:records}), and how to
     4.9 -  reason about them.
    4.10 +\item Pairs ({\S}\ref{sec:products}) and records ({\S}\ref{sec:records}),
and how to reason about them.
    4.11  \item Type classes: how to specify and reason about axiomatic collections of
    4.12 -  types ({\S}\ref{sec:axclass}).
    4.13 -\item Introducing your own types: how to introduce new types that
    4.14 +  types ({\S}\ref{sec:axclass}). This section leads on to a discussion of
    4.15 +  Isabelle's numeric types ({\S}\ref{sec:numbers}).  
    4.16 +\item Introducing your own types: how to define types that
    4.17    cannot be constructed with any of the basic methods
    4.18    ({\S}\ref{sec:adv-typedef}).
    4.19  \end{itemize}
    4.20  
    4.21 -The material in this section goes beyond the needs of most novices.  Serious
    4.22 -users should at least skim the sections on basic types and on type classes.
    4.23 -The latter material is fairly advanced; read the beginning to understand what
    4.24 -it is 
    4.25 -about, but consult the rest only when necessary.
    4.26 -
    4.27 -\input{Types/numerics}
    4.28 +The material in this section goes beyond the needs of most novices.
Serious users should at least skim the sections as far as type classes.
That material is fairly advanced; read the beginning to understand what it
is about, but consult the rest only when necessary.
    4.29  
    4.30  \index{pairs and tuples|(}
    4.31 -\input{Types/document/Pairs}
    4.32 +\input{Types/document/Pairs}    %%%Section "Pairs and Tuples"
    4.33  \index{pairs and tuples|)}
    4.34  
    4.35 -\input{Types/document/Records}
    4.36 +\input{Types/document/Records}  %%%Section "Records"
    4.37  
    4.38  
    4.39 -\section{Axiomatic Type Classes}
    4.40 +\section{Axiomatic Type Classes} %%%Section
    4.41  \label{sec:axclass}
    4.42  \index{axiomatic type classes|(}
    4.43  \index{*axclass|(}
    4.44  
    4.45 -
    4.46  The programming language Haskell has popularized the notion of type classes.
    4.47  In its simplest form, a type class is a set of types with a common interface:
    4.48  all types in that class must provide the functions in the interface.
    4.49 @@ -67,5 +59,6 @@
    4.50  \index{axiomatic type classes|)}
    4.51  \index{*axclass|)}
    4.52  
    4.53 +\input{Types/numerics}             %%%Section "Numbers"
    4.54  
    4.55 -\input{Types/document/Typedefs}
    4.56 +\input{Types/document/Typedefs}    %%%Section "Introducing New Types"
     5.1 --- a/doc-src/TutorialI/tutorial.sty	Thu Feb 19 16:44:21 2004 +0100
     5.2 +++ b/doc-src/TutorialI/tutorial.sty	Thu Feb 19 17:57:54 2004 +0100
     5.3 @@ -34,6 +34,7 @@
     5.4  
     5.5  \newcommand\cldx[1]{\isa{#1}\index{#1@\protect\isa{#1} (class)}}
     5.6  \newcommand\tydx[1]{\isa{#1}\index{#1@\protect\isa{#1} (type)}}
     5.7 +\newcommand\tcdx[1]{\isa{#1}\index{#1@\protect\isa{#1} (type class)}}
     5.8  \newcommand\thydx[1]{\isa{#1}\index{#1@\protect\isa{#1} (theory)}}
     5.9  
    5.10  \newcommand\attrdx[1]{\isa{#1}\index{#1@\protect\isa{#1} (attribute)}}
     6.1 --- a/doc-src/TutorialI/tutorial.tex	Thu Feb 19 16:44:21 2004 +0100
     6.2 +++ b/doc-src/TutorialI/tutorial.tex	Thu Feb 19 17:57:54 2004 +0100
     6.3 @@ -1,4 +1,5 @@
     6.4  \documentclass{article}
     6.5 +%%\includeonly{Types/types} %%UNCOMMENT to process only selected chapters
     6.6  \usepackage{cl2emono-modified,isabelle,isabellesym}
     6.7  \usepackage{../proof,amsmath,amsfonts}
     6.8  \usepackage{latexsym,wasysym,verbatim,graphicx,tutorial,../ttbox,comment}
     6.9 @@ -52,26 +53,26 @@
    6.10  \vspace*{\fill}
    6.11  \vspace*{\fill}
    6.12  \newpage
    6.13 -\input{preface}
    6.14 +\include{preface}
    6.15  
    6.16  \tableofcontents
    6.17  
    6.18  \cleardoublepage\pagenumbering{arabic}
    6.19  
    6.20  \part{Elementary Techniques}
    6.21 -\input{basics}
    6.22 -\input{fp}
    6.23 -\input{Documents/documents}
    6.24 +\include{basics}
    6.25 +\include{fp}
    6.26 +\include{Documents/documents}
    6.27  
    6.28  \part{Logic and Sets}
    6.29 -\input{Rules/rules}
    6.30 -\input{Sets/sets}\input{CTL/ctl}  %these constitute ONE chapter
    6.31 -\input{Inductive/inductive}
    6.32 +\include{Rules/rules}
    6.33 +\include{Sets/sets}
    6.34 +\include{Inductive/inductive}
    6.35  
    6.36  \part{Advanced Material}
    6.37 -\input{Types/types}
    6.38 -\input{Advanced/advanced}
    6.39 -\input{Protocol/protocol}
    6.40 +\include{Types/types}
    6.41 +\include{Advanced/advanced}
    6.42 +\include{Protocol/protocol}
    6.43  
    6.44  \markboth{}{}
    6.45  \cleardoublepage
    6.46 @@ -85,9 +86,12 @@
    6.47  \vspace*{\fill}
    6.48  \vspace*{\fill}
    6.49  
    6.50 -\input{appendix}
    6.51 +\underscoreoff
    6.52 +
    6.53 +\include{appendix}
    6.54  
    6.55  \bibliographystyle{plain}
    6.56  \bibliography{../manual}
    6.57 +\underscoreoff
    6.58  \printindex
    6.59  \end{document}