src/HOL/Library/Infinite_Set.thy
author huffman
Thu, 17 Dec 2009 09:33:30 -0800
changeset 34112 ca842111d698
parent 30663 0b6aff7451b2
child 34113 dbc0fb6e7eae
permissions -rw-r--r--
added lemmas about INFM/MOST
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27407
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
     1
(*  Title:      HOL/Library/Infinite_Set.thy
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
     2
    Author:     Stephan Merz
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
     3
*)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
     4
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
     5
header {* Infinite Sets and Related Concepts *}
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
     6
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
     7
theory Infinite_Set
30663
0b6aff7451b2 Main is (Complex_Main) base entry point in library theories
haftmann
parents: 29901
diff changeset
     8
imports Main
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
     9
begin
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    10
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    11
subsection "Infinite Sets"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    12
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    13
text {*
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    14
  Some elementary facts about infinite sets, mostly by Stefan Merz.
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    15
  Beware! Because "infinite" merely abbreviates a negation, these
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    16
  lemmas may not work well with @{text "blast"}.
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    17
*}
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    18
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    19
abbreviation
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21256
diff changeset
    20
  infinite :: "'a set \<Rightarrow> bool" where
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    21
  "infinite S == \<not> finite S"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    22
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    23
text {*
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    24
  Infinite sets are non-empty, and if we remove some elements from an
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    25
  infinite set, the result is still infinite.
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    26
*}
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    27
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    28
lemma infinite_imp_nonempty: "infinite S ==> S \<noteq> {}"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    29
  by auto
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    30
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    31
lemma infinite_remove:
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    32
  "infinite S \<Longrightarrow> infinite (S - {a})"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    33
  by simp
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    34
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    35
lemma Diff_infinite_finite:
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    36
  assumes T: "finite T" and S: "infinite S"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    37
  shows "infinite (S - T)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    38
  using T
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    39
proof induct
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    40
  from S
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    41
  show "infinite (S - {})" by auto
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    42
next
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    43
  fix T x
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    44
  assume ih: "infinite (S - T)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    45
  have "S - (insert x T) = (S - T) - {x}"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    46
    by (rule Diff_insert)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    47
  with ih
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    48
  show "infinite (S - (insert x T))"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    49
    by (simp add: infinite_remove)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    50
qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    51
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    52
lemma Un_infinite: "infinite S \<Longrightarrow> infinite (S \<union> T)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    53
  by simp
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    54
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    55
lemma infinite_super:
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    56
  assumes T: "S \<subseteq> T" and S: "infinite S"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    57
  shows "infinite T"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    58
proof
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    59
  assume "finite T"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    60
  with T have "finite S" by (simp add: finite_subset)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    61
  with S show False by simp
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    62
qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    63
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    64
text {*
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    65
  As a concrete example, we prove that the set of natural numbers is
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    66
  infinite.
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    67
*}
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    68
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    69
lemma finite_nat_bounded:
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    70
  assumes S: "finite (S::nat set)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    71
  shows "\<exists>k. S \<subseteq> {..<k}"  (is "\<exists>k. ?bounded S k")
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    72
using S
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    73
proof induct
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    74
  have "?bounded {} 0" by simp
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    75
  then show "\<exists>k. ?bounded {} k" ..
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    76
next
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    77
  fix S x
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    78
  assume "\<exists>k. ?bounded S k"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    79
  then obtain k where k: "?bounded S k" ..
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    80
  show "\<exists>k. ?bounded (insert x S) k"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    81
  proof (cases "x < k")
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    82
    case True
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    83
    with k show ?thesis by auto
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    84
  next
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    85
    case False
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    86
    with k have "?bounded S (Suc x)" by auto
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    87
    then show ?thesis by auto
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    88
  qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    89
qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    90
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    91
lemma finite_nat_iff_bounded:
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    92
  "finite (S::nat set) = (\<exists>k. S \<subseteq> {..<k})"  (is "?lhs = ?rhs")
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    93
proof
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    94
  assume ?lhs
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    95
  then show ?rhs by (rule finite_nat_bounded)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    96
next
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    97
  assume ?rhs
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    98
  then obtain k where "S \<subseteq> {..<k}" ..
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    99
  then show "finite S"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   100
    by (rule finite_subset) simp
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   101
qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   102
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   103
lemma finite_nat_iff_bounded_le:
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   104
  "finite (S::nat set) = (\<exists>k. S \<subseteq> {..k})"  (is "?lhs = ?rhs")
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   105
proof
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   106
  assume ?lhs
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   107
  then obtain k where "S \<subseteq> {..<k}"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   108
    by (blast dest: finite_nat_bounded)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   109
  then have "S \<subseteq> {..k}" by auto
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   110
  then show ?rhs ..
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   111
next
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   112
  assume ?rhs
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   113
  then obtain k where "S \<subseteq> {..k}" ..
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   114
  then show "finite S"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   115
    by (rule finite_subset) simp
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   116
qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   117
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   118
lemma infinite_nat_iff_unbounded:
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   119
  "infinite (S::nat set) = (\<forall>m. \<exists>n. m<n \<and> n\<in>S)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   120
  (is "?lhs = ?rhs")
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   121
proof
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   122
  assume ?lhs
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   123
  show ?rhs
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   124
  proof (rule ccontr)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   125
    assume "\<not> ?rhs"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   126
    then obtain m where m: "\<forall>n. m<n \<longrightarrow> n\<notin>S" by blast
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   127
    then have "S \<subseteq> {..m}"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   128
      by (auto simp add: sym [OF linorder_not_less])
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   129
    with `?lhs` show False
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   130
      by (simp add: finite_nat_iff_bounded_le)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   131
  qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   132
next
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   133
  assume ?rhs
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   134
  show ?lhs
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   135
  proof
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   136
    assume "finite S"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   137
    then obtain m where "S \<subseteq> {..m}"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   138
      by (auto simp add: finite_nat_iff_bounded_le)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   139
    then have "\<forall>n. m<n \<longrightarrow> n\<notin>S" by auto
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   140
    with `?rhs` show False by blast
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   141
  qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   142
qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   143
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   144
lemma infinite_nat_iff_unbounded_le:
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   145
  "infinite (S::nat set) = (\<forall>m. \<exists>n. m\<le>n \<and> n\<in>S)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   146
  (is "?lhs = ?rhs")
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   147
proof
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   148
  assume ?lhs
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   149
  show ?rhs
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   150
  proof
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   151
    fix m
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   152
    from `?lhs` obtain n where "m<n \<and> n\<in>S"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   153
      by (auto simp add: infinite_nat_iff_unbounded)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   154
    then have "m\<le>n \<and> n\<in>S" by simp
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   155
    then show "\<exists>n. m \<le> n \<and> n \<in> S" ..
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   156
  qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   157
next
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   158
  assume ?rhs
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   159
  show ?lhs
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   160
  proof (auto simp add: infinite_nat_iff_unbounded)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   161
    fix m
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   162
    from `?rhs` obtain n where "Suc m \<le> n \<and> n\<in>S"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   163
      by blast
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   164
    then have "m<n \<and> n\<in>S" by simp
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   165
    then show "\<exists>n. m < n \<and> n \<in> S" ..
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   166
  qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   167
qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   168
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   169
text {*
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   170
  For a set of natural numbers to be infinite, it is enough to know
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   171
  that for any number larger than some @{text k}, there is some larger
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   172
  number that is an element of the set.
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   173
*}
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   174
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   175
lemma unbounded_k_infinite:
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   176
  assumes k: "\<forall>m. k<m \<longrightarrow> (\<exists>n. m<n \<and> n\<in>S)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   177
  shows "infinite (S::nat set)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   178
