src/HOL/Library/Infinite_Set.thy
author paulson <lp15@cam.ac.uk>
Wed, 17 Apr 2019 21:53:45 +0100
changeset 70179 269dcea7426c
parent 70178 4900351361b0
child 71813 b11d7ffb48e0
permissions -rw-r--r--
moved subset_image_inj into Hilbert_Choice
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
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60040
diff changeset
     5
section \<open>Infinite Sets and Related Concepts\<close>
20809
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
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
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
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    11
subsection \<open>The set of natural numbers is infinite\<close>
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    12
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    13
lemma infinite_nat_iff_unbounded_le: "infinite S \<longleftrightarrow> (\<forall>m. \<exists>n\<ge>m. n \<in> S)"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    14
  for S :: "nat set"
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
    15
  using frequently_cofinite[of "\<lambda>x. x \<in> S"]
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
    16
  by (simp add: cofinite_eq_sequentially frequently_def eventually_sequentially)
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
    17
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    18
lemma infinite_nat_iff_unbounded: "infinite S \<longleftrightarrow> (\<forall>m. \<exists>n>m. n \<in> S)"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    19
  for S :: "nat set"
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
    20
  using frequently_cofinite[of "\<lambda>x. x \<in> S"]
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
    21
  by (simp add: cofinite_eq_sequentially frequently_def eventually_at_top_dense)
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    22
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    23
lemma finite_nat_iff_bounded: "finite S \<longleftrightarrow> (\<exists>k. S \<subseteq> {..<k})"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    24
  for S :: "nat set"
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
    25
  using infinite_nat_iff_unbounded_le[of S] by (simp add: subset_eq) (metis not_le)
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    26
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    27
lemma finite_nat_iff_bounded_le: "finite S \<longleftrightarrow> (\<exists>k. S \<subseteq> {.. k})"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    28
  for S :: "nat set"
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
    29
  using infinite_nat_iff_unbounded[of S] by (simp add: subset_eq) (metis not_le)
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    30
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    31
lemma finite_nat_bounded: "finite S \<Longrightarrow> \<exists>k. S \<subseteq> {..<k}"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    32
  for S :: "nat set"
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
    33
  by (simp add: finite_nat_iff_bounded)
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    34
61762
d50b993b4fb9 Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents: 61585
diff changeset
    35
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60040
diff changeset
    36
text \<open>
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    37
  For a set of natural numbers to be infinite, it is enough to know
61585
a9599d3d7610 isabelle update_cartouches -c -t;
wenzelm
parents: 60828
diff changeset
    38
  that for any number larger than some \<open>k\<close>, there is some larger
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    39
  number that is an element of the set.
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60040
diff changeset
    40
\<close>
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    41
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
    42
lemma unbounded_k_infinite: "\<forall>m>k. \<exists>n>m. n \<in> S \<Longrightarrow> infinite (S::nat set)"
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    43
  apply (clarsimp simp add: finite_nat_set_iff_bounded)
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    44
  apply (drule_tac x="Suc (max m k)" in spec)
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    45
  using less_Suc_eq apply fastforce
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    46
  done
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    47
35056
d97b5c3af6d5 remove redundant theorem attributes
huffman
parents: 34941
diff changeset
    48
lemma nat_not_finite: "finite (UNIV::nat set) \<Longrightarrow> R"
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    49
  by simp
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    50
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    51
lemma range_inj_infinite:
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    52
  fixes f :: "nat \<Rightarrow> 'a"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    53
  assumes "inj f"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    54
  shows "infinite (range f)"
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    55
proof
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    56
  assume "finite (range f)"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    57
  from this assms 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
    58
    by (rule finite_imageD)
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    59
  then show False by simp
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    60
qed
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    61
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    62
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    63
subsection \<open>The set of integers is also infinite\<close>
61762
d50b993b4fb9 Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents: 61585
diff changeset
    64
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    65
lemma infinite_int_iff_infinite_nat_abs: "infinite S \<longleftrightarrow> infinite ((nat \<circ> abs) ` S)"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    66
  for S :: "int set"
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69593
diff changeset
    67
