| author | wenzelm | 
| Thu, 15 Aug 2019 16:38:55 +0200 | |
| changeset 70537 | 17160e0a60b6 | 
| parent 70179 | 269dcea7426c | 
| child 71544 | 66bc4b668d6e | 
| permissions | -rw-r--r-- | 
| 11451 
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
 paulson parents: diff
changeset | 1 | (* Title: HOL/Hilbert_Choice.thy | 
| 32988 | 2 | Author: Lawrence C Paulson, Tobias Nipkow | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 3 | Author: Viorel Preoteasa (Results about complete distributive lattices) | 
| 11451 
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
 paulson parents: diff
changeset | 4 | Copyright 2001 University of Cambridge | 
| 12023 | 5 | *) | 
| 11451 
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
 paulson parents: diff
changeset | 6 | |
| 60758 | 7 | section \<open>Hilbert's Epsilon-Operator and the Axiom of Choice\<close> | 
| 11451 
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
 paulson parents: diff
changeset | 8 | |
| 15131 | 9 | theory Hilbert_Choice | 
| 63612 | 10 | imports Wellfounded | 
| 69913 | 11 | keywords "specification" :: thy_goal_defn | 
| 15131 | 12 | begin | 
| 12298 | 13 | |
| 60758 | 14 | subsection \<open>Hilbert's epsilon\<close> | 
| 12298 | 15 | |
| 63612 | 16 | axiomatization Eps :: "('a \<Rightarrow> bool) \<Rightarrow> 'a"
 | 
| 17 | where someI: "P x \<Longrightarrow> P (Eps P)" | |
| 11451 
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
 paulson parents: diff
changeset | 18 | |
| 14872 
3f2144aebd76
improved symbolic syntax of Eps: \<some> for mode "epsilon";
 wenzelm parents: 
14760diff
changeset | 19 | syntax (epsilon) | 
| 63612 | 20 |   "_Eps" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a"  ("(3\<some>_./ _)" [0, 10] 10)
 | 
| 62521 | 21 | syntax (input) | 
| 63612 | 22 |   "_Eps" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a"  ("(3@ _./ _)" [0, 10] 10)
 | 
| 11451 
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
 paulson parents: diff
changeset | 23 | syntax | 
| 63612 | 24 |   "_Eps" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a"  ("(3SOME _./ _)" [0, 10] 10)
 | 
| 11451 
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
 paulson parents: diff
changeset | 25 | translations | 
| 63612 | 26 | "SOME x. P" \<rightleftharpoons> "CONST Eps (\<lambda>x. P)" | 
| 13763 
f94b569cd610
added print translations tha avoid eta contraction for important binders.
 nipkow parents: 
13585diff
changeset | 27 | |
| 60758 | 28 | print_translation \<open> | 
| 69593 | 29 | [(\<^const_syntax>\<open>Eps\<close>, fn _ => fn [Abs abs] => | 
| 42284 | 30 | let val (x, t) = Syntax_Trans.atomic_abs_tr' abs | 
| 69593 | 31 | in Syntax.const \<^syntax_const>\<open>_Eps\<close> $ x $ t end)] | 
| 61799 | 32 | \<close> \<comment> \<open>to avoid eta-contraction of body\<close> | 
| 11451 
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
 paulson parents: diff
changeset | 33 | |
| 65815 | 34 | definition inv_into :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'a)" where
 | 
| 35 | "inv_into A f = (\<lambda>x. SOME y. y \<in> A \<and> f y = x)" | |
| 11454 
7514e5e21cb8
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
 paulson parents: 
11451diff
changeset | 36 | |
| 65815 | 37 | lemma inv_into_def2: "inv_into A f x = (SOME y. y \<in> A \<and> f y = x)" | 
| 38 | by(simp add: inv_into_def) | |
| 39 | ||
| 40 | abbreviation inv :: "('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'a)" where
 | |
| 41 | "inv \<equiv> inv_into UNIV" | |
| 14760 | 42 | |
| 43 | ||
| 60758 | 44 | subsection \<open>Hilbert's Epsilon-operator\<close> | 
| 14760 | 45 | |
| 70097 
4005298550a6
The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
 paulson <lp15@cam.ac.uk> parents: 
69913diff
changeset | 46 | lemma Eps_cong: | 
| 
4005298550a6
The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
 paulson <lp15@cam.ac.uk> parents: 
69913diff
changeset | 47 | assumes "\<And>x. P x = Q x" | 
| 
4005298550a6
The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
 paulson <lp15@cam.ac.uk> parents: 
69913diff
changeset | 48 | shows "Eps P = Eps Q" | 
| 
4005298550a6
The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
 paulson <lp15@cam.ac.uk> parents: 
69913diff
changeset | 49 | using ext[of P Q, OF assms] by simp | 
| 
4005298550a6
The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
 paulson <lp15@cam.ac.uk> parents: 
69913diff
changeset | 50 | |
| 63612 | 51 | text \<open> | 
| 52 | Easier to apply than \<open>someI\<close> if the witness comes from an | |
| 53 | existential formula. | |
| 54 | \<close> | |
| 55 | lemma someI_ex [elim?]: "\<exists>x. P x \<Longrightarrow> P (SOME x. P x)" | |
| 56 | apply (erule exE) | |
| 57 | apply (erule someI) | |
| 58 | done | |
| 14760 | 59 | |
| 63612 | 60 | text \<open> | 
| 61 | Easier to apply than \<open>someI\<close> because the conclusion has only one | |
| 69593 | 62 | occurrence of \<^term>\<open>P\<close>. | 
| 63612 | 63 | \<close> | 
| 64 | lemma someI2: "P a \<Longrightarrow> (\<And>x. P x \<Longrightarrow> Q x) \<Longrightarrow> Q (SOME x. P x)" | |
| 60974 
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
 paulson <lp15@cam.ac.uk> parents: 
60758diff
changeset | 65 | by (blast intro: someI) | 
| 14760 | 66 | |
| 63612 | 67 | text \<open> | 
| 68 | Easier to apply than \<open>someI2\<close> if the witness comes from an | |
| 69 | existential formula. | |
| 70 | \<close> | |
| 71 | lemma someI2_ex: "\<exists>a. P a \<Longrightarrow> (\<And>x. P x \<Longrightarrow> Q x) \<Longrightarrow> Q (SOME x. P x)" | |
| 60974 
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
 paulson <lp15@cam.ac.uk> parents: 
60758diff
changeset | 72 | by (blast intro: someI2) | 
| 14760 | 73 | |
| 63612 | 74 | lemma someI2_bex: "\<exists>a\<in>A. P a \<Longrightarrow> (\<And>x. x \<in> A \<and> P x \<Longrightarrow> Q x) \<Longrightarrow> Q (SOME x. x \<in> A \<and> P x)" | 
| 75 | by (blast intro: someI2) | |
| 76 | ||
| 77 | lemma some_equality [intro]: "P a \<Longrightarrow> (\<And>x. P x \<Longrightarrow> x = a) \<Longrightarrow> (SOME x. P x) = a" | |
| 78 | by (blast intro: someI2) | |
| 14760 | 79 | |
| 63629 | 80 | lemma some1_equality: "\<exists>!x. P x \<Longrightarrow> P a \<Longrightarrow> (SOME x. P x) = a" | 
| 63612 | 81 | by blast | 
| 14760 | 82 | |
| 63612 | 83 | lemma some_eq_ex: "P (SOME x. P x) \<longleftrightarrow> (\<exists>x. P x)" | 
| 84 | by (blast intro: someI) | |
| 14760 | 85 | |
| 59000 | 86 | lemma some_in_eq: "(SOME x. x \<in> A) \<in> A \<longleftrightarrow> A \<noteq> {}"
 | 
| 87 | unfolding ex_in_conv[symmetric] by (rule some_eq_ex) | |
| 88 | ||
| 63612 | 89 | lemma some_eq_trivial [simp]: "(SOME y. y = x) = x" | 
| 90 | by (rule some_equality) (rule refl) | |
| 14760 | 91 | |
| 63612 | 92 | lemma some_sym_eq_trivial [simp]: "(SOME y. x = y) = x" | 
| 93 | apply (rule some_equality) | |
| 94 | apply (rule refl) | |
| 95 | apply (erule sym) | |
| 96 | done | |
| 14760 | 97 | |
| 98 | ||
| 63612 | 99 | subsection \<open>Axiom of Choice, Proved Using the Description Operator\<close> | 
| 14760 | 100 | |
| 63612 | 101 | lemma choice: "\<forall>x. \<exists>y. Q x y \<Longrightarrow> \<exists>f. \<forall>x. Q x (f x)" | 
| 102 | by (fast elim: someI) | |
| 14760 | 103 | |
| 63612 | 104 | lemma bchoice: "\<forall>x\<in>S. \<exists>y. Q x y \<Longrightarrow> \<exists>f. \<forall>x\<in>S. Q x (f x)" | 
| 105 | by (fast elim: someI) | |
| 14760 | 106 | |
| 50105 | 107 | lemma choice_iff: "(\<forall>x. \<exists>y. Q x y) \<longleftrightarrow> (\<exists>f. \<forall>x. Q x (f x))" | 
| 63612 | 108 | by (fast elim: someI) | 
| 50105 | 109 | |
| 110 | lemma choice_iff': "(\<forall>x. P x \<longrightarrow> (\<exists>y. Q x y)) \<longleftrightarrow> (\<exists>f. \<forall>x. P x \<longrightarrow> Q x (f x))" | |
| 63612 | 111 | by (fast elim: someI) | 
| 50105 | 112 | |
| 113 | lemma bchoice_iff: "(\<forall>x\<in>S. \<exists>y. Q x y) \<longleftrightarrow> (\<exists>f. \<forall>x\<in>S. Q x (f x))" | |
| 63612 | 114 | by (fast elim: someI) | 
| 50105 | 115 | |
| 116 | lemma bchoice_iff': "(\<forall>x\<in>S. P x \<longrightarrow> (\<exists>y. Q x y)) \<longleftrightarrow> (\<exists>f. \<forall>x\<in>S. P x \<longrightarrow> Q x (f x))" | |
| 63612 | 117 | by (fast elim: someI) | 
| 14760 | 118 | |
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
56740diff
changeset | 119 | lemma dependent_nat_choice: | 
| 63612 | 120 | assumes 1: "\<exists>x. P 0 x" | 
| 121 | and 2: "\<And>x n. P n x \<Longrightarrow> \<exists>y. P (Suc n) y \<and> Q n x y" | |
| 57448 
159e45728ceb
more equalities of topological filters; strengthen dependent_nat_choice; tuned a couple of proofs
 hoelzl parents: 
57275diff
changeset | 122 | shows "\<exists>f. \<forall>n. P n (f n) \<and> Q n (f n) (f (Suc n))" | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
56740diff
changeset | 123 | proof (intro exI allI conjI) | 
| 63040 | 124 | fix n | 
| 125 | define f where "f = rec_nat (SOME x. P 0 x) (\<lambda>n x. SOME y. P (Suc n) y \<and> Q n x y)" | |
| 63612 | 126 | then have "P 0 (f 0)" "\<And>n. P n (f n) \<Longrightarrow> P (Suc n) (f (Suc n)) \<and> Q n (f n) (f (Suc n))" | 
| 127 | using someI_ex[OF 1] someI_ex[OF 2] by simp_all | |
| 57448 
159e45728ceb
more equalities of topological filters; strengthen dependent_nat_choice; tuned a couple of proofs
 hoelzl parents: 
