src/HOL/Library/Nat_Infinity.thy
changeset 11351 c5c403d30c77
child 11355 778c369559d9
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOL/Library/Nat_Infinity.thy	Thu May 31 17:06:00 2001 +0200
     1.3 @@ -0,0 +1,216 @@
     1.4 +(*  Title: 	HOL/Library/Nat_Infinity.thy
     1.5 +    ID:         $ $
     1.6 +    Author: 	David von Oheimb, TU Muenchen
     1.7 +    License:    GPL (GNU GENERAL PUBLIC LICENSE)
     1.8 +
     1.9 +*)
    1.10 +
    1.11 +header {*
    1.12 +  \title{Natural numbers with infinity}
    1.13 +  \author{David von Oheimb}
    1.14 +*}
    1.15 +
    1.16 +theory Nat_Infinity = Datatype:
    1.17 +
    1.18 +subsection "Definitions"
    1.19 +
    1.20 +text {*
    1.21 + We extend the standard natural numbers by a special value indicating infinity.
    1.22 + This includes extending the ordering relations @{term "op <"} and 
    1.23 + @{term "op <="}.
    1.24 +*}
    1.25 +
    1.26 +datatype inat = Fin nat | Infty
    1.27 +
    1.28 +instance inat :: ord ..
    1.29 +instance inat :: zero ..
    1.30 +
    1.31 +consts
    1.32 +
    1.33 +  iSuc	:: "inat => inat"
    1.34 +
    1.35 +syntax (xsymbols)
    1.36 +
    1.37 +  Infty		:: inat					("\<infinity>")
    1.38 +
    1.39 +defs
    1.40 +
    1.41 +  iZero_def:	"0      == Fin 0"
    1.42 +  iSuc_def:	"iSuc i == case i of Fin n  => Fin (Suc n) | \<infinity> => \<infinity>"
    1.43 +  iless_def:	"m < n  == case m of Fin m1 => (case n of Fin n1 => m1 < n1 
    1.44 +						             | \<infinity> => True)
    1.45 +				   | \<infinity>  => False "
    1.46 +  ile_def:	"(m::inat) <= n == \<not>(n<m)"
    1.47 +
    1.48 +lemmas inat_defs = iZero_def iSuc_def iless_def ile_def
    1.49 +lemmas inat_splits = inat.split inat.split_asm
    1.50 +
    1.51 +
    1.52 +text {* Below is a not quite complete set of theorems. Use
    1.53 +@{text "apply(simp add:inat_defs split:inat_splits, arith?)"}
    1.54 +to prove new theorems or solve arithmetic subgoals involving @{typ inat} 
    1.55 +on the fly.
    1.56 +*}
    1.57 +
    1.58 +subsection "Constructors"
    1.59 +
    1.60 +lemma Fin_0: "Fin 0 = 0"
    1.61 +by(simp add:inat_defs split:inat_splits, arith?)
    1.62 +
    1.63 +lemma Infty_ne_i0 [simp]: "\<infinity> \<noteq> 0"
    1.64 +by(simp add:inat_defs split:inat_splits, arith?)
    1.65 +
    1.66 +lemma i0_ne_Infty [simp]: "0 \<noteq> \<infinity>"
    1.67 +by(simp add:inat_defs split:inat_splits, arith?)
    1.68 +
    1.69 +lemma iSuc_Fin [simp]: "iSuc (Fin n) = Fin (Suc n)"
    1.70 +by(simp add:inat_defs split:inat_splits, arith?)
    1.71 +
    1.72 +lemma iSuc_Infty [simp]: "iSuc \<infinity> = \<infinity>"
    1.73 +by(simp add:inat_defs split:inat_splits, arith?)
    1.74 +
    1.75 +lemma iSuc_ne_0 [simp]: "iSuc n \<noteq> 0"
    1.76 +by(simp add:inat_defs split:inat_splits, arith?)
    1.77 +
    1.78 +lemma iSuc_inject [simp]: "(iSuc x = iSuc y) = (x = y)"
    1.79 +by(simp add:inat_defs split:inat_splits, arith?)
    1.80 +
    1.81 +
    1.82 +subsection "Ordering relations"
    1.83 +
    1.84 +lemma Infty_ilessE [elim!]: "\<infinity> < Fin m ==> R"
    1.85 +by(simp add:inat_defs split:inat_splits, arith?)
    1.86 +
    1.87 +lemma iless_linear: "m < n | m = n | n < (m::inat)"
    1.88 +by(simp add:inat_defs split:inat_splits, arith?)
    1.89 +
    1.90 +lemma iless_not_refl [simp]: "\<not> n < (n::inat)"
    1.91 +by(simp add:inat_defs split:inat_splits, arith?)
    1.92 +
    1.93 +lemma iless_trans: "i < j ==> j < k ==> i < (k::inat)"
    1.94 +by(simp add:inat_defs split:inat_splits, arith?)
    1.95 +
    1.96 +lemma iless_not_sym: "n < m ==> \<not> m < (n::inat)"
    1.97 +by(simp add:inat_defs split:inat_splits, arith?)
    1.98 +
    1.99 +lemma Fin_iless_mono [simp]: "(Fin n < Fin m) = (n < m)"
   1.100 +by(simp add:inat_defs split:inat_splits, arith?)
   1.101 +
   1.102 +lemma Fin_iless_Infty [simp]: "Fin n < \<infinity>"
   1.103 +by(simp add:inat_defs split:inat_splits, arith?)
   1.104 +
   1.105 +lemma Infty_eq [simp]: "n < \<infinity> = (n \<noteq> \<infinity>)"
   1.106 +by(simp add:inat_defs split:inat_splits, arith?)
   1.107 +
   1.108 +lemma i0_eq [simp]: "((0::inat) < n) = (n \<noteq> 0)"
   1.109 +by(simp add:inat_defs split:inat_splits, arith?)
   1.110 +
   1.111 +lemma i0_iless_iSuc [simp]: "0 < iSuc n"
   1.112 +by(simp add:inat_defs split:inat_splits, arith?)
   1.113 +
   1.114 +lemma not_ilessi0 [simp]: "\<not> n < (0::inat)"
   1.115 +by(simp add:inat_defs split:inat_splits, arith?)
   1.116 +
   1.117 +lemma Fin_iless: "n < Fin m ==> \<exists>k. n = Fin k"
   1.118 +by(simp add:inat_defs split:inat_splits, arith?)
   1.119 +
   1.120 +lemma iSuc_mono [simp]: "iSuc n < iSuc m = (n < m)"
   1.121 +by(simp add:inat_defs split:inat_splits, arith?)
   1.122 +
   1.123 +
   1.124 +(* ----------------------------------------------------------------------- *)
   1.125 +
   1.126 +lemma ile_def2: "m <= n = (m < n | m = (n::inat))"
   1.127 +by(simp add:inat_defs split:inat_splits, arith?)
   1.128 +
   1.129 +lemma ile_refl [simp]: "n <= (n::inat)"
   1.130 +by(simp add:inat_defs split:inat_splits, arith?)
   1.131 +
   1.132 +lemma ile_trans: "i <= j ==> j <= k ==> i <= (k::inat)"
   1.133 +by(simp add:inat_defs split:inat_splits, arith?)
   1.134 +
   1.135 +lemma ile_iless_trans: "i <= j ==> j < k ==> i < (k::inat)"
   1.136 +by(simp add:inat_defs split:inat_splits, arith?)
   1.137 +
   1.138 +lemma iless_ile_trans: "i < j ==> j <= k ==> i < (k::inat)"
   1.139 +by(simp add:inat_defs split:inat_splits, arith?)
   1.140 +
   1.141 +lemma Infty_ub [simp]: "n <= \<infinity>"
   1.142 +by(simp add:inat_defs split:inat_splits, arith?)
   1.143 +
   1.144 +lemma i0_lb [simp]: "(0::inat) <= n"
   1.145 +by(simp add:inat_defs split:inat_splits, arith?)
   1.146 +
   1.147 +lemma Infty_ileE [elim!]: "\<infinity> <= Fin m ==> R"
   1.148 +by(simp add:inat_defs split:inat_splits, arith?)
   1.149 +
   1.150 +lemma Fin_ile_mono [simp]: "(Fin n <= Fin m) = (n <= m)"
   1.151 +by(simp add:inat_defs split:inat_splits, arith?)
   1.152 +
   1.153 +lemma ilessI1: "n <= m ==> n \<noteq> m ==> n < (m::inat)"
   1.154 +by(simp add:inat_defs split:inat_splits, arith?)
   1.155 +
   1.156 +lemma ileI1: "m < n ==> iSuc m <= n"
   1.157 +by(simp add:inat_defs split:inat_splits, arith?)
   1.158 +
   1.159 +lemma Suc_ile_eq: "Fin (Suc m) <= n = (Fin m < n)"
   1.160 +by(simp add:inat_defs split:inat_splits, arith?)
   1.161 +
   1.162 +lemma iSuc_ile_mono [simp]: "iSuc n <= iSuc m = (n <= m)"
   1.163 +by(simp add:inat_defs split:inat_splits, arith?)
   1.164 +
   1.165 +lemma iless_Suc_eq [simp]: "Fin m < iSuc n = (Fin m <= n)"
   1.166 +by(simp add:inat_defs split:inat_splits, arith?)
   1.167 +
   1.168 +lemma not_iSuc_ilei0 [simp]: "\<not> iSuc n <= 0"
   1.169 +by(simp add:inat_defs split:inat_splits, arith?)
   1.170 +
   1.171 +lemma ile_iSuc [simp]: "n <= iSuc n"
   1.172 +by(simp add:inat_defs split:inat_splits, arith?)
   1.173 +
   1.174 +lemma Fin_ile: "n <= Fin m ==> \<exists>k. n = Fin k"
   1.175 +by(simp add:inat_defs split:inat_splits, arith?)
   1.176 +
   1.177 +lemma chain_incr: "\<forall>i. \<exists>j. Y i < Y j ==> \<exists>j. Fin k < Y j"
   1.178 +apply (induct_tac "k")
   1.179 +apply  (simp (no_asm) only: Fin_0)
   1.180 +apply  (fast intro: ile_iless_trans i0_lb)
   1.181 +apply (erule exE)
   1.182 +apply (drule spec)
   1.183 +apply (erule exE)
   1.184 +apply (drule ileI1)
   1.185 +apply (rule iSuc_Fin [THEN subst])
   1.186 +apply (rule exI)
   1.187 +apply (erule (1) ile_iless_trans)
   1.188 +done
   1.189 +
   1.190 +ML {*
   1.191 +val Fin_0 = thm "Fin_0";
   1.192 +val Suc_ile_eq = thm "Suc_ile_eq";
   1.193 +val iSuc_Fin = thm "iSuc_Fin";
   1.194 +val iSuc_Infty = thm "iSuc_Infty";
   1.195 +val iSuc_mono = thm "iSuc_mono";
   1.196 +val iSuc_ile_mono = thm "iSuc_ile_mono";
   1.197 +val not_iSuc_ilei0=thm "not_iSuc_ilei0";
   1.198 +val iSuc_inject = thm "iSuc_inject";
   1.199 +val i0_iless_iSuc = thm "i0_iless_iSuc";
   1.200 +val i0_eq = thm "i0_eq";
   1.201 +val i0_lb = thm "i0_lb";
   1.202 +val ile_def = thm "ile_def";
   1.203 +val ile_refl = thm "ile_refl";
   1.204 +val Infty_ub = thm "Infty_ub";
   1.205 +val ilessI1 = thm "ilessI1";
   1.206 +val ile_iless_trans = thm "ile_iless_trans";
   1.207 +val ile_trans = thm "ile_trans";
   1.208 +val ileI1 = thm "ileI1";
   1.209 +val ile_iSuc = thm "ile_iSuc";
   1.210 +val Fin_iless_Infty = thm "Fin_iless_Infty";
   1.211 +val Fin_ile_mono = thm "Fin_ile_mono";
   1.212 +val chain_incr = thm "chain_incr";
   1.213 +val Infty_eq = thm "Infty_eq";
   1.214 +*}
   1.215 +
   1.216 +end
   1.217 +
   1.218 +
   1.219 +