proof (unfold Not_eq_iff, rule iffI)
a03a63b81f44 tuned proofs
haftmann
parents: 69593
diff changeset
    68
  assume "finite ((nat \<circ> abs) ` S)"
a03a63b81f44 tuned proofs
haftmann
parents: 69593
diff changeset
    69
  then have "finite (nat ` (abs ` S))"
a03a63b81f44 tuned proofs
haftmann
parents: 69593
diff changeset
    70
    by (simp add: image_image cong: image_cong)
a03a63b81f44 tuned proofs
haftmann
parents: 69593
diff changeset
    71
  moreover have "inj_on nat (abs ` S)"
66837
6ba663ff2b1c tuned proofs
haftmann
parents: 64967
diff changeset
    72
    by (rule inj_onI) auto
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69593
diff changeset
    73
  ultimately have "finite (abs ` S)"
a03a63b81f44 tuned proofs
haftmann
parents: 69593
diff changeset
    74
    by (rule finite_imageD)
a03a63b81f44 tuned proofs
haftmann
parents: 69593
diff changeset
    75
  then show "finite S"
a03a63b81f44 tuned proofs
haftmann
parents: 69593
diff changeset
    76
    by (rule finite_image_absD)
a03a63b81f44 tuned proofs
haftmann
parents: 69593
diff changeset
    77
qed simp
61762
d50b993b4fb9 Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents: 61585
diff changeset
    78
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    79
proposition infinite_int_iff_unbounded_le: "infinite S \<longleftrightarrow> (\<forall>m. \<exists>n. \<bar>n\<bar> \<ge> m \<and> n \<in> S)"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    80
  for S :: "int set"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    81
  by (simp add: infinite_int_iff_infinite_nat_abs infinite_nat_iff_unbounded_le o_def image_def)
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    82
    (metis abs_ge_zero nat_le_eq_zle le_nat_iff)
61762
d50b993b4fb9 Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents: 61585
diff changeset
    83
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    84
proposition infinite_int_iff_unbounded: "infinite S \<longleftrightarrow> (\<forall>m. \<exists>n. \<bar>n\<bar> > m \<and> n \<in> S)"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    85
  for S :: "int set"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    86
  by (simp add: infinite_int_iff_infinite_nat_abs infinite_nat_iff_unbounded o_def image_def)
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    87
    (metis (full_types) nat_le_iff nat_mono not_le)
61762
d50b993b4fb9 Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents: 61585
diff changeset
    88
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    89
proposition finite_int_iff_bounded: "finite S \<longleftrightarrow> (\<exists>k. abs ` S \<subseteq> {..<k})"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    90
  for S :: "int set"
61762
d50b993b4fb9 Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents: 61585
diff changeset
    91
  using infinite_int_iff_unbounded_le[of S] by (simp add: subset_eq) (metis not_le)
d50b993b4fb9 Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents: 61585
diff changeset
    92
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    93
proposition finite_int_iff_bounded_le: "finite S \<longleftrightarrow> (\<exists>k. abs ` S \<subseteq> {.. k})"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    94
  for S :: "int set"
61762
d50b993b4fb9 Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents: 61585
diff changeset
    95
  using infinite_int_iff_unbounded[of S] by (simp add: subset_eq) (metis not_le)
d50b993b4fb9 Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents: 61585
diff changeset
    96
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    97
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
    98
subsection \<open>Infinitely Many and Almost All\<close>
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
    99
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60040
diff changeset
   100
text \<open>
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   101
  We often need to reason about the existence of infinitely many
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   102
  (resp., all but finitely many) objects satisfying some predicate, so
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   103
  we introduce corresponding binders and their proof rules.
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60040
diff changeset
   104
