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