src/HOL/Library/Nat_Infinity.thy
author noschinl
Thu, 26 May 2011 23:21:00 +0200
changeset 42993 da014b00d7a4
parent 41855 c3b6e69da386
child 43532 d32d72ea3215
permissions -rw-r--r--
instance inat for complete_lattice
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11355
wenzelm
parents: 11351
diff changeset
     1
(*  Title:      HOL/Library/Nat_Infinity.thy
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
     2
    Author:     David von Oheimb, TU Muenchen;  Florian Haftmann, TU Muenchen
41853
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
     3
    Contributions: David Trachtenherz, TU Muenchen
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
     4
*)
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
     5
14706
71590b7733b7 tuned document;
wenzelm
parents: 14691
diff changeset
     6
header {* Natural numbers with infinity *}
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
     7
15131
c69542757a4d New theory header syntax.
nipkow
parents: 14981
diff changeset
     8
theory Nat_Infinity
30663
0b6aff7451b2 Main is (Complex_Main) base entry point in library theories
haftmann
parents: 29668
diff changeset
     9
imports Main
15131
c69542757a4d New theory header syntax.
nipkow
parents: 14981
diff changeset
    10
begin
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
    11
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    12
subsection {* Type definition *}
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
    13
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
    14
text {*
11355
wenzelm
parents: 11351
diff changeset
    15
  We extend the standard natural numbers by a special value indicating
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    16
  infinity.
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
    17
*}
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
    18
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
    19
datatype inat = Fin nat | Infty
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
    20
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 19736
diff changeset
    21
notation (xsymbols)
19736
wenzelm
parents: 15140
diff changeset
    22
  Infty  ("\<infinity>")
wenzelm
parents: 15140
diff changeset
    23
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 19736
diff changeset
    24
notation (HTML output)
19736
wenzelm
parents: 15140
diff changeset
    25
  Infty  ("\<infinity>")
wenzelm
parents: 15140
diff changeset
    26
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
    27
31084
f4db921165ce fixed HOLCF proofs
nipkow
parents: 31077
diff changeset
    28
lemma not_Infty_eq[iff]: "(x ~= Infty) = (EX i. x = Fin i)"
f4db921165ce fixed HOLCF proofs
nipkow
parents: 31077
diff changeset
    29
by (cases x) auto
f4db921165ce fixed HOLCF proofs
nipkow
parents: 31077
diff changeset
    30
f4db921165ce fixed HOLCF proofs
nipkow
parents: 31077
diff changeset
    31
lemma not_Fin_eq [iff]: "(ALL y. x ~= Fin y) = (x = Infty)"
31077
28dd6fd3d184 more lemmas
nipkow
parents: 30663
diff changeset
    32
by (cases x) auto
28dd6fd3d184 more lemmas
nipkow
parents: 30663
diff changeset
    33
28dd6fd3d184 more lemmas
nipkow
parents: 30663
diff changeset
    34
41855
c3b6e69da386 added a few lemmas by Andreas Lochbihler
nipkow
parents: 41853
diff changeset
    35
primrec the_Fin :: "inat \<Rightarrow> nat"
c3b6e69da386 added a few lemmas by Andreas Lochbihler
nipkow
parents: 41853
diff changeset
    36
where "the_Fin (Fin n) = n"
c3b6e69da386 added a few lemmas by Andreas Lochbihler
nipkow
parents: 41853
diff changeset
    37
c3b6e69da386 added a few lemmas by Andreas Lochbihler
nipkow
parents: 41853
diff changeset
    38
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    39
subsection {* Constructors and numbers *}
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    40
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    41
instantiation inat :: "{zero, one, number}"
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 25134
diff changeset
    42
begin
43c718438f9f switched import from Main to PreList
haftmann
parents: 25134
diff changeset
    43
43c718438f9f switched import from Main to PreList
haftmann
parents: 25134
diff changeset
    44
definition
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    45
  "0 = Fin 0"
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 25134
diff changeset
    46
43c718438f9f switched import from Main to PreList
haftmann
parents: 25134
diff changeset
    47
definition
32069
6d28bbd33e2c prefer code_inline over code_unfold; use code_unfold_post where appropriate
haftmann
parents: 31998
diff changeset
    48
  [code_unfold]: "1 = Fin 1"
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 25134
diff changeset
    49
43c718438f9f switched import from Main to PreList
haftmann
parents: 25134
diff changeset
    50
definition
32069
6d28bbd33e2c prefer code_inline over code_unfold; use code_unfold_post where appropriate
haftmann
parents: 31998
diff changeset
    51
  [code_unfold, code del]: "number_of k = Fin (number_of k)"
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
    52