\<close>
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   105
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   106
lemma not_INFM [simp]: "\<not> (INFM x. P x) \<longleftrightarrow> (MOST x. \<not> P x)"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   107
  by (rule not_frequently)
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   108
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   109
lemma not_MOST [simp]: "\<not> (MOST x. P x) \<longleftrightarrow> (INFM x. \<not> P x)"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   110
  by (rule not_eventually)
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   111
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   112
lemma INFM_const [simp]: "(INFM x::'a. P) \<longleftrightarrow> P \<and> infinite (UNIV::'a set)"
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   113
  by (simp add: frequently_const_iff)
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   114
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   115
lemma MOST_const [simp]: "(MOST x::'a. P) \<longleftrightarrow> P \<or> finite (UNIV::'a set)"
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   116
  by (simp add: eventually_const_iff)
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   117
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   118
lemma INFM_imp_distrib: "(INFM x. P x \<longrightarrow> Q x) \<longleftrightarrow> ((MOST x. P x) \<longrightarrow> (INFM x. Q x))"
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   119
  by (rule frequently_imp_iff)
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   120
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   121
lemma MOST_imp_iff: "MOST x. P x \<Longrightarrow> (MOST x. P x \<longrightarrow> Q x) \<longleftrightarrow> (MOST x. Q x)"
61810
3c5040d5694a sorted out eventually_mono
paulson <lp15@cam.ac.uk>
parents: 61762
diff changeset
   122
  by (auto intro: eventually_rev_mp eventually_mono)
34113
dbc0fb6e7eae add lemma INFM_conjI
huffman
parents: 34112
diff changeset
   123
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   124
lemma INFM_conjI: "INFM x. P x \<Longrightarrow> MOST x. Q x \<Longrightarrow> INFM x. P x \<and> Q x"
61810
3c5040d5694a sorted out eventually_mono
paulson <lp15@cam.ac.uk>
parents: 61762
diff changeset
   125
  by (rule frequently_rev_mp[of P]) (auto elim: eventually_mono)
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   126
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   127
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60040
diff changeset
   128
text \<open>Properties of quantifiers with injective functions.\<close>
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   129
53239
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   130
lemma INFM_inj: "INFM x. P (f x) \<Longrightarrow> inj f \<Longrightarrow> INFM x. P x"
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   131
  using finite_vimageI[of "{x. P x}" f] by (auto simp: frequently_cofinite)
27407
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   132
53239
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   133
lemma MOST_inj: "MOST x. P x \<Longrightarrow> inj f \<Longrightarrow> MOST x. P (f x)"
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   134
  using finite_vimageI[of "{x. \<not> P x}" f] by (auto simp: eventually_cofinite)
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   135
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   136
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60040
diff changeset
   137
text \<open>Properties of quantifiers with singletons.\<close>
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   138
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   139
lemma not_INFM_eq [simp]:
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   140
  "\<not> (INFM x. x = a)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   141
  "\<not> (INFM x. a = x)"
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   142
  unfolding frequently_cofinite by simp_all
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   143
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   144
lemma MOST_neq [simp]:
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   145
  "MOST x. x \<noteq> a"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   146
  "MOST x. a \<noteq> x"
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   147
  unfolding eventually_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
   148
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   149
lemma INFM_neq [simp]:
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   150
  "(INFM x::'a. x \<noteq> a) \<longleftrightarrow> infinite (UNIV::'a set)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   151
  "(INFM x::'a. a \<noteq> x) \<longleftrightarrow> infinite (UNIV::'a set)"
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   152
  unfolding frequently_cofinite by simp_all
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   153
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   154
lemma MOST_eq [simp]:
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   155
  "(MOST x::'a. x = a) \<longleftrightarrow> finite (UNIV::'a set)"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   156
  "(MOST x::'a. a = x) \<longleftrightarrow> finite (UNIV::'a set)"
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   157
  unfolding eventually_cofinite by simp_all
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   158
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   159
lemma MOST_eq_imp:
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   160
  "MOST x. x = a \<longrightarrow> P x"
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   161
  "MOST x. a = x \<longrightarrow> P x"
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   162
  unfolding eventually_cofinite by simp_all
34112
ca842111d698 added lemmas about INFM/MOST
huffman
parents: 30663
diff changeset
   163
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   164
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60040
diff changeset
   165
text \<open>Properties of quantifiers over the naturals.\<close>
27407
68e111812b83 rename lemmas INF_foo to INFM_foo; add new lemmas about MOST and INFM
huffman
parents: 27368
diff changeset
   166
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   167
lemma MOST_nat: "(\<forall>\<^sub>\<infinity>n. P n) \<longleftrightarrow> (\<exists>m. \<forall>n>m. P n)"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   168
  for P :: "nat \<Rightarrow> bool"
68406
6beb45f6cf67 utilize 'flip'
nipkow
parents: 67408
diff changeset
   169
  by (auto simp add: eventually_cofinite finite_nat_iff_bounded_le subset_eq simp flip: not_le)
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   170
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   171
lemma MOST_nat_le: "(\<forall>\<^sub>\<infinity>n. P n) \<longleftrightarrow> (\<exists>m. \<forall>n\<ge>m. P n)"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   172
  for P :: "nat \<Rightarrow> bool"
68406
6beb45f6cf67 utilize 'flip'
nipkow
parents: 67408
diff changeset
   173
  by (auto simp add: eventually_cofinite finite_nat_iff_bounded subset_eq simp flip: not_le)
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   174
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   175
lemma INFM_nat: "(\<exists>\<^sub>\<infinity>n. P n) \<longleftrightarrow> (\<forall>m. \<exists>n>m. P n)"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   176
  for P :: "nat \<Rightarrow> bool"
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   177
  by (simp add: frequently_cofinite infinite_nat_iff_unbounded)
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   178
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   179
lemma INFM_nat_le: "(\<exists>\<^sub>\<infinity>n. P n) \<longleftrightarrow> (\<forall>m. \<exists>n\<ge>m. P n)"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   180
  for P :: "nat \<Rightarrow> bool"
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   181
  by (simp add: frequently_cofinite infinite_nat_iff_unbounded_le)
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   182
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   183
lemma MOST_INFM: "infinite (UNIV::'a set) \<Longrightarrow> MOST x::'a. P x \<Longrightarrow> INFM x::'a. P x"
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   184
  by (simp add: eventually_frequently)
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   185
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   186
lemma MOST_Suc_iff: "(MOST n. P (Suc n)) \<longleftrightarrow> (MOST n. P n)"
64697
wenzelm
parents: 63993
diff changeset
   187
  by (simp add: cofinite_eq_sequentially)
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   188
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   189
lemma MOST_SucI: "MOST n. P n \<Longrightarrow> MOST n. P (Suc n)"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   190
  and MOST_SucD: "MOST n. P (Suc n) \<Longrightarrow> MOST n. P n"
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   191
  by (simp_all add: MOST_Suc_iff)
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   192
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   193
lemma MOST_ge_nat: "MOST n::nat. m \<le> n"
66837
6ba663ff2b1c tuned proofs
haftmann
parents: 64967
diff changeset
   194
  by (simp add: cofinite_eq_sequentially)
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   195
67408
4a4c14b24800 prefer formal comments;
wenzelm
parents: 66837
diff changeset
   196
