doc-src/TutorialI/Misc/document/natsum.tex
changeset 11866 fbd097aec213
parent 11708 d27253c4594f
child 12327 5a4d78204492
equal deleted inserted replaced
11865:93d5408eb7d9 11866:fbd097aec213
     1 %
     1 %
     2 \begin{isabellebody}%
     2 \begin{isabellebody}%
     3 \def\isabellecontext{natsum}%
     3 \def\isabellecontext{natsum}%
       
     4 \isamarkupfalse%
     4 %
     5 %
     5 \begin{isamarkuptext}%
     6 \begin{isamarkuptext}%
     6 \noindent
     7 \noindent
     7 In particular, there are \isa{case}-expressions, for example
     8 In particular, there are \isa{case}-expressions, for example
     8 \begin{isabelle}%
     9 \begin{isabelle}%
     9 \ \ \ \ \ case\ n\ of\ {\isadigit{0}}\ {\isasymRightarrow}\ {\isadigit{0}}\ {\isacharbar}\ Suc\ m\ {\isasymRightarrow}\ m%
    10 \ \ \ \ \ case\ n\ of\ {\isadigit{0}}\ {\isasymRightarrow}\ {\isadigit{0}}\ {\isacharbar}\ Suc\ m\ {\isasymRightarrow}\ m%
    10 \end{isabelle}
    11 \end{isabelle}
    11 primitive recursion, for example%
    12 primitive recursion, for example%
    12 \end{isamarkuptext}%
    13 \end{isamarkuptext}%
       
    14 \isamarkuptrue%
    13 \isacommand{consts}\ sum\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}nat\ {\isasymRightarrow}\ nat{\isachardoublequote}\isanewline
    15 \isacommand{consts}\ sum\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}nat\ {\isasymRightarrow}\ nat{\isachardoublequote}\isanewline
       
    16 \isamarkupfalse%
    14 \isacommand{primrec}\ {\isachardoublequote}sum\ {\isadigit{0}}\ {\isacharequal}\ {\isadigit{0}}{\isachardoublequote}\isanewline
    17 \isacommand{primrec}\ {\isachardoublequote}sum\ {\isadigit{0}}\ {\isacharequal}\ {\isadigit{0}}{\isachardoublequote}\isanewline
    15 \ \ \ \ \ \ \ \ {\isachardoublequote}sum\ {\isacharparenleft}Suc\ n{\isacharparenright}\ {\isacharequal}\ Suc\ n\ {\isacharplus}\ sum\ n{\isachardoublequote}%
    18 \ \ \ \ \ \ \ \ {\isachardoublequote}sum\ {\isacharparenleft}Suc\ n{\isacharparenright}\ {\isacharequal}\ Suc\ n\ {\isacharplus}\ sum\ n{\isachardoublequote}\isamarkupfalse%
       
    19 %
    16 \begin{isamarkuptext}%
    20 \begin{isamarkuptext}%
    17 \noindent
    21 \noindent
    18 and induction, for example%
    22 and induction, for example%
    19 \end{isamarkuptext}%
    23 \end{isamarkuptext}%
       
    24 \isamarkuptrue%
    20 \isacommand{lemma}\ {\isachardoublequote}sum\ n\ {\isacharplus}\ sum\ n\ {\isacharequal}\ n{\isacharasterisk}{\isacharparenleft}Suc\ n{\isacharparenright}{\isachardoublequote}\isanewline
    25 \isacommand{lemma}\ {\isachardoublequote}sum\ n\ {\isacharplus}\ sum\ n\ {\isacharequal}\ n{\isacharasterisk}{\isacharparenleft}Suc\ n{\isacharparenright}{\isachardoublequote}\isanewline
       
    26 \isamarkupfalse%
    21 \isacommand{apply}{\isacharparenleft}induct{\isacharunderscore}tac\ n{\isacharparenright}\isanewline
    27 \isacommand{apply}{\isacharparenleft}induct{\isacharunderscore}tac\ n{\isacharparenright}\isanewline
       
    28 \isamarkupfalse%
    22 \isacommand{apply}{\isacharparenleft}auto{\isacharparenright}\isanewline
    29 \isacommand{apply}{\isacharparenleft}auto{\isacharparenright}\isanewline
    23 \isacommand{done}%
    30 \isamarkupfalse%
       
    31 \isacommand{done}\isamarkupfalse%
       
    32 %
    24 \begin{isamarkuptext}%
    33 \begin{isamarkuptext}%
    25 \newcommand{\mystar}{*%
    34 \newcommand{\mystar}{*%
    26 }
    35 }
    27 \index{arithmetic operations!for \protect\isa{nat}}%
    36 \index{arithmetic operations!for \protect\isa{nat}}%
    28 The usual arithmetic operations \ttindexboldpos{+}{$HOL2arithfun},
    37 The usual arithmetic operations \ttindexboldpos{+}{$HOL2arithfun},
    65 
    74 
    66 Both \isa{auto} and \isa{simp}
    75 Both \isa{auto} and \isa{simp}
    67 (a method introduced below, \S\ref{sec:Simplification}) prove 
    76 (a method introduced below, \S\ref{sec:Simplification}) prove 
    68 simple arithmetic goals automatically:%
    77 simple arithmetic goals automatically:%
    69 \end{isamarkuptext}%
    78 \end{isamarkuptext}%
    70 \isacommand{lemma}\ {\isachardoublequote}{\isasymlbrakk}\ {\isasymnot}\ m\ {\isacharless}\ n{\isacharsemicolon}\ m\ {\isacharless}\ n\ {\isacharplus}\ {\isacharparenleft}{\isadigit{1}}{\isacharcolon}{\isacharcolon}nat{\isacharparenright}\ {\isasymrbrakk}\ {\isasymLongrightarrow}\ m\ {\isacharequal}\ n{\isachardoublequote}%
    79 \isamarkuptrue%
       
    80 \isacommand{lemma}\ {\isachardoublequote}{\isasymlbrakk}\ {\isasymnot}\ m\ {\isacharless}\ n{\isacharsemicolon}\ m\ {\isacharless}\ n\ {\isacharplus}\ {\isacharparenleft}{\isadigit{1}}{\isacharcolon}{\isacharcolon}nat{\isacharparenright}\ {\isasymrbrakk}\ {\isasymLongrightarrow}\ m\ {\isacharequal}\ n{\isachardoublequote}\isamarkupfalse%
       
    81 \isamarkupfalse%
       
    82 %
    71 \begin{isamarkuptext}%
    83 \begin{isamarkuptext}%
    72 \noindent
    84 \noindent
    73 For efficiency's sake, this built-in prover ignores quantified formulae,
    85 For efficiency's sake, this built-in prover ignores quantified formulae,
    74 logical connectives, and all arithmetic operations apart from addition.
    86 logical connectives, and all arithmetic operations apart from addition.
    75 In consequence, \isa{auto} cannot prove this slightly more complex goal:%
    87 In consequence, \isa{auto} cannot prove this slightly more complex goal:%
    76 \end{isamarkuptext}%
    88 \end{isamarkuptext}%
    77 \isacommand{lemma}\ {\isachardoublequote}{\isasymnot}\ m\ {\isacharless}\ n\ {\isasymand}\ m\ {\isacharless}\ n\ {\isacharplus}\ {\isacharparenleft}{\isadigit{1}}{\isacharcolon}{\isacharcolon}nat{\isacharparenright}\ {\isasymLongrightarrow}\ m\ {\isacharequal}\ n{\isachardoublequote}%
    89 \isamarkuptrue%
       
    90 \isacommand{lemma}\ {\isachardoublequote}{\isasymnot}\ m\ {\isacharless}\ n\ {\isasymand}\ m\ {\isacharless}\ n\ {\isacharplus}\ {\isacharparenleft}{\isadigit{1}}{\isacharcolon}{\isacharcolon}nat{\isacharparenright}\ {\isasymLongrightarrow}\ m\ {\isacharequal}\ n{\isachardoublequote}\isamarkupfalse%
       
    91 \isamarkupfalse%
       
    92 %
    78 \begin{isamarkuptext}%
    93 \begin{isamarkuptext}%
    79 \noindent
    94 \noindent
    80 The method \methdx{arith} is more general.  It attempts to prove
    95 The method \methdx{arith} is more general.  It attempts to prove
    81 the first subgoal provided it is a quantifier-free \textbf{linear arithmetic}
    96 the first subgoal provided it is a quantifier-free \textbf{linear arithmetic}
    82 formula.  Such formulas may involve the
    97 formula.  Such formulas may involve the
    84 \isa{{\isasymlongrightarrow}}), the relations \isa{{\isacharequal}}, \isa{{\isasymle}} and \isa{{\isacharless}},
    99 \isa{{\isasymlongrightarrow}}), the relations \isa{{\isacharequal}}, \isa{{\isasymle}} and \isa{{\isacharless}},
    85 and the operations
   100 and the operations
    86 \isa{{\isacharplus}}, \isa{{\isacharminus}}, \isa{min} and \isa{max}. 
   101 \isa{{\isacharplus}}, \isa{{\isacharminus}}, \isa{min} and \isa{max}. 
    87 For example,%
   102 For example,%
    88 \end{isamarkuptext}%
   103 \end{isamarkuptext}%
       
   104 \isamarkuptrue%
    89 \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
   105 \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
    90 \isacommand{apply}{\isacharparenleft}arith{\isacharparenright}%
   106 \isamarkupfalse%
       
   107 \isacommand{apply}{\isacharparenleft}arith{\isacharparenright}\isamarkupfalse%
       
   108 \isamarkupfalse%
       
   109 %
    91 \begin{isamarkuptext}%
   110 \begin{isamarkuptext}%
    92 \noindent
   111 \noindent
    93 succeeds because \isa{k\ {\isacharasterisk}\ k} can be treated as atomic. In contrast,%
   112 succeeds because \isa{k\ {\isacharasterisk}\ k} can be treated as atomic. In contrast,%
    94 \end{isamarkuptext}%
   113 \end{isamarkuptext}%
    95 \isacommand{lemma}\ {\isachardoublequote}n{\isacharasterisk}n\ {\isacharequal}\ n\ {\isasymLongrightarrow}\ n{\isacharequal}{\isadigit{0}}\ {\isasymor}\ n{\isacharequal}{\isadigit{1}}{\isachardoublequote}%
   114 \isamarkuptrue%
       
   115 \isacommand{lemma}\ {\isachardoublequote}n{\isacharasterisk}n\ {\isacharequal}\ n\ {\isasymLongrightarrow}\ n{\isacharequal}{\isadigit{0}}\ {\isasymor}\ n{\isacharequal}{\isadigit{1}}{\isachardoublequote}\isamarkupfalse%
       
   116 \isamarkupfalse%
       
   117 %
    96 \begin{isamarkuptext}%
   118 \begin{isamarkuptext}%
    97 \noindent
   119 \noindent
    98 is not proved even by \isa{arith} because the proof relies 
   120 is not proved even by \isa{arith} because the proof relies 
    99 on properties of multiplication.
   121 on properties of multiplication.
   100 
   122 
   106   Even for linear arithmetic formulae, \isa{arith} is incomplete. If divisibility plays a
   128   Even for linear arithmetic formulae, \isa{arith} is incomplete. If divisibility plays a
   107   role, it may fail to prove a valid formula, for example
   129   role, it may fail to prove a valid formula, for example
   108   \isa{m\ {\isacharplus}\ m\ {\isasymnoteq}\ n\ {\isacharplus}\ n\ {\isacharplus}\ {\isacharparenleft}{\isadigit{1}}{\isasymColon}{\isacharprime}a{\isacharparenright}}. Fortunately, such examples are rare.
   130   \isa{m\ {\isacharplus}\ m\ {\isasymnoteq}\ n\ {\isacharplus}\ n\ {\isacharplus}\ {\isacharparenleft}{\isadigit{1}}{\isasymColon}{\isacharprime}a{\isacharparenright}}. Fortunately, such examples are rare.
   109 \end{warn}%
   131 \end{warn}%
   110 \end{isamarkuptext}%
   132 \end{isamarkuptext}%
       
   133 \isamarkuptrue%
       
   134 \isamarkupfalse%
   111 \end{isabellebody}%
   135 \end{isabellebody}%
   112 %%% Local Variables:
   136 %%% Local Variables:
   113 %%% mode: latex
   137 %%% mode: latex
   114 %%% TeX-master: "root"
   138 %%% TeX-master: "root"
   115 %%% End:
   139 %%% End: