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