proof -
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   179
  {
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   180
    fix m have "\<exists>n. m<n \<and> n\<in>S"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   181
    proof (cases "k<m")
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   182
      case True
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   183
      with k show ?thesis by blast
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   184
    next
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   185
      case False
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   186
      from k obtain n where "Suc k < n \<and> n\<in>S" by auto
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   187
      with False have "m<n \<and> n\<in>S" by auto
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   188
      then show ?thesis ..
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   189
    qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   190
  }
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   191
  then show ?thesis
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   192
    by (auto simp add: infinite_nat_iff_unbounded)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   193
qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   194
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   195
lemma nat_infinite [simp]: "infinite (UNIV :: nat set)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   196
  by (auto simp add: infinite_nat_iff_unbounded)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   197
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   198
lemma nat_not_finite [elim]: "finite (UNIV::nat set) \<Longrightarrow> R"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   199
  by simp
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   200
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   201
text {*
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   202
  Every infinite set contains a countable subset. More precisely we
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   203
  show that a set @{text S} is infinite if and only if there exists an
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   204
  injective function from the naturals into @{text S}.
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   205
*}
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   206
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   207
lemma range_inj_infinite:
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   208
  "inj (f::nat \<Rightarrow> 'a) \<Longrightarrow> infinite (range f)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   209
proof
27407
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   210
  assume "finite (range f)" and "inj f"
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   211
  then have "finite (UNIV::nat set)"
27407
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   212
    by (rule finite_imageD)
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   213
  then show False by simp
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   214
qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   215
22226
699385e6cb45 new theorem int_infinite
paulson
parents: 21404
diff changeset
   216
lemma int_infinite [simp]:
699385e6cb45 new theorem int_infinite
paulson
parents: 21404
diff changeset
   217
  shows "infinite (UNIV::int set)"
699385e6cb45 new theorem int_infinite
paulson
parents: 21404
diff changeset
   218
proof -
699385e6cb45 new theorem int_infinite
paulson
parents: 21404
diff changeset
   219
  from inj_int have "infinite (range int)" by (rule range_inj_infinite)
699385e6cb45 new theorem int_infinite
paulson
parents: 21404
diff changeset
   220
  moreover 
699385e6cb45 new theorem int_infinite
paulson
parents: 21404
diff changeset
   221
  have "range int \<subseteq> (UNIV::int set)" by simp
699385e6cb45 new theorem int_infinite
paulson
parents: 21404
diff changeset
   222
  ultimately show "infinite (UNIV::int set)" by (simp add: infinite_super)
699385e6cb45 new theorem int_infinite
paulson
parents: 21404
diff changeset
   223
qed
699385e6cb45 new theorem int_infinite
paulson
parents: 21404
diff changeset
   224
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   225
text {*
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   226
  The ``only if'' direction is harder because it requires the
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   227
  construction of a sequence of pairwise different elements of an
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   228
  infinite set @{text S}. The idea is to construct a sequence of
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   229
  non-empty and infinite subsets of @{text S} obtained by successively
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   230
  removing elements of @{text S}.
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   231
*}
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   232
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   233
lemma linorder_injI:
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   234
  assumes hyp: "!!x y. x < (y::'a::linorder) ==> f x \<noteq> f y"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   235
  shows "inj f"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   236
proof (rule inj_onI)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   237
  fix x y
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   238
  assume f_eq: "f x = f y"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   239
  show "x = y"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   240
  proof (rule linorder_cases)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   241
    assume "x < y"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   242
    with hyp have "f x \<noteq> f y" by blast
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   243
    with f_eq show ?thesis by simp
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   244
  next
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   245
    assume "x = y"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   246
    then show ?thesis .
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   247
  next
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   248
    assume "y < x"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   249
    with hyp have "f y \<noteq> f x" by blast
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   250
    with f_eq show ?thesis by simp
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   251
  qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   252
qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   253
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   254
lemma infinite_countable_subset:
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   255
  assumes inf: "infinite (S::'a set)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   256
  shows "\<exists>f. inj (f::nat \<Rightarrow> 'a) \<and> range f \<subseteq> S"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   257
proof -
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   258
  def Sseq \<equiv> "nat_rec S (\<lambda>n T. T - {SOME e. e \<in> T})"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   259
  def pick \<equiv> "\<lambda>n. (SOME e. e \<in> Sseq n)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   260
  have Sseq_inf: "\<And>n. infinite (Sseq n)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   261
  proof -
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   262
    fix n
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   263
    show "infinite (Sseq n)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   264
    proof (induct n)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   265
      from inf show "infinite (Sseq 0)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   266
        by (simp add: Sseq_def)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   267
    next
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   268
      fix n
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   269
      assume "infinite (Sseq n)" then show "infinite (Sseq (Suc n))"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   270
        by (simp add: Sseq_def infinite_remove)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   271
    qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   272
  qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   273
  have Sseq_S: "\<And>n. Sseq n \<subseteq> S"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   274
  proof -
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   275
    fix n
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   276
    show "Sseq n \<subseteq> S"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   277
      by (induct n) (auto simp add: Sseq_def)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   278
  qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   279
  have Sseq_pick: "\<And>n. pick n \<in> Sseq n"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   280
  proof -
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   281
    fix n
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   282
    show "pick n \<in> Sseq n"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   283
    proof (unfold pick_def, rule someI_ex)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   284
      from Sseq_inf have "infinite (Sseq n)" .
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   285
      then have "Sseq n \<noteq> {}" by auto
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   286
      then show "\<exists>x. x \<in> Sseq n" by auto
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   287
    qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   288
  qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   289
  with Sseq_S have rng: "range pick \<subseteq> S"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   290
    by auto
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   291
  have pick_Sseq_gt: "\<And>n m. pick n \<notin> Sseq (n + Suc m)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   292
  proof -
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   293
    fix n m
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   294
    show "pick n \<notin> Sseq (n + Suc m)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   295
      by (induct m) (auto simp add: Sseq_def pick_def)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   296
  qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   297
  have pick_pick: "\<And>n m. pick n \<noteq> pick (n + Suc m)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   298
  proof -
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   299
    fix n m
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   300
    from Sseq_pick have "pick (n + Suc m) \<in> Sseq (n + Suc m)" .
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   301
    moreover from pick_Sseq_gt
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   302
    have "pick n \<notin> Sseq (n + Suc m)" .
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   303
    ultimately show "pick n \<noteq> pick (n + Suc m)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   304
      by auto
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   305
  qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   306
  have inj: "inj pick"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   307
  proof (rule linorder_injI)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   308
    fix i j :: nat
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   309
    assume "i < j"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   310
    show "pick i \<noteq> pick j"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   311
    proof
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   312
      assume eq: "pick i = pick j"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   313
      from `i < j` obtain k where "j = i + Suc k"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   314
        by (auto simp add: less_iff_Suc_add)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   315
      with pick_pick have "pick i \<noteq> pick j" by simp
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   316
      with eq show False by simp
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   317
    qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   318
  qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   319
  from rng inj show ?thesis by auto
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   320
qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   321
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   322
lemma infinite_iff_countable_subset:
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   323
    "infinite S = (\<exists>f. inj (f::nat \<Rightarrow> 'a) \<and> range f \<subseteq> S)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   324
  by (auto simp add: infinite_countable_subset range_inj_infinite infinite_super)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   325
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   326
text {*
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   327
  For any function with infinite domain and finite range there is some
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   328
  element that is the image of infinitely many domain elements.  In
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   329
  particular, any infinite sequence of elements from a finite set
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   330
  contains some element that occurs infinitely often.
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   331
*}
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   332
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   333
lemma inf_img_fin_dom:
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   334
  assumes img: "finite (f`A)" and dom: "infinite A"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   335
  shows "\<exists>y \<in> f`A. infinite (f -` {y})"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   336
proof (rule ccontr)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   337
  assume "\<not> ?thesis"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   338
  with img have "finite (UN y:f`A. f -` {y})" by (blast intro: finite_UN_I)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   339
  moreover have "A \<subseteq> (UN y:f`A. f -` {y})" by auto
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   340
  moreover note dom
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   341
  ultimately show False by (simp add: infinite_super)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   342
qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   343
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   344
lemma inf_img_fin_domE:
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   345
  assumes "finite (f`A)" and "infinite A"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   346
  obtains y where "y \<in> f`A" and "infinite (f -` {y})"
23394
474ff28210c0 tuned proofs;
wenzelm
parents: 22432
diff changeset
   347
  using assms by (blast dest: inf_img_fin_dom)
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   348
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   349
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   350
subsection "Infinitely Many and Almost All"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   351
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   352
text {*
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   353
  We often need to reason about the existence of infinitely many
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   354
  (resp., all but finitely many) objects satisfying some predicate, so
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   355
  we introduce corresponding binders and their proof rules.
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   356
*}
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   357
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   358
definition
22432
1d00d26fee0d Renamed INF to INFM to avoid clash with INF operator defined in FixedPoint theory.
berghofe
parents: 22226
diff changeset
   359
  Inf_many :: "('a \<Rightarrow> bool) \<Rightarrow> bool"  (binder "INFM " 10) where
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   360
  "Inf_many P = infinite {x. P x}"
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21256
diff changeset
   361
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21256
diff changeset
   362
definition
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21256
diff changeset
   363
  Alm_all :: "('a \<Rightarrow> bool) \<Rightarrow> bool"  (binder "MOST " 10) where
22432
1d00d26fee0d Renamed INF to INFM to avoid clash with INF operator defined in FixedPoint theory.
berghofe
parents: 22226
diff changeset
   364
  "Alm_all P = (\<not> (INFM x. \<not> P x))"
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   365
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 20809
diff changeset
   366
notation (xsymbols)
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21256
diff changeset
   367
  Inf_many  (binder "\<exists>\<^sub>\<infinity>" 10) and
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   368
  Alm_all  (binder "\<forall>\<^sub>\<infinity>" 10)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   369
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 20809
diff changeset
   370
notation (HTML output)
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21256
diff changeset
   371
  Inf_many  (binder "\<exists>\<^sub>\<infinity>" 10) and
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   372
  Alm_all  (binder "\<forall>\<^sub>\<infinity>" 10)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   373
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   374
lemma INFM_iff_infinite: "(INFM x. P x) \<longleftrightarrow> infinite {x. P x}"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   375
  unfolding Inf_many_def ..
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   376
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   377
lemma MOST_iff_cofinite: "(MOST x. P x) \<longleftrightarrow> finite {x. \<not> P x}"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   378
  unfolding Alm_all_def Inf_many_def by simp
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   379
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   380
(* legacy name *)
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   381
lemmas MOST_iff_finiteNeg = MOST_iff_cofinite
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   382
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   383
lemma not_INFM [simp]: "\<not> (INFM x. P x) \<longleftrightarrow> (MOST x. \<not> P x)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   384
  unfolding Alm_all_def not_not ..
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   385
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   386
lemma not_MOST [simp]: "\<not> (MOST x. P x) \<longleftrightarrow> (INFM x. \<not> P x)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   387
  unfolding Alm_all_def not_not ..
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   388
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   389
lemma INFM_const [simp]: "(INFM x::'a. P) \<longleftrightarrow> P \<and> infinite (UNIV::'a set)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   390
  unfolding Inf_many_def by simp
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   391
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   392
lemma MOST_const [simp]: "(MOST x::'a. P) \<longleftrightarrow> P \<or> finite (UNIV::'a set)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   393
  unfolding Alm_all_def by simp
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   394
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   395
lemma INFM_EX: "(\<exists>\<^sub>\<infinity>x. P x) \<Longrightarrow> (\<exists>x. P x)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   396
  by (erule contrapos_pp, simp)
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   397
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   398
lemma ALL_MOST: "\<forall>x. P x \<Longrightarrow> \<forall>\<^sub>\<infinity>x. P x"
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   399
  by simp
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   400
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   401
lemma INFM_E: assumes "INFM x. P x" obtains x where "P x"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   402
  using INFM_EX [OF assms] by (rule exE)
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   403
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   404
lemma MOST_I: assumes "\<And>x. P x" shows "MOST x. P x"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   405
  using assms by simp
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   406
27407
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   407
lemma INFM_mono:
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   408
  assumes inf: "\<exists>\<^sub>\<infinity>x. P x" and q: "\<And>x. P x \<Longrightarrow> Q x"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   409
  shows "\<exists>\<^sub>\<infinity>x. Q x"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   410