25594
43c718438f9f switched import from Main to PreList
haftmann
parents: 25134
diff changeset
    53
instance ..
43c718438f9f switched import from Main to PreList
haftmann
parents: 25134
diff changeset
    54
43c718438f9f switched import from Main to PreList
haftmann
parents: 25134
diff changeset
    55
end
43c718438f9f switched import from Main to PreList
haftmann
parents: 25134
diff changeset
    56
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    57
definition iSuc :: "inat \<Rightarrow> inat" where
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    58
  "iSuc i = (case i of Fin n \<Rightarrow> Fin (Suc n) | \<infinity> \<Rightarrow> \<infinity>)"
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
    59
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
    60
lemma Fin_0: "Fin 0 = 0"
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    61
  by (simp add: zero_inat_def)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    62
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    63
lemma Fin_1: "Fin 1 = 1"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    64
  by (simp add: one_inat_def)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    65
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    66
lemma Fin_number: "Fin (number_of k) = number_of k"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    67
  by (simp add: number_of_inat_def)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    68
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    69
lemma one_iSuc: "1 = iSuc 0"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    70
  by (simp add: zero_inat_def one_inat_def iSuc_def)
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
    71
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
    72
lemma Infty_ne_i0 [simp]: "\<infinity> \<noteq> 0"
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    73
  by (simp add: zero_inat_def)
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
    74
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
    75
lemma i0_ne_Infty [simp]: "0 \<noteq> \<infinity>"
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    76
  by (simp add: zero_inat_def)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    77
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    78
lemma zero_inat_eq [simp]:
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    79
  "number_of k = (0\<Colon>inat) \<longleftrightarrow> number_of k = (0\<Colon>nat)"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    80
  "(0\<Colon>inat) = number_of k \<longleftrightarrow> number_of k = (0\<Colon>nat)"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    81
  unfolding zero_inat_def number_of_inat_def by simp_all
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    82
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    83
lemma one_inat_eq [simp]:
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    84
  "number_of k = (1\<Colon>inat) \<longleftrightarrow> number_of k = (1\<Colon>nat)"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    85
  "(1\<Colon>inat) = number_of k \<longleftrightarrow> number_of k = (1\<Colon>nat)"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    86
  unfolding one_inat_def number_of_inat_def by simp_all
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    87
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    88
lemma zero_one_inat_neq [simp]:
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    89
  "\<not> 0 = (1\<Colon>inat)"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    90
  "\<not> 1 = (0\<Colon>inat)"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    91
  unfolding zero_inat_def one_inat_def by simp_all
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
    92
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    93
lemma Infty_ne_i1 [simp]: "\<infinity> \<noteq> 1"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    94
  by (simp add: one_inat_def)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    95
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    96
lemma i1_ne_Infty [simp]: "1 \<noteq> \<infinity>"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    97
  by (simp add: one_inat_def)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    98
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
    99
lemma Infty_ne_number [simp]: "\<infinity> \<noteq> number_of k"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   100
  by (simp add: number_of_inat_def)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   101
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   102
lemma number_ne_Infty [simp]: "number_of k \<noteq> \<infinity>"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   103
  by (simp add: number_of_inat_def)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   104
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   105
lemma iSuc_Fin: "iSuc (Fin n) = Fin (Suc n)"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   106
  by (simp add: iSuc_def)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   107
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   108
lemma iSuc_number_of: "iSuc (number_of k) = Fin (Suc (number_of k))"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   109
  by (simp add: iSuc_Fin number_of_inat_def)
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   110
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   111
lemma iSuc_Infty [simp]: "iSuc \<infinity> = \<infinity>"
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   112
  by (simp add: iSuc_def)
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   113
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   114
lemma iSuc_ne_0 [simp]: "iSuc n \<noteq> 0"
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   115
  by (simp add: iSuc_def zero_inat_def split: inat.splits)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   116
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   117
lemma zero_ne_iSuc [simp]: "0 \<noteq> iSuc n"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   118
  by (rule iSuc_ne_0 [symmetric])
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   119
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   120
lemma iSuc_inject [simp]: "iSuc m = iSuc n \<longleftrightarrow> m = n"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   121
  by (simp add: iSuc_def split: inat.splits)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   122
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   123
lemma number_of_inat_inject [simp]:
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   124
  "(number_of k \<Colon> inat) = number_of l \<longleftrightarrow> (number_of k \<Colon> nat) = number_of l"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   125
  by (simp add: number_of_inat_def)
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   126
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   127
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   128
subsection {* Addition *}
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   129
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   130
instantiation inat :: comm_monoid_add
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   131
begin
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   132
38167
ab528533db92 help Nitpick
blanchet
parents: 37765
diff changeset
   133