\<comment> \<open>legacy names\<close>
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   197
lemma Inf_many_def: "Inf_many P \<longleftrightarrow> infinite {x. P x}" by (fact frequently_cofinite)
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   198
lemma Alm_all_def: "Alm_all P \<longleftrightarrow> \<not> (INFM x. \<not> P x)" by simp
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   199
lemma INFM_iff_infinite: "(INFM x. P x) \<longleftrightarrow> infinite {x. P x}" by (fact frequently_cofinite)
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   200
lemma MOST_iff_cofinite: "(MOST x. P x) \<longleftrightarrow> finite {x. \<not> P x}" by (fact eventually_cofinite)
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   201
lemma INFM_EX: "(\<exists>\<^sub>\<infinity>x. P x) \<Longrightarrow> (\<exists>x. P x)" by (fact frequently_ex)
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   202
lemma ALL_MOST: "\<forall>x. P x \<Longrightarrow> \<forall>\<^sub>\<infinity>x. P x" by (fact always_eventually)
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   203
lemma INFM_mono: "\<exists>\<^sub>\<infinity>x. P x \<Longrightarrow> (\<And>x. P x \<Longrightarrow> Q x) \<Longrightarrow> \<exists>\<^sub>\<infinity>x. Q x" by (fact frequently_elim1)
61810
3c5040d5694a sorted out eventually_mono
paulson <lp15@cam.ac.uk>
parents: 61762
diff changeset
   204
lemma MOST_mono: "\<forall>\<^sub>\<infinity>x. P x \<Longrightarrow> (\<And>x. P x \<Longrightarrow> Q x) \<Longrightarrow> \<forall>\<^sub>\<infinity>x. Q x" by (fact eventually_mono)
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   205
lemma INFM_disj_distrib: "(\<exists>\<^sub>\<infinity>x. P x \<or> Q x) \<longleftrightarrow> (\<exists>\<^sub>\<infinity>x. P x) \<or> (\<exists>\<^sub>\<infinity>x. Q x)" by (fact frequently_disj_iff)
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   206
lemma MOST_rev_mp: "\<forall>\<^sub>\<infinity>x. P x \<Longrightarrow> \<forall>\<^sub>\<infinity>x. P x \<longrightarrow> Q x \<Longrightarrow> \<forall>\<^sub>\<infinity>x. Q x" by (fact eventually_rev_mp)
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   207
lemma MOST_conj_distrib: "(\<forall>\<^sub>\<infinity>x. P x \<and> Q x) \<longleftrightarrow> (\<forall>\<^sub>\<infinity>x. P x) \<and> (\<forall>\<^sub>\<infinity>x. Q x)" by (fact eventually_conj_iff)
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   208
lemma MOST_conjI: "MOST x. P x \<Longrightarrow> MOST x. Q x \<Longrightarrow> MOST x. P x \<and> Q x" by (fact eventually_conj)
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   209
lemma INFM_finite_Bex_distrib: "finite A \<Longrightarrow> (INFM y. \<exists>x\<in>A. P x y) \<longleftrightarrow> (\<exists>x\<in>A. INFM y. P x y)" by (fact frequently_bex_finite_distrib)
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   210
lemma MOST_finite_Ball_distrib: "finite A \<Longrightarrow> (MOST y. \<forall>x\<in>A. P x y) \<longleftrightarrow> (\<forall>x\<in>A. MOST y. P x y)" by (fact eventually_ball_finite_distrib)
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   211
lemma INFM_E: "INFM x. P x \<Longrightarrow> (\<And>x. P x \<Longrightarrow> thesis) \<Longrightarrow> thesis" by (fact frequentlyE)
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   212
lemma MOST_I: "(\<And>x. P x) \<Longrightarrow> MOST x. P x" by (rule eventuallyI)
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   213
lemmas MOST_iff_finiteNeg = MOST_iff_cofinite
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   214
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   215
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   216
subsection \<open>Enumeration of an Infinite Set\<close>
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   217
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   218
text \<open>The set's element type must be wellordered (e.g. the natural numbers).\<close>
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   219
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   220
text \<open>
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   221
  Could be generalized to
