src/HOL/Library/Nat_Infinity.thy
author wenzelm
Sat May 01 22:01:57 2004 +0200 (2004-05-01)
changeset 14691 e1eedc8cad37
parent 14565 c6dc17aab88a
child 14706 71590b7733b7
permissions -rw-r--r--
tuned instance statements;
     1 (*  Title:      HOL/Library/Nat_Infinity.thy
     2     ID:         $Id$
     3     Author:     David von Oheimb, TU Muenchen
     4     License:    GPL (GNU GENERAL PUBLIC LICENSE)
     5 *)
     6 
     7 header {*
     8   \title{Natural numbers with infinity}
     9   \author{David von Oheimb}
    10 *}
    11 
    12 theory Nat_Infinity = Main:
    13 
    14 subsection "Definitions"
    15 
    16 text {*
    17   We extend the standard natural numbers by a special value indicating
    18   infinity.  This includes extending the ordering relations @{term "op
    19   <"} and @{term "op \<le>"}.
    20 *}
    21 
    22 datatype inat = Fin nat | Infty
    23 
    24 instance inat :: "{ord, zero}" ..
    25 
    26 consts
    27   iSuc :: "inat => inat"
    28 
    29 syntax (xsymbols)
    30   Infty :: inat    ("\<infinity>")
    31 
    32 syntax (HTML output)
    33   Infty :: inat    ("\<infinity>")
    34 
    35 defs
    36   Zero_inat_def: "0 == Fin 0"
    37   iSuc_def: "iSuc i == case i of Fin n  => Fin (Suc n) | \<infinity> => \<infinity>"
    38   iless_def: "m < n ==
    39     case m of Fin m1 => (case n of Fin n1 => m1 < n1 | \<infinity> => True)
    40     | \<infinity>  => False"
    41   ile_def: "(m::inat) \<le> n == \<not> (n < m)"
    42 
    43 lemmas inat_defs = Zero_inat_def iSuc_def iless_def ile_def
    44 lemmas inat_splits = inat.split inat.split_asm
    45 
    46 text {*
    47   Below is a not quite complete set of theorems.  Use the method
    48   @{text "(simp add: inat_defs split:inat_splits, arith?)"} to prove
    49   new theorems or solve arithmetic subgoals involving @{typ inat} on
    50   the fly.
    51 *}
    52 
    53 subsection "Constructors"
    54 
    55 lemma Fin_0: "Fin 0 = 0"
    56   by (simp add: inat_defs split:inat_splits, arith?)
    57 
    58 lemma Infty_ne_i0 [simp]: "\<infinity> \<noteq> 0"
    59   by (simp add: inat_defs split:inat_splits, arith?)
    60 
    61 lemma i0_ne_Infty [simp]: "0 \<noteq> \<infinity>"
    62   by (simp add: inat_defs split:inat_splits, arith?)
    63 
    64 lemma iSuc_Fin [simp]: "iSuc (Fin n) = Fin (Suc n)"
    65   by (simp add: inat_defs split:inat_splits, arith?)
    66 
    67 lemma iSuc_Infty [simp]: "iSuc \<infinity> = \<infinity>"
    68   by (simp add: inat_defs split:inat_splits, arith?)
    69 
    70 lemma iSuc_ne_0 [simp]: "iSuc n \<noteq> 0"
    71   by (simp add: inat_defs split:inat_splits, arith?)
    72 
    73 lemma iSuc_inject [simp]: "(iSuc x = iSuc y) = (x = y)"
    74   by (simp add: inat_defs split:inat_splits, arith?)
    75 
    76 
    77 subsection "Ordering relations"
    78 
    79 lemma Infty_ilessE [elim!]: "\<infinity> < Fin m ==> R"
    80   by (simp add: inat_defs split:inat_splits, arith?)
    81 
    82 lemma iless_linear: "m < n \<or> m = n \<or> n < (m::inat)"
    83   by (simp add: inat_defs split:inat_splits, arith?)
    84 
    85 lemma iless_not_refl [simp]: "\<not> n < (n::inat)"
    86   by (simp add: inat_defs split:inat_splits, arith?)
    87 
    88 lemma iless_trans: "i < j ==> j < k ==> i < (k::inat)"
    89   by (simp add: inat_defs split:inat_splits, arith?)
    90 
    91 lemma iless_not_sym: "n < m ==> \<not> m < (n::inat)"
    92   by (simp add: inat_defs split:inat_splits, arith?)
    93 
    94 lemma Fin_iless_mono [simp]: "(Fin n < Fin m) = (n < m)"
    95   by (simp add: inat_defs split:inat_splits, arith?)
    96 
    97 lemma Fin_iless_Infty [simp]: "Fin n < \<infinity>"
    98   by (simp add: inat_defs split:inat_splits, arith?)
    99 
   100 lemma Infty_eq [simp]: "(n < \<infinity>) = (n \<noteq> \<infinity>)"
   101   by (simp add: inat_defs split:inat_splits, arith?)
   102 
   103 lemma i0_eq [simp]: "((0::inat) < n) = (n \<noteq> 0)"
   104   by (simp add: inat_defs split:inat_splits, arith?)
   105 
   106 lemma i0_iless_iSuc [simp]: "0 < iSuc n"
   107   by (simp add: inat_defs split:inat_splits, arith?)
   108 
   109 lemma not_ilessi0 [simp]: "\<not> n < (0::inat)"
   110   by (simp add: inat_defs split:inat_splits, arith?)
   111 
   112 lemma Fin_iless: "n < Fin m ==> \<exists>k. n = Fin k"
   113   by (simp add: inat_defs split:inat_splits, arith?)
   114 
   115 lemma iSuc_mono [simp]: "(iSuc n < iSuc m) = (n < m)"
   116   by (simp add: inat_defs split:inat_splits, arith?)
   117 
   118 
   119 (* ----------------------------------------------------------------------- *)
   120 
   121 lemma ile_def2: "(m \<le> n) = (m < n \<or> m = (n::inat))"
   122   by (simp add: inat_defs split:inat_splits, arith?)
   123 
   124 lemma ile_refl [simp]: "n \<le> (n::inat)"
   125   by (simp add: inat_defs split:inat_splits, arith?)
   126 
   127 lemma ile_trans: "i \<le> j ==> j \<le> k ==> i \<le> (k::inat)"
   128   by (simp add: inat_defs split:inat_splits, arith?)
   129 
   130 lemma ile_iless_trans: "i \<le> j ==> j < k ==> i < (k::inat)"
   131   by (simp add: inat_defs split:inat_splits, arith?)
   132 
   133 lemma iless_ile_trans: "i < j ==> j \<le> k ==> i < (k::inat)"
   134   by (simp add: inat_defs split:inat_splits, arith?)
   135 
   136 lemma Infty_ub [simp]: "n \<le> \<infinity>"
   137   by (simp add: inat_defs split:inat_splits, arith?)
   138 
   139 lemma i0_lb [simp]: "(0::inat) \<le> n"
   140   by (simp add: inat_defs split:inat_splits, arith?)
   141 
   142 lemma Infty_ileE [elim!]: "\<infinity> \<le> Fin m ==> R"
   143   by (simp add: inat_defs split:inat_splits, arith?)
   144 
   145 lemma Fin_ile_mono [simp]: "(Fin n \<le> Fin m) = (n \<le> m)"
   146   by (simp add: inat_defs split:inat_splits, arith?)
   147 
   148 lemma ilessI1: "n \<le> m ==> n \<noteq> m ==> n < (m::inat)"
   149   by (simp add: inat_defs split:inat_splits, arith?)
   150 
   151 lemma ileI1: "m < n ==> iSuc m \<le> n"
   152   by (simp add: inat_defs split:inat_splits, arith?)
   153 
   154 lemma Suc_ile_eq: "(Fin (Suc m) \<le> n) = (Fin m < n)"
   155   by (simp add: inat_defs split:inat_splits, arith?)
   156 
   157 lemma iSuc_ile_mono [simp]: "(iSuc n \<le> iSuc m) = (n \<le> m)"
   158   by (simp add: inat_defs split:inat_splits, arith?)
   159 
   160 lemma iless_Suc_eq [simp]: "(Fin m < iSuc n) = (Fin m \<le> n)"
   161   by (simp add: inat_defs split:inat_splits, arith?)
   162 
   163 lemma not_iSuc_ilei0 [simp]: "\<not> iSuc n \<le> 0"
   164   by (simp add: inat_defs split:inat_splits, arith?)
   165 
   166 lemma ile_iSuc [simp]: "n \<le> iSuc n"
   167   by (simp add: inat_defs split:inat_splits, arith?)
   168 
   169 lemma Fin_ile: "n \<le> Fin m ==> \<exists>k. n = Fin k"
   170   by (simp add: inat_defs split:inat_splits, arith?)
   171 
   172 lemma chain_incr: "\<forall>i. \<exists>j. Y i < Y j ==> \<exists>j. Fin k < Y j"
   173   apply (induct_tac k)
   174    apply (simp (no_asm) only: Fin_0)
   175    apply (fast intro: ile_iless_trans i0_lb)
   176   apply (erule exE)
   177   apply (drule spec)
   178   apply (erule exE)
   179   apply (drule ileI1)
   180   apply (rule iSuc_Fin [THEN subst])
   181   apply (rule exI)
   182   apply (erule (1) ile_iless_trans)
   183   done
   184 
   185 end