definition [nitpick_simp]:
37765
26bdfb7b680b dropped superfluous [code del]s
haftmann
parents: 35028
diff changeset
   134
  "m + n = (case m of \<infinity> \<Rightarrow> \<infinity> | Fin m \<Rightarrow> (case n of \<infinity> \<Rightarrow> \<infinity> | Fin n \<Rightarrow> Fin (m + n)))"
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   135
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   136
lemma plus_inat_simps [simp, code]:
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   137
  "Fin m + Fin n = Fin (m + n)"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   138
  "\<infinity> + q = \<infinity>"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   139
  "q + \<infinity> = \<infinity>"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   140
  by (simp_all add: plus_inat_def split: inat.splits)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   141
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   142
instance proof
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   143
  fix n m q :: inat
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   144
  show "n + m + q = n + (m + q)"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   145
    by (cases n, auto, cases m, auto, cases q, auto)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   146
  show "n + m = m + n"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   147
    by (cases n, auto, cases m, auto)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   148
  show "0 + n = n"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   149
    by (cases n) (simp_all add: zero_inat_def)
26089
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   150
qed
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   151
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   152
end
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   153
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   154
lemma plus_inat_0 [simp]:
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   155
  "0 + (q\<Colon>inat) = q"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   156
  "(q\<Colon>inat) + 0 = q"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   157
  by (simp_all add: plus_inat_def zero_inat_def split: inat.splits)
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   158
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   159
lemma plus_inat_number [simp]:
29012
9140227dc8c5 change lemmas to avoid using neg
huffman
parents: 28562
diff changeset
   160
  "(number_of k \<Colon> inat) + number_of l = (if k < Int.Pls then number_of l
9140227dc8c5 change lemmas to avoid using neg
huffman
parents: 28562
diff changeset
   161
    else if l < Int.Pls then number_of k else number_of (k + l))"
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   162
  unfolding number_of_inat_def plus_inat_simps nat_arith(1) if_distrib [symmetric, of _ Fin] ..
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   163
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   164
lemma iSuc_number [simp]:
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   165
  "iSuc (number_of k) = (if neg (number_of k \<Colon> int) then 1 else number_of (Int.succ k))"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   166
  unfolding iSuc_number_of
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   167
  unfolding one_inat_def number_of_inat_def Suc_nat_number_of if_distrib [symmetric] ..
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   168
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   169
lemma iSuc_plus_1:
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   170
  "iSuc n = n + 1"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   171
  by (cases n) (simp_all add: iSuc_Fin one_inat_def)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   172
  
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   173
lemma plus_1_iSuc:
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   174
  "1 + q = iSuc q"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   175
  "q + 1 = iSuc q"
41853
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   176
by (simp_all add: iSuc_plus_1 add_ac)
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   177
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   178
lemma iadd_Suc: "iSuc m + n = iSuc (m + n)"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   179
by (simp_all add: iSuc_plus_1 add_ac)
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   180
41853
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   181
lemma iadd_Suc_right: "m + iSuc n = iSuc (m + n)"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   182
by (simp only: add_commute[of m] iadd_Suc)
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   183
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   184
lemma iadd_is_0: "(m + n = (0::inat)) = (m = 0 \<and> n = 0)"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   185
by (cases m, cases n, simp_all add: zero_inat_def)
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   186
29014
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   187
subsection {* Multiplication *}
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   188
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   189
instantiation inat :: comm_semiring_1
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   190
begin
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   191
38167
ab528533db92 help Nitpick
blanchet
parents: 37765
diff changeset
   192