57275diff
changeset | 128 | then show "P n (f n)" "Q n (f n) (f (Suc n))" | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
56740diff
changeset | 129 | by (induct n) auto | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
56740diff
changeset | 130 | qed | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
56740diff
changeset | 131 | |
| 68975 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68802diff
changeset | 132 | lemma finite_subset_Union: | 
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68802diff
changeset | 133 | assumes "finite A" "A \<subseteq> \<Union>\<B>" | 
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68802diff
changeset | 134 | obtains \<F> where "finite \<F>" "\<F> \<subseteq> \<B>" "A \<subseteq> \<Union>\<F>" | 
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68802diff
changeset | 135 | proof - | 
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68802diff
changeset | 136 | have "\<forall>x\<in>A. \<exists>B\<in>\<B>. x\<in>B" | 
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68802diff
changeset | 137 | using assms by blast | 
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68802diff
changeset | 138 | then obtain f where f: "\<And>x. x \<in> A \<Longrightarrow> f x \<in> \<B> \<and> x \<in> f x" | 
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68802diff
changeset | 139 | by (auto simp add: bchoice_iff Bex_def) | 
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68802diff
changeset | 140 | show thesis | 
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68802diff
changeset | 141 | proof | 
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68802diff
changeset | 142 | show "finite (f ` A)" | 
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68802diff
changeset | 143 | using assms by auto | 
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68802diff
changeset | 144 | qed (use f in auto) | 
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68802diff
changeset | 145 | qed | 
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68802diff
changeset | 146 | |
| 58074 | 147 | |
| 60758 | 148 | subsection \<open>Function Inverse\<close> | 
| 14760 | 149 | |
| 63612 | 150 | lemma inv_def: "inv f = (\<lambda>y. SOME x. f x = y)" | 
| 151 | by (simp add: inv_into_def) | |
| 33014 | 152 | |
| 63612 | 153 | lemma inv_into_into: "x \<in> f ` A \<Longrightarrow> inv_into A f x \<in> A" | 
| 154 | by (simp add: inv_into_def) (fast intro: someI2) | |
| 14760 | 155 | |
| 63612 | 156 | lemma inv_identity [simp]: "inv (\<lambda>a. a) = (\<lambda>a. a)" | 
| 63365 | 157 | by (simp add: inv_def) | 
| 158 | ||
| 63612 | 159 | lemma inv_id [simp]: "inv id = id" | 
| 63365 | 160 | by (simp add: id_def) | 
| 14760 | 161 | |
| 63612 | 162 | lemma inv_into_f_f [simp]: "inj_on f A \<Longrightarrow> x \<in> A \<Longrightarrow> inv_into A f (f x) = x" | 
| 163 | by (simp add: inv_into_def inj_on_def) (blast intro: someI2) | |
| 14760 | 164 | |
| 63612 | 165 | lemma inv_f_f: "inj f \<Longrightarrow> inv f (f x) = x" | 
| 166 | by simp | |
| 32988 | 167 | |
| 67613 | 168 | lemma f_inv_into_f: "y \<in> f`A \<Longrightarrow> f (inv_into A f y) = y" | 
| 63612 | 169 | by (simp add: inv_into_def) (fast intro: someI2) | 
| 32988 | 170 | |
| 63612 | 171 | lemma inv_into_f_eq: "inj_on f A \<Longrightarrow> x \<in> A \<Longrightarrow> f x = y \<Longrightarrow> inv_into A f y = x" | 
| 172 | by (erule subst) (fast intro: inv_into_f_f) | |
| 32988 | 173 | |
| 63612 | 174 | lemma inv_f_eq: "inj f \<Longrightarrow> f x = y \<Longrightarrow> inv f y = x" | 
| 175 | by (simp add:inv_into_f_eq) | |
| 32988 | 176 | |
| 63612 | 177 | lemma inj_imp_inv_eq: "inj f \<Longrightarrow> \<forall>x. f (g x) = x \<Longrightarrow> inv f = g" | 
| 44921 | 178 | by (blast intro: inv_into_f_eq) | 
| 14760 | 179 | |
| 63612 | 180 | text \<open>But is it useful?\<close> | 
| 14760 | 181 | lemma inj_transfer: | 
| 63612 | 182 | assumes inj: "inj f" | 
| 183 | and minor: "\<And>y. y \<in> range f \<Longrightarrow> P (inv f y)" | |
| 14760 | 184 | shows "P x" | 
| 185 | proof - | |
| 186 | have "f x \<in> range f" by auto | |
| 63612 | 187 | then have "P(inv f (f x))" by (rule minor) | 
| 188 | then show "P x" by (simp add: inv_into_f_f [OF inj]) | |
| 14760 | 189 | qed | 
| 11451 
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
 paulson parents: diff
changeset | 190 | |
| 63612 | 191 | lemma inj_iff: "inj f \<longleftrightarrow> inv f \<circ> f = id" | 
| 192 | by (simp add: o_def fun_eq_iff) (blast intro: inj_on_inverseI inv_into_f_f) | |
| 14760 | 193 | |
| 63612 | 194 | lemma inv_o_cancel[simp]: "inj f \<Longrightarrow> inv f \<circ> f = id" | 
| 195 | by (simp add: inj_iff) | |
| 196 | ||
| 197 | lemma o_inv_o_cancel[simp]: "inj f \<Longrightarrow> g \<circ> inv f \<circ> f = g" | |
| 198 | by (simp add: comp_assoc) | |
| 23433 | 199 | |
| 63612 | 200 | lemma inv_into_image_cancel[simp]: "inj_on f A \<Longrightarrow> S \<subseteq> A \<Longrightarrow> inv_into A f ` f ` S = S" | 
| 201 | by (fastforce simp: image_def) | |
| 23433 | 202 | |
| 63612 | 203 | lemma inj_imp_surj_inv: "inj f \<Longrightarrow> surj (inv f)" | 
| 204 | by (blast intro!: surjI inv_into_f_f) | |
| 32988 | 205 | |
| 63612 | 206 | lemma surj_f_inv_f: "surj f \<Longrightarrow> f (inv f y) = y" | 
| 207 | by (simp add: f_inv_into_f) | |
| 14760 | 208 | |
| 67673 
c8caefb20564
lots of new material, ultimately related to measure theory
 paulson <lp15@cam.ac.uk> parents: 
67613diff
changeset | 209 | lemma bij_inv_eq_iff: "bij p \<Longrightarrow> x = inv p y \<longleftrightarrow> p x = y" | 
| 
c8caefb20564
lots of new material, ultimately related to measure theory
 paulson <lp15@cam.ac.uk> parents: 
67613diff
changeset | 210 | using surj_f_inv_f[of p] by (auto simp add: bij_def) | 
| 
c8caefb20564
lots of new material, ultimately related to measure theory
 paulson <lp15@cam.ac.uk> parents: 