69593
3dda49e08b9d isabelle update -u control_cartouches;
wenzelm
parents: 69516
diff changeset
   222
    \<^prop>\<open>enumerate' S n = (SOME t. t \<in> s \<and> finite {s\<in>S. s < t} \<and> card {s\<in>S. s < t} = n)\<close>.
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   223
\<close>
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   224
53239
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   225
primrec (in wellorder) enumerate :: "'a set \<Rightarrow> nat \<Rightarrow> 'a"
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   226
  where
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   227
    enumerate_0: "enumerate S 0 = (LEAST n. n \<in> S)"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   228
  | enumerate_Suc: "enumerate S (Suc n) = enumerate (S - {LEAST n. n \<in> S}) n"
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   229
53239
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   230
lemma enumerate_Suc': "enumerate S (Suc n) = enumerate (S - {enumerate S 0}) n"
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   231
  by simp
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   232
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   233
lemma enumerate_in_set: "infinite S \<Longrightarrow> enumerate S n \<in> S"
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   234
proof (induct n arbitrary: S)
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   235
  case 0
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   236
  then show ?case
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   237
    by (fastforce intro: LeastI dest!: infinite_imp_nonempty)
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   238
next
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   239
  case (Suc n)
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   240
  then show ?case
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   241
    by simp (metis DiffE infinite_remove)
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   242
qed
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   243
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   244
declare enumerate_0 [simp del] enumerate_Suc [simp del]
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   245
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   246
lemma enumerate_step: "infinite S \<Longrightarrow> enumerate S n < enumerate S (Suc n)"
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   247
  apply (induct n arbitrary: S)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   248
   apply (rule order_le_neq_trans)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   249
    apply (simp add: enumerate_0 Least_le enumerate_in_set)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   250
   apply (simp only: enumerate_Suc')
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   251
   apply (subgoal_tac "enumerate (S - {enumerate S 0}) 0 \<in> S - {enumerate S 0}")
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   252
    apply (blast intro: sym)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   253
   apply (simp add: enumerate_in_set del: Diff_iff)
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   254
  apply (simp add: enumerate_Suc')
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   255
  done
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   256
60040
1fa1023b13b9 move MOST and INFM in Infinite_Set to Filter; change them to abbreviations over the cofinite filter
hoelzl
parents: 59506
diff changeset
   257
lemma enumerate_mono: "m < n \<Longrightarrow> infinite S \<Longrightarrow> enumerate S m < enumerate S n"
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   258
  by (induct m n rule: less_Suc_induct) (auto intro: enumerate_step)
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   259
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   260
lemma le_enumerate:
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   261
  assumes S: "infinite S"
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   262
  shows "n \<le> enumerate S n"
61810
3c5040d5694a sorted out eventually_mono
paulson <lp15@cam.ac.uk>
parents: 61762
diff changeset
   263
  using S
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   264
proof (induct n)
53239
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   265
  case 0
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   266
  then show ?case by simp
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   267
next
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   268
  case (Suc n)
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   269
  then have "n \<le> enumerate S n" by simp
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60040
diff changeset
   270
  also note enumerate_mono[of n "Suc n", OF _ \<open>infinite S\<close>]
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   271
  finally show ?case by simp
53239
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   272
qed
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   273
69516
09bb8f470959 most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
immler
parents: 68406
diff changeset
   274
lemma infinite_enumerate:
09bb8f470959 most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
immler
parents: 68406
diff changeset
   275
  assumes fS: "infinite S"
09bb8f470959 most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
immler
parents: 68406
diff changeset
   276
  shows "\<exists>r::nat\<Rightarrow>nat. strict_mono r \<and> (\<forall>n. r n \<in> S)"
09bb8f470959 most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
immler
parents: 68406
diff changeset
   277
  unfolding strict_mono_def
09bb8f470959 most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
immler
parents: 68406
diff changeset
   278
  using enumerate_in_set[OF fS] enumerate_mono[of _ _ S] fS by auto
09bb8f470959 most of Topology_Euclidean_Space (now Elementary_Topology) requires fewer dependencies
immler
parents: 68406
diff changeset
   279
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   280
lemma enumerate_Suc'':
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   281
  fixes S :: "'a::wellorder set"
53239
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   282
  assumes "infinite S"
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   283
  shows "enumerate S (Suc n) = (LEAST s. s \<in> S \<and> enumerate S n < s)"
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   284
  using assms
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   285
proof (induct n arbitrary: S)
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   286
  case 0
53239
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   287
  then have "\<forall>s \<in> S. enumerate S 0 \<le> s"
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   288
    by (auto simp: enumerate.simps intro: Least_le)
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   289
  then show ?case
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   290
    unfolding enumerate_Suc' enumerate_0[of "S - {enumerate S 0}"]
53239
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   291
    by (intro arg_cong[where f = Least] ext) auto
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   292
next
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   293
  case (Suc n S)
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   294
  show ?case
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60040
diff changeset
   295
    using enumerate_mono[OF zero_less_Suc \<open>infinite S\<close>, of n] \<open>infinite S\<close>
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   296
    apply (subst (1 2) enumerate_Suc')
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   297
    apply (subst Suc)
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   298
     apply (use \<open>infinite S\<close> in simp)
53239
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   299
    apply (intro arg_cong[where f = Least] ext)
68406
6beb45f6cf67 utilize 'flip'
nipkow
parents: 67408
diff changeset
   300
    apply (auto simp flip: enumerate_Suc')
53239
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   301
    done
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   302
qed
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   303
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   304
lemma enumerate_Ex:
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   305
  fixes S :: "nat set"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   306
  assumes S: "infinite S"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   307
    and s: "s \<in> S"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   308
  shows "\<exists>n. enumerate S n = s"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   309
  using s
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   310
proof (induct s rule: less_induct)
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   311
  case (less s)
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   312
  show ?case
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   313
  proof (cases "\<exists>y\<in>S. y < s")
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   314
    case True
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   315
    let ?y = "Max {s'\<in>S. s' < s}"
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   316
    from True have y: "\<And>x. ?y < x \<longleftrightarrow> (\<forall>s'\<in>S. s' < s \<longrightarrow> s' < x)"
53239
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   317
      by (subst Max_less_iff) auto
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   318
    then have y_in: "?y \<in> {s'\<in>S. s' < s}"
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   319
      by (intro Max_in) auto
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   320
    with less.hyps[of ?y] obtain n where "enumerate S n = ?y"
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   321
      by auto
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   322
    with S have "enumerate S (Suc n) = s"
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   323
      by (auto simp: y less enumerate_Suc'' intro!: Least_equality)
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   324
    then show ?thesis by auto
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   325
  next
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   326
    case False
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   327
    then have "\<forall>t\<in>S. s \<le> t" by auto
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60040
diff changeset
   328
    with \<open>s \<in> S\<close> show ?thesis
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   329
      by (auto intro!: exI[of _ 0] Least_equality simp: enumerate_0)
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   330
  qed
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   331
qed
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   332
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   333
lemma bij_enumerate:
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   334
  fixes S :: "nat set"
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   335
  assumes S: "infinite S"
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   336
  shows "bij_betw (enumerate S) UNIV S"
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   337
proof -
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   338
  have "\<And>n m. n \<noteq> m \<Longrightarrow> enumerate S n \<noteq> enumerate S m"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60040
diff changeset
   339
    using enumerate_mono[OF _ \<open>infinite S\<close>] by (auto simp: neq_iff)
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   340
  then have "inj (enumerate S)"
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   341
    by (auto simp: inj_on_def)
53239
2f21813cf2f0 tuned proofs;
wenzelm
parents: 50134
diff changeset
   342
  moreover have "\<forall>s \<in> S. \<exists>i. enumerate S i = s"
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   343
    using enumerate_Ex[OF S] by auto
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60040
diff changeset
   344
  moreover note \<open>infinite S\<close>
50134
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   345
  ultimately show ?thesis
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   346
    unfolding bij_betw_def by (auto intro: enumerate_in_set)
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   347
qed
13211e07d931 add Countable_Set theory
hoelzl
parents: 46783
diff changeset
   348
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   349
text \<open>A pair of weird and wonderful lemmas from HOL Light.\<close>
63492
a662e8139804 More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents: 61945
diff changeset
   350
lemma finite_transitivity_chain:
a662e8139804 More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents: 61945
diff changeset
   351
  assumes "finite A"
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   352
    and R: "\<And>x. \<not> R x x" "\<And>x y z. \<lbrakk>R x y; R y z\<rbrakk> \<Longrightarrow> R x z"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   353
    and A: "\<And>x. x \<in> A \<Longrightarrow> \<exists>y. y \<in> A \<and> R x y"
63492
a662e8139804 More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents: 61945
diff changeset
   354
  shows "A = {}"
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   355
  using \<open>finite A\<close> A
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   356
proof (induct A)
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   357
  case empty
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   358
  then show ?case by simp
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   359
next
63492
a662e8139804 More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents: 61945
diff changeset
   360
  case (insert a A)
a662e8139804 More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents: 61945
diff changeset
   361
  with R show ?case
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   362
    by (metis empty_iff insert_iff)   (* somewhat slow *)
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   363
qed
63492
a662e8139804 More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents: 61945
diff changeset
   364
a662e8139804 More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents: 61945
diff changeset
   365
corollary Union_maximal_sets:
a662e8139804 More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents: 61945
diff changeset
   366
  assumes "finite \<F>"
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   367
  shows "\<Union>{T \<in> \<F>. \<forall>U\<in>\<F>. \<not> T \<subset> U} = \<Union>\<F>"
63492
a662e8139804 More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents: 61945
diff changeset
   368
    (is "?lhs = ?rhs")
a662e8139804 More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents: 61945
diff changeset
   369
proof
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   370
  show "?lhs \<subseteq> ?rhs" by force
63492
a662e8139804 More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents: 61945
diff changeset
   371
  show "?rhs \<subseteq> ?lhs"
a662e8139804 More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents: 61945
diff changeset
   372
  proof (rule Union_subsetI)
a662e8139804 More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents: 61945
diff changeset
   373
    fix S
a662e8139804 More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents: 61945
diff changeset
   374
    assume "S \<in> \<F>"
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   375
    have "{T \<in> \<F>. S \<subseteq> T} = {}"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   376
      if "\<not> (\<exists>y. y \<in> {T \<in> \<F>. \<forall>U\<in>\<F>. \<not> T \<subset> U} \<and> S \<subseteq> y)"
63492
a662e8139804 More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents: 61945
diff changeset
   377
      apply (rule finite_transitivity_chain [of _ "\<lambda>T U. S \<subseteq> T \<and> T \<subset> U"])
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   378
         apply (use assms that in auto)
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   379
      apply (blast intro: dual_order.trans psubset_imp_subset)
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   380
      done
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   381
    with \<open>S \<in> \<F>\<close> show "\<exists>y. y \<in> {T \<in> \<F>. \<forall>U\<in>\<F>. \<not> T \<subset> U} \<and> S \<subseteq> y"
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   382
      by blast
63492
a662e8139804 More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents: 61945
diff changeset
   383
  qed
64967
1ab49aa7f3c0 misc tuning and modernization;
wenzelm
parents: 64697
diff changeset
   384
qed
63492
a662e8139804 More advanced theorems about retracts, homotopies., etc
paulson <lp15@cam.ac.uk>
parents: 61945
diff changeset
   385
20809
6c4fd0b4b63a moved theory Infinite_Set to Library;
wenzelm
parents:
diff changeset
   386
end