definition times_inat_def [nitpick_simp]:
29014
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   193
  "m * n = (case m of \<infinity> \<Rightarrow> if n = 0 then 0 else \<infinity> | Fin m \<Rightarrow>
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   194
    (case n of \<infinity> \<Rightarrow> if m = 0 then 0 else \<infinity> | Fin n \<Rightarrow> Fin (m * n)))"
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   195
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   196
lemma times_inat_simps [simp, code]:
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   197
  "Fin m * Fin n = Fin (m * n)"
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   198
  "\<infinity> * \<infinity> = \<infinity>"
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   199
  "\<infinity> * Fin n = (if n = 0 then 0 else \<infinity>)"
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   200
  "Fin m * \<infinity> = (if m = 0 then 0 else \<infinity>)"
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   201
  unfolding times_inat_def zero_inat_def
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   202
  by (simp_all split: inat.split)
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   203
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   204
instance proof
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   205
  fix a b c :: inat
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   206
  show "(a * b) * c = a * (b * c)"
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   207
    unfolding times_inat_def zero_inat_def
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   208
    by (simp split: inat.split)
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   209
  show "a * b = b * a"
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   210
    unfolding times_inat_def zero_inat_def
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   211
    by (simp split: inat.split)
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   212
  show "1 * a = a"
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   213
    unfolding times_inat_def zero_inat_def one_inat_def
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   214
    by (simp split: inat.split)
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   215
  show "(a + b) * c = a * c + b * c"
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   216
    unfolding times_inat_def zero_inat_def
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   217
    by (simp split: inat.split add: left_distrib)
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   218
  show "0 * a = 0"
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   219
    unfolding times_inat_def zero_inat_def
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   220
    by (simp split: inat.split)
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   221
  show "a * 0 = 0"
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   222
    unfolding times_inat_def zero_inat_def
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   223
    by (simp split: inat.split)
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   224
  show "(0::inat) \<noteq> 1"
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   225
    unfolding zero_inat_def one_inat_def
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   226
    by simp
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   227
qed
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   228
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   229
end
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   230
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   231
lemma mult_iSuc: "iSuc m * n = n + m * n"
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29337
diff changeset
   232
  unfolding iSuc_plus_1 by (simp add: algebra_simps)
29014
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   233
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   234
lemma mult_iSuc_right: "m * iSuc n = m + m * n"
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29337
diff changeset
   235
  unfolding iSuc_plus_1 by (simp add: algebra_simps)
29014
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   236
29023
ef3adebc6d98 instance inat :: semiring_char_0
huffman
parents: 29014
diff changeset
   237
lemma of_nat_eq_Fin: "of_nat n = Fin n"
ef3adebc6d98 instance inat :: semiring_char_0
huffman
parents: 29014
diff changeset
   238
  apply (induct n)
ef3adebc6d98 instance inat :: semiring_char_0
huffman
parents: 29014
diff changeset
   239
  apply (simp add: Fin_0)
ef3adebc6d98 instance inat :: semiring_char_0
huffman
parents: 29014
diff changeset
   240
  apply (simp add: plus_1_iSuc iSuc_Fin)
ef3adebc6d98 instance inat :: semiring_char_0
huffman
parents: 29014
diff changeset
   241
  done
ef3adebc6d98 instance inat :: semiring_char_0
huffman
parents: 29014
diff changeset
   242
38621
d6cb7e625d75 more concise characterization of of_nat operation and class semiring_char_0
haftmann
parents: 38167
diff changeset
   243
instance inat :: semiring_char_0 proof
d6cb7e625d75 more concise characterization of of_nat operation and class semiring_char_0
haftmann
parents: 38167
diff changeset
   244
  have "inj Fin" by (rule injI) simp
d6cb7e625d75 more concise characterization of of_nat operation and class semiring_char_0
haftmann
parents: 38167
diff changeset
   245
  then show "inj (\<lambda>n. of_nat n :: inat)" by (simp add: of_nat_eq_Fin)
d6cb7e625d75 more concise characterization of of_nat operation and class semiring_char_0
haftmann
parents: 38167
diff changeset
   246
qed
29023
ef3adebc6d98 instance inat :: semiring_char_0
huffman
parents: 29014
diff changeset
   247
41853
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   248
lemma imult_is_0[simp]: "((m::inat) * n = 0) = (m = 0 \<or> n = 0)"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   249
by(auto simp add: times_inat_def zero_inat_def split: inat.split)
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   250
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   251
lemma imult_is_Infty: "((a::inat) * b = \<infinity>) = (a = \<infinity> \<and> b \<noteq> 0 \<or> b = \<infinity> \<and> a \<noteq> 0)"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   252
by(auto simp add: times_inat_def zero_inat_def split: inat.split)
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   253
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   254
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   255
subsection {* Subtraction *}
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   256
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   257
instantiation inat :: minus
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   258
begin
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   259
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   260
definition diff_inat_def:
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   261
"a - b = (case a of (Fin x) \<Rightarrow> (case b of (Fin y) \<Rightarrow> Fin (x - y) | \<infinity> \<Rightarrow> 0)
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   262
          | \<infinity> \<Rightarrow> \<infinity>)"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   263
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   264
instance ..
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   265
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   266
end
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   267
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   268
lemma idiff_Fin_Fin[simp,code]: "Fin a - Fin b = Fin (a - b)"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   269
by(simp add: diff_inat_def)
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   270
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   271
lemma idiff_Infty[simp,code]: "\<infinity> - n = \<infinity>"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   272
by(simp add: diff_inat_def)
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   273
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   274
lemma idiff_Infty_right[simp,code]: "Fin a - \<infinity> = 0"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   275
by(simp add: diff_inat_def)
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   276
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   277
lemma idiff_0[simp]: "(0::inat) - n = 0"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   278
by (cases n, simp_all add: zero_inat_def)
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   279
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   280
lemmas idiff_Fin_0[simp] = idiff_0[unfolded zero_inat_def]
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   281
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   282
lemma idiff_0_right[simp]: "(n::inat) - 0 = n"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   283
by (cases n) (simp_all add: zero_inat_def)
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   284
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   285
lemmas idiff_Fin_0_right[simp] = idiff_0_right[unfolded zero_inat_def]
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   286
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   287
lemma idiff_self[simp]: "n \<noteq> \<infinity> \<Longrightarrow> (n::inat) - n = 0"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   288
by(auto simp: zero_inat_def)
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   289
41855
c3b6e69da386 added a few lemmas by Andreas Lochbihler
nipkow
parents: 41853
diff changeset
   290
