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