(* Title: ZF/Nat.thy Author: Lawrence C Paulson, Cambridge University Computer Laboratory Copyright 1994 University of Cambridge
*)
section\<open>The Natural numbers As a Least Fixed Point\<close>
theory Nat imports OrdQuant Bool begin
definition
nat :: i where "nat \ lfp(Inf, \X. {0} \ {succ(i). i \ X})"
definition
quasinat :: "i \ o" where "quasinat(n) \ n=0 | (\m. n = succ(m))"
definition (*Has an unconditional succ case, which is used in "recursor" below.*)
nat_case :: "[i, i\i, i]\i" where "nat_case(a,b,k) \ THE y. k=0 \ y=a | (\x. k=succ(x) \ y=b(x))"
definition
nat_rec :: "[i, i, [i,i]\i]\i" where "nat_rec(k,a,b) \
wfrec(Memrel(nat), k, \<lambda>n f. nat_case(a, \<lambda>m. b(m, f`m), n))"
(*Internalized relations on the naturals*)
definition
Le :: i where "Le \ {\x,y\:nat*nat. x \ y}"
definition
Lt :: i where "Lt \ {\x, y\:nat*nat. x < y}"
definition
Ge :: i where "Ge \ {\x,y\:nat*nat. y \ x}"
definition
Gt :: i where "Gt \ {\x,y\:nat*nat. y < x}"
definition
greater_than :: "i\i" where "greater_than(n) \ {i \ nat. n < i}"
text\<open>No need for a less-than operator: a natural number is its list of
predecessors!\<close>
lemma natE: assumes"n \ nat" obtains ("0") "n=0" | (succ) x where"x \ nat" "n=succ(x)" using assms by (rule nat_unfold [THEN equalityD1, THEN subsetD, THEN UnE]) auto
lemma complete_induct_rule [case_names less, consumes 1]: "i \ nat \ (\x. x \ nat \ (\y. y \ x \ P(y)) \ P(x)) \ P(i)" using complete_induct [of i P] by simp
(*Induction starting from m rather than 0*) lemma nat_induct_from: assumes"m \ n" "m \ nat" "n \ nat" and"P(m)" and"\x. \x \ nat; m \ x; P(x)\ \ P(succ(x))" shows"P(n)" proof - from assms(3) have"m \ n \ P(m) \ P(n)" by (rule nat_induct) (use assms(5) in\<open>simp_all add: distrib_simps le_succ_iff\<close>) with assms(1,2,4) show ?thesis by blast qed
(*Induction suitable for subtraction and less-than*) lemma diff_induct [case_names 0 0_succ succ_succ, consumes 2]: "\m \ nat; n \ nat; \<And>x. x \<in> nat \<Longrightarrow> P(x,0); \<And>y. y \<in> nat \<Longrightarrow> P(0,succ(y)); \<And>x y. \<lbrakk>x \<in> nat; y \<in> nat; P(x,y)\<rbrakk> \<Longrightarrow> P(succ(x),succ(y))\<rbrakk> \<Longrightarrow> P(m,n)" apply (erule_tac x = m in rev_bspec) apply (erule nat_induct, simp) apply (rule ballI) apply (rename_tac i j) apply (erule_tac n=j in nat_induct, auto) done
(** Induction principle analogous to trancl_induct **)
(*needed to simplify unions over nat*) lemma nat_nonempty [simp]: "nat \ 0" by blast
text\<open>A natural number is the set of its predecessors\<close> lemma nat_eq_Collect_lt: "i \ nat \ {j\nat. j apply (rule equalityI) apply (blast dest: ltD) apply (auto simp add: Ord_mem_iff_lt) apply (blast intro: lt_trans) done
lemma Le_iff [iff]: "\x,y\ \ Le \ x \ y \ x \ nat \ y \ nat" by (force simp add: Le_def)
end
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.