lemma iSuc_minus_iSuc [simp]: "iSuc n - iSuc m = n - m"
c3b6e69da386 added a few lemmas by Andreas Lochbihler
nipkow
parents: 41853
diff changeset
   291
by(simp add: iSuc_def split: inat.split)
c3b6e69da386 added a few lemmas by Andreas Lochbihler
nipkow
parents: 41853
diff changeset
   292
c3b6e69da386 added a few lemmas by Andreas Lochbihler
nipkow
parents: 41853
diff changeset
   293
lemma iSuc_minus_1 [simp]: "iSuc n - 1 = n"
c3b6e69da386 added a few lemmas by Andreas Lochbihler
nipkow
parents: 41853
diff changeset
   294
by(simp add: one_inat_def iSuc_Fin[symmetric] zero_inat_def[symmetric])
c3b6e69da386 added a few lemmas by Andreas Lochbihler
nipkow
parents: 41853
diff changeset
   295
41853
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   296
(*lemmas idiff_self_eq_0_Fin = idiff_self_eq_0[unfolded zero_inat_def]*)
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   297
29014
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   298
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   299
subsection {* Ordering *}
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   300
35028
108662d50512 more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents: 32069
diff changeset
   301
instantiation inat :: linordered_ab_semigroup_add
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   302
begin
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   303
38167
ab528533db92 help Nitpick
blanchet
parents: 37765
diff changeset
   304
definition [nitpick_simp]:
37765
26bdfb7b680b dropped superfluous [code del]s
haftmann
parents: 35028
diff changeset
   305
  "m \<le> n = (case n of Fin n1 \<Rightarrow> (case m of Fin m1 \<Rightarrow> m1 \<le> n1 | \<infinity> \<Rightarrow> False)
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   306
    | \<infinity> \<Rightarrow> True)"
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   307
38167
ab528533db92 help Nitpick
blanchet
parents: 37765
diff changeset
   308
definition [nitpick_simp]:
37765
26bdfb7b680b dropped superfluous [code del]s
haftmann
parents: 35028
diff changeset
   309
  "m < n = (case m of Fin m1 \<Rightarrow> (case n of Fin n1 \<Rightarrow> m1 < n1 | \<infinity> \<Rightarrow> True)
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   310
    | \<infinity> \<Rightarrow> False)"
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   311
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   312
lemma inat_ord_simps [simp]:
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   313
  "Fin m \<le> Fin n \<longleftrightarrow> m \<le> n"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   314
  "Fin m < Fin n \<longleftrightarrow> m < n"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   315
  "q \<le> \<infinity>"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   316
  "q < \<infinity> \<longleftrightarrow> q \<noteq> \<infinity>"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   317
  "\<infinity> \<le> q \<longleftrightarrow> q = \<infinity>"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   318
  "\<infinity> < q \<longleftrightarrow> False"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   319
  by (simp_all add: less_eq_inat_def less_inat_def split: inat.splits)
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   320
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   321
lemma inat_ord_code [code]:
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   322
  "Fin m \<le> Fin n \<longleftrightarrow> m \<le> n"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   323
  "Fin m < Fin n \<longleftrightarrow> m < n"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   324
  "q \<le> \<infinity> \<longleftrightarrow> True"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   325
  "Fin m < \<infinity> \<longleftrightarrow> True"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   326
  "\<infinity> \<le> Fin n \<longleftrightarrow> False"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   327
  "\<infinity> < q \<longleftrightarrow> False"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   328
  by simp_all
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   329
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   330
instance by default
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   331
  (auto simp add: less_eq_inat_def less_inat_def plus_inat_def split: inat.splits)
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   332
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   333
end
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   334
35028
108662d50512 more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents: 32069
diff changeset
   335
