normal_form to lemma test
authornipkow
Fri, 30 Jun 2006 18:26:36 +0200
changeset 19971 ddf69abaffa8
parent 19970 d6e238c46d1b
child 19972 89c5afe4139a
normal_form to lemma test
src/HOL/ex/NormalForm.thy
--- a/src/HOL/ex/NormalForm.thy	Fri Jun 30 18:26:22 2006 +0200
+++ b/src/HOL/ex/NormalForm.thy	Fri Jun 30 18:26:36 2006 +0200
@@ -8,7 +8,7 @@
 imports Main
 begin
 
-normal_form "True \<longrightarrow> p"
+lemma "p \<longrightarrow> True" by normalization
 
 (* FIXME Eventually the code generator should be able to handle this
 by re-generating the existing code for "or":
@@ -20,6 +20,12 @@
 *)
 
 
+lemma "0 + (n::nat) = n" by normalization
+lemma "0 + Suc(n) = Suc n" by normalization
+lemma "Suc(n) + Suc m = n + Suc(Suc m)" by normalization
+lemma "~((0::nat) < (0::nat))" by normalization
+
+
 datatype n = Z | S n
 consts
  add :: "n \<Rightarrow> n \<Rightarrow> n"
@@ -40,10 +46,10 @@
 by(induct n, auto)
 lemma [code]: "add2 n Z = n"
 by(induct n, auto)
- 
-normal_form "add2 (add2 n m) k"
-normal_form "add2 (add2 (S n) (S m)) (S k)"
-normal_form "add2 (add2 (S n)(add2 (S m) Z)) (S k)"
+
+lemma "add2 (add2 n m) k = add2 n (add2 m k)" by normalization
+lemma "add2 (add2 (S n) (S m)) (S k) = S(S(S(add2 n (add2 m k))))" by normalization
+lemma "add2 (add2 (S n) (add2 (S m) Z)) (S k) = S(S(S(add2 n (add2 m k))))" by normalization
 
 primrec
 "mul Z = (%n. Z)"
@@ -55,13 +61,17 @@
 "exp m Z = S Z"
 "exp m (S n) = mul (exp m n) m"
 
-normal_form "mul2 (S(S(S(S(S(S(S Z))))))) (S(S(S(S(S Z)))))"
-normal_form "mul (S(S(S(S(S(S(S Z))))))) (S(S(S(S(S Z)))))"
-normal_form "exp (S(S Z)) (S(S(S(S(S Z)))))"
+lemma "mul2 (S(S(S(S(S Z))))) (S(S(S Z))) = S(S(S(S(S(S(S(S(S(S(S(S(S(S(S Z))))))))))))))" by normalization
+lemma "mul (S(S(S(S(S Z))))) (S(S(S Z))) = S(S(S(S(S(S(S(S(S(S(S(S(S(S(S Z))))))))))))))" by normalization
+lemma "exp (S(S Z)) (S(S(S(S Z)))) = exp (S(S(S(S Z)))) (S(S Z))" by normalization
+
+lemma "(let ((x,y),(u,v)) = ((Z,Z),(Z,Z)) in add (add x y) (add u v)) = Z" by normalization
+lemma "(%((x,y),(u,v)). add (add x y) (add u v)) ((Z,Z),(Z,Z)) = Z" by normalization
+
+lemma "case Z of Z \<Rightarrow> True | S x \<Rightarrow> False" by normalization
 
 normal_form "[] @ []"
 normal_form "[] @ xs"
-normal_form "[] @ (xs:: 'b list)"
 normal_form "[a::'d,b,c] @ xs"
 normal_form "[%a::'x. a, %b. b, c] @ xs"
 normal_form "[%a::'x. a, %b. b, c] @ [u,v]"
@@ -77,7 +87,6 @@
 normal_form "map (%F. F [Z,S Z,S(S Z)]) (map map [S,add (S Z),mul (S(S Z)),id])"
 normal_form "map (%x. case x of None \<Rightarrow> False | Some y \<Rightarrow> True) [None, Some ()]"
 normal_form "case xs of [] \<Rightarrow> True | x#xs \<Rightarrow> False"
-normal_form "case Z of Z \<Rightarrow> True | S x \<Rightarrow> False"
 normal_form "map (%x. case x of None \<Rightarrow> False | Some y \<Rightarrow> True) xs"
 normal_form "let x = y::'x in [x,x]"
 normal_form "Let y (%x. [x,x])"
@@ -86,24 +95,14 @@
 normal_form "filter (%x. x) ([True,False,x]@xs)"
 normal_form "filter Not ([True,False,x]@xs)"
 
-normal_form "0 + (n::nat)"
-normal_form "0 + Suc(n)"
-normal_form "0::nat"
-normal_form "Suc(n) + Suc m"
-normal_form "[] @ xs"
-normal_form "(x#xs) @ ys"
 normal_form "[x,y,z] @ [a,b,c]"
 normal_form "%(xs, ys). xs @ ys"
 normal_form "(%(xs, ys). xs @ ys) ([a, b, c], [d, e, f])"
 normal_form "%x. case x of None \<Rightarrow> False | Some y \<Rightarrow> True"
 normal_form "map (%x. case x of None \<Rightarrow> False | Some y \<Rightarrow> True) [None, Some ()]"
 
-normal_form "case n of None \<Rightarrow> True | Some((x,y),(u,v)) \<Rightarrow> False"
-normal_form "let ((x,y),(u,v)) = ((Z,Z),(Z,Z)) in add (add x y) (add u v)"
-normal_form "(%((x,y),(u,v)). add (add x y) (add u v)) ((Z,Z),(Z,Z))"
 normal_form "last[a,b,c]"
 normal_form "last([a,b,c]@xs)"
-normal_form " (0::nat) < (0::nat)"
 
 (* FIXME
   won't work since it relies on