67613diff
changeset | 211 | |
| 33057 | 212 | lemma inv_into_injective: | 
| 213 | assumes eq: "inv_into A f x = inv_into A f y" | |
| 63612 | 214 | and x: "x \<in> f`A" | 
| 215 | and y: "y \<in> f`A" | |
| 216 | shows "x = y" | |
| 14760 | 217 | proof - | 
| 63612 | 218 | from eq have "f (inv_into A f x) = f (inv_into A f y)" | 
| 219 | by simp | |
| 220 | with x y show ?thesis | |
| 221 | by (simp add: f_inv_into_f) | |
| 14760 | 222 | qed | 
| 223 | ||
| 63612 | 224 | lemma inj_on_inv_into: "B \<subseteq> f`A \<Longrightarrow> inj_on (inv_into A f) B" | 
| 225 | by (blast intro: inj_onI dest: inv_into_injective injD) | |
| 32988 | 226 | |
| 63612 | 227 | lemma bij_betw_inv_into: "bij_betw f A B \<Longrightarrow> bij_betw (inv_into A f) B A" | 
| 228 | by (auto simp add: bij_betw_def inj_on_inv_into) | |
| 14760 | 229 | |
| 63612 | 230 | lemma surj_imp_inj_inv: "surj f \<Longrightarrow> inj (inv f)" | 
| 231 | by (simp add: inj_on_inv_into) | |
| 14760 | 232 | |
| 63612 | 233 | lemma surj_iff: "surj f \<longleftrightarrow> f \<circ> inv f = id" | 
| 234 | by (auto intro!: surjI simp: surj_f_inv_f fun_eq_iff[where 'b='a]) | |
| 40702 | 235 | |
| 236 | lemma surj_iff_all: "surj f \<longleftrightarrow> (\<forall>x. f (inv f x) = x)" | |
| 63612 | 237 | by (simp add: o_def surj_iff fun_eq_iff) | 
| 14760 | 238 | |
| 63612 | 239 | lemma surj_imp_inv_eq: "surj f \<Longrightarrow> \<forall>x. g (f x) = x \<Longrightarrow> inv f = g" | 
| 240 | apply (rule ext) | |
| 241 | apply (drule_tac x = "inv f x" in spec) | |
| 242 | apply (simp add: surj_f_inv_f) | |
| 243 | done | |
| 14760 | 244 | |
| 63612 | 245 | lemma bij_imp_bij_inv: "bij f \<Longrightarrow> bij (inv f)" | 
| 246 | by (simp add: bij_def inj_imp_surj_inv surj_imp_inj_inv) | |
| 12372 | 247 | |
| 63612 | 248 | lemma inv_equality: "(\<And>x. g (f x) = x) \<Longrightarrow> (\<And>y. f (g y) = y) \<Longrightarrow> inv f = g" | 
| 249 | by (rule ext) (auto simp add: inv_into_def) | |
| 250 | ||
| 251 | lemma inv_inv_eq: "bij f \<Longrightarrow> inv (inv f) = f" | |
| 252 | by (rule inv_equality) (auto simp add: bij_def surj_f_inv_f) | |
| 14760 | 253 | |
| 63612 | 254 | text \<open> | 
| 255 | \<open>bij (inv f)\<close> implies little about \<open>f\<close>. Consider \<open>f :: bool \<Rightarrow> bool\<close> such | |
| 256 | that \<open>f True = f False = True\<close>. Then it ia consistent with axiom \<open>someI\<close> | |
| 257 | that \<open>inv f\<close> could be any function at all, including the identity function. | |
| 258 | If \<open>inv f = id\<close> then \<open>inv f\<close> is a bijection, but \<open>inj f\<close>, \<open>surj f\<close> and \<open>inv | |
| 259 | (inv f) = f\<close> all fail. | |
| 260 | \<close> | |
| 14760 | 261 | |
| 33057 | 262 | lemma inv_into_comp: | 
| 63612 | 263 | "inj_on f (g ` A) \<Longrightarrow> inj_on g A \<Longrightarrow> x \<in> f ` g ` A \<Longrightarrow> | 
| 264 | inv_into A (f \<circ> g) x = (inv_into A g \<circ> inv_into (g ` A) f) x" | |
| 265 | apply (rule inv_into_f_eq) | |
| 266 | apply (fast intro: comp_inj_on) | |
| 267 | apply (simp add: inv_into_into) | |
| 268 | apply (simp add: f_inv_into_f inv_into_into) | |
| 269 | done | |
| 32988 | 270 | |
| 63612 | 271 | lemma o_inv_distrib: "bij f \<Longrightarrow> bij g \<Longrightarrow> inv (f \<circ> g) = inv g \<circ> inv f" | 
| 272 | by (rule inv_equality) (auto simp add: bij_def surj_f_inv_f) | |
| 14760 | 273 | |
| 63807 | 274 | lemma image_f_inv_f: "surj f \<Longrightarrow> f ` (inv f ` A) = A" | 
| 62343 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
61859diff
changeset | 275 | by (simp add: surj_f_inv_f image_comp comp_def) | 
| 14760 | 276 | |
| 63612 | 277 | lemma image_inv_f_f: "inj f \<Longrightarrow> inv f ` (f ` A) = A" | 
| 62343 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
61859diff
changeset | 278 | by simp | 
| 14760 | 279 | |
| 63612 | 280 | lemma bij_image_Collect_eq: "bij f \<Longrightarrow> f ` Collect P = {y. P (inv f y)}"
 | 
| 281 | apply auto | |
| 282 | apply (force simp add: bij_is_inj) | |
| 283 | apply (blast intro: bij_is_surj [THEN surj_f_inv_f, symmetric]) | |
| 284 | done | |
| 14760 | 285 | |
| 63612 | 286 | lemma bij_vimage_eq_inv_image: "bij f \<Longrightarrow> f -` A = inv f ` A" | 
| 287 | apply (auto simp add: bij_is_surj [THEN surj_f_inv_f]) | |
| 288 | apply (blast intro: bij_is_inj [THEN inv_into_f_f, symmetric]) | |
| 289 | done | |
| 14760 | 290 | |
| 68610 | 291 | lemma inv_fn_o_fn_is_id: | 
| 292 | fixes f::"'a \<Rightarrow> 'a" | |
| 293 | assumes "bij f" | |
| 294 | shows "((inv f)^^n) o (f^^n) = (\<lambda>x. x)" | |
| 295 | proof - | |
| 296 | have "((inv f)^^n)((f^^n) x) = x" for x n | |
| 297 | proof (induction n) | |
| 298 | case (Suc n) | |
| 299 | have *: "(inv f) (f y) = y" for y | |
| 300 | by (simp add: assms bij_is_inj) | |
| 301 | have "(inv f ^^ Suc n) ((f ^^ Suc n) x) = (inv f^^n) (inv f (f ((f^^n) x)))" | |
| 302 | by (simp add: funpow_swap1) | |
| 303 | also have "... = (inv f^^n) ((f^^n) x)" | |
| 304 | using * by auto | |
| 305 | also have "... = x" using Suc.IH by auto | |
| 306 | finally show ?case by simp | |
| 307 | qed (auto) | |
| 308 | then show ?thesis unfolding o_def by blast | |
| 309 | qed | |
| 310 | ||
| 311 | lemma fn_o_inv_fn_is_id: | |
| 312 | fixes f::"'a \<Rightarrow> 'a" | |
| 313 | assumes "bij f" | |
| 314 | shows "(f^^n) o ((inv f)^^n) = (\<lambda>x. x)" | |
| 315 | proof - | |
| 316 | have "(f^^n) (((inv f)^^n) x) = x" for x n | |
| 317 | proof (induction n) | |
| 318 | case (Suc n) | |
| 319 | have *: "f(inv f y) = y" for y | |
| 320 | using bij_inv_eq_iff[OF assms] by auto | |
| 321 | have "(f ^^ Suc n) ((inv f ^^ Suc n) x) = (f^^n) (f (inv f ((inv f^^n) x)))" | |
| 322 | by (simp add: funpow_swap1) | |
| 323 | also have "... = (f^^n) ((inv f^^n) x)" | |
| 324 | using * by auto | |
| 325 | also have "... = x" using Suc.IH by auto | |
| 326 | finally show ?case by simp | |
| 327 | qed (auto) | |
| 328 | then show ?thesis unfolding o_def by blast | |
| 329 | qed | |
| 330 | ||
| 331 | lemma inv_fn: | |
| 332 | fixes f::"'a \<Rightarrow> 'a" | |
| 333 | assumes "bij f" | |
| 334 | shows "inv (f^^n) = ((inv f)^^n)" | |
| 335 | proof - | |
| 336 | have "inv (f^^n) x = ((inv f)^^n) x" for x | |
| 337 | apply (rule inv_into_f_eq, auto simp add: inj_fn[OF bij_is_inj[OF assms]]) | |
| 338 | using fn_o_inv_fn_is_id[OF assms, of n, THEN fun_cong] by (simp) | |
| 339 | then show ?thesis by auto | |
| 340 | qed | |
| 341 | ||
| 342 | lemma mono_inv: | |
| 343 | fixes f::"'a::linorder \<Rightarrow> 'b::linorder" | |
| 344 | assumes "mono f" "bij f" | |
| 345 | shows "mono (inv f)" | |
| 346 | proof | |
| 347 | fix x y::'b assume "x \<le> y" | |
| 348 | from \<open>bij f\<close> obtain a b where x: "x = f a" and y: "y = f b" by(fastforce simp: bij_def surj_def) | |
| 349 | show "inv f x \<le> inv f y" | |
| 350 | proof (rule le_cases) | |
| 351 | assume "a \<le> b" | |
| 352 | thus ?thesis using \<open>bij f\<close> x y by(simp add: bij_def inv_f_f) | |
| 353 | next | |
| 354 | assume "b \<le> a" | |
| 355 | hence "f b \<le> f a" by(rule monoD[OF \<open>mono f\<close>]) | |
| 356 | hence "y \<le> x" using x y by simp | |
| 357 | hence "x = y" using \<open>x \<le> y\<close> by auto | |
| 358 | thus ?thesis by simp | |
| 359 | qed | |
| 360 | qed | |
| 361 | ||
| 362 | lemma mono_bij_Inf: | |
| 363 | fixes f :: "'a::complete_linorder \<Rightarrow> 'b::complete_linorder" | |
| 364 | assumes "mono f" "bij f" | |
| 365 | shows "f (Inf A) = Inf (f`A)" | |
| 366 | proof - | |
| 367 | have "surj f" using \<open>bij f\<close> by (auto simp: bij_betw_def) | |
| 368 | have *: "(inv f) (Inf (f`A)) \<le> Inf ((inv f)`(f`A))" | |
| 369 | using mono_Inf[OF mono_inv[OF assms], of "f`A"] by simp | |
| 370 | have "Inf (f`A) \<le> f (Inf ((inv f)`(f`A)))" | |
| 371 | using monoD[OF \<open>mono f\<close> *] by(simp add: surj_f_inv_f[OF \<open>surj f\<close>]) | |
| 372 | also have "... = f(Inf A)" | |
| 373 | using assms by (simp add: bij_is_inj) | |
| 374 | finally show ?thesis using mono_Inf[OF assms(1), of A] by auto | |
| 375 | qed | |
| 376 | ||
| 31380 | 377 | lemma finite_fun_UNIVD1: | 
| 378 |   assumes fin: "finite (UNIV :: ('a \<Rightarrow> 'b) set)"
 | |
| 63612 | 379 | and card: "card (UNIV :: 'b set) \<noteq> Suc 0" | 
| 31380 | 380 | shows "finite (UNIV :: 'a set)" | 
| 381 | proof - | |
| 63630 | 382 | let ?UNIV_b = "UNIV :: 'b set" | 
| 383 | from fin have "finite ?UNIV_b" | |
| 63612 | 384 | by (rule finite_fun_UNIVD2) | 
| 63630 | 385 | with card have "card ?UNIV_b \<ge> Suc (Suc 0)" | 
| 386 | by (cases "card ?UNIV_b") (auto simp: card_eq_0_iff) | |
| 387 | then have "card ?UNIV_b = Suc (Suc (card ?UNIV_b - Suc (Suc 0)))" | |
| 388 | by simp | |
| 63629 | 389 | then obtain b1 b2 :: 'b where b1b2: "b1 \<noteq> b2" | 
| 390 | by (auto simp: card_Suc_eq) | |
| 63630 | 391 | from fin have fin': "finite (range (\<lambda>f :: 'a \<Rightarrow> 'b. inv f b1))" | 
| 63612 | 392 | by (rule finite_imageI) | 
| 63630 | 393 | have "UNIV = range (\<lambda>f :: 'a \<Rightarrow> 'b. inv f b1)" | 
| 31380 | 394 | proof (rule UNIV_eq_I) | 
| 395 | fix x :: 'a | |
| 63612 | 396 | from b1b2 have "x = inv (\<lambda>y. if y = x then b1 else b2) b1" | 
| 397 | by (simp add: inv_into_def) | |
| 398 | then show "x \<in> range (\<lambda>f::'a \<Rightarrow> 'b. inv f b1)" | |
| 399 | by blast | |
| 31380 | 400 | qed | 
| 63630 | 401 | with fin' show ?thesis | 
| 63612 | 402 | by simp | 
| 31380 | 403 | qed | 
| 14760 | 404 | |
| 60758 | 405 | text \<open> | 
| 54578 
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
 traytel parents: 
54295diff
changeset | 406 | Every infinite set contains a countable subset. More precisely we | 
| 61799 | 407 | show that a set \<open>S\<close> is infinite if and only if there exists an | 
| 408 | injective function from the naturals into \<open>S\<close>. | |
| 54578 
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
 traytel parents: 
54295diff
changeset | 409 | |
| 
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
 traytel parents: 
54295diff
changeset | 410 | The ``only if'' direction is harder because it requires the | 
| 
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
 traytel parents: 
54295diff
changeset | 411 | construction of a sequence of pairwise different elements of an | 
| 61799 | 412 | infinite set \<open>S\<close>. The idea is to construct a sequence of | 
| 413 | non-empty and infinite subsets of \<open>S\<close> obtained by successively | |
| 414 | removing elements of \<open>S\<close>. | |
| 60758 | 415 | \<close> | 
| 54578 
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
 traytel parents: 
54295diff
changeset | 416 | |
| 
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
 traytel parents: 
54295diff
changeset | 417 | lemma infinite_countable_subset: | 
| 63629 | 418 | assumes inf: "\<not> finite S" | 
| 419 | shows "\<exists>f::nat \<Rightarrow> 'a. inj f \<and> range f \<subseteq> S" | |
| 61799 | 420 | \<comment> \<open>Courtesy of Stephan Merz\<close> | 
| 54578 
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
 traytel parents: 
54295diff
changeset | 421 | proof - | 
| 63040 | 422 |   define Sseq where "Sseq = rec_nat S (\<lambda>n T. T - {SOME e. e \<in> T})"
 | 
| 423 | define pick where "pick n = (SOME e. e \<in> Sseq n)" for n | |
| 63540 | 424 | have *: "Sseq n \<subseteq> S" "\<not> finite (Sseq n)" for n | 
| 63612 | 425 | by (induct n) (auto simp: Sseq_def inf) | 
| 63540 | 426 | then have **: "\<And>n. pick n \<in> Sseq n" | 
| 55811 | 427 | unfolding pick_def by (subst (asm) finite.simps) (auto simp add: ex_in_conv intro: someI_ex) | 
| 63540 | 428 | with * have "range pick \<subseteq> S" by auto | 
| 63612 | 429 | moreover have "pick n \<noteq> pick (n + Suc m)" for m n | 
| 430 | proof - | |
| 63540 | 431 | have "pick n \<notin> Sseq (n + Suc m)" | 
| 432 | by (induct m) (auto simp add: Sseq_def pick_def) | |
| 63612 | 433 | with ** show ?thesis by auto | 
| 434 | qed | |
| 435 | then have "inj pick" | |
| 436 | by (intro linorder_injI) (auto simp add: less_iff_Suc_add) | |
| 54578 
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
 traytel parents: 
54295diff
changeset | 437 | ultimately show ?thesis by blast | 
| 
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
 traytel parents: 
54295diff
changeset | 438 | qed | 
| 
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
 traytel parents: 
54295diff
changeset | 439 | |
| 63629 | 440 | lemma infinite_iff_countable_subset: "\<not> finite S \<longleftrightarrow> (\<exists>f::nat \<Rightarrow> 'a. inj f \<and> range f \<subseteq> S)" | 
| 61799 | 441 | \<comment> \<open>Courtesy of Stephan Merz\<close> | 
| 55811 | 442 | using finite_imageD finite_subset infinite_UNIV_char_0 infinite_countable_subset by auto | 
| 54578 
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
 traytel parents: 
54295diff
changeset | 443 | |
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 444 | lemma image_inv_into_cancel: | 
| 63612 | 445 | assumes surj: "f`A = A'" | 
| 446 | and sub: "B' \<subseteq> A'" | |
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 447 | shows "f `((inv_into A f)`B') = B'" | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 448 | using assms | 
| 63612 | 449 | proof (auto simp: f_inv_into_f) | 
| 450 | let ?f' = "inv_into A f" | |
| 451 | fix a' | |
| 452 | assume *: "a' \<in> B'" | |
| 453 | with sub have "a' \<in> A'" by auto | |
| 454 | with surj have "a' = f (?f' a')" | |
| 455 | by (auto simp: f_inv_into_f) | |
| 456 | with * show "a' \<in> f ` (?f' ` B')" by blast | |
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 457 | qed | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 458 | |
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 459 | lemma inv_into_inv_into_eq: | 
| 63612 | 460 | assumes "bij_betw f A A'" | 
| 461 | and a: "a \<in> A" | |
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 462 | shows "inv_into A' (inv_into A f) a = f a" | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 463 | proof - | 
| 63612 | 464 | let ?f' = "inv_into A f" | 
| 465 | let ?f'' = "inv_into A' ?f'" | |
| 466 | from assms have *: "bij_betw ?f' A' A" | |
| 467 | by (auto simp: bij_betw_inv_into) | |
| 468 | with a obtain a' where a': "a' \<in> A'" "?f' a' = a" | |
| 469 | unfolding bij_betw_def by force | |
| 470 | with a * have "?f'' a = a'" | |
| 471 | by (auto simp: f_inv_into_f bij_betw_def) | |
| 472 | moreover from assms a' have "f a = a'" | |
| 473 | by (auto simp: bij_betw_def) | |
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 474 | ultimately show "?f'' a = f a" by simp | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 475 | qed | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 476 | |
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 477 | lemma inj_on_iff_surj: | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 478 |   assumes "A \<noteq> {}"
 | 
| 63629 | 479 | shows "(\<exists>f. inj_on f A \<and> f ` A \<subseteq> A') \<longleftrightarrow> (\<exists>g. g ` A' = A)" | 
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 480 | proof safe | 
| 63612 | 481 | fix f | 
| 482 | assume inj: "inj_on f A" and incl: "f ` A \<subseteq> A'" | |
| 483 | let ?phi = "\<lambda>a' a. a \<in> A \<and> f a = a'" | |
| 484 | let ?csi = "\<lambda>a. a \<in> A" | |
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 485 | let ?g = "\<lambda>a'. if a' \<in> f ` A then (SOME a. ?phi a' a) else (SOME a. ?csi a)" | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 486 | have "?g ` A' = A" | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 487 | proof | 
| 63612 | 488 | show "?g ` A' \<subseteq> A" | 
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 489 | proof clarify | 
| 63612 | 490 | fix a' | 
| 491 | assume *: "a' \<in> A'" | |
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 492 | show "?g a' \<in> A" | 
| 63612 | 493 | proof (cases "a' \<in> f ` A") | 
| 494 | case True | |
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 495 | then obtain a where "?phi a' a" by blast | 
| 63612 | 496 | then have "?phi a' (SOME a. ?phi a' a)" | 
| 497 | using someI[of "?phi a'" a] by blast | |
| 498 | with True show ?thesis by auto | |
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 499 | next | 
| 63612 | 500 | case False | 
| 501 | with assms have "?csi (SOME a. ?csi a)" | |
| 502 | using someI_ex[of ?csi] by blast | |
| 503 | with False show ?thesis by auto | |
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 504 | qed | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 505 | qed | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 506 | next | 
| 63612 | 507 | show "A \<subseteq> ?g ` A'" | 
| 508 | proof - | |
| 509 | have "?g (f a) = a \<and> f a \<in> A'" if a: "a \<in> A" for a | |
| 510 | proof - | |
| 511 | let ?b = "SOME aa. ?phi (f a) aa" | |
| 512 | from a have "?phi (f a) a" by auto | |
| 513 | then have *: "?phi (f a) ?b" | |
| 514 | using someI[of "?phi(f a)" a] by blast | |
| 515 | then have "?g (f a) = ?b" using a by auto | |
| 516 | moreover from inj * a have "a = ?b" | |
| 517 | by (auto simp add: inj_on_def) | |
| 518 | ultimately have "?g(f a) = a" by simp | |
| 519 | with incl a show ?thesis by auto | |
| 520 | qed | |
| 521 | then show ?thesis by force | |
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 522 | qed | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 523 | qed | 
| 63612 | 524 | then show "\<exists>g. g ` A' = A" by blast | 
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 525 | next | 
| 63612 | 526 | fix g | 
| 527 | let ?f = "inv_into A' g" | |
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 528 | have "inj_on ?f (g ` A')" | 
| 63612 | 529 | by (auto simp: inj_on_inv_into) | 
| 530 | moreover have "?f (g a') \<in> A'" if a': "a' \<in> A'" for a' | |
| 531 | proof - | |
| 532 | let ?phi = "\<lambda> b'. b' \<in> A' \<and> g b' = g a'" | |
| 533 | from a' have "?phi a'" by auto | |
| 534 | then have "?phi (SOME b'. ?phi b')" | |
| 535 | using someI[of ?phi] by blast | |
| 536 | then show ?thesis by (auto simp: inv_into_def) | |
| 537 | qed | |
| 538 | ultimately show "\<exists>f. inj_on f (g ` A') \<and> f ` g ` A' \<subseteq> A'" | |
| 539 | by auto | |
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 540 | qed | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 541 | |
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 542 | lemma Ex_inj_on_UNION_Sigma: | 
| 63629 | 543 | "\<exists>f. (inj_on f (\<Union>i \<in> I. A i) \<and> f ` (\<Union>i \<in> I. A i) \<subseteq> (SIGMA i : I. A i))" | 
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 544 | proof | 
| 63612 | 545 | let ?phi = "\<lambda>a i. i \<in> I \<and> a \<in> A i" | 
| 546 | let ?sm = "\<lambda>a. SOME i. ?phi a i" | |
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 547 | let ?f = "\<lambda>a. (?sm a, a)" | 
| 63612 | 548 | have "inj_on ?f (\<Union>i \<in> I. A i)" | 
| 549 | by (auto simp: inj_on_def) | |
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 550 | moreover | 
| 63612 | 551 | have "?sm a \<in> I \<and> a \<in> A(?sm a)" if "i \<in> I" and "a \<in> A i" for i a | 
| 552 | using that someI[of "?phi a" i] by auto | |
| 63629 | 553 | then have "?f ` (\<Union>i \<in> I. A i) \<subseteq> (SIGMA i : I. A i)" | 
| 63612 | 554 | by auto | 
| 63629 | 555 | ultimately show "inj_on ?f (\<Union>i \<in> I. A i) \<and> ?f ` (\<Union>i \<in> I. A i) \<subseteq> (SIGMA i : I. A i)" | 
| 63612 | 556 | by auto | 
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 557 | qed | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
40702diff
changeset | 558 | |
| 56608 | 559 | lemma inv_unique_comp: | 
| 560 | assumes fg: "f \<circ> g = id" | |
| 561 | and gf: "g \<circ> f = id" | |
| 562 | shows "inv f = g" | |
| 563 | using fg gf inv_equality[of g f] by (auto simp add: fun_eq_iff) | |
| 564 | ||
| 70179 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 565 | lemma subset_image_inj: | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 566 | "S \<subseteq> f ` T \<longleftrightarrow> (\<exists>U. U \<subseteq> T \<and> inj_on f U \<and> S = f ` U)" | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 567 | proof safe | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 568 | show "\<exists>U\<subseteq>T. inj_on f U \<and> S = f ` U" | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 569 | if "S \<subseteq> f ` T" | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 570 | proof - | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 571 | from that [unfolded subset_image_iff subset_iff] | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 572 | obtain g where g: "\<And>x. x \<in> S \<Longrightarrow> g x \<in> T \<and> x = f (g x)" | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 573 | by (auto simp add: image_iff Bex_def choice_iff') | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 574 | show ?thesis | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 575 | proof (intro exI conjI) | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 576 | show "g ` S \<subseteq> T" | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 577 | by (simp add: g image_subsetI) | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 578 | show "inj_on f (g ` S)" | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 579 | using g by (auto simp: inj_on_def) | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 580 | show "S = f ` (g ` S)" | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 581 | using g image_subset_iff by auto | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 582 | qed | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 583 | qed | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 584 | qed blast | 
| 
269dcea7426c
moved subset_image_inj into Hilbert_Choice
 paulson <lp15@cam.ac.uk> parents: 
70097diff
changeset | 585 | |
| 56608 | 586 | |
| 60758 | 587 | subsection \<open>Other Consequences of Hilbert's Epsilon\<close> | 
| 14760 | 588 | |
| 69593 | 589 | text \<open>Hilbert's Epsilon and the \<^term>\<open>split\<close> Operator\<close> | 
| 14760 | 590 | |
| 63612 | 591 | text \<open>Looping simprule!\<close> | 
| 592 | lemma split_paired_Eps: "(SOME x. P x) = (SOME (a, b). P (a, b))" | |
| 26347 | 593 | by simp | 
| 14760 | 594 | |
| 61424 
c3658c18b7bc
prod_case as canonical name for product type eliminator
 haftmann parents: 
61076diff
changeset | 595 | lemma Eps_case_prod: "Eps (case_prod P) = (SOME xy. P (fst xy) (snd xy))" | 
| 26347 | 596 | by (simp add: split_def) | 
| 14760 | 597 | |
| 63612 | 598 | lemma Eps_case_prod_eq [simp]: "(SOME (x', y'). x = x' \<and> y = y') = (x, y)" | 
| 26347 | 599 | by blast | 
| 14760 | 600 | |
| 601 | ||
| 63612 | 602 | text \<open>A relation is wellfounded iff it has no infinite descending chain.\<close> | 
| 63981 | 603 | lemma wf_iff_no_infinite_down_chain: "wf r \<longleftrightarrow> (\<nexists>f. \<forall>i. (f (Suc i), f i) \<in> r)" | 
| 604 | (is "_ \<longleftrightarrow> \<not> ?ex") | |
| 605 | proof | |
| 606 | assume "wf r" | |
| 607 | show "\<not> ?ex" | |
| 608 | proof | |
| 609 | assume ?ex | |
| 610 | then obtain f where f: "(f (Suc i), f i) \<in> r" for i | |
| 611 | by blast | |
| 612 | from \<open>wf r\<close> have minimal: "x \<in> Q \<Longrightarrow> \<exists>z\<in>Q. \<forall>y. (y, z) \<in> r \<longrightarrow> y \<notin> Q" for x Q | |
| 613 | by (auto simp: wf_eq_minimal) | |
| 614 |     let ?Q = "{w. \<exists>i. w = f i}"
 | |
| 615 | fix n | |
| 616 | have "f n \<in> ?Q" by blast | |
| 617 | from minimal [OF this] obtain j where "(y, f j) \<in> r \<Longrightarrow> y \<notin> ?Q" for y by blast | |
| 618 | with this [OF \<open>(f (Suc j), f j) \<in> r\<close>] have "f (Suc j) \<notin> ?Q" by simp | |
| 619 | then show False by blast | |
| 620 | qed | |
| 621 | next | |
| 622 | assume "\<not> ?ex" | |
| 623 | then show "wf r" | |
| 624 | proof (rule contrapos_np) | |
| 625 | assume "\<not> wf r" | |
| 626 | then obtain Q x where x: "x \<in> Q" and rec: "z \<in> Q \<Longrightarrow> \<exists>y. (y, z) \<in> r \<and> y \<in> Q" for z | |
| 627 | by (auto simp add: wf_eq_minimal) | |
| 628 | obtain descend :: "nat \<Rightarrow> 'a" | |
| 629 | where descend_0: "descend 0 = x" | |
| 630 | and descend_Suc: "descend (Suc n) = (SOME y. y \<in> Q \<and> (y, descend n) \<in> r)" for n | |
| 631 | by (rule that [of "rec_nat x (\<lambda>_ rec. (SOME y. y \<in> Q \<and> (y, rec) \<in> r))"]) simp_all | |
| 632 | have descend_Q: "descend n \<in> Q" for n | |
| 633 | proof (induct n) | |
| 634 | case 0 | |
| 635 | with x show ?case by (simp only: descend_0) | |
| 636 | next | |
| 637 | case Suc | |
| 638 | then show ?case by (simp only: descend_Suc) (rule someI2_ex; use rec in blast) | |
| 639 | qed | |
| 640 | have "(descend (Suc i), descend i) \<in> r" for i | |
| 641 | by (simp only: descend_Suc) (rule someI2_ex; use descend_Q rec in blast) | |
| 642 | then show "\<exists>f. \<forall>i. (f (Suc i), f i) \<in> r" by blast | |
| 643 | qed | |
| 644 | qed | |
| 14760 | 645 | |
| 27760 | 646 | lemma wf_no_infinite_down_chainE: | 
| 63612 | 647 | assumes "wf r" | 
| 648 | obtains k where "(f (Suc k), f k) \<notin> r" | |
| 649 | using assms wf_iff_no_infinite_down_chain[of r] by blast | |
| 27760 | 650 | |
| 651 | ||
| 63612 | 652 | text \<open>A dynamically-scoped fact for TFL\<close> | 
| 653 | lemma tfl_some: "\<forall>P x. P x \<longrightarrow> P (Eps P)" | |
| 12298 | 654 | by (blast intro: someI) | 
| 11451 
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
 paulson parents: diff
changeset | 655 | |
| 12298 | 656 | |
| 60758 | 657 | subsection \<open>An aside: bounded accessible part\<close> | 
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 658 | |
| 60758 | 659 | text \<open>Finite monotone eventually stable sequences\<close> | 
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 660 | |
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 661 | lemma finite_mono_remains_stable_implies_strict_prefix: | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 662 | fixes f :: "nat \<Rightarrow> 'a::order" | 
| 63612 | 663 | assumes S: "finite (range f)" "mono f" | 
| 664 | and eq: "\<forall>n. f n = f (Suc n) \<longrightarrow> f (Suc n) = f (Suc (Suc n))" | |
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 665 | shows "\<exists>N. (\<forall>n\<le>N. \<forall>m\<le>N. m < n \<longrightarrow> f m < f n) \<and> (\<forall>n\<ge>N. f N = f n)" | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 666 | using assms | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 667 | proof - | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 668 | have "\<exists>n. f n = f (Suc n)" | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 669 | proof (rule ccontr) | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 670 | assume "\<not> ?thesis" | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 671 | then have "\<And>n. f n \<noteq> f (Suc n)" by auto | 
| 63612 | 672 | with \<open>mono f\<close> have "\<And>n. f n < f (Suc n)" | 
| 673 | by (auto simp: le_less mono_iff_le_Suc) | |
| 674 | with lift_Suc_mono_less_iff[of f] have *: "\<And>n m. n < m \<Longrightarrow> f n < f m" | |
| 675 | by auto | |
| 55811 | 676 | have "inj f" | 
| 677 | proof (intro injI) | |
| 678 | fix x y | |
| 679 | assume "f x = f y" | |
| 63612 | 680 | then show "x = y" | 
| 681 | by (cases x y rule: linorder_cases) (auto dest: *) | |
| 55811 | 682 | qed | 
| 60758 | 683 | with \<open>finite (range f)\<close> have "finite (UNIV::nat set)" | 
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 684 | by (rule finite_imageD) | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 685 | then show False by simp | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 686 | qed | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 687 | then obtain n where n: "f n = f (Suc n)" .. | 
| 63040 | 688 | define N where "N = (LEAST n. f n = f (Suc n))" | 
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 689 | have N: "f N = f (Suc N)" | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 690 | unfolding N_def using n by (rule LeastI) | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 691 | show ?thesis | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 692 | proof (intro exI[of _ N] conjI allI impI) | 
| 63612 | 693 | fix n | 
| 694 | assume "N \<le> n" | |
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 695 | then have "\<And>m. N \<le> m \<Longrightarrow> m \<le> n \<Longrightarrow> f m = f N" | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 696 | proof (induct rule: dec_induct) | 
| 63612 | 697 | case base | 
| 698 | then show ?case by simp | |
| 699 | next | |
| 700 | case (step n) | |
| 701 | then show ?case | |
| 702 | using eq [rule_format, of "n - 1"] N | |
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 703 | by (cases n) (auto simp add: le_Suc_eq) | 
| 63612 | 704 | qed | 
| 60758 | 705 | from this[of n] \<open>N \<le> n\<close> show "f N = f n" by auto | 
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 706 | next | 
| 63612 | 707 | fix n m :: nat | 
| 708 | assume "m < n" "n \<le> N" | |
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 709 | then show "f m < f n" | 
| 62683 | 710 | proof (induct rule: less_Suc_induct) | 
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 711 | case (1 i) | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 712 | then have "i < N" by simp | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 713 | then have "f i \<noteq> f (Suc i)" | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 714 | unfolding N_def by (rule not_less_Least) | 
| 60758 | 715 | with \<open>mono f\<close> show ?case by (simp add: mono_iff_le_Suc less_le) | 
| 63612 | 716 | next | 
| 717 | case 2 | |
| 718 | then show ?case by simp | |
| 719 | qed | |
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 720 | qed | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 721 | qed | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 722 | |
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 723 | lemma finite_mono_strict_prefix_implies_finite_fixpoint: | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 724 | fixes f :: "nat \<Rightarrow> 'a set" | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 725 | assumes S: "\<And>i. f i \<subseteq> S" "finite S" | 
| 63612 | 726 | and ex: "\<exists>N. (\<forall>n\<le>N. \<forall>m\<le>N. m < n \<longrightarrow> f m \<subset> f n) \<and> (\<forall>n\<ge>N. f N = f n)" | 
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 727 | shows "f (card S) = (\<Union>n. f n)" | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 728 | proof - | 
| 63612 | 729 | from ex obtain N where inj: "\<And>n m. n \<le> N \<Longrightarrow> m \<le> N \<Longrightarrow> m < n \<Longrightarrow> f m \<subset> f n" | 
| 730 | and eq: "\<forall>n\<ge>N. f N = f n" | |
| 731 | by atomize auto | |
| 732 | have "i \<le> N \<Longrightarrow> i \<le> card (f i)" for i | |
| 733 | proof (induct i) | |
| 734 | case 0 | |
| 735 | then show ?case by simp | |
| 736 | next | |
| 737 | case (Suc i) | |
| 738 | with inj [of "Suc i" i] have "(f i) \<subset> (f (Suc i))" by auto | |
| 739 | moreover have "finite (f (Suc i))" using S by (rule finite_subset) | |
| 740 | ultimately have "card (f i) < card (f (Suc i))" by (intro psubset_card_mono) | |
| 741 | with Suc inj show ?case by auto | |
| 742 | qed | |
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 743 | then have "N \<le> card (f N)" by simp | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 744 | also have "\<dots> \<le> card S" using S by (intro card_mono) | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 745 | finally have "f (card S) = f N" using eq by auto | 
| 63612 | 746 | then show ?thesis | 
| 747 | using eq inj [of N] | |
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 748 | apply auto | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 749 | apply (case_tac "n < N") | 
| 63612 | 750 | apply (auto simp: not_less) | 
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 751 | done | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 752 | qed | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 753 | |
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49739diff
changeset | 754 | |
| 60758 | 755 | subsection \<open>More on injections, bijections, and inverses\<close> | 
| 55020 | 756 | |
| 63374 | 757 | locale bijection = | 
| 758 | fixes f :: "'a \<Rightarrow> 'a" | |
| 759 | assumes bij: "bij f" | |
| 760 | begin | |
| 761 | ||
| 63612 | 762 | lemma bij_inv: "bij (inv f)" | 
| 63374 | 763 | using bij by (rule bij_imp_bij_inv) | 
| 764 | ||
| 63612 | 765 | lemma surj [simp]: "surj f" | 
| 63374 | 766 | using bij by (rule bij_is_surj) | 
| 767 | ||
| 63612 | 768 | lemma inj: "inj f" | 
| 63374 | 769 | using bij by (rule bij_is_inj) | 
| 770 | ||
| 63612 | 771 | lemma surj_inv [simp]: "surj (inv f)" | 
| 63374 | 772 | using inj by (rule inj_imp_surj_inv) | 
| 773 | ||
| 63612 | 774 | lemma inj_inv: "inj (inv f)" | 
| 63374 | 775 | using surj by (rule surj_imp_inj_inv) | 
| 776 | ||
| 63612 | 777 | lemma eqI: "f a = f b \<Longrightarrow> a = b" | 
| 63374 | 778 | using inj by (rule injD) | 
| 779 | ||
| 63612 | 780 | lemma eq_iff [simp]: "f a = f b \<longleftrightarrow> a = b" | 
| 63374 | 781 | by (auto intro: eqI) | 
| 782 | ||
| 63612 | 783 | lemma eq_invI: "inv f a = inv f b \<Longrightarrow> a = b" | 
| 63374 | 784 | using inj_inv by (rule injD) | 
| 785 | ||
| 63612 | 786 | lemma eq_inv_iff [simp]: "inv f a = inv f b \<longleftrightarrow> a = b" | 
| 63374 | 787 | by (auto intro: eq_invI) | 
| 788 | ||
| 63612 | 789 | lemma inv_left [simp]: "inv f (f a) = a" | 
| 63374 | 790 | using inj by (simp add: inv_f_eq) | 
| 791 | ||
| 63612 | 792 | lemma inv_comp_left [simp]: "inv f \<circ> f = id" | 
| 63374 | 793 | by (simp add: fun_eq_iff) | 
| 794 | ||
| 63612 | 795 | lemma inv_right [simp]: "f (inv f a) = a" | 
| 63374 | 796 | using surj by (simp add: surj_f_inv_f) | 
| 797 | ||
| 63612 | 798 | lemma inv_comp_right [simp]: "f \<circ> inv f = id" | 
| 63374 | 799 | by (simp add: fun_eq_iff) | 
| 800 | ||
| 63612 | 801 | lemma inv_left_eq_iff [simp]: "inv f a = b \<longleftrightarrow> f b = a" | 
| 63374 | 802 | by auto | 
| 803 | ||
| 63612 | 804 | lemma inv_right_eq_iff [simp]: "b = inv f a \<longleftrightarrow> f b = a" | 
| 63374 | 805 | by auto | 
| 806 | ||
| 807 | end | |
| 808 | ||
| 55020 | 809 | lemma infinite_imp_bij_betw: | 
| 63612 | 810 | assumes infinite: "\<not> finite A" | 
| 811 |   shows "\<exists>h. bij_betw h A (A - {a})"
 | |
| 812 | proof (cases "a \<in> A") | |
| 813 | case False | |
| 814 |   then have "A - {a} = A" by blast
 | |
| 815 | then show ?thesis | |
| 816 | using bij_betw_id[of A] by auto | |
| 55020 | 817 | next | 
| 63612 | 818 | case True | 
| 819 |   with infinite have "\<not> finite (A - {a})" by auto
 | |
| 820 |   with infinite_iff_countable_subset[of "A - {a}"]
 | |
| 821 |   obtain f :: "nat \<Rightarrow> 'a" where 1: "inj f" and 2: "f ` UNIV \<subseteq> A - {a}" by blast
 | |
| 822 | define g where "g n = (if n = 0 then a else f (Suc n))" for n | |
| 823 | define A' where "A' = g ` UNIV" | |
| 824 | have *: "\<forall>y. f y \<noteq> a" using 2 by blast | |
| 825 | have 3: "inj_on g UNIV \<and> g ` UNIV \<subseteq> A \<and> a \<in> g ` UNIV" | |
| 826 | apply (auto simp add: True g_def [abs_def]) | |
| 827 | apply (unfold inj_on_def) | |
| 828 | apply (intro ballI impI) | |
| 829 | apply (case_tac "x = 0") | |
| 830 | apply (auto simp add: 2) | |
| 831 | proof - | |
| 832 | fix y | |
| 833 | assume "a = (if y = 0 then a else f (Suc y))" | |
| 834 | then show "y = 0" by (cases "y = 0") (use * in auto) | |
| 55020 | 835 | next | 
| 836 | fix x y | |
| 837 | assume "f (Suc x) = (if y = 0 then a else f (Suc y))" | |
| 63612 | 838 | with 1 * show "x = y" by (cases "y = 0") (auto simp: inj_on_def) | 
| 55020 | 839 | next | 
| 63612 | 840 | fix n | 
| 841 | from 2 show "f (Suc n) \<in> A" by blast | |
| 55020 | 842 | qed | 
| 63612 | 843 | then have 4: "bij_betw g UNIV A' \<and> a \<in> A' \<and> A' \<subseteq> A" | 
| 844 | using inj_on_imp_bij_betw[of g] by (auto simp: A'_def) | |
| 845 | then have 5: "bij_betw (inv g) A' UNIV" | |
| 846 | by (auto simp add: bij_betw_inv_into) | |
| 847 | from 3 obtain n where n: "g n = a" by auto | |
| 848 |   have 6: "bij_betw g (UNIV - {n}) (A' - {a})"
 | |
| 849 | by (rule bij_betw_subset) (use 3 4 n in \<open>auto simp: image_set_diff A'_def\<close>) | |
| 850 | define v where "v m = (if m < n then m else Suc m)" for m | |
| 55020 | 851 |   have 7: "bij_betw v UNIV (UNIV - {n})"
 | 
| 63612 | 852 | proof (unfold bij_betw_def inj_on_def, intro conjI, clarify) | 
| 853 | fix m1 m2 | |
| 854 | assume "v m1 = v m2" | |
| 855 | then show "m1 = m2" | |
| 856 | apply (cases "m1 < n") | |
| 857 | apply (cases "m2 < n") | |
| 858 | apply (auto simp: inj_on_def v_def [abs_def]) | |
| 859 | apply (cases "m2 < n") | |
| 860 | apply auto | |
| 861 | done | |
| 55020 | 862 | next | 
| 863 |     show "v ` UNIV = UNIV - {n}"
 | |
| 63612 | 864 | proof (auto simp: v_def [abs_def]) | 
| 865 | fix m | |
| 866 | assume "m \<noteq> n" | |
| 867 |       assume *: "m \<notin> Suc ` {m'. \<not> m' < n}"
 | |
| 868 | have False if "n \<le> m" | |
| 869 | proof - | |
| 870 | from \<open>m \<noteq> n\<close> that have **: "Suc n \<le> m" by auto | |
| 871 | from Suc_le_D [OF this] obtain m' where m': "m = Suc m'" .. | |
| 872 | with ** have "n \<le> m'" by auto | |
| 873 | with m' * show ?thesis by auto | |
| 874 | qed | |
| 875 | then show "m < n" by force | |
| 55020 | 876 | qed | 
| 877 | qed | |
| 63612 | 878 | define h' where "h' = g \<circ> v \<circ> (inv g)" | 
| 879 |   with 5 6 7 have 8: "bij_betw h' A' (A' - {a})"
 | |
| 880 | by (auto simp add: bij_betw_trans) | |
| 881 | define h where "h b = (if b \<in> A' then h' b else b)" for b | |
| 882 | then have "\<forall>b \<in> A'. h b = h' b" by simp | |
| 883 |   with 8 have "bij_betw h  A' (A' - {a})"
 | |
| 884 | using bij_betw_cong[of A' h] by auto | |
| 55020 | 885 | moreover | 
| 63612 | 886 | have "\<forall>b \<in> A - A'. h b = b" by (auto simp: h_def) | 
| 887 | then have "bij_betw h (A - A') (A - A')" | |
| 888 | using bij_betw_cong[of "A - A'" h id] bij_betw_id[of "A - A'"] by auto | |
| 55020 | 889 | moreover | 
| 63612 | 890 |   from 4 have "(A' \<inter> (A - A') = {} \<and> A' \<union> (A - A') = A) \<and>
 | 
| 891 |     ((A' - {a}) \<inter> (A - A') = {} \<and> (A' - {a}) \<union> (A - A') = A - {a})"
 | |
| 892 | by blast | |
| 55020 | 893 |   ultimately have "bij_betw h A (A - {a})"
 | 
| 63612 | 894 |     using bij_betw_combine[of h A' "A' - {a}" "A - A'" "A - A'"] by simp
 | 
| 895 | then show ?thesis by blast | |
| 55020 | 896 | qed | 
| 897 | ||
| 898 | lemma infinite_imp_bij_betw2: | |
| 63612 | 899 | assumes "\<not> finite A" | 
| 900 |   shows "\<exists>h. bij_betw h A (A \<union> {a})"
 | |
| 901 | proof (cases "a \<in> A") | |
| 902 | case True | |
| 903 |   then have "A \<union> {a} = A" by blast
 | |
| 904 | then show ?thesis using bij_betw_id[of A] by auto | |
| 55020 | 905 | next | 
| 63612 | 906 | case False | 
| 55020 | 907 |   let ?A' = "A \<union> {a}"
 | 
| 63612 | 908 |   from False have "A = ?A' - {a}" by blast
 | 
| 909 | moreover from assms have "\<not> finite ?A'" by auto | |
| 55020 | 910 | ultimately obtain f where "bij_betw f ?A' A" | 
| 63612 | 911 | using infinite_imp_bij_betw[of ?A' a] by auto | 
| 912 | then have "bij_betw (inv_into ?A' f) A ?A'" by (rule bij_betw_inv_into) | |
| 913 | then show ?thesis by auto | |
| 55020 | 914 | qed | 
| 915 | ||
| 63612 | 916 | lemma bij_betw_inv_into_left: "bij_betw f A A' \<Longrightarrow> a \<in> A \<Longrightarrow> inv_into A f (f a) = a" | 
| 917 | unfolding bij_betw_def by clarify (rule inv_into_f_f) | |
| 55020 | 918 | |
| 63612 | 919 | lemma bij_betw_inv_into_right: "bij_betw f A A' \<Longrightarrow> a' \<in> A' \<Longrightarrow> f (inv_into A f a') = a'" | 
| 920 | unfolding bij_betw_def using f_inv_into_f by force | |
| 55020 | 921 | |
| 922 | lemma bij_betw_inv_into_subset: | |
| 63612 | 923 | "bij_betw f A A' \<Longrightarrow> B \<subseteq> A \<Longrightarrow> f ` B = B' \<Longrightarrow> bij_betw (inv_into A f) B' B" | 
| 924 | by (auto simp: bij_betw_def intro: inj_on_inv_into) | |
| 55020 | 925 | |
| 926 | ||
| 60758 | 927 | subsection \<open>Specification package -- Hilbertized version\<close> | 
| 17893 
aef5a6d11c2a
added lemma exE_some (from specification_package.ML);
 wenzelm parents: 
17702diff
changeset | 928 | |
| 63612 | 929 | lemma exE_some: "Ex P \<Longrightarrow> c \<equiv> Eps P \<Longrightarrow> P c" | 
| 17893 
aef5a6d11c2a
added lemma exE_some (from specification_package.ML);
 wenzelm parents: 
17702diff
changeset | 930 | by (simp only: someI_ex) | 
| 
aef5a6d11c2a
added lemma exE_some (from specification_package.ML);
 wenzelm parents: 
17702diff
changeset | 931 | |
| 69605 | 932 | ML_file \<open>Tools/choice_specification.ML\<close> | 
| 14115 | 933 | |
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 934 | subsection \<open>Complete Distributive Lattices -- Properties depending on Hilbert Choice\<close> | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 935 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 936 | context complete_distrib_lattice | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 937 | begin | 
| 69479 | 938 | |
| 939 | lemma Sup_Inf: "\<Squnion> (Inf ` A) = \<Sqinter> (Sup ` {f ` A |f. \<forall>B\<in>A. f B \<in> B})"
 | |
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 940 | proof (rule antisym) | 
| 69479 | 941 |   show "\<Squnion> (Inf ` A) \<le> \<Sqinter> (Sup ` {f ` A |f. \<forall>B\<in>A. f B \<in> B})"
 | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 942 | apply (rule Sup_least, rule INF_greatest) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 943 | using Inf_lower2 Sup_upper by auto | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 944 | next | 
| 69479 | 945 |   show "\<Sqinter> (Sup ` {f ` A |f. \<forall>B\<in>A. f B \<in> B}) \<le> \<Squnion> (Inf ` A)"
 | 
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 946 | proof (simp add: Inf_Sup, rule SUP_least, simp, safe) | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 947 | fix f | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 948 | assume "\<forall>Y. (\<exists>f. Y = f ` A \<and> (\<forall>Y\<in>A. f Y \<in> Y)) \<longrightarrow> f Y \<in> Y" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 949 | from this have B: "\<And> F . (\<forall> Y \<in> A . F Y \<in> Y) \<Longrightarrow> \<exists> Z \<in> A . f (F ` A) = F Z" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 950 | by auto | 
| 69275 | 951 |     show "\<Sqinter>(f ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}) \<le> \<Squnion>(Inf ` A)"
 | 
| 952 |     proof (cases "\<exists> Z \<in> A . \<Sqinter>(f ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}) \<le> Inf Z")
 | |
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 953 | case True | 
| 69275 | 954 |       from this obtain Z where [simp]: "Z \<in> A" and A: "\<Sqinter>(f ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}) \<le> Inf Z"
 | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 955 | by blast | 
| 69275 | 956 | have B: "... \<le> \<Squnion>(Inf ` A)" | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 957 | by (simp add: SUP_upper) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 958 | from A and B show ?thesis | 
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 959 | by simp | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 960 | next | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 961 | case False | 
| 69275 | 962 |       from this have X: "\<And> Z . Z \<in> A \<Longrightarrow> \<exists> x . x \<in> Z \<and> \<not> \<Sqinter>(f ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}) \<le> x"
 | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 963 | using Inf_greatest by blast | 
| 69275 | 964 |       define F where "F = (\<lambda> Z . SOME x . x \<in> Z \<and> \<not> \<Sqinter>(f ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}) \<le> x)"
 | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 965 | have C: "\<And> Y . Y \<in> A \<Longrightarrow> F Y \<in> Y" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 966 | using X by (simp add: F_def, rule someI2_ex, auto) | 
| 69275 | 967 |       have E: "\<And> Y . Y \<in> A \<Longrightarrow> \<not> \<Sqinter>(f ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}) \<le> F Y"
 | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 968 | using X by (simp add: F_def, rule someI2_ex, auto) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 969 | from C and B obtain Z where D: "Z \<in> A " and Y: "f (F ` A) = F Z" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 970 | by blast | 
| 69275 | 971 |       from E and D have W: "\<not> \<Sqinter>(f ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}) \<le> F Z"
 | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 972 | by simp | 
| 69275 | 973 |       have "\<Sqinter>(f ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}) \<le> f (F ` A)"
 | 
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 974 | apply (rule INF_lower) | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 975 | using C by blast | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 976 | from this and W and Y show ?thesis | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 977 | by simp | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 978 | qed | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 979 | qed | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 980 | qed | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 981 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 982 | lemma dual_complete_distrib_lattice: | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 983 | "class.complete_distrib_lattice Sup Inf sup (\<ge>) (>) inf \<top> \<bottom>" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 984 | apply (rule class.complete_distrib_lattice.intro) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 985 | apply (fact dual_complete_lattice) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 986 | by (simp add: class.complete_distrib_lattice_axioms_def Sup_Inf) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 987 | |
| 68802 | 988 | lemma sup_Inf: "a \<squnion> \<Sqinter>B = \<Sqinter>((\<squnion>) a ` B)" | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 989 | proof (rule antisym) | 
| 68802 | 990 | show "a \<squnion> \<Sqinter>B \<le> \<Sqinter>((\<squnion>) a ` B)" | 
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 991 | apply (rule INF_greatest) | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 992 | using Inf_lower sup.mono by fastforce | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 993 | next | 
| 68802 | 994 |   have "\<Sqinter>((\<squnion>) a ` B) \<le> \<Sqinter>(Sup ` {{f {a}, f B} |f. f {a} = a \<and> f B \<in> B})"
 | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 995 | by (rule INF_greatest, auto simp add: INF_lower) | 
| 69275 | 996 |   also have "... = \<Squnion>(Inf ` {{a}, B})"
 | 
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 997 | by (unfold Sup_Inf, simp) | 
| 68802 | 998 | finally show "\<Sqinter>((\<squnion>) a ` B) \<le> a \<squnion> \<Sqinter>B" | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 999 | by simp | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1000 | qed | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1001 | |
| 68802 | 1002 | lemma inf_Sup: "a \<sqinter> \<Squnion>B = \<Squnion>((\<sqinter>) a ` B)" | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1003 | using dual_complete_distrib_lattice | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1004 | by (rule complete_distrib_lattice.sup_Inf) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1005 | |
| 69479 | 1006 | lemma INF_SUP: "(\<Sqinter>y. \<Squnion>x. P x y) = (\<Squnion>f. \<Sqinter>x. P (f x) x)" | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1007 | proof (rule antisym) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1008 | show "(SUP x. INF y. P (x y) y) \<le> (INF y. SUP x. P x y)" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1009 | by (rule SUP_least, rule INF_greatest, rule SUP_upper2, simp_all, rule INF_lower2, simp, blast) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1010 | next | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1011 |   have "(INF y. SUP x. ((P x y))) \<le> Inf (Sup ` {{P x y | x . True} | y . True })" (is "?A \<le> ?B")
 | 
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1012 | proof (rule INF_greatest, clarsimp) | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1013 | fix y | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1014 | have "?A \<le> (SUP x. P x y)" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1015 | by (rule INF_lower, simp) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1016 |     also have "... \<le> Sup {uu. \<exists>x. uu = P x y}"
 | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1017 | by (simp add: full_SetCompr_eq) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1018 |     finally show "?A \<le> Sup {uu. \<exists>x. uu = P x y}"
 | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1019 | by simp | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1020 | qed | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1021 | also have "... \<le> (SUP x. INF y. P (x y) y)" | 
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1022 | proof (subst Inf_Sup, rule SUP_least, clarsimp) | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1023 | fix f | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1024 |     assume A: "\<forall>Y. (\<exists>y. Y = {uu. \<exists>x. uu = P x y}) \<longrightarrow> f Y \<in> Y"
 | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1025 | |
| 68802 | 1026 |     have " \<Sqinter>(f ` {uu. \<exists>y. uu = {uu. \<exists>x. uu = P x y}}) \<le>
 | 
| 1027 |       (\<Sqinter>y. P (SOME x. f {P x y |x. True} = P x y) y)"
 | |
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1028 | proof (rule INF_greatest, clarsimp) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1029 | fix y | 
| 68802 | 1030 |         have "(INF x\<in>{uu. \<exists>y. uu = {uu. \<exists>x. uu = P x y}}. f x) \<le> f {uu. \<exists>x. uu = P x y}"
 | 
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1031 | by (rule INF_lower, blast) | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1032 |         also have "... \<le> P (SOME x. f {uu . \<exists>x. uu = P x y} = P x y) y"
 | 
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1033 | apply (rule someI2_ex) | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1034 | using A by auto | 
| 68802 | 1035 |         finally show "\<Sqinter>(f ` {uu. \<exists>y. uu = {uu. \<exists>x. uu = P x y}}) \<le>
 | 
| 1036 |           P (SOME x. f {uu. \<exists>x. uu = P x y} = P x y) y"
 | |
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1037 | by simp | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1038 | qed | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1039 | also have "... \<le> (SUP x. INF y. P (x y) y)" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1040 | by (rule SUP_upper, simp) | 
| 68802 | 1041 |       finally show "\<Sqinter>(f ` {uu. \<exists>y. uu = {uu. \<exists>x. uu = P x y}}) \<le> (\<Squnion>x. \<Sqinter>y. P (x y) y)"
 | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1042 | by simp | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1043 | qed | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1044 | finally show "(INF y. SUP x. P x y) \<le> (SUP x. INF y. P (x y) y)" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1045 | by simp | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1046 | qed | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1047 | |
| 69478 | 1048 | lemma INF_SUP_set: "(\<Sqinter>B\<in>A. \<Squnion>(g ` B)) = (\<Squnion>B\<in>{f ` A |f. \<forall>C\<in>A. f C \<in> C}. \<Sqinter>(g ` B))"
 | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1049 | proof (rule antisym) | 
| 69478 | 1050 | have "\<Sqinter> ((g \<circ> f) ` A) \<le> \<Squnion> (g ` B)" if "\<And>B. B \<in> A \<Longrightarrow> f B \<in> B" and "B \<in> A" | 
| 1051 | for f and B | |
| 1052 | using that by (auto intro: SUP_upper2 INF_lower2) | |
| 1053 |   then show "(\<Squnion>x\<in>{f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}. \<Sqinter>a\<in>x. g a) \<le> (\<Sqinter>x\<in>A. \<Squnion>a\<in>x. g a)"
 | |
| 69861 
62e47f06d22c
avoid context-sensitive simp rules whose context-free form (image_comp) is not simp by default
 haftmann parents: 
69768diff
changeset | 1054 | by (auto intro!: SUP_least INF_greatest simp add: image_comp) | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1055 | next | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1056 |   show "(\<Sqinter>x\<in>A. \<Squnion>a\<in>x. g a) \<le> (\<Squnion>x\<in>{f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}. \<Sqinter>a\<in>x. g a)"
 | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1057 |   proof (cases "{} \<in> A")
 | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1058 | case True | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1059 | then show ?thesis | 
| 69478 | 1060 | by (rule INF_lower2) simp_all | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1061 | next | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1062 | case False | 
| 69478 | 1063 | have *: "\<And>f B. B \<in> A \<Longrightarrow> f B \<in> B \<Longrightarrow> | 
| 1064 | (\<Sqinter>B. if B \<in> A then if f B \<in> B then g (f B) else \<bottom> else \<top>) \<le> g (f B)" | |
| 1065 | by (rule INF_lower2, auto) | |
| 1066 | have **: "\<And>f B. B \<in> A \<Longrightarrow> f B \<notin> B \<Longrightarrow> | |
| 1067 | (\<Sqinter>B. if B \<in> A then if f B \<in> B then g (f B) else \<bottom> else \<top>) \<le> g (SOME x. x \<in> B)" | |
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1068 | by (rule INF_lower2, auto) | 
| 69478 | 1069 | have ****: "\<And>f B. B \<in> A \<Longrightarrow> | 
| 1070 | (\<Sqinter>B. if B \<in> A then if f B \<in> B then g (f B) else \<bottom> else \<top>) | |
| 1071 | \<le> (if f B \<in> B then g (f B) else g (SOME x. x \<in> B))" | |
| 1072 | by (rule INF_lower2) auto | |
| 1073 | have ***: "\<And>x. (\<Sqinter>B. if B \<in> A then if x B \<in> B then g (x B) else \<bottom> else \<top>) | |
| 1074 |         \<le> (\<Squnion>x\<in>{f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}. \<Sqinter>x\<in>x. g x)"
 | |
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1075 | proof - | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1076 | fix x | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1077 | define F where "F = (\<lambda> (y::'b set) . if x y \<in> y then x y else (SOME x . x \<in>y))" | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1078 | have B: "(\<forall>Y\<in>A. F Y \<in> Y)" | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1079 | using False some_in_eq F_def by auto | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1080 |       have A: "F ` A \<in> {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}"
 | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1081 | using B by blast | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1082 |       show "(\<Sqinter>xa. if xa \<in> A then if x xa \<in> xa then g (x xa) else \<bottom> else \<top>) \<le> (\<Squnion>x\<in>{f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}. \<Sqinter>x\<in>x. g x)"
 | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1083 | using A apply (rule SUP_upper2) | 
| 69478 | 1084 | apply (rule INF_greatest) | 
| 69768 | 1085 | using * ** | 
| 1086 | apply (auto simp add: F_def) | |
| 69478 | 1087 | done | 
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1088 | qed | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1089 | |
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1090 |     {fix x
 | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1091 | have "(\<Sqinter>x\<in>A. \<Squnion>x\<in>x. g x) \<le> (\<Squnion>xa. if x \<in> A then if xa \<in> x then g xa else \<bottom> else \<top>)" | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1092 | proof (cases "x \<in> A") | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1093 | case True | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1094 | then show ?thesis | 
| 69768 | 1095 | apply (rule INF_lower2) | 
| 1096 | apply (rule SUP_least) | |
| 1097 | apply (rule SUP_upper2) | |
| 1098 | apply auto | |
| 1099 | done | |
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1100 | next | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1101 | case False | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1102 | then show ?thesis by simp | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1103 | qed | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1104 | } | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1105 | from this have "(\<Sqinter>x\<in>A. \<Squnion>a\<in>x. g a) \<le> (\<Sqinter>x. \<Squnion>xa. if x \<in> A then if xa \<in> x then g xa else \<bottom> else \<top>)" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1106 | by (rule INF_greatest) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1107 | also have "... = (\<Squnion>x. \<Sqinter>xa. if xa \<in> A then if x xa \<in> xa then g (x xa) else \<bottom> else \<top>)" | 
| 69768 | 1108 | by (simp only: INF_SUP) | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1109 |     also have "... \<le> (\<Squnion>x\<in>{f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}. \<Sqinter>a\<in>x. g a)"
 | 
| 69768 | 1110 | apply (rule SUP_least) | 
| 1111 | using *** apply simp | |
| 1112 | done | |
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1113 | finally show ?thesis by simp | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1114 | qed | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1115 | qed | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1116 | |
| 69479 | 1117 | lemma SUP_INF: "(\<Squnion>y. \<Sqinter>x. P x y) = (\<Sqinter>x. \<Squnion>y. P (x y) y)" | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1118 | using dual_complete_distrib_lattice | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1119 | by (rule complete_distrib_lattice.INF_SUP) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1120 | |
| 69479 | 1121 | lemma SUP_INF_set: "(\<Squnion>x\<in>A. \<Sqinter> (g ` x)) = (\<Sqinter>x\<in>{f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}. \<Squnion> (g ` x))"
 | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1122 | using dual_complete_distrib_lattice | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1123 | by (rule complete_distrib_lattice.INF_SUP_set) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1124 | |
| 11451 
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
 paulson parents: diff
changeset | 1125 | end | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1126 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1127 | (*properties of the former complete_distrib_lattice*) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1128 | context complete_distrib_lattice | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1129 | begin | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1130 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1131 | lemma sup_INF: "a \<squnion> (\<Sqinter>b\<in>B. f b) = (\<Sqinter>b\<in>B. a \<squnion> f b)" | 
| 69861 
62e47f06d22c
avoid context-sensitive simp rules whose context-free form (image_comp) is not simp by default
 haftmann parents: 
69768diff
changeset | 1132 | by (simp add: sup_Inf image_comp) | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1133 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1134 | lemma inf_SUP: "a \<sqinter> (\<Squnion>b\<in>B. f b) = (\<Squnion>b\<in>B. a \<sqinter> f b)" | 
| 69861 
62e47f06d22c
avoid context-sensitive simp rules whose context-free form (image_comp) is not simp by default
 haftmann parents: 
69768diff
changeset | 1135 | by (simp add: inf_Sup image_comp) | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1136 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1137 | lemma Inf_sup: "\<Sqinter>B \<squnion> a = (\<Sqinter>b\<in>B. b \<squnion> a)" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1138 | by (simp add: sup_Inf sup_commute) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1139 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1140 | lemma Sup_inf: "\<Squnion>B \<sqinter> a = (\<Squnion>b\<in>B. b \<sqinter> a)" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1141 | by (simp add: inf_Sup inf_commute) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1142 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1143 | lemma INF_sup: "(\<Sqinter>b\<in>B. f b) \<squnion> a = (\<Sqinter>b\<in>B. f b \<squnion> a)" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1144 | by (simp add: sup_INF sup_commute) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1145 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1146 | lemma SUP_inf: "(\<Squnion>b\<in>B. f b) \<sqinter> a = (\<Squnion>b\<in>B. f b \<sqinter> a)" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1147 | by (simp add: inf_SUP inf_commute) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1148 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1149 | lemma Inf_sup_eq_top_iff: "(\<Sqinter>B \<squnion> a = \<top>) \<longleftrightarrow> (\<forall>b\<in>B. b \<squnion> a = \<top>)" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1150 | by (simp only: Inf_sup INF_top_conv) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1151 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1152 | lemma Sup_inf_eq_bot_iff: "(\<Squnion>B \<sqinter> a = \<bottom>) \<longleftrightarrow> (\<forall>b\<in>B. b \<sqinter> a = \<bottom>)" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1153 | by (simp only: Sup_inf SUP_bot_conv) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1154 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1155 | lemma INF_sup_distrib2: "(\<Sqinter>a\<in>A. f a) \<squnion> (\<Sqinter>b\<in>B. g b) = (\<Sqinter>a\<in>A. \<Sqinter>b\<in>B. f a \<squnion> g b)" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1156 | by (subst INF_commute) (simp add: sup_INF INF_sup) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1157 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1158 | lemma SUP_inf_distrib2: "(\<Squnion>a\<in>A. f a) \<sqinter> (\<Squnion>b\<in>B. g b) = (\<Squnion>a\<in>A. \<Squnion>b\<in>B. f a \<sqinter> g b)" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1159 | by (subst SUP_commute) (simp add: inf_SUP SUP_inf) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1160 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1161 | end | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1162 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1163 | context complete_boolean_algebra | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1164 | begin | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1165 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1166 | lemma dual_complete_boolean_algebra: | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1167 | "class.complete_boolean_algebra Sup Inf sup (\<ge>) (>) inf \<top> \<bottom> (\<lambda>x y. x \<squnion> - y) uminus" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1168 | by (rule class.complete_boolean_algebra.intro, | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1169 | rule dual_complete_distrib_lattice, | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1170 | rule dual_boolean_algebra) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1171 | end | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1172 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1173 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1174 | |
| 68802 | 1175 | instantiation set :: (type) complete_distrib_lattice | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1176 | begin | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1177 | instance proof (standard, clarsimp) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1178 |   fix A :: "(('a set) set) set"
 | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1179 | fix x::'a | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1180 | define F where "F = (\<lambda> Y . (SOME X . (Y \<in> A \<and> X \<in> Y \<and> x \<in> X)))" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1181 | assume A: "\<forall>xa\<in>A. \<exists>X\<in>xa. x \<in> X" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1182 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1183 | from this have B: " (\<forall>xa \<in> F ` A. x \<in> xa)" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1184 | apply (safe, simp add: F_def) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1185 | by (rule someI2_ex, auto) | 
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1186 | |
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1187 | have C: "(\<forall>Y\<in>A. F Y \<in> Y)" | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1188 | apply (simp add: F_def, safe) | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1189 | apply (rule someI2_ex) | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1190 | using A by auto | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1191 | |
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1192 | have "(\<exists>f. F ` A = f ` A \<and> (\<forall>Y\<in>A. f Y \<in> Y))" | 
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1193 | using C by blast | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1194 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1195 | from B and this show "\<exists>X. (\<exists>f. X = f ` A \<and> (\<forall>Y\<in>A. f Y \<in> Y)) \<and> (\<forall>xa\<in>X. x \<in> xa)" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1196 | by auto | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1197 | qed | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1198 | end | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1199 | |
| 68802 | 1200 | instance set :: (type) complete_boolean_algebra .. | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1201 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1202 | instantiation "fun" :: (type, complete_distrib_lattice) complete_distrib_lattice | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1203 | begin | 
| 69861 
62e47f06d22c
avoid context-sensitive simp rules whose context-free form (image_comp) is not simp by default
 haftmann parents: 
69768diff
changeset | 1204 | instance by standard (simp add: le_fun_def INF_SUP_set image_comp) | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1205 | end | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1206 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1207 | instance "fun" :: (type, complete_boolean_algebra) complete_boolean_algebra .. | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1208 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1209 | context complete_linorder | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1210 | begin | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1211 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1212 | subclass complete_distrib_lattice | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1213 | proof (standard, rule ccontr) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1214 | fix A | 
| 69275 | 1215 |   assume "\<not> \<Sqinter>(Sup ` A) \<le> \<Squnion>(Inf ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y})"
 | 
| 1216 |   then have C: "\<Sqinter>(Sup ` A) > \<Squnion>(Inf ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y})"
 | |
| 1217 | by (simp add: not_le) | |
| 1218 | show False | |
| 1219 |     proof (cases "\<exists> z . \<Sqinter>(Sup ` A) > z \<and> z > \<Squnion>(Inf ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y})")
 | |
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1220 | case True | 
| 69275 | 1221 |       from this obtain z where A: "z < \<Sqinter>(Sup ` A)" and X: "z > \<Squnion>(Inf ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y})"
 | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1222 | by blast | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1223 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1224 | from A have "\<And> Y . Y \<in> A \<Longrightarrow> z < Sup Y" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1225 | by (simp add: less_INF_D) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1226 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1227 | from this have B: "\<And> Y . Y \<in> A \<Longrightarrow> \<exists> k \<in>Y . z < k" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1228 | using local.less_Sup_iff by blast | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1229 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1230 | define F where "F = (\<lambda> Y . SOME k . k \<in> Y \<and> z < k)" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1231 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1232 | have D: "\<And> Y . Y \<in> A \<Longrightarrow> z < F Y" | 
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1233 | using B apply (simp add: F_def) | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1234 | by (rule someI2_ex, auto) | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1235 | |
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1236 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1237 | have E: "\<And> Y . Y \<in> A \<Longrightarrow> F Y \<in> Y" | 
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1238 | using B apply (simp add: F_def) | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1239 | by (rule someI2_ex, auto) | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1240 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1241 | have "z \<le> Inf (F ` A)" | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1242 | by (simp add: D local.INF_greatest local.order.strict_implies_order) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1243 | |
| 69275 | 1244 |       also have "... \<le> \<Squnion>(Inf ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y})"
 | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1245 | apply (rule SUP_upper, safe) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1246 | using E by blast | 
| 69275 | 1247 |       finally have "z \<le> \<Squnion>(Inf ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y})"
 | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1248 | by simp | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1249 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1250 | from X and this show ?thesis | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1251 | using local.not_less by blast | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1252 | next | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1253 | case False | 
| 69275 | 1254 |       from this have A: "\<And> z . \<Sqinter>(Sup ` A) \<le> z \<or> z \<le> \<Squnion>(Inf ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y})"
 | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1255 | using local.le_less_linear by blast | 
| 69275 | 1256 | |
| 1257 |       from C have "\<And> Y . Y \<in> A \<Longrightarrow> \<Squnion>(Inf ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}) < Sup Y"
 | |
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1258 | by (simp add: less_INF_D) | 
| 69275 | 1259 | |
| 1260 |       from this have B: "\<And> Y . Y \<in> A \<Longrightarrow> \<exists> k \<in>Y . \<Squnion>(Inf ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}) < k"
 | |
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1261 | using local.less_Sup_iff by blast | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1262 | |
| 69275 | 1263 |       define F where "F = (\<lambda> Y . SOME k . k \<in> Y \<and> \<Squnion>(Inf ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}) < k)"
 | 
| 1264 | ||
| 1265 |       have D: "\<And> Y . Y \<in> A \<Longrightarrow> \<Squnion>(Inf ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}) < F Y"
 | |
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1266 | using B apply (simp add: F_def) | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1267 | by (rule someI2_ex, auto) | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1268 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1269 | have E: "\<And> Y . Y \<in> A \<Longrightarrow> F Y \<in> Y" | 
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1270 | using B apply (simp add: F_def) | 
| 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1271 | by (rule someI2_ex, auto) | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1272 | |
| 69275 | 1273 | have "\<And> Y . Y \<in> A \<Longrightarrow> \<Sqinter>(Sup ` A) \<le> F Y" | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1274 | using D False local.leI by blast | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1275 | |
| 69275 | 1276 | from this have "\<Sqinter>(Sup ` A) \<le> Inf (F ` A)" | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1277 | by (simp add: local.INF_greatest) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1278 | |
| 69275 | 1279 |       also have "Inf (F ` A) \<le> \<Squnion>(Inf ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y})"
 | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1280 | apply (rule SUP_upper, safe) | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1281 | using E by blast | 
| 69275 | 1282 | |
| 1283 |       finally have "\<Sqinter>(Sup ` A) \<le> \<Squnion>(Inf ` {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y})"
 | |
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1284 | by simp | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1285 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1286 | from C and this show ?thesis | 
| 67951 
655aa11359dc
Removed some uses of deprecated _tac methods. (Patch from Viorel Preoteasa)
 Manuel Eberl <eberlm@in.tum.de> parents: 
67829diff
changeset | 1287 | using not_less by blast | 
| 67829 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1288 | qed | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1289 | qed | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1290 | end | 
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1291 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1292 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1293 | |
| 
2a6ef5ba4822
Changes to complete distributive lattices due to Viorel Preoteasa
 Manuel Eberl <eberlm@in.tum.de> parents: 
67673diff
changeset | 1294 | end |