instance inat :: ordered_comm_semiring
29014
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   336
proof
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   337
  fix a b c :: inat
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   338
  assume "a \<le> b" and "0 \<le> c"
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   339
  thus "c * a \<le> c * b"
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   340
    unfolding times_inat_def less_eq_inat_def zero_inat_def
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   341
    by (simp split: inat.splits)
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   342
qed
e515f42d1db7 multiplication for type inat
huffman
parents: 29012
diff changeset
   343
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   344
lemma inat_ord_number [simp]:
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   345
  "(number_of m \<Colon> inat) \<le> number_of n \<longleftrightarrow> (number_of m \<Colon> nat) \<le> number_of n"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   346
  "(number_of m \<Colon> inat) < number_of n \<longleftrightarrow> (number_of m \<Colon> nat) < number_of n"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   347
  by (simp_all add: number_of_inat_def)
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   348
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   349
lemma i0_lb [simp]: "(0\<Colon>inat) \<le> n"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   350
  by (simp add: zero_inat_def less_eq_inat_def split: inat.splits)
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   351
41853
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   352
lemma ile0_eq [simp]: "n \<le> (0\<Colon>inat) \<longleftrightarrow> n = 0"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   353
by (simp add: zero_inat_def less_eq_inat_def split: inat.splits)
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   354
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   355
lemma Infty_ileE [elim!]: "\<infinity> \<le> Fin m \<Longrightarrow> R"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   356
  by (simp add: zero_inat_def less_eq_inat_def split: inat.splits)
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   357
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   358
lemma Infty_ilessE [elim!]: "\<infinity> < Fin m \<Longrightarrow> R"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   359
  by simp
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   360
41853
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   361
lemma not_iless0 [simp]: "\<not> n < (0\<Colon>inat)"
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   362
  by (simp add: zero_inat_def less_inat_def split: inat.splits)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   363
41853
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   364
lemma i0_less [simp]: "(0\<Colon>inat) < n \<longleftrightarrow> n \<noteq> 0"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   365
by (simp add: zero_inat_def less_inat_def split: inat.splits)
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   366
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   367
lemma iSuc_ile_mono [simp]: "iSuc n \<le> iSuc m \<longleftrightarrow> n \<le> m"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   368
  by (simp add: iSuc_def less_eq_inat_def split: inat.splits)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   369
 
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   370
lemma iSuc_mono [simp]: "iSuc n < iSuc m \<longleftrightarrow> n < m"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   371
  by (simp add: iSuc_def less_inat_def split: inat.splits)
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   372
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   373
lemma ile_iSuc [simp]: "n \<le> iSuc n"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   374
  by (simp add: iSuc_def less_eq_inat_def split: inat.splits)
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   375
11355
wenzelm
parents: 11351
diff changeset
   376
lemma not_iSuc_ilei0 [simp]: "\<not> iSuc n \<le> 0"
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   377
  by (simp add: zero_inat_def iSuc_def less_eq_inat_def split: inat.splits)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   378
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   379
lemma i0_iless_iSuc [simp]: "0 < iSuc n"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   380
  by (simp add: zero_inat_def iSuc_def less_inat_def split: inat.splits)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   381
