src/HOL/Library/Nat_Infinity.thy
 author nipkow Wed Aug 18 11:09:40 2004 +0200 (2004-08-18) changeset 15140 322485b816ac parent 15131 c69542757a4d child 19736 d8d0f8f51d69 permissions -rw-r--r--
import -> imports
```     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 Main
```
```    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 instance inat :: "{ord, zero}" ..
```
```    23
```
```    24 consts
```
```    25   iSuc :: "inat => inat"
```
```    26
```
```    27 syntax (xsymbols)
```
```    28   Infty :: inat    ("\<infinity>")
```
```    29
```
```    30 syntax (HTML output)
```
```    31   Infty :: inat    ("\<infinity>")
```
```    32
```
```    33 defs
```
```    34   Zero_inat_def: "0 == Fin 0"
```
```    35   iSuc_def: "iSuc i == case i of Fin n  => Fin (Suc n) | \<infinity> => \<infinity>"
```
```    36   iless_def: "m < n ==
```
```    37     case m of Fin m1 => (case n of Fin n1 => m1 < n1 | \<infinity> => True)
```
```    38     | \<infinity>  => False"
```
```    39   ile_def: "(m::inat) \<le> n == \<not> (n < m)"
```
```    40
```
```    41 lemmas inat_defs = Zero_inat_def iSuc_def iless_def ile_def
```
```    42 lemmas inat_splits = inat.split inat.split_asm
```
```    43
```
```    44 text {*
```
```    45   Below is a not quite complete set of theorems.  Use the method
```
```    46   @{text "(simp add: inat_defs split:inat_splits, arith?)"} to prove
```
```    47   new theorems or solve arithmetic subgoals involving @{typ inat} on
```
```    48   the fly.
```
```    49 *}
```
```    50
```
```    51 subsection "Constructors"
```
```    52
```
```    53 lemma Fin_0: "Fin 0 = 0"
```
```    54   by (simp add: inat_defs split:inat_splits, arith?)
```
```    55
```
```    56 lemma Infty_ne_i0 [simp]: "\<infinity> \<noteq> 0"
```
```    57   by (simp add: inat_defs split:inat_splits, arith?)
```
```    58
```
```    59 lemma i0_ne_Infty [simp]: "0 \<noteq> \<infinity>"
```
```    60   by (simp add: inat_defs split:inat_splits, arith?)
```
```    61
```
```    62 lemma iSuc_Fin [simp]: "iSuc (Fin n) = Fin (Suc n)"
```
```    63   by (simp add: inat_defs split:inat_splits, arith?)
```
```    64
```
```    65 lemma iSuc_Infty [simp]: "iSuc \<infinity> = \<infinity>"
```
```    66   by (simp add: inat_defs split:inat_splits, arith?)
```
```    67
```
```    68 lemma iSuc_ne_0 [simp]: "iSuc n \<noteq> 0"
```
```    69   by (simp add: inat_defs split:inat_splits, arith?)
```
```    70
```
```    71 lemma iSuc_inject [simp]: "(iSuc x = iSuc y) = (x = y)"
```
```    72   by (simp add: inat_defs split:inat_splits, arith?)
```
```    73
```
```    74
```
```    75 subsection "Ordering relations"
```
```    76
```
```    77 lemma Infty_ilessE [elim!]: "\<infinity> < Fin m ==> R"
```
```    78   by (simp add: inat_defs split:inat_splits, arith?)
```
```    79
```
```    80 lemma iless_linear: "m < n \<or> m = n \<or> n < (m::inat)"
```
```    81   by (simp add: inat_defs split:inat_splits, arith?)
```
```    82
```
```    83 lemma iless_not_refl [simp]: "\<not> n < (n::inat)"
```
```    84   by (simp add: inat_defs split:inat_splits, arith?)
```
```    85
```
```    86 lemma iless_trans: "i < j ==> j < k ==> i < (k::inat)"
```
```    87   by (simp add: inat_defs split:inat_splits, arith?)
```
```    88
```
```    89 lemma iless_not_sym: "n < m ==> \<not> m < (n::inat)"
```
```    90   by (simp add: inat_defs split:inat_splits, arith?)
```
```    91
```
```    92 lemma Fin_iless_mono [simp]: "(Fin n < Fin m) = (n < m)"
```
```    93   by (simp add: inat_defs split:inat_splits, arith?)
```
```    94
```
```    95 lemma Fin_iless_Infty [simp]: "Fin n < \<infinity>"
```
```    96   by (simp add: inat_defs split:inat_splits, arith?)
```
```    97
```
```    98 lemma Infty_eq [simp]: "(n < \<infinity>) = (n \<noteq> \<infinity>)"
```
```    99   by (simp add: inat_defs split:inat_splits, arith?)
```
```   100
```
```   101 lemma i0_eq [simp]: "((0::inat) < n) = (n \<noteq> 0)"
```
```   102   by (simp add: inat_defs split:inat_splits, arith?)
```
```   103
```
```   104 lemma i0_iless_iSuc [simp]: "0 < iSuc n"
```
```   105   by (simp add: inat_defs split:inat_splits, arith?)
```
```   106
```
```   107 lemma not_ilessi0 [simp]: "\<not> n < (0::inat)"
```
```   108   by (simp add: inat_defs split:inat_splits, arith?)
```
```   109
```
```   110 lemma Fin_iless: "n < Fin m ==> \<exists>k. n = Fin k"
```
```   111   by (simp add: inat_defs split:inat_splits, arith?)
```
```   112
```
```   113 lemma iSuc_mono [simp]: "(iSuc n < iSuc m) = (n < m)"
```
```   114   by (simp add: inat_defs split:inat_splits, arith?)
```
```   115
```
```   116
```
```   117 (* ----------------------------------------------------------------------- *)
```
```   118
```
```   119 lemma ile_def2: "(m \<le> n) = (m < n \<or> m = (n::inat))"
```
```   120   by (simp add: inat_defs split:inat_splits, arith?)
```
```   121
```
```   122 lemma ile_refl [simp]: "n \<le> (n::inat)"
```
```   123   by (simp add: inat_defs split:inat_splits, arith?)
```
```   124
```
```   125 lemma ile_trans: "i \<le> j ==> j \<le> k ==> i \<le> (k::inat)"
```
```   126   by (simp add: inat_defs split:inat_splits, arith?)
```
```   127
```
```   128 lemma ile_iless_trans: "i \<le> j ==> j < k ==> i < (k::inat)"
```
```   129   by (simp add: inat_defs split:inat_splits, arith?)
```
```   130
```
```   131 lemma iless_ile_trans: "i < j ==> j \<le> k ==> i < (k::inat)"
```
```   132   by (simp add: inat_defs split:inat_splits, arith?)
```
```   133
```
```   134 lemma Infty_ub [simp]: "n \<le> \<infinity>"
```
```   135   by (simp add: inat_defs split:inat_splits, arith?)
```
```   136
```
```   137 lemma i0_lb [simp]: "(0::inat) \<le> n"
```
```   138   by (simp add: inat_defs split:inat_splits, arith?)
```
```   139
```
```   140 lemma Infty_ileE [elim!]: "\<infinity> \<le> Fin m ==> R"
```
```   141   by (simp add: inat_defs split:inat_splits, arith?)
```
```   142
```
```   143 lemma Fin_ile_mono [simp]: "(Fin n \<le> Fin m) = (n \<le> m)"
```
```   144   by (simp add: inat_defs split:inat_splits, arith?)
```
```   145
```
```   146 lemma ilessI1: "n \<le> m ==> n \<noteq> m ==> n < (m::inat)"
```
```   147   by (simp add: inat_defs split:inat_splits, arith?)
```
```   148
```
```   149 lemma ileI1: "m < n ==> iSuc m \<le> n"
```
```   150   by (simp add: inat_defs split:inat_splits, arith?)
```
```   151
```
```   152 lemma Suc_ile_eq: "(Fin (Suc m) \<le> n) = (Fin m < n)"
```
```   153   by (simp add: inat_defs split:inat_splits, arith?)
```
```   154
```
```   155 lemma iSuc_ile_mono [simp]: "(iSuc n \<le> iSuc m) = (n \<le> m)"
```
```   156   by (simp add: inat_defs split:inat_splits, arith?)
```
```   157
```
```   158 lemma iless_Suc_eq [simp]: "(Fin m < iSuc n) = (Fin m \<le> n)"
```
```   159   by (simp add: inat_defs split:inat_splits, arith?)
```
```   160
```
```   161 lemma not_iSuc_ilei0 [simp]: "\<not> iSuc n \<le> 0"
```
```   162   by (simp add: inat_defs split:inat_splits, arith?)
```
```   163
```
```   164 lemma ile_iSuc [simp]: "n \<le> iSuc n"
```
```   165   by (simp add: inat_defs split:inat_splits, arith?)
```
```   166
```
```   167 lemma Fin_ile: "n \<le> Fin m ==> \<exists>k. n = Fin k"
```
```   168   by (simp add: inat_defs split:inat_splits, arith?)
```
```   169
```
```   170 lemma chain_incr: "\<forall>i. \<exists>j. Y i < Y j ==> \<exists>j. Fin k < Y j"
```
```   171   apply (induct_tac k)
```
```   172    apply (simp (no_asm) only: Fin_0)
```
```   173    apply (fast intro: ile_iless_trans i0_lb)
```
```   174   apply (erule exE)
```
```   175   apply (drule spec)
```
```   176   apply (erule exE)
```
```   177   apply (drule ileI1)
```
```   178   apply (rule iSuc_Fin [THEN subst])
```
```   179   apply (rule exI)
```
```   180   apply (erule (1) ile_iless_trans)
```
```   181   done
```
```   182
```
```   183 end
```