proof -
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   411
  from inf have "infinite {x. P x}" unfolding Inf_many_def .
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   412
  moreover from q have "{x. P x} \<subseteq> {x. Q x}" by auto
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   413
  ultimately show ?thesis
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   414
    by (simp add: Inf_many_def infinite_super)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   415
qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   416
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   417
lemma MOST_mono: "\<forall>\<^sub>\<infinity>x. P x \<Longrightarrow> (\<And>x. P x \<Longrightarrow> Q x) \<Longrightarrow> \<forall>\<^sub>\<infinity>x. Q x"
27407
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   418
  unfolding Alm_all_def by (blast intro: INFM_mono)
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   419
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   420
lemma INFM_disj_distrib:
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   421
  "(\<exists>\<^sub>\<infinity>x. P x \<or> Q x) \<longleftrightarrow> (\<exists>\<^sub>\<infinity>x. P x) \<or> (\<exists>\<^sub>\<infinity>x. Q x)"
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   422
  unfolding Inf_many_def by (simp add: Collect_disj_eq)
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   423
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   424
lemma INFM_imp_distrib:
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   425
  "(INFM x. P x \<longrightarrow> Q x) \<longleftrightarrow> ((MOST x. P x) \<longrightarrow> (INFM x. Q x))"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   426
  by (simp only: imp_conv_disj INFM_disj_distrib not_MOST)
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   427
27407
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   428
lemma MOST_conj_distrib:
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   429
  "(\<forall>\<^sub>\<infinity>x. P x \<and> Q x) \<longleftrightarrow> (\<forall>\<^sub>\<infinity>x. P x) \<and> (\<forall>\<^sub>\<infinity>x. Q x)"
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   430
  unfolding Alm_all_def by (simp add: INFM_disj_distrib del: disj_not1)
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   431
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   432
lemma MOST_conjI:
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   433
  "MOST x. P x \<Longrightarrow> MOST x. Q x \<Longrightarrow> MOST x. P x \<and> Q x"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   434
  by (simp add: MOST_conj_distrib)
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   435
27407
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   436
lemma MOST_rev_mp:
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   437
  assumes "\<forall>\<^sub>\<infinity>x. P x" and "\<forall>\<^sub>\<infinity>x. P x \<longrightarrow> Q x"
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   438
  shows "\<forall>\<^sub>\<infinity>x. Q x"
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   439
proof -
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   440
  have "\<forall>\<^sub>\<infinity>x. P x \<and> (P x \<longrightarrow> Q x)"
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   441
    using assms by (rule MOST_conjI)
27407
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   442
  thus ?thesis by (rule MOST_mono) simp
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   443
qed
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   444
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   445
lemma MOST_imp_iff:
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   446
  assumes "MOST x. P x"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   447
  shows "(MOST x. P x \<longrightarrow> Q x) \<longleftrightarrow> (MOST x. Q x)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   448