41853
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   382
lemma iless_iSuc0[simp]: "(n < iSuc 0) = (n = 0)"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   383
by (simp add: zero_inat_def iSuc_def less_inat_def split: inat.split)
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   384
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   385
lemma ileI1: "m < n \<Longrightarrow> iSuc m \<le> n"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   386
  by (simp add: iSuc_def less_eq_inat_def less_inat_def split: inat.splits)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   387
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   388
lemma Suc_ile_eq: "Fin (Suc m) \<le> n \<longleftrightarrow> Fin m < n"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   389
  by (cases n) auto
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   390
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   391
lemma iless_Suc_eq [simp]: "Fin m < iSuc n \<longleftrightarrow> Fin m \<le> n"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   392
  by (auto simp add: iSuc_def less_inat_def split: inat.splits)
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   393
41853
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   394
lemma imult_Infty: "(0::inat) < n \<Longrightarrow> \<infinity> * n = \<infinity>"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   395
by (simp add: zero_inat_def less_inat_def split: inat.splits)
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   396
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   397
lemma imult_Infty_right: "(0::inat) < n \<Longrightarrow> n * \<infinity> = \<infinity>"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   398
by (simp add: zero_inat_def less_inat_def split: inat.splits)
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   399
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   400
lemma inat_0_less_mult_iff: "(0 < (m::inat) * n) = (0 < m \<and> 0 < n)"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   401
by (simp only: i0_less imult_is_0, simp)
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   402
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   403
lemma mono_iSuc: "mono iSuc"
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   404
by(simp add: mono_def)
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   405
258a489c24b2 Added material by David Trachtenherz
nipkow
parents: 38621
diff changeset
   406
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   407
lemma min_inat_simps [simp]:
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   408
  "min (Fin m) (Fin n) = Fin (min m n)"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   409
  "min q 0 = 0"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   410
  "min 0 q = 0"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   411
  "min q \<infinity> = q"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   412
  "min \<infinity> q = q"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   413
  by (auto simp add: min_def)
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   414
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   415
lemma max_inat_simps [simp]:
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   416
  "max (Fin m) (Fin n) = Fin (max m n)"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   417
  "max q 0 = q"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   418
  "max 0 q = q"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   419
  "max q \<infinity> = \<infinity>"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   420
  "max \<infinity> q = \<infinity>"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   421
  by (simp_all add: max_def)
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   422
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   423
lemma Fin_ile: "n \<le> Fin m \<Longrightarrow> \<exists>k. n = Fin k"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   424
  by (cases n) simp_all
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   425
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   426
lemma Fin_iless: "n < Fin m \<Longrightarrow> \<exists>k. n = Fin k"
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   427
  by (cases n) simp_all
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   428
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   429
lemma chain_incr: "\<forall>i. \<exists>j. Y i < Y j ==> \<exists>j. Fin k < Y j"
25134
3d4953e88449 Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents: 25112
diff changeset
   430
apply (induct_tac k)
3d4953e88449 Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents: 25112
diff changeset
   431
 apply (simp (no_asm) only: Fin_0)
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   432
 apply (fast intro: le_less_trans [OF i0_lb])
25134
3d4953e88449 Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents: 25112
diff changeset
   433
apply (erule exE)
3d4953e88449 Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents: 25112
diff changeset
   434
apply (drule spec)
3d4953e88449 Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents: 25112
diff changeset
   435
apply (erule exE)
3d4953e88449 Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents: 25112
diff changeset
   436
apply (drule ileI1)
3d4953e88449 Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents: 25112
diff changeset
   437
apply (rule iSuc_Fin [THEN subst])
3d4953e88449 Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents: 25112
diff changeset
   438
apply (rule exI)
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   439
apply (erule (1) le_less_trans)
25134
3d4953e88449 Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents: 25112
diff changeset
   440
done
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   441
29337
450805a4a91f added instance for bot, top
haftmann
parents: 29023
diff changeset
   442
instantiation inat :: "{bot, top}"
450805a4a91f added instance for bot, top
haftmann
parents: 29023
diff changeset
   443
begin
450805a4a91f added instance for bot, top
haftmann
parents: 29023
diff changeset
   444
450805a4a91f added instance for bot, top
haftmann
parents: 29023
diff changeset
   445
definition bot_inat :: inat where
450805a4a91f added instance for bot, top
haftmann
parents: 29023
diff changeset
   446
  "bot_inat = 0"
450805a4a91f added instance for bot, top
haftmann
parents: 29023
diff changeset
   447
450805a4a91f added instance for bot, top
haftmann
parents: 29023
diff changeset
   448
definition top_inat :: inat where
450805a4a91f added instance for bot, top
haftmann
parents: 29023
diff changeset
   449
  "top_inat = \<infinity>"
450805a4a91f added instance for bot, top
haftmann
parents: 29023
diff changeset
   450
450805a4a91f added instance for bot, top
haftmann
parents: 29023
diff changeset
   451
instance proof
450805a4a91f added instance for bot, top
haftmann
parents: 29023
diff changeset
   452
qed (simp_all add: bot_inat_def top_inat_def)
450805a4a91f added instance for bot, top
haftmann
parents: 29023
diff changeset
   453
450805a4a91f added instance for bot, top
haftmann
parents: 29023
diff changeset
   454
end
450805a4a91f added instance for bot, top
haftmann
parents: 29023
diff changeset
   455
