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