src/HOL/Library/Nat_Infinity.thy
changeset 11355 778c369559d9
parent 11351 c5c403d30c77
child 11357 908b761cdfb0
     1.1 --- a/src/HOL/Library/Nat_Infinity.thy	Thu May 31 18:28:23 2001 +0200
     1.2 +++ b/src/HOL/Library/Nat_Infinity.thy	Thu May 31 20:52:51 2001 +0200
     1.3 @@ -1,8 +1,7 @@
     1.4 -(*  Title: 	HOL/Library/Nat_Infinity.thy
     1.5 -    ID:         $ $
     1.6 -    Author: 	David von Oheimb, TU Muenchen
     1.7 +(*  Title:      HOL/Library/Nat_Infinity.thy
     1.8 +    ID:         $Id$
     1.9 +    Author:     David von Oheimb, TU Muenchen
    1.10      License:    GPL (GNU GENERAL PUBLIC LICENSE)
    1.11 -
    1.12  *)
    1.13  
    1.14  header {*
    1.15 @@ -10,14 +9,14 @@
    1.16    \author{David von Oheimb}
    1.17  *}
    1.18  
    1.19 -theory Nat_Infinity = Datatype:
    1.20 +theory Nat_Infinity = Main:
    1.21  
    1.22  subsection "Definitions"
    1.23  
    1.24  text {*
    1.25 - We extend the standard natural numbers by a special value indicating infinity.
    1.26 - This includes extending the ordering relations @{term "op <"} and 
    1.27 - @{term "op <="}.
    1.28 +  We extend the standard natural numbers by a special value indicating
    1.29 +  infinity.  This includes extending the ordering relations @{term "op
    1.30 +  <"} and @{term "op \<le>"}.
    1.31  *}
    1.32  
    1.33  datatype inat = Fin nat | Infty
    1.34 @@ -26,191 +25,159 @@
    1.35  instance inat :: zero ..
    1.36  
    1.37  consts
    1.38 -
    1.39 -  iSuc	:: "inat => inat"
    1.40 +  iSuc :: "inat => inat"
    1.41  
    1.42  syntax (xsymbols)
    1.43 -
    1.44 -  Infty		:: inat					("\<infinity>")
    1.45 +  Infty :: inat    ("\<infinity>")
    1.46  
    1.47  defs
    1.48 -
    1.49 -  iZero_def:	"0      == Fin 0"
    1.50 -  iSuc_def:	"iSuc i == case i of Fin n  => Fin (Suc n) | \<infinity> => \<infinity>"
    1.51 -  iless_def:	"m < n  == case m of Fin m1 => (case n of Fin n1 => m1 < n1 
    1.52 -						             | \<infinity> => True)
    1.53 -				   | \<infinity>  => False "
    1.54 -  ile_def:	"(m::inat) <= n == \<not>(n<m)"
    1.55 +  iZero_def: "0 == Fin 0"
    1.56 +  iSuc_def: "iSuc i == case i of Fin n  => Fin (Suc n) | \<infinity> => \<infinity>"
    1.57 +  iless_def: "m < n ==
    1.58 +    case m of Fin m1 => (case n of Fin n1 => m1 < n1 | \<infinity> => True)
    1.59 +    | \<infinity>  => False"
    1.60 +  ile_def: "(m::inat) \<le> n == \<not> (n < m)"
    1.61  
    1.62  lemmas inat_defs = iZero_def iSuc_def iless_def ile_def
    1.63  lemmas inat_splits = inat.split inat.split_asm
    1.64  
    1.65 -
    1.66 -text {* Below is a not quite complete set of theorems. Use
    1.67 -@{text "apply(simp add:inat_defs split:inat_splits, arith?)"}
    1.68 -to prove new theorems or solve arithmetic subgoals involving @{typ inat} 
    1.69 -on the fly.
    1.70 +text {*
    1.71 +  Below is a not quite complete set of theorems.  Use method @{text
    1.72 +  "(simp add: inat_defs split:inat_splits, arith?)"} to prove new
    1.73 +  theorems or solve arithmetic subgoals involving @{typ inat} on the
    1.74 +  fly.
    1.75  *}
    1.76  
    1.77  subsection "Constructors"
    1.78  
    1.79  lemma Fin_0: "Fin 0 = 0"
    1.80 -by(simp add:inat_defs split:inat_splits, arith?)
    1.81 +  by (simp add:inat_defs split:inat_splits, arith?)
    1.82  
    1.83  lemma Infty_ne_i0 [simp]: "\<infinity> \<noteq> 0"
    1.84 -by(simp add:inat_defs split:inat_splits, arith?)
    1.85 +  by (simp add:inat_defs split:inat_splits, arith?)
    1.86  
    1.87  lemma i0_ne_Infty [simp]: "0 \<noteq> \<infinity>"
    1.88 -by(simp add:inat_defs split:inat_splits, arith?)
    1.89 +  by (simp add:inat_defs split:inat_splits, arith?)
    1.90  
    1.91  lemma iSuc_Fin [simp]: "iSuc (Fin n) = Fin (Suc n)"
    1.92 -by(simp add:inat_defs split:inat_splits, arith?)
    1.93 +  by (simp add:inat_defs split:inat_splits, arith?)
    1.94  
    1.95  lemma iSuc_Infty [simp]: "iSuc \<infinity> = \<infinity>"
    1.96 -by(simp add:inat_defs split:inat_splits, arith?)
    1.97 +  by (simp add:inat_defs split:inat_splits, arith?)
    1.98  
    1.99  lemma iSuc_ne_0 [simp]: "iSuc n \<noteq> 0"
   1.100 -by(simp add:inat_defs split:inat_splits, arith?)
   1.101 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.102  
   1.103  lemma iSuc_inject [simp]: "(iSuc x = iSuc y) = (x = y)"
   1.104 -by(simp add:inat_defs split:inat_splits, arith?)
   1.105 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.106  
   1.107  
   1.108  subsection "Ordering relations"
   1.109  
   1.110  lemma Infty_ilessE [elim!]: "\<infinity> < Fin m ==> R"
   1.111 -by(simp add:inat_defs split:inat_splits, arith?)
   1.112 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.113  
   1.114 -lemma iless_linear: "m < n | m = n | n < (m::inat)"
   1.115 -by(simp add:inat_defs split:inat_splits, arith?)
   1.116 +lemma iless_linear: "m < n \<or> m = n \<or> n < (m::inat)"
   1.117 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.118  
   1.119  lemma iless_not_refl [simp]: "\<not> n < (n::inat)"
   1.120 -by(simp add:inat_defs split:inat_splits, arith?)
   1.121 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.122  
   1.123  lemma iless_trans: "i < j ==> j < k ==> i < (k::inat)"
   1.124 -by(simp add:inat_defs split:inat_splits, arith?)
   1.125 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.126  
   1.127  lemma iless_not_sym: "n < m ==> \<not> m < (n::inat)"
   1.128 -by(simp add:inat_defs split:inat_splits, arith?)
   1.129 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.130  
   1.131  lemma Fin_iless_mono [simp]: "(Fin n < Fin m) = (n < m)"
   1.132 -by(simp add:inat_defs split:inat_splits, arith?)
   1.133 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.134  
   1.135  lemma Fin_iless_Infty [simp]: "Fin n < \<infinity>"
   1.136 -by(simp add:inat_defs split:inat_splits, arith?)
   1.137 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.138  
   1.139  lemma Infty_eq [simp]: "n < \<infinity> = (n \<noteq> \<infinity>)"
   1.140 -by(simp add:inat_defs split:inat_splits, arith?)
   1.141 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.142  
   1.143  lemma i0_eq [simp]: "((0::inat) < n) = (n \<noteq> 0)"
   1.144 -by(simp add:inat_defs split:inat_splits, arith?)
   1.145 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.146  
   1.147  lemma i0_iless_iSuc [simp]: "0 < iSuc n"
   1.148 -by(simp add:inat_defs split:inat_splits, arith?)
   1.149 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.150  
   1.151  lemma not_ilessi0 [simp]: "\<not> n < (0::inat)"
   1.152 -by(simp add:inat_defs split:inat_splits, arith?)
   1.153 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.154  
   1.155  lemma Fin_iless: "n < Fin m ==> \<exists>k. n = Fin k"
   1.156 -by(simp add:inat_defs split:inat_splits, arith?)
   1.157 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.158  
   1.159  lemma iSuc_mono [simp]: "iSuc n < iSuc m = (n < m)"
   1.160 -by(simp add:inat_defs split:inat_splits, arith?)
   1.161 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.162  
   1.163  
   1.164  (* ----------------------------------------------------------------------- *)
   1.165  
   1.166 -lemma ile_def2: "m <= n = (m < n | m = (n::inat))"
   1.167 -by(simp add:inat_defs split:inat_splits, arith?)
   1.168 +lemma ile_def2: "m \<le> n = (m < n \<or> m = (n::inat))"
   1.169 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.170  
   1.171 -lemma ile_refl [simp]: "n <= (n::inat)"
   1.172 -by(simp add:inat_defs split:inat_splits, arith?)
   1.173 +lemma ile_refl [simp]: "n \<le> (n::inat)"
   1.174 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.175  
   1.176 -lemma ile_trans: "i <= j ==> j <= k ==> i <= (k::inat)"
   1.177 -by(simp add:inat_defs split:inat_splits, arith?)
   1.178 +lemma ile_trans: "i \<le> j ==> j \<le> k ==> i \<le> (k::inat)"
   1.179 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.180  
   1.181 -lemma ile_iless_trans: "i <= j ==> j < k ==> i < (k::inat)"
   1.182 -by(simp add:inat_defs split:inat_splits, arith?)
   1.183 +lemma ile_iless_trans: "i \<le> j ==> j < k ==> i < (k::inat)"
   1.184 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.185  
   1.186 -lemma iless_ile_trans: "i < j ==> j <= k ==> i < (k::inat)"
   1.187 -by(simp add:inat_defs split:inat_splits, arith?)
   1.188 +lemma iless_ile_trans: "i < j ==> j \<le> k ==> i < (k::inat)"
   1.189 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.190  
   1.191 -lemma Infty_ub [simp]: "n <= \<infinity>"
   1.192 -by(simp add:inat_defs split:inat_splits, arith?)
   1.193 +lemma Infty_ub [simp]: "n \<le> \<infinity>"
   1.194 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.195  
   1.196 -lemma i0_lb [simp]: "(0::inat) <= n"
   1.197 -by(simp add:inat_defs split:inat_splits, arith?)
   1.198 +lemma i0_lb [simp]: "(0::inat) \<le> n"
   1.199 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.200  
   1.201 -lemma Infty_ileE [elim!]: "\<infinity> <= Fin m ==> R"
   1.202 -by(simp add:inat_defs split:inat_splits, arith?)
   1.203 +lemma Infty_ileE [elim!]: "\<infinity> \<le> Fin m ==> R"
   1.204 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.205  
   1.206 -lemma Fin_ile_mono [simp]: "(Fin n <= Fin m) = (n <= m)"
   1.207 -by(simp add:inat_defs split:inat_splits, arith?)
   1.208 +lemma Fin_ile_mono [simp]: "(Fin n \<le> Fin m) = (n \<le> m)"
   1.209 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.210  
   1.211 -lemma ilessI1: "n <= m ==> n \<noteq> m ==> n < (m::inat)"
   1.212 -by(simp add:inat_defs split:inat_splits, arith?)
   1.213 +lemma ilessI1: "n \<le> m ==> n \<noteq> m ==> n < (m::inat)"
   1.214 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.215  
   1.216 -lemma ileI1: "m < n ==> iSuc m <= n"
   1.217 -by(simp add:inat_defs split:inat_splits, arith?)
   1.218 +lemma ileI1: "m < n ==> iSuc m \<le> n"
   1.219 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.220  
   1.221 -lemma Suc_ile_eq: "Fin (Suc m) <= n = (Fin m < n)"
   1.222 -by(simp add:inat_defs split:inat_splits, arith?)
   1.223 +lemma Suc_ile_eq: "Fin (Suc m) \<le> n = (Fin m < n)"
   1.224 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.225  
   1.226 -lemma iSuc_ile_mono [simp]: "iSuc n <= iSuc m = (n <= m)"
   1.227 -by(simp add:inat_defs split:inat_splits, arith?)
   1.228 +lemma iSuc_ile_mono [simp]: "iSuc n \<le> iSuc m = (n \<le> m)"
   1.229 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.230  
   1.231 -lemma iless_Suc_eq [simp]: "Fin m < iSuc n = (Fin m <= n)"
   1.232 -by(simp add:inat_defs split:inat_splits, arith?)
   1.233 +lemma iless_Suc_eq [simp]: "Fin m < iSuc n = (Fin m \<le> n)"
   1.234 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.235  
   1.236 -lemma not_iSuc_ilei0 [simp]: "\<not> iSuc n <= 0"
   1.237 -by(simp add:inat_defs split:inat_splits, arith?)
   1.238 +lemma not_iSuc_ilei0 [simp]: "\<not> iSuc n \<le> 0"
   1.239 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.240  
   1.241 -lemma ile_iSuc [simp]: "n <= iSuc n"
   1.242 -by(simp add:inat_defs split:inat_splits, arith?)
   1.243 +lemma ile_iSuc [simp]: "n \<le> iSuc n"
   1.244 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.245  
   1.246 -lemma Fin_ile: "n <= Fin m ==> \<exists>k. n = Fin k"
   1.247 -by(simp add:inat_defs split:inat_splits, arith?)
   1.248 +lemma Fin_ile: "n \<le> Fin m ==> \<exists>k. n = Fin k"
   1.249 +  by (simp add:inat_defs split:inat_splits, arith?)
   1.250  
   1.251  lemma chain_incr: "\<forall>i. \<exists>j. Y i < Y j ==> \<exists>j. Fin k < Y j"
   1.252 -apply (induct_tac "k")
   1.253 -apply  (simp (no_asm) only: Fin_0)
   1.254 -apply  (fast intro: ile_iless_trans i0_lb)
   1.255 -apply (erule exE)
   1.256 -apply (drule spec)
   1.257 -apply (erule exE)
   1.258 -apply (drule ileI1)
   1.259 -apply (rule iSuc_Fin [THEN subst])
   1.260 -apply (rule exI)
   1.261 -apply (erule (1) ile_iless_trans)
   1.262 -done
   1.263 -
   1.264 -ML {*
   1.265 -val Fin_0 = thm "Fin_0";
   1.266 -val Suc_ile_eq = thm "Suc_ile_eq";
   1.267 -val iSuc_Fin = thm "iSuc_Fin";
   1.268 -val iSuc_Infty = thm "iSuc_Infty";
   1.269 -val iSuc_mono = thm "iSuc_mono";
   1.270 -val iSuc_ile_mono = thm "iSuc_ile_mono";
   1.271 -val not_iSuc_ilei0=thm "not_iSuc_ilei0";
   1.272 -val iSuc_inject = thm "iSuc_inject";
   1.273 -val i0_iless_iSuc = thm "i0_iless_iSuc";
   1.274 -val i0_eq = thm "i0_eq";
   1.275 -val i0_lb = thm "i0_lb";
   1.276 -val ile_def = thm "ile_def";
   1.277 -val ile_refl = thm "ile_refl";
   1.278 -val Infty_ub = thm "Infty_ub";
   1.279 -val ilessI1 = thm "ilessI1";
   1.280 -val ile_iless_trans = thm "ile_iless_trans";
   1.281 -val ile_trans = thm "ile_trans";
   1.282 -val ileI1 = thm "ileI1";
   1.283 -val ile_iSuc = thm "ile_iSuc";
   1.284 -val Fin_iless_Infty = thm "Fin_iless_Infty";
   1.285 -val Fin_ile_mono = thm "Fin_ile_mono";
   1.286 -val chain_incr = thm "chain_incr";
   1.287 -val Infty_eq = thm "Infty_eq";
   1.288 -*}
   1.289 +  apply (induct_tac k)
   1.290 +   apply (simp (no_asm) only: Fin_0)
   1.291 +   apply (fast intro: ile_iless_trans i0_lb)
   1.292 +  apply (erule exE)
   1.293 +  apply (drule spec)
   1.294 +  apply (erule exE)
   1.295 +  apply (drule ileI1)
   1.296 +  apply (rule iSuc_Fin [THEN subst])
   1.297 +  apply (rule exI)
   1.298 +  apply (erule (1) ile_iless_trans)
   1.299 +  done
   1.300  
   1.301  end
   1.302 -
   1.303 -
   1.304 -