Added solution to exercise.
authornipkow
Tue, 12 Oct 2004 17:00:39 +0200
changeset 15243 ba52fdc2c4e8
parent 15242 1a4b471b1afa
child 15244 9473137b3550
Added solution to exercise.
doc-src/TutorialI/Ifexpr/Ifexpr.thy
doc-src/TutorialI/Ifexpr/document/Ifexpr.tex
--- a/doc-src/TutorialI/Ifexpr/Ifexpr.thy	Tue Oct 12 16:59:56 2004 +0200
+++ b/doc-src/TutorialI/Ifexpr/Ifexpr.thy	Tue Oct 12 17:00:39 2004 +0200
@@ -189,5 +189,43 @@
 \index{boolean expressions example|)}
 *}
 (*<*)
+
+consts normif2 :: "ifex => ifex => ifex => ifex"
+primrec
+"normif2 (CIF b)    t e = (if b then t else e)"
+"normif2 (VIF x)    t e = IF (VIF x) t e"
+"normif2 (IF b t e) u f = normif2 b (normif2 t u f) (normif2 e u f)"
+
+consts norm2 :: "ifex => ifex"
+primrec
+"norm2 (CIF b)    = CIF b"
+"norm2 (VIF x)    = VIF x"
+"norm2 (IF b t e) = normif2 b (norm2 t) (norm2 e)"
+
+consts normal2 :: "ifex => bool"
+primrec
+"normal2(CIF b) = True"
+"normal2(VIF x) = True"
+"normal2(IF b t e) = (normal2 t & normal2 e &
+     (case b of CIF b => False | VIF x => True | IF x y z => False))"
+
+
+lemma [simp]:
+  "ALL t e. valif (normif2 b t e) env = valif (IF b t e) env"
+apply(induct b)
+by(auto)
+
+theorem "valif (norm2 b) env = valif b env"
+apply(induct b)
+by(auto)
+
+lemma [simp]: "ALL t e. normal2 t & normal2 e --> normal2(normif2 b t e)"
+apply(induct b)
+by(auto)
+
+theorem "normal2(norm2 b)"
+apply(induct b)
+by(auto)
+
 end
 (*>*)
--- a/doc-src/TutorialI/Ifexpr/document/Ifexpr.tex	Tue Oct 12 16:59:56 2004 +0200
+++ b/doc-src/TutorialI/Ifexpr/document/Ifexpr.tex	Tue Oct 12 17:00:39 2004 +0200
@@ -213,6 +213,24 @@
 \end{isamarkuptext}%
 \isamarkuptrue%
 \isamarkupfalse%
+\isamarkupfalse%
+\isamarkupfalse%
+\isamarkupfalse%
+\isamarkupfalse%
+\isamarkupfalse%
+\isamarkupfalse%
+\isamarkupfalse%
+\isamarkupfalse%
+\isamarkupfalse%
+\isamarkupfalse%
+\isamarkupfalse%
+\isamarkupfalse%
+\isamarkupfalse%
+\isamarkupfalse%
+\isamarkupfalse%
+\isamarkupfalse%
+\isamarkupfalse%
+\isamarkupfalse%
 \end{isabellebody}%
 %%% Local Variables:
 %%% mode: latex