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