src/HOL/Library/Nat_Infinity.thy
author wenzelm
Tue Nov 07 11:47:57 2006 +0100 (2006-11-07)
changeset 21210 c17fd2df4e9e
parent 19736 d8d0f8f51d69
child 21404 eb85850d3eb7
permissions -rw-r--r--
renamed 'const_syntax' to 'notation';
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
nipkow@15140
     9
imports Main
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@14691
    28
instance inat :: "{ord, zero}" ..
oheimb@11351
    29
wenzelm@19736
    30
definition
wenzelm@11355
    31
  iSuc :: "inat => inat"
wenzelm@19736
    32
  "iSuc i = (case i of Fin n => Fin (Suc n) | \<infinity> => \<infinity>)"
oheimb@11351
    33
wenzelm@19736
    34
defs (overloaded)
wenzelm@11701
    35
  Zero_inat_def: "0 == Fin 0"
wenzelm@11355
    36
  iless_def: "m < n ==
wenzelm@11355
    37
    case m of Fin m1 => (case n of Fin n1 => m1 < n1 | \<infinity> => True)
wenzelm@11355
    38
    | \<infinity>  => False"
wenzelm@11355
    39
  ile_def: "(m::inat) \<le> n == \<not> (n < m)"
oheimb@11351
    40
wenzelm@11701
    41
lemmas inat_defs = Zero_inat_def iSuc_def iless_def ile_def
oheimb@11351
    42
lemmas inat_splits = inat.split inat.split_asm
oheimb@11351
    43
wenzelm@11355
    44
text {*
wenzelm@11357
    45
  Below is a not quite complete set of theorems.  Use the method
wenzelm@11357
    46
  @{text "(simp add: inat_defs split:inat_splits, arith?)"} to prove
wenzelm@11357
    47
  new theorems or solve arithmetic subgoals involving @{typ inat} on
wenzelm@11357
    48
  the fly.
oheimb@11351
    49
*}
oheimb@11351
    50
oheimb@11351
    51
subsection "Constructors"
oheimb@11351
    52
oheimb@11351
    53
lemma Fin_0: "Fin 0 = 0"
wenzelm@11357
    54
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
    55
oheimb@11351
    56
lemma Infty_ne_i0 [simp]: "\<infinity> \<noteq> 0"
wenzelm@11357
    57
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
    58
oheimb@11351
    59
lemma i0_ne_Infty [simp]: "0 \<noteq> \<infinity>"
wenzelm@11357
    60
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
    61
oheimb@11351
    62
lemma iSuc_Fin [simp]: "iSuc (Fin n) = Fin (Suc n)"
wenzelm@11357
    63
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
    64
oheimb@11351
    65
lemma iSuc_Infty [simp]: "iSuc \<infinity> = \<infinity>"
wenzelm@11357
    66
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
    67
oheimb@11351
    68
lemma iSuc_ne_0 [simp]: "iSuc n \<noteq> 0"
wenzelm@11357
    69
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
    70
oheimb@11351
    71
lemma iSuc_inject [simp]: "(iSuc x = iSuc y) = (x = y)"
wenzelm@11357
    72
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
    73
oheimb@11351
    74
oheimb@11351
    75
subsection "Ordering relations"
oheimb@11351
    76
oheimb@11351
    77
lemma Infty_ilessE [elim!]: "\<infinity> < Fin m ==> R"
wenzelm@11357
    78
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
    79
wenzelm@11355
    80
lemma iless_linear: "m < n \<or> m = n \<or> n < (m::inat)"
wenzelm@11357
    81
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
    82
oheimb@11351
    83
lemma iless_not_refl [simp]: "\<not> n < (n::inat)"
wenzelm@11357
    84
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
    85
oheimb@11351
    86
lemma iless_trans: "i < j ==> j < k ==> i < (k::inat)"
wenzelm@11357
    87
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
    88
oheimb@11351
    89
lemma iless_not_sym: "n < m ==> \<not> m < (n::inat)"
wenzelm@11357
    90
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
    91
oheimb@11351
    92
lemma Fin_iless_mono [simp]: "(Fin n < Fin m) = (n < m)"
wenzelm@11357
    93
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
    94
oheimb@11351
    95
lemma Fin_iless_Infty [simp]: "Fin n < \<infinity>"
wenzelm@11357
    96
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
    97
wenzelm@11655
    98
lemma Infty_eq [simp]: "(n < \<infinity>) = (n \<noteq> \<infinity>)"
wenzelm@11357
    99
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
   100
oheimb@11351
   101
lemma i0_eq [simp]: "((0::inat) < n) = (n \<noteq> 0)"
wenzelm@11357
   102
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
   103
oheimb@11351
   104
lemma i0_iless_iSuc [simp]: "0 < iSuc n"
wenzelm@11357
   105
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
   106
oheimb@11351
   107
lemma not_ilessi0 [simp]: "\<not> n < (0::inat)"
wenzelm@11357
   108
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
   109
oheimb@11351
   110
lemma Fin_iless: "n < Fin m ==> \<exists>k. n = Fin k"
wenzelm@11357
   111
  by (simp add: inat_defs split:inat_splits, arith?)
oheimb@11351
   112
wenzelm@11655
   113
lemma iSuc_mono [simp]: "(iSuc n < iSuc m) = (n < m)"
wenzelm@11357
   114
  by (simp add: inat_defs split:inat_splits, arith?)
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