proof
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   449
  assume "MOST x. P x \<longrightarrow> Q x"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   450
  with assms show "MOST x. Q x" by (rule MOST_rev_mp)
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   451
next
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   452
  assume "MOST x. Q x"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   453
  then show "MOST x. P x \<longrightarrow> Q x" by (rule MOST_mono) simp
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   454
qed
27407
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   455
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   456
lemma INFM_MOST_simps [simp]:
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   457
  "\<And>P Q. (INFM x. P x \<and> Q) \<longleftrightarrow> (INFM x. P x) \<and> Q"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   458
  "\<And>P Q. (INFM x. P \<and> Q x) \<longleftrightarrow> P \<and> (INFM x. Q x)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   459
  "\<And>P Q. (MOST x. P x \<or> Q) \<longleftrightarrow> (MOST x. P x) \<or> Q"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   460
  "\<And>P Q. (MOST x. P \<or> Q x) \<longleftrightarrow> P \<or> (MOST x. Q x)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   461
  "\<And>P Q. (MOST x. P x \<longrightarrow> Q) \<longleftrightarrow> ((INFM x. P x) \<longrightarrow> Q)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   462
  "\<And>P Q. (MOST x. P \<longrightarrow> Q x) \<longleftrightarrow> (P \<longrightarrow> (MOST x. Q x))"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   463
  unfolding Alm_all_def Inf_many_def
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   464
  by (simp_all add: Collect_conj_eq)
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   465
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   466
text {* Properties of quantifiers with injective functions. *}
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   467
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   468
lemma INFM_inj:
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   469
  "INFM x. P (f x) \<Longrightarrow> inj f \<Longrightarrow> INFM x. P x"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   470
  unfolding INFM_iff_infinite
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   471
  by (clarify, drule (1) finite_vimageI, simp)
27407
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   472
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   473
lemma MOST_inj:
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   474
  "MOST x. P x \<Longrightarrow> inj f \<Longrightarrow> MOST x. P (f x)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   475
  unfolding MOST_iff_cofinite
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   476
  by (drule (1) finite_vimageI, simp)
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   477
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   478
text {* Properties of quantifiers with singletons. *}
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   479
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   480
lemma not_INFM_eq [simp]:
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   481
  "\<not> (INFM x. x = a)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   482
  "\<not> (INFM x. a = x)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   483
  unfolding INFM_iff_infinite by simp_all
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   484
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   485
lemma MOST_neq [simp]:
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   486
  "MOST x. x \<noteq> a"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   487
  "MOST x. a \<noteq> x"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   488
  unfolding MOST_iff_cofinite by simp_all
27407
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   489
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   490
lemma INFM_neq [simp]:
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   491
  "(INFM x::'a. x \<noteq> a) \<longleftrightarrow> infinite (UNIV::'a set)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   492
  "(INFM x::'a. a \<noteq> x) \<longleftrightarrow> infinite (UNIV::'a set)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   493
  unfolding INFM_iff_infinite by simp_all
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   494
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   495
lemma MOST_eq [simp]:
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   496
  "(MOST x::'a. x = a) \<longleftrightarrow> finite (UNIV::'a set)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   497
  "(MOST x::'a. a = x) \<longleftrightarrow> finite (UNIV::'a set)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   498
  unfolding MOST_iff_cofinite by simp_all
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   499
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   500
lemma MOST_eq_imp:
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   501
  "MOST x. x = a \<longrightarrow> P x"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   502
  "MOST x. a = x \<longrightarrow> P x"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   503
  unfolding MOST_iff_cofinite by simp_all
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   504
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   505
text {* Properties of quantifiers over the naturals. *}
27407
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   506
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   507
lemma INFM_nat: "(\<exists>\<^sub>\<infinity>n. P (n::nat)) = (\<forall>m. \<exists>n. m<n \<and> P n)"
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   508
  by (simp add: Inf_many_def infinite_nat_iff_unbounded)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   509
