src/HOL/ex/Efficient_Nat_examples.thy
changeset 47108 2a1953f0d20d
parent 47107 35807a5d8dc2
child 47109 db5026631799
     1.1 --- a/src/HOL/ex/Efficient_Nat_examples.thy	Sat Mar 24 16:27:04 2012 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,56 +0,0 @@
     1.4 -(*  Title:      HOL/ex/Efficient_Nat_examples.thy
     1.5 -    Author:     Florian Haftmann, TU Muenchen
     1.6 -*)
     1.7 -
     1.8 -header {* Simple examples for Efficient\_Nat theory. *}
     1.9 -
    1.10 -theory Efficient_Nat_examples
    1.11 -imports Complex_Main "~~/src/HOL/Library/Efficient_Nat"
    1.12 -begin
    1.13 -
    1.14 -fun to_n :: "nat \<Rightarrow> nat list" where
    1.15 -  "to_n 0 = []"
    1.16 -  | "to_n (Suc 0) = []"
    1.17 -  | "to_n (Suc (Suc 0)) = []"
    1.18 -  | "to_n (Suc n) = n # to_n n"
    1.19 -
    1.20 -definition naive_prime :: "nat \<Rightarrow> bool" where
    1.21 -  "naive_prime n \<longleftrightarrow> n \<ge> 2 \<and> filter (\<lambda>m. n mod m = 0) (to_n n) = []"
    1.22 -
    1.23 -primrec fac :: "nat \<Rightarrow> nat" where
    1.24 -  "fac 0 = 1"
    1.25 -  | "fac (Suc n) = Suc n * fac n"
    1.26 -
    1.27 -primrec rat_of_nat :: "nat \<Rightarrow> rat" where
    1.28 -  "rat_of_nat 0 = 0"
    1.29 -  | "rat_of_nat (Suc n) = rat_of_nat n + 1"
    1.30 -
    1.31 -primrec harmonic :: "nat \<Rightarrow> rat" where
    1.32 -  "harmonic 0 = 0"
    1.33 -  | "harmonic (Suc n) = 1 / rat_of_nat (Suc n) + harmonic n"
    1.34 -
    1.35 -lemma "harmonic 200 \<ge> 5"
    1.36 -  by eval
    1.37 -
    1.38 -lemma "harmonic 20 \<ge> 3"
    1.39 -  by normalization
    1.40 -
    1.41 -lemma "naive_prime 89"
    1.42 -  by eval
    1.43 -
    1.44 -lemma "naive_prime 89"
    1.45 -  by normalization
    1.46 -
    1.47 -lemma "\<not> naive_prime 87"
    1.48 -  by eval
    1.49 -
    1.50 -lemma "\<not> naive_prime 87"
    1.51 -  by normalization
    1.52 -
    1.53 -lemma "fac 10 > 3000000"
    1.54 -  by eval
    1.55 -
    1.56 -lemma "fac 10 > 3000000"
    1.57 -  by normalization
    1.58 -
    1.59 -end