42993
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   456
lemma finite_Fin_bounded:
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   457
  assumes le_fin: "\<And>y. y \<in> A \<Longrightarrow> y \<le> Fin n"
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   458
  shows "finite A"
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   459
proof (rule finite_subset)
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   460
  show "finite (Fin ` {..n})" by blast
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   461
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   462
  have "A \<subseteq> {..Fin n}" using le_fin by fastsimp
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   463
  also have "\<dots> \<subseteq> Fin ` {..n}"
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   464
    by (rule subsetI) (case_tac x, auto)
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   465
  finally show "A \<subseteq> Fin ` {..n}" .
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   466
qed
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   467
26089
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   468
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   469
subsection {* Well-ordering *}
26089
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   470
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   471
lemma less_FinE:
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   472
  "[| n < Fin m; !!k. n = Fin k ==> k < m ==> P |] ==> P"
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   473
by (induct n) auto
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   474
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   475
lemma less_InftyE:
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   476
  "[| n < Infty; !!k. n = Fin k ==> P |] ==> P"
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   477
by (induct n) auto
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   478
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   479
lemma inat_less_induct:
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   480
  assumes prem: "!!n. \<forall>m::inat. m < n --> P m ==> P n" shows "P n"
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   481
proof -
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   482
  have P_Fin: "!!k. P (Fin k)"
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   483
    apply (rule nat_less_induct)
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   484
    apply (rule prem, clarify)
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   485
    apply (erule less_FinE, simp)
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   486
    done
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   487
  show ?thesis
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   488
  proof (induct n)
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   489
    fix nat
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   490
    show "P (Fin nat)" by (rule P_Fin)
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   491
  next
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   492
    show "P Infty"
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   493
      apply (rule prem, clarify)
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   494
      apply (erule less_InftyE)
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   495
      apply (simp add: P_Fin)
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   496
      done
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   497
  qed
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   498
qed
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   499
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   500
instance inat :: wellorder
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   501
proof
27823
52971512d1a2 moved class wellorder to theory Orderings
haftmann
parents: 27487
diff changeset
   502
  fix P and n
52971512d1a2 moved class wellorder to theory Orderings
haftmann
parents: 27487
diff changeset
   503
  assume hyp: "(\<And>n\<Colon>inat. (\<And>m\<Colon>inat. m < n \<Longrightarrow> P m) \<Longrightarrow> P n)"
52971512d1a2 moved class wellorder to theory Orderings
haftmann
parents: 27487
diff changeset
   504
  show "P n" by (blast intro: inat_less_induct hyp)
26089
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   505
qed
373221497340 proved linorder and wellorder class instances
huffman
parents: 25691
diff changeset
   506
42993
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   507
subsection {* Complete Lattice *}
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   508
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   509
instantiation inat :: complete_lattice
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   510
begin
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   511
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   512
definition inf_inat :: "inat \<Rightarrow> inat \<Rightarrow> inat" where
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   513
  "inf_inat \<equiv> min"
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   514
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   515
definition sup_inat :: "inat \<Rightarrow> inat \<Rightarrow> inat" where
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   516
  "sup_inat \<equiv> max"
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   517
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   518
definition Inf_inat :: "inat set \<Rightarrow> inat" where
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   519
  "Inf_inat A \<equiv> if A = {} then \<infinity> else (LEAST x. x \<in> A)"
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   520
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   521
definition Sup_inat :: "inat set \<Rightarrow> inat" where
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   522
  "Sup_inat A \<equiv> if A = {} then 0
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   523
    else if finite A then Max A
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   524
                     else \<infinity>"
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   525
instance proof
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   526
  fix x :: "inat" and A :: "inat set"
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   527
  { assume "x \<in> A" then show "Inf A \<le> x"
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   528
      unfolding Inf_inat_def by (auto intro: Least_le) }
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   529
  { assume "\<And>y. y \<in> A \<Longrightarrow> x \<le> y" then show "x \<le> Inf A"
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   530
      unfolding Inf_inat_def
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   531
      by (cases "A = {}") (auto intro: LeastI2_ex) }
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   532
  { assume "x \<in> A" then show "x \<le> Sup A"
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   533
      unfolding Sup_inat_def by (cases "finite A") auto }
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   534
  { assume "\<And>y. y \<in> A \<Longrightarrow> y \<le> x" then show "Sup A \<le> x"
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   535
      unfolding Sup_inat_def using finite_Fin_bounded by auto }
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   536
qed (simp_all add: inf_inat_def sup_inat_def)
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   537
end
da014b00d7a4 instance inat for complete_lattice
noschinl
parents: 41855
diff changeset
   538
27110
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   539
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   540
subsection {* Traditional theorem names *}
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   541
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   542
lemmas inat_defs = zero_inat_def one_inat_def number_of_inat_def iSuc_def
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   543
  plus_inat_def less_eq_inat_def less_inat_def
194aa674c2a1 refactoring; addition, numerals
haftmann
parents: 26089
diff changeset
   544
11351
c5c403d30c77 added Library/Nat_Infinity.thy and Library/Continuity.thy
oheimb
parents:
diff changeset
   545
end