doc-src/TutorialI/Misc/document/case_exprs.tex
changeset 17175 1eced27ee0e1
parent 17056 05fc32a23b8b
child 17181 5f42dd5e6570
equal deleted inserted replaced
17174:11aa41ed306d 17175:1eced27ee0e1
     5 \isadelimtheory
     5 \isadelimtheory
     6 %
     6 %
     7 \endisadelimtheory
     7 \endisadelimtheory
     8 %
     8 %
     9 \isatagtheory
     9 \isatagtheory
       
    10 \isamarkupfalse%
    10 %
    11 %
    11 \endisatagtheory
    12 \endisatagtheory
    12 {\isafoldtheory}%
    13 {\isafoldtheory}%
    13 %
    14 %
    14 \isadelimtheory
    15 \isadelimtheory
    15 %
    16 %
    16 \endisadelimtheory
    17 \endisadelimtheory
    17 \isamarkuptrue%
       
    18 %
    18 %
    19 \isamarkupsubsection{Case Expressions%
    19 \isamarkupsubsection{Case Expressions%
    20 }
    20 }
    21 \isamarkuptrue%
    21 \isamarkuptrue%
    22 %
    22 %
    75 Induction is invoked by \methdx{induct_tac}, as we have seen above; 
    75 Induction is invoked by \methdx{induct_tac}, as we have seen above; 
    76 it works for any datatype.  In some cases, induction is overkill and a case
    76 it works for any datatype.  In some cases, induction is overkill and a case
    77 distinction over all constructors of the datatype suffices.  This is performed
    77 distinction over all constructors of the datatype suffices.  This is performed
    78 by \methdx{case_tac}.  Here is a trivial example:%
    78 by \methdx{case_tac}.  Here is a trivial example:%
    79 \end{isamarkuptext}%
    79 \end{isamarkuptext}%
    80 \isamarkupfalse%
    80 \isamarkuptrue%
    81 \isacommand{lemma}\ {\isachardoublequote}{\isacharparenleft}case\ xs\ of\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymRightarrow}\ {\isacharbrackleft}{\isacharbrackright}\ {\isacharbar}\ y{\isacharhash}ys\ {\isasymRightarrow}\ xs{\isacharparenright}\ {\isacharequal}\ xs{\isachardoublequote}\isanewline
    81 \isacommand{lemma}\isamarkupfalse%
       
    82 \ {\isachardoublequoteopen}{\isacharparenleft}case\ xs\ of\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymRightarrow}\ {\isacharbrackleft}{\isacharbrackright}\ {\isacharbar}\ y{\isacharhash}ys\ {\isasymRightarrow}\ xs{\isacharparenright}\ {\isacharequal}\ xs{\isachardoublequoteclose}\isanewline
    82 %
    83 %
    83 \isadelimproof
    84 \isadelimproof
    84 %
    85 %
    85 \endisadelimproof
    86 \endisadelimproof
    86 %
    87 %
    87 \isatagproof
    88 \isatagproof
    88 \isamarkupfalse%
    89 \isacommand{apply}\isamarkupfalse%
    89 \isacommand{apply}{\isacharparenleft}case{\isacharunderscore}tac\ xs{\isacharparenright}\isamarkuptrue%
    90 {\isacharparenleft}case{\isacharunderscore}tac\ xs{\isacharparenright}%
    90 %
       
    91 \begin{isamarkuptxt}%
    91 \begin{isamarkuptxt}%
    92 \noindent
    92 \noindent
    93 results in the proof state
    93 results in the proof state
    94 \begin{isabelle}%
    94 \begin{isabelle}%
    95 \ {\isadigit{1}}{\isachardot}\ xs\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymLongrightarrow}\ {\isacharparenleft}case\ xs\ of\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymRightarrow}\ {\isacharbrackleft}{\isacharbrackright}\ {\isacharbar}\ y\ {\isacharhash}\ ys\ {\isasymRightarrow}\ xs{\isacharparenright}\ {\isacharequal}\ xs\isanewline
    95 \ {\isadigit{1}}{\isachardot}\ xs\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymLongrightarrow}\ {\isacharparenleft}case\ xs\ of\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymRightarrow}\ {\isacharbrackleft}{\isacharbrackright}\ {\isacharbar}\ y\ {\isacharhash}\ ys\ {\isasymRightarrow}\ xs{\isacharparenright}\ {\isacharequal}\ xs\isanewline
    96 \ {\isadigit{2}}{\isachardot}\ {\isasymAnd}a\ list{\isachardot}\isanewline
    96 \ {\isadigit{2}}{\isachardot}\ {\isasymAnd}a\ list{\isachardot}\isanewline
    97 \isaindent{\ {\isadigit{2}}{\isachardot}\ \ \ \ }xs\ {\isacharequal}\ a\ {\isacharhash}\ list\ {\isasymLongrightarrow}\ {\isacharparenleft}case\ xs\ of\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymRightarrow}\ {\isacharbrackleft}{\isacharbrackright}\ {\isacharbar}\ y\ {\isacharhash}\ ys\ {\isasymRightarrow}\ xs{\isacharparenright}\ {\isacharequal}\ xs%
    97 \isaindent{\ {\isadigit{2}}{\isachardot}\ \ \ \ }xs\ {\isacharequal}\ a\ {\isacharhash}\ list\ {\isasymLongrightarrow}\ {\isacharparenleft}case\ xs\ of\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymRightarrow}\ {\isacharbrackleft}{\isacharbrackright}\ {\isacharbar}\ y\ {\isacharhash}\ ys\ {\isasymRightarrow}\ xs{\isacharparenright}\ {\isacharequal}\ xs%
    98 \end{isabelle}
    98 \end{isabelle}
    99 which is solved automatically:%
    99 which is solved automatically:%
   100 \end{isamarkuptxt}%
   100 \end{isamarkuptxt}%
   101 \isamarkupfalse%
   101 \isamarkuptrue%
   102 \isacommand{apply}{\isacharparenleft}auto{\isacharparenright}%
   102 \isacommand{apply}\isamarkupfalse%
       
   103 {\isacharparenleft}auto{\isacharparenright}\isamarkupfalse%
       
   104 %
   103 \endisatagproof
   105 \endisatagproof
   104 {\isafoldproof}%
   106 {\isafoldproof}%
   105 %
   107 %
   106 \isadelimproof
   108 \isadelimproof
   107 %
   109 %
   108 \endisadelimproof
   110 \endisadelimproof
   109 \isamarkuptrue%
       
   110 %
   111 %
   111 \begin{isamarkuptext}%
   112 \begin{isamarkuptext}%
   112 Note that we do not need to give a lemma a name if we do not intend to refer
   113 Note that we do not need to give a lemma a name if we do not intend to refer
   113 to it explicitly in the future.
   114 to it explicitly in the future.
   114 Other basic laws about a datatype are applied automatically during
   115 Other basic laws about a datatype are applied automatically during
   125   \isa{case{\isacharunderscore}tac\ xs} will not work as expected because Isabelle interprets
   126   \isa{case{\isacharunderscore}tac\ xs} will not work as expected because Isabelle interprets
   126   the \isa{xs} as a new free variable distinct from the bound
   127   the \isa{xs} as a new free variable distinct from the bound
   127   \isa{xs} in the goal.
   128   \isa{xs} in the goal.
   128 \end{warn}%
   129 \end{warn}%
   129 \end{isamarkuptext}%
   130 \end{isamarkuptext}%
       
   131 \isamarkuptrue%
   130 %
   132 %
   131 \isadelimtheory
   133 \isadelimtheory
   132 %
   134 %
   133 \endisadelimtheory
   135 \endisadelimtheory
   134 %
   136 %
   135 \isatagtheory
   137 \isatagtheory
       
   138 \isamarkupfalse%
   136 %
   139 %
   137 \endisatagtheory
   140 \endisatagtheory
   138 {\isafoldtheory}%
   141 {\isafoldtheory}%
   139 %
   142 %
   140 \isadelimtheory
   143 \isadelimtheory