doc-src/TutorialI/Ifexpr/Ifexpr.thy
changeset 9933 9feb1e0c4cb3
parent 9792 bbefb6ce5cb2
child 10171 59d6633835fa
equal deleted inserted replaced
9932:5b6305cab436 9933:9feb1e0c4cb3
     1 (*<*)
     1 (*<*)
     2 theory Ifexpr = Main:;
     2 theory Ifexpr = Main:;
     3 (*>*)
     3 (*>*)
     4 
     4 
       
     5 subsection{*Case study: boolean expressions*}
       
     6 
       
     7 text{*\label{sec:boolex}
       
     8 The aim of this case study is twofold: it shows how to model boolean
       
     9 expressions and some algorithms for manipulating them, and it demonstrates
       
    10 the constructs introduced above.
       
    11 *}
       
    12 
       
    13 subsubsection{*How can we model boolean expressions?*}
       
    14 
     5 text{*
    15 text{*
     6 \subsubsection{How can we model boolean expressions?}
       
     7 
       
     8 We want to represent boolean expressions built up from variables and
    16 We want to represent boolean expressions built up from variables and
     9 constants by negation and conjunction. The following datatype serves exactly
    17 constants by negation and conjunction. The following datatype serves exactly
    10 that purpose:
    18 that purpose:
    11 *}
    19 *}
    12 
    20 
   159 by(auto);
   167 by(auto);
   160 
   168 
   161 theorem "normal(norm b)";
   169 theorem "normal(norm b)";
   162 apply(induct_tac b);
   170 apply(induct_tac b);
   163 by(auto);
   171 by(auto);
       
   172 (*>*)
   164 
   173 
       
   174 text{*\medskip
       
   175 How does one come up with the required lemmas? Try to prove the main theorems
       
   176 without them and study carefully what @{text auto} leaves unproved. This has
       
   177 to provide the clue.  The necessity of universal quantification
       
   178 (@{text"\<forall>t e"}) in the two lemmas is explained in
       
   179 \S\ref{sec:InductionHeuristics}
       
   180 
       
   181 \begin{exercise}
       
   182   We strengthen the definition of a @{term normal} If-expression as follows:
       
   183   the first argument of all @{term IF}s must be a variable. Adapt the above
       
   184   development to this changed requirement. (Hint: you may need to formulate
       
   185   some of the goals as implications (@{text"\<longrightarrow>"}) rather than
       
   186   equalities (@{text"="}).)
       
   187 \end{exercise}
       
   188 *}
       
   189 (*<*)
   165 end
   190 end
   166 (*>*)
   191 (*>*)