27407
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   510
lemma INFM_nat_le: "(\<exists>\<^sub>\<infinity>n. P (n::nat)) = (\<forall>m. \<exists>n. m\<le>n \<and> P n)"
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   511
  by (simp add: Inf_many_def infinite_nat_iff_unbounded_le)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   512
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   513
lemma MOST_nat: "(\<forall>\<^sub>\<infinity>n. P (n::nat)) = (\<exists>m. \<forall>n. m<n \<longrightarrow> P n)"
27407
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   514
  by (simp add: Alm_all_def INFM_nat)
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   515
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   516
lemma MOST_nat_le: "(\<forall>\<^sub>\<infinity>n. P (n::nat)) = (\<exists>m. \<forall>n. m\<le>n \<longrightarrow> P n)"
27407
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   517
  by (simp add: Alm_all_def INFM_nat_le)
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   518
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   519
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   520
subsection "Enumeration of an Infinite Set"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   521
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   522
text {*
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   523
  The set's element type must be wellordered (e.g. the natural numbers).
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   524
*}
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   525
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   526
consts
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   527
  enumerate   :: "'a::wellorder set => (nat => 'a::wellorder)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   528
primrec
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   529
  enumerate_0:   "enumerate S 0       = (LEAST n. n \<in> S)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   530
  enumerate_Suc: "enumerate S (Suc n) = enumerate (S - {LEAST n. n \<in> S}) n"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   531
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   532
lemma enumerate_Suc':
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   533
    "enumerate S (Suc n) = enumerate (S - {enumerate S 0}) n"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   534
  by simp
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   535
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   536
lemma enumerate_in_set: "infinite S \<Longrightarrow> enumerate S n : S"
29901
f4b3f8fbf599 finiteness lemmas
nipkow
parents: 29839
diff changeset
   537
apply (induct n arbitrary: S)
f4b3f8fbf599 finiteness lemmas
nipkow
parents: 29839
diff changeset
   538
 apply (fastsimp intro: LeastI dest!: infinite_imp_nonempty)
f4b3f8fbf599 finiteness lemmas
nipkow
parents: 29839
diff changeset
   539
apply simp
f4b3f8fbf599 finiteness lemmas
nipkow
parents: 29839
diff changeset
   540
apply (metis Collect_def Collect_mem_eq DiffE infinite_remove)
f4b3f8fbf599 finiteness lemmas
nipkow
parents: 29839
diff changeset
   541
done
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   542
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   543
declare enumerate_0 [simp del] enumerate_Suc [simp del]
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   544
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   545
lemma enumerate_step: "infinite S \<Longrightarrow> enumerate S n < enumerate S (Suc n)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   546
  apply (induct n arbitrary: S)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   547
   apply (rule order_le_neq_trans)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   548
    apply (simp add: enumerate_0 Least_le enumerate_in_set)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   549
   apply (simp only: enumerate_Suc')
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   550
   apply (subgoal_tac "enumerate (S - {enumerate S 0}) 0 : S - {enumerate S 0}")
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   551
    apply (blast intro: sym)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   552
   apply (simp add: enumerate_in_set del: Diff_iff)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   553
  apply (simp add: enumerate_Suc')
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   554
  done
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   555
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   556
lemma enumerate_mono: "m<n \<Longrightarrow> infinite S \<Longrightarrow> enumerate S m < enumerate S n"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   557
  apply (erule less_Suc_induct)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   558
  apply (auto intro: enumerate_step)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   559
  done
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   560
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   561
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   562
subsection "Miscellaneous"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   563
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   564
text {*
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   565
  A few trivial lemmas about sets that contain at most one element.
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   566
  These simplify the reasoning about deterministic automata.
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   567
*}
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   568
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   569
definition
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21256
diff changeset
   570
  atmost_one :: "'a set \<Rightarrow> bool" where
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   571
  "atmost_one S = (\<forall>x y. x\<in>S \<and> y\<in>S \<longrightarrow> x=y)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   572
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   573
lemma atmost_one_empty: "S = {} \<Longrightarrow> atmost_one S"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   574
  by (simp add: atmost_one_def)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   575
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   576
lemma atmost_one_singleton: "S = {x} \<Longrightarrow> atmost_one S"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   577
  by (simp add: atmost_one_def)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   578
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   579
lemma atmost_one_unique [elim]: "atmost_one S \<Longrightarrow> x \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> y = x"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   580
  by (simp add: atmost_one_def)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   581
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   582
end