src/HOL/Hilbert_Choice.thy
author wenzelm
Fri, 23 Mar 2018 17:09:36 +0100
changeset 67933 604da273e18d
parent 67829 2a6ef5ba4822
child 67951 655aa11359dc
permissions -rw-r--r--
more robust timing info: do not rely on order of markup;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11451
8abfb4f7bd02 partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff changeset
     1
(*  Title:      HOL/Hilbert_Choice.thy
32988
d1d4d7a08a66 Inv -> inv_onto, inv abbr. inv_onto UNIV.
nipkow
parents: 31723
diff changeset
     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: 67673
diff 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
wenzelm
parents: 11506
diff changeset
     5
*)
11451
8abfb4f7bd02 partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff changeset
     6
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60585
diff changeset
     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
c69542757a4d New theory header syntax.
nipkow
parents: 14872
diff changeset
     9
theory Hilbert_Choice
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    10
  imports Wellfounded
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    11
  keywords "specification" :: thy_goal
15131
c69542757a4d New theory header syntax.
nipkow
parents: 14872
diff changeset
    12
begin
12298
wenzelm
parents: 12023
diff changeset
    13
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60585
diff changeset
    14
subsection \<open>Hilbert's epsilon\<close>
12298
wenzelm
parents: 12023
diff changeset
    15
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    16
axiomatization Eps :: "('a \<Rightarrow> bool) \<Rightarrow> 'a"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    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: 14760
diff changeset
    19
syntax (epsilon)
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    20
  "_Eps" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a"  ("(3\<some>_./ _)" [0, 10] 10)
62521
6383440f41a8 old HOL syntax is for input only;
wenzelm
parents: 62343
diff changeset
    21
syntax (input)
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    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
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    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
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    26
  "SOME x. P" \<rightleftharpoons> "CONST Eps (\<lambda>x. P)"
13763
f94b569cd610 added print translations tha avoid eta contraction for important binders.
nipkow
parents: 13585
diff changeset
    27
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60585
diff changeset
    28
print_translation \<open>
52143
36ffe23b25f8 syntax translations always depend on context;
wenzelm
parents: 50105
diff changeset
    29
  [(@{const_syntax Eps}, fn _ => fn [Abs abs] =>
42284
326f57825e1a explicit structure Syntax_Trans;
wenzelm
parents: 40703
diff changeset
    30
      let val (x, t) = Syntax_Trans.atomic_abs_tr' abs
35115
446c5063e4fd modernized translations;
wenzelm
parents: 33057
diff changeset
    31
      in Syntax.const @{syntax_const "_Eps"} $ x $ t end)]
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 61424
diff changeset
    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
416aa3b00cbe added lemma
nipkow
parents: 64591
diff changeset
    34
definition inv_into :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'a)" where
416aa3b00cbe added lemma
nipkow
parents: 64591
diff changeset
    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: 11451
diff changeset
    36
65815
416aa3b00cbe added lemma
nipkow
parents: 64591
diff changeset
    37
lemma inv_into_def2: "inv_into A f x = (SOME y. y \<in> A \<and> f y = x)"
416aa3b00cbe added lemma
nipkow
parents: 64591
diff changeset
    38
by(simp add: inv_into_def)
416aa3b00cbe added lemma
nipkow
parents: 64591
diff changeset
    39
416aa3b00cbe added lemma
nipkow
parents: 64591
diff changeset
    40
abbreviation inv :: "('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'a)" where
416aa3b00cbe added lemma
nipkow
parents: 64591
diff changeset
    41
"inv \<equiv> inv_into UNIV"
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
    42
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
    43
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60585
diff changeset
    44
subsection \<open>Hilbert's Epsilon-operator\<close>
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
    45
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    46
text \<open>
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    47
  Easier to apply than \<open>someI\<close> if the witness comes from an
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    48
  existential formula.
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    49
\<close>
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    50
lemma someI_ex [elim?]: "\<exists>x. P x \<Longrightarrow> P (SOME x. P x)"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    51
  apply (erule exE)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    52
  apply (erule someI)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    53
  done
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
    54
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    55
text \<open>
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    56
  Easier to apply than \<open>someI\<close> because the conclusion has only one
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    57
  occurrence of @{term P}.
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    58
\<close>
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    59
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: 60758
diff changeset
    60
  by (blast intro: someI)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
    61
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    62
text \<open>
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    63
  Easier to apply than \<open>someI2\<close> if the witness comes from an
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    64
  existential formula.
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    65
\<close>
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    66
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: 60758
diff changeset
    67
  by (blast intro: someI2)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
    68
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    69
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)"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    70
  by (blast intro: someI2)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    71
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    72
lemma some_equality [intro]: "P a \<Longrightarrow> (\<And>x. P x \<Longrightarrow> x = a) \<Longrightarrow> (SOME x. P x) = a"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    73
  by (blast intro: someI2)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
    74
63629
wenzelm
parents: 63612
diff changeset
    75
lemma some1_equality: "\<exists>!x. P x \<Longrightarrow> P a \<Longrightarrow> (SOME x. P x) = a"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    76
  by blast
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
    77
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    78
lemma some_eq_ex: "P (SOME x. P x) \<longleftrightarrow> (\<exists>x. P x)"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    79
  by (blast intro: someI)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
    80
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58889
diff changeset
    81
lemma some_in_eq: "(SOME x. x \<in> A) \<in> A \<longleftrightarrow> A \<noteq> {}"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58889
diff changeset
    82
  unfolding ex_in_conv[symmetric] by (rule some_eq_ex)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58889
diff changeset
    83
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    84
lemma some_eq_trivial [simp]: "(SOME y. y = x) = x"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    85
  by (rule some_equality) (rule refl)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
    86
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    87
lemma some_sym_eq_trivial [simp]: "(SOME y. x = y) = x"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    88
  apply (rule some_equality)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    89
   apply (rule refl)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    90
  apply (erule sym)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    91
  done
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
    92
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
    93
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    94
subsection \<open>Axiom of Choice, Proved Using the Description Operator\<close>
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
    95
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    96
lemma choice: "\<forall>x. \<exists>y. Q x y \<Longrightarrow> \<exists>f. \<forall>x. Q x (f x)"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    97
  by (fast elim: someI)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
    98
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
    99
lemma bchoice: "\<forall>x\<in>S. \<exists>y. Q x y \<Longrightarrow> \<exists>f. \<forall>x\<in>S. Q x (f x)"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   100
  by (fast elim: someI)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   101
50105
65d5b18e1626 moved (b)choice_iff(') to Hilbert_Choice
hoelzl
parents: 49948
diff changeset
   102
lemma choice_iff: "(\<forall>x. \<exists>y. Q x y) \<longleftrightarrow> (\<exists>f. \<forall>x. Q x (f x))"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   103
  by (fast elim: someI)
50105
65d5b18e1626 moved (b)choice_iff(') to Hilbert_Choice
hoelzl
parents: 49948
diff changeset
   104
65d5b18e1626 moved (b)choice_iff(') to Hilbert_Choice
hoelzl
parents: 49948
diff changeset
   105
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
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   106
  by (fast elim: someI)
50105
65d5b18e1626 moved (b)choice_iff(') to Hilbert_Choice
hoelzl
parents: 49948
diff changeset
   107
65d5b18e1626 moved (b)choice_iff(') to Hilbert_Choice
hoelzl
parents: 49948
diff changeset
   108
lemma bchoice_iff: "(\<forall>x\<in>S. \<exists>y. Q x y) \<longleftrightarrow> (\<exists>f. \<forall>x\<in>S. Q x (f x))"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   109
  by (fast elim: someI)
50105
65d5b18e1626 moved (b)choice_iff(') to Hilbert_Choice
hoelzl
parents: 49948
diff changeset
   110
65d5b18e1626 moved (b)choice_iff(') to Hilbert_Choice
hoelzl
parents: 49948
diff changeset
   111
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
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   112
  by (fast elim: someI)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   113
57275
0ddb5b755cdc moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
hoelzl
parents: 56740
diff changeset
   114
lemma dependent_nat_choice:
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   115
  assumes 1: "\<exists>x. P 0 x"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   116
    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: 57275
diff changeset
   117
  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: 56740
diff changeset
   118
proof (intro exI allI conjI)
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62683
diff changeset
   119
  fix n
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62683
diff changeset
   120
  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
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   121
  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))"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   122
    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: 57275
diff changeset
   123
  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: 56740
diff changeset
   124
    by (induct n) auto
0ddb5b755cdc moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
hoelzl
parents: 56740
diff changeset
   125
qed
0ddb5b755cdc moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
hoelzl
parents: 56740
diff changeset
   126
58074
87a8cc594bf6 moved skolem method
blanchet
parents: 57448
diff changeset
   127
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60585
diff changeset
   128
subsection \<open>Function Inverse\<close>
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   129
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   130
lemma inv_def: "inv f = (\<lambda>y. SOME x. f x = y)"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   131
  by (simp add: inv_into_def)
33014
85d7a096e63f added inv_def for compatibility as a lemma
nipkow
parents: 32988
diff changeset
   132
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   133
lemma inv_into_into: "x \<in> f ` A \<Longrightarrow> inv_into A f x \<in> A"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   134
  by (simp add: inv_into_def) (fast intro: someI2)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   135
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   136
lemma inv_identity [simp]: "inv (\<lambda>a. a) = (\<lambda>a. a)"
63365
5340fb6633d0 more theorems
haftmann
parents: 63040
diff changeset
   137
  by (simp add: inv_def)
5340fb6633d0 more theorems
haftmann
parents: 63040
diff changeset
   138
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   139
lemma inv_id [simp]: "inv id = id"
63365
5340fb6633d0 more theorems
haftmann
parents: 63040
diff changeset
   140
  by (simp add: id_def)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   141
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   142
lemma inv_into_f_f [simp]: "inj_on f A \<Longrightarrow> x \<in> A \<Longrightarrow> inv_into A f (f x) = x"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   143
  by (simp add: inv_into_def inj_on_def) (blast intro: someI2)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   144
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   145
lemma inv_f_f: "inj f \<Longrightarrow> inv f (f x) = x"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   146
  by simp
32988
d1d4d7a08a66 Inv -> inv_onto, inv abbr. inv_onto UNIV.
nipkow
parents: 31723
diff changeset
   147
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 65955
diff changeset
   148
lemma f_inv_into_f: "y \<in> f`A \<Longrightarrow> f (inv_into A f y) = y"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   149
  by (simp add: inv_into_def) (fast intro: someI2)
32988
d1d4d7a08a66 Inv -> inv_onto, inv abbr. inv_onto UNIV.
nipkow
parents: 31723
diff changeset
   150
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   151
lemma inv_into_f_eq: "inj_on f A \<Longrightarrow> x \<in> A \<Longrightarrow> f x = y \<Longrightarrow> inv_into A f y = x"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   152
  by (erule subst) (fast intro: inv_into_f_f)
32988
d1d4d7a08a66 Inv -> inv_onto, inv abbr. inv_onto UNIV.
nipkow
parents: 31723
diff changeset
   153
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   154
lemma inv_f_eq: "inj f \<Longrightarrow> f x = y \<Longrightarrow> inv f y = x"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   155
  by (simp add:inv_into_f_eq)
32988
d1d4d7a08a66 Inv -> inv_onto, inv abbr. inv_onto UNIV.
nipkow
parents: 31723
diff changeset
   156
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   157
lemma inj_imp_inv_eq: "inj f \<Longrightarrow> \<forall>x. f (g x) = x \<Longrightarrow> inv f = g"
44921
58eef4843641 tuned proofs
huffman
parents: 44890
diff changeset
   158
  by (blast intro: inv_into_f_eq)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   159
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   160
text \<open>But is it useful?\<close>
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   161
lemma inj_transfer:
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   162
  assumes inj: "inj f"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   163
    and minor: "\<And>y. y \<in> range f \<Longrightarrow> P (inv f y)"
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   164
  shows "P x"
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   165
proof -
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   166
  have "f x \<in> range f" by auto
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   167
  then have "P(inv f (f x))" by (rule minor)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   168
  then show "P x" by (simp add: inv_into_f_f [OF inj])
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   169
qed
11451
8abfb4f7bd02 partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff changeset
   170
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   171
lemma inj_iff: "inj f \<longleftrightarrow> inv f \<circ> f = id"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   172
  by (simp add: o_def fun_eq_iff) (blast intro: inj_on_inverseI inv_into_f_f)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   173
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   174
lemma inv_o_cancel[simp]: "inj f \<Longrightarrow> inv f \<circ> f = id"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   175
  by (simp add: inj_iff)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   176
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   177
lemma o_inv_o_cancel[simp]: "inj f \<Longrightarrow> g \<circ> inv f \<circ> f = g"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   178
  by (simp add: comp_assoc)
23433
c2c10abd2a1e added lemmas
nipkow
parents: 22690
diff changeset
   179
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   180
lemma inv_into_image_cancel[simp]: "inj_on f A \<Longrightarrow> S \<subseteq> A \<Longrightarrow> inv_into A f ` f ` S = S"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   181
  by (fastforce simp: image_def)
23433
c2c10abd2a1e added lemmas
nipkow
parents: 22690
diff changeset
   182
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   183
lemma inj_imp_surj_inv: "inj f \<Longrightarrow> surj (inv f)"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   184
  by (blast intro!: surjI inv_into_f_f)
32988
d1d4d7a08a66 Inv -> inv_onto, inv abbr. inv_onto UNIV.
nipkow
parents: 31723
diff changeset
   185
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   186
lemma surj_f_inv_f: "surj f \<Longrightarrow> f (inv f y) = y"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   187
  by (simp add: f_inv_into_f)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   188
67673
c8caefb20564 lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents: 67613
diff changeset
   189
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: 67613
diff changeset
   190
  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: 67613
diff changeset
   191
33057
764547b68538 inv_onto -> inv_into
nipkow
parents: 33014
diff changeset
   192
lemma inv_into_injective:
764547b68538 inv_onto -> inv_into
nipkow
parents: 33014
diff changeset
   193
  assumes eq: "inv_into A f x = inv_into A f y"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   194
    and x: "x \<in> f`A"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   195
    and y: "y \<in> f`A"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   196
  shows "x = y"
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   197
proof -
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   198
  from eq have "f (inv_into A f x) = f (inv_into A f y)"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   199
    by simp
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   200
  with x y show ?thesis
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   201
    by (simp add: f_inv_into_f)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   202
qed
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   203
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   204
lemma inj_on_inv_into: "B \<subseteq> f`A \<Longrightarrow> inj_on (inv_into A f) B"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   205
  by (blast intro: inj_onI dest: inv_into_injective injD)
32988
d1d4d7a08a66 Inv -> inv_onto, inv abbr. inv_onto UNIV.
nipkow
parents: 31723
diff changeset
   206
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   207
lemma bij_betw_inv_into: "bij_betw f A B \<Longrightarrow> bij_betw (inv_into A f) B A"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   208
  by (auto simp add: bij_betw_def inj_on_inv_into)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   209
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   210
lemma surj_imp_inj_inv: "surj f \<Longrightarrow> inj (inv f)"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   211
  by (simp add: inj_on_inv_into)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   212
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   213
lemma surj_iff: "surj f \<longleftrightarrow> f \<circ> inv f = id"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   214
  by (auto intro!: surjI simp: surj_f_inv_f fun_eq_iff[where 'b='a])
40702
cf26dd7395e4 Replace surj by abbreviation; remove surj_on.
hoelzl
parents: 39950
diff changeset
   215
cf26dd7395e4 Replace surj by abbreviation; remove surj_on.
hoelzl
parents: 39950
diff changeset
   216
lemma surj_iff_all: "surj f \<longleftrightarrow> (\<forall>x. f (inv f x) = x)"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   217
  by (simp add: o_def surj_iff fun_eq_iff)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   218
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   219
lemma surj_imp_inv_eq: "surj f \<Longrightarrow> \<forall>x. g (f x) = x \<Longrightarrow> inv f = g"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   220
  apply (rule ext)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   221
  apply (drule_tac x = "inv f x" in spec)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   222
  apply (simp add: surj_f_inv_f)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   223
  done
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   224
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   225
lemma bij_imp_bij_inv: "bij f \<Longrightarrow> bij (inv f)"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   226
  by (simp add: bij_def inj_imp_surj_inv surj_imp_inj_inv)
12372
cd3a09c7dac9 tuned declarations;
wenzelm
parents: 12298
diff changeset
   227
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   228
lemma inv_equality: "(\<And>x. g (f x) = x) \<Longrightarrow> (\<And>y. f (g y) = y) \<Longrightarrow> inv f = g"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   229
  by (rule ext) (auto simp add: inv_into_def)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   230
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   231
lemma inv_inv_eq: "bij f \<Longrightarrow> inv (inv f) = f"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   232
  by (rule inv_equality) (auto simp add: bij_def surj_f_inv_f)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   233
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   234
text \<open>
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   235
  \<open>bij (inv f)\<close> implies little about \<open>f\<close>. Consider \<open>f :: bool \<Rightarrow> bool\<close> such
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   236
  that \<open>f True = f False = True\<close>. Then it ia consistent with axiom \<open>someI\<close>
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   237
  that \<open>inv f\<close> could be any function at all, including the identity function.
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   238
  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
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   239
  (inv f) = f\<close> all fail.
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   240
\<close>
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   241
33057
764547b68538 inv_onto -> inv_into
nipkow
parents: 33014
diff changeset
   242
lemma inv_into_comp:
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   243
  "inj_on f (g ` A) \<Longrightarrow> inj_on g A \<Longrightarrow> x \<in> f ` g ` A \<Longrightarrow>
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   244
    inv_into A (f \<circ> g) x = (inv_into A g \<circ> inv_into (g ` A) f) x"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   245
  apply (rule inv_into_f_eq)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   246
    apply (fast intro: comp_inj_on)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   247
   apply (simp add: inv_into_into)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   248
  apply (simp add: f_inv_into_f inv_into_into)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   249
  done
32988
d1d4d7a08a66 Inv -> inv_onto, inv abbr. inv_onto UNIV.
nipkow
parents: 31723
diff changeset
   250
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   251
lemma o_inv_distrib: "bij f \<Longrightarrow> bij g \<Longrightarrow> inv (f \<circ> g) = inv g \<circ> inv f"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   252
  by (rule inv_equality) (auto simp add: bij_def surj_f_inv_f)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   253
63807
5f77017055a3 clarified obscure facts;
wenzelm
parents: 63630
diff changeset
   254
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: 61859
diff changeset
   255
  by (simp add: surj_f_inv_f image_comp comp_def)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   256
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   257
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: 61859
diff changeset
   258
  by simp
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   259
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   260
lemma bij_image_Collect_eq: "bij f \<Longrightarrow> f ` Collect P = {y. P (inv f y)}"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   261
  apply auto
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   262
   apply (force simp add: bij_is_inj)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   263
  apply (blast intro: bij_is_surj [THEN surj_f_inv_f, symmetric])
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   264
  done
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   265
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   266
lemma bij_vimage_eq_inv_image: "bij f \<Longrightarrow> f -` A = inv f ` A"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   267
  apply (auto simp add: bij_is_surj [THEN surj_f_inv_f])
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   268
  apply (blast intro: bij_is_inj [THEN inv_into_f_f, symmetric])
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   269
  done
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   270
31380
f25536c0bb80 added/moved lemmas by Andreas Lochbihler
haftmann
parents: 29655
diff changeset
   271
lemma finite_fun_UNIVD1:
f25536c0bb80 added/moved lemmas by Andreas Lochbihler
haftmann
parents: 29655
diff changeset
   272
  assumes fin: "finite (UNIV :: ('a \<Rightarrow> 'b) set)"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   273
    and card: "card (UNIV :: 'b set) \<noteq> Suc 0"
31380
f25536c0bb80 added/moved lemmas by Andreas Lochbihler
haftmann
parents: 29655
diff changeset
   274
  shows "finite (UNIV :: 'a set)"
f25536c0bb80 added/moved lemmas by Andreas Lochbihler
haftmann
parents: 29655
diff changeset
   275
proof -
63630
b2a6a1a49d39 tuned proof;
wenzelm
parents: 63629
diff changeset
   276
  let ?UNIV_b = "UNIV :: 'b set"
b2a6a1a49d39 tuned proof;
wenzelm
parents: 63629
diff changeset
   277
  from fin have "finite ?UNIV_b"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   278
    by (rule finite_fun_UNIVD2)
63630
b2a6a1a49d39 tuned proof;
wenzelm
parents: 63629
diff changeset
   279
  with card have "card ?UNIV_b \<ge> Suc (Suc 0)"
b2a6a1a49d39 tuned proof;
wenzelm
parents: 63629
diff changeset
   280
    by (cases "card ?UNIV_b") (auto simp: card_eq_0_iff)
b2a6a1a49d39 tuned proof;
wenzelm
parents: 63629
diff changeset
   281
  then have "card ?UNIV_b = Suc (Suc (card ?UNIV_b - Suc (Suc 0)))"
b2a6a1a49d39 tuned proof;
wenzelm
parents: 63629
diff changeset
   282
    by simp
63629
wenzelm
parents: 63612
diff changeset
   283
  then obtain b1 b2 :: 'b where b1b2: "b1 \<noteq> b2"
wenzelm
parents: 63612
diff changeset
   284
    by (auto simp: card_Suc_eq)
63630
b2a6a1a49d39 tuned proof;
wenzelm
parents: 63629
diff changeset
   285
  from fin have fin': "finite (range (\<lambda>f :: 'a \<Rightarrow> 'b. inv f b1))"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   286
    by (rule finite_imageI)
63630
b2a6a1a49d39 tuned proof;
wenzelm
parents: 63629
diff changeset
   287
  have "UNIV = range (\<lambda>f :: 'a \<Rightarrow> 'b. inv f b1)"
31380
f25536c0bb80 added/moved lemmas by Andreas Lochbihler
haftmann
parents: 29655
diff changeset
   288
  proof (rule UNIV_eq_I)
f25536c0bb80 added/moved lemmas by Andreas Lochbihler
haftmann
parents: 29655
diff changeset
   289
    fix x :: 'a
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   290
    from b1b2 have "x = inv (\<lambda>y. if y = x then b1 else b2) b1"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   291
      by (simp add: inv_into_def)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   292
    then show "x \<in> range (\<lambda>f::'a \<Rightarrow> 'b. inv f b1)"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   293
      by blast
31380
f25536c0bb80 added/moved lemmas by Andreas Lochbihler
haftmann
parents: 29655
diff changeset
   294
  qed
63630
b2a6a1a49d39 tuned proof;
wenzelm
parents: 63629
diff changeset
   295
  with fin' show ?thesis
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   296
    by simp
31380
f25536c0bb80 added/moved lemmas by Andreas Lochbihler
haftmann
parents: 29655
diff changeset
   297
qed
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   298
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60585
diff changeset
   299
text \<open>
54578
9387251b6a46 eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents: 54295
diff changeset
   300
  Every infinite set contains a countable subset. More precisely we
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 61424
diff changeset
   301
  show that a set \<open>S\<close> is infinite if and only if there exists an
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 61424
diff changeset
   302
  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: 54295
diff changeset
   303
9387251b6a46 eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents: 54295
diff changeset
   304
  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: 54295
diff changeset
   305
  construction of a sequence of pairwise different elements of an
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 61424
diff changeset
   306
  infinite set \<open>S\<close>. The idea is to construct a sequence of
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 61424
diff changeset
   307
  non-empty and infinite subsets of \<open>S\<close> obtained by successively
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 61424
diff changeset
   308
  removing elements of \<open>S\<close>.
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60585
diff changeset
   309
\<close>
54578
9387251b6a46 eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents: 54295
diff changeset
   310
9387251b6a46 eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents: 54295
diff changeset
   311
lemma infinite_countable_subset:
63629
wenzelm
parents: 63612
diff changeset
   312
  assumes inf: "\<not> finite S"
wenzelm
parents: 63612
diff changeset
   313
  shows "\<exists>f::nat \<Rightarrow> 'a. inj f \<and> range f \<subseteq> S"
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 61424
diff changeset
   314
  \<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: 54295
diff changeset
   315
proof -
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62683
diff changeset
   316
  define Sseq where "Sseq = rec_nat S (\<lambda>n T. T - {SOME e. e \<in> T})"
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62683
diff changeset
   317
  define pick where "pick n = (SOME e. e \<in> Sseq n)" for n
63540
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63374
diff changeset
   318
  have *: "Sseq n \<subseteq> S" "\<not> finite (Sseq n)" for n
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   319
    by (induct n) (auto simp: Sseq_def inf)
63540
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63374
diff changeset
   320
  then have **: "\<And>n. pick n \<in> Sseq n"
55811
aa1acc25126b load Metis a little later
traytel
parents: 55415
diff changeset
   321
    unfolding pick_def by (subst (asm) finite.simps) (auto simp add: ex_in_conv intro: someI_ex)
63540
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63374
diff changeset
   322
  with * have "range pick \<subseteq> S" by auto
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   323
  moreover have "pick n \<noteq> pick (n + Suc m)" for m n
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   324
  proof -
63540
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63374
diff changeset
   325
    have "pick n \<notin> Sseq (n + Suc m)"
f8652d0534fa tuned proofs -- avoid unstructured calculation;
wenzelm
parents: 63374
diff changeset
   326
      by (induct m) (auto simp add: Sseq_def pick_def)
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   327
    with ** show ?thesis by auto
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   328
  qed
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   329
  then have "inj pick"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   330
    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: 54295
diff changeset
   331
  ultimately show ?thesis by blast
9387251b6a46 eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents: 54295
diff changeset
   332
qed
9387251b6a46 eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents: 54295
diff changeset
   333
63629
wenzelm
parents: 63612
diff changeset
   334
lemma infinite_iff_countable_subset: "\<not> finite S \<longleftrightarrow> (\<exists>f::nat \<Rightarrow> 'a. inj f \<and> range f \<subseteq> S)"
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 61424
diff changeset
   335
  \<comment> \<open>Courtesy of Stephan Merz\<close>
55811
aa1acc25126b load Metis a little later
traytel
parents: 55415
diff changeset
   336
  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: 54295
diff changeset
   337
40703
d1fc454d6735 Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents: 40702
diff changeset
   338
lemma image_inv_into_cancel:
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   339
  assumes surj: "f`A = A'"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   340
    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: 40702
diff changeset
   341
  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: 40702
diff changeset
   342
  using assms
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   343
proof (auto simp: f_inv_into_f)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   344
  let ?f' = "inv_into A f"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   345
  fix a'
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   346
  assume *: "a' \<in> B'"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   347
  with sub have "a' \<in> A'" by auto
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   348
  with surj have "a' = f (?f' a')"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   349
    by (auto simp: f_inv_into_f)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   350
  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: 40702
diff changeset
   351
qed
d1fc454d6735 Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents: 40702
diff changeset
   352
d1fc454d6735 Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents: 40702
diff changeset
   353
lemma inv_into_inv_into_eq:
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   354
  assumes "bij_betw f A A'"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   355
    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: 40702
diff changeset
   356
  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: 40702
diff changeset
   357
proof -
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   358
  let ?f' = "inv_into A f"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   359
  let ?f'' = "inv_into A' ?f'"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   360
  from assms have *: "bij_betw ?f' A' A"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   361
    by (auto simp: bij_betw_inv_into)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   362
  with a obtain a' where a': "a' \<in> A'" "?f' a' = a"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   363
    unfolding bij_betw_def by force
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   364
  with a * have "?f'' a = a'"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   365
    by (auto simp: f_inv_into_f bij_betw_def)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   366
  moreover from assms a' have "f a = a'"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   367
    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: 40702
diff changeset
   368
  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: 40702
diff changeset
   369
qed
d1fc454d6735 Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents: 40702
diff changeset
   370
d1fc454d6735 Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents: 40702
diff changeset
   371
lemma inj_on_iff_surj:
d1fc454d6735 Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents: 40702
diff changeset
   372
  assumes "A \<noteq> {}"
63629
wenzelm
parents: 63612
diff changeset
   373
  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: 40702
diff changeset
   374
proof safe
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   375
  fix f
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   376
  assume inj: "inj_on f A" and incl: "f ` A \<subseteq> A'"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   377
  let ?phi = "\<lambda>a' a. a \<in> A \<and> f a = a'"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   378
  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: 40702
diff changeset
   379
  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: 40702
diff changeset
   380
  have "?g ` A' = A"
d1fc454d6735 Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents: 40702
diff changeset
   381
  proof
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   382
    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: 40702
diff changeset
   383
    proof clarify
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   384
      fix a'
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   385
      assume *: "a' \<in> A'"
40703
d1fc454d6735 Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents: 40702
diff changeset
   386
      show "?g a' \<in> A"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   387
      proof (cases "a' \<in> f ` A")
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   388
        case True
40703
d1fc454d6735 Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents: 40702
diff changeset
   389
        then obtain a where "?phi a' a" by blast
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   390
        then have "?phi a' (SOME a. ?phi a' a)"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   391
          using someI[of "?phi a'" a] by blast
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   392
        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: 40702
diff changeset
   393
      next
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   394
        case False
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   395
        with assms have "?csi (SOME a. ?csi a)"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   396
          using someI_ex[of ?csi] by blast
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   397
        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: 40702
diff changeset
   398
      qed
d1fc454d6735 Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents: 40702
diff changeset
   399
    qed
d1fc454d6735 Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents: 40702
diff changeset
   400
  next
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   401
    show "A \<subseteq> ?g ` A'"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   402
    proof -
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   403
      have "?g (f a) = a \<and> f a \<in> A'" if a: "a \<in> A" for a
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   404
      proof -
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   405
        let ?b = "SOME aa. ?phi (f a) aa"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   406
        from a have "?phi (f a) a" by auto
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   407
        then have *: "?phi (f a) ?b"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   408
          using someI[of "?phi(f a)" a] by blast
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   409
        then have "?g (f a) = ?b" using a by auto
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   410
        moreover from inj * a have "a = ?b"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   411
          by (auto simp add: inj_on_def)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   412
        ultimately have "?g(f a) = a" by simp
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   413
        with incl a show ?thesis by auto
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   414
      qed
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   415
      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: 40702
diff changeset
   416
    qed
d1fc454d6735 Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents: 40702
diff changeset
   417
  qed
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   418
  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: 40702
diff changeset
   419
next
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   420
  fix g
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   421
  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: 40702
diff changeset
   422
  have "inj_on ?f (g ` A')"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   423
    by (auto simp: inj_on_inv_into)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   424
  moreover have "?f (g a') \<in> A'" if a': "a' \<in> A'" for a'
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   425
  proof -
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   426
    let ?phi = "\<lambda> b'. b' \<in> A' \<and> g b' = g a'"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   427
    from a' have "?phi a'" by auto
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   428
    then have "?phi (SOME b'. ?phi b')"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   429
      using someI[of ?phi] by blast
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   430
    then show ?thesis by (auto simp: inv_into_def)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   431
  qed
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   432
  ultimately show "\<exists>f. inj_on f (g ` A') \<and> f ` g ` A' \<subseteq> A'"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   433
    by auto
40703
d1fc454d6735 Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents: 40702
diff changeset
   434
qed
d1fc454d6735 Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents: 40702
diff changeset
   435
d1fc454d6735 Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents: 40702
diff changeset
   436
lemma Ex_inj_on_UNION_Sigma:
63629
wenzelm
parents: 63612
diff changeset
   437
  "\<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: 40702
diff changeset
   438
proof
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   439
  let ?phi = "\<lambda>a i. i \<in> I \<and> a \<in> A i"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   440
  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: 40702
diff changeset
   441
  let ?f = "\<lambda>a. (?sm a, a)"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   442
  have "inj_on ?f (\<Union>i \<in> I. A i)"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   443
    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: 40702
diff changeset
   444
  moreover
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   445
  have "?sm a \<in> I \<and> a \<in> A(?sm a)" if "i \<in> I" and "a \<in> A i" for i a
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   446
    using that someI[of "?phi a" i] by auto
63629
wenzelm
parents: 63612
diff changeset
   447
  then have "?f ` (\<Union>i \<in> I. A i) \<subseteq> (SIGMA i : I. A i)"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   448
    by auto
63629
wenzelm
parents: 63612
diff changeset
   449
  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
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   450
    by auto
40703
d1fc454d6735 Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents: 40702
diff changeset
   451
qed
d1fc454d6735 Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents: 40702
diff changeset
   452
56608
8e3c848008fa more simp rules for Fun.swap
haftmann
parents: 56270
diff changeset
   453
lemma inv_unique_comp:
8e3c848008fa more simp rules for Fun.swap
haftmann
parents: 56270
diff changeset
   454
  assumes fg: "f \<circ> g = id"
8e3c848008fa more simp rules for Fun.swap
haftmann
parents: 56270
diff changeset
   455
    and gf: "g \<circ> f = id"
8e3c848008fa more simp rules for Fun.swap
haftmann
parents: 56270
diff changeset
   456
  shows "inv f = g"
8e3c848008fa more simp rules for Fun.swap
haftmann
parents: 56270
diff changeset
   457
  using fg gf inv_equality[of g f] by (auto simp add: fun_eq_iff)
8e3c848008fa more simp rules for Fun.swap
haftmann
parents: 56270
diff changeset
   458
8e3c848008fa more simp rules for Fun.swap
haftmann
parents: 56270
diff changeset
   459
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60585
diff changeset
   460
subsection \<open>Other Consequences of Hilbert's Epsilon\<close>
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   461
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60585
diff changeset
   462
text \<open>Hilbert's Epsilon and the @{term split} Operator\<close>
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   463
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   464
text \<open>Looping simprule!\<close>
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   465
lemma split_paired_Eps: "(SOME x. P x) = (SOME (a, b). P (a, b))"
26347
105f55201077 tuned proofs
haftmann
parents: 26105
diff changeset
   466
  by simp
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   467
61424
c3658c18b7bc prod_case as canonical name for product type eliminator
haftmann
parents: 61076
diff changeset
   468
lemma Eps_case_prod: "Eps (case_prod P) = (SOME xy. P (fst xy) (snd xy))"
26347
105f55201077 tuned proofs
haftmann
parents: 26105
diff changeset
   469
  by (simp add: split_def)
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   470
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   471
lemma Eps_case_prod_eq [simp]: "(SOME (x', y'). x = x' \<and> y = y') = (x, y)"
26347
105f55201077 tuned proofs
haftmann
parents: 26105
diff changeset
   472
  by blast
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   473
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   474
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   475
text \<open>A relation is wellfounded iff it has no infinite descending chain.\<close>
63981
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   476
lemma wf_iff_no_infinite_down_chain: "wf r \<longleftrightarrow> (\<nexists>f. \<forall>i. (f (Suc i), f i) \<in> r)"
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   477
  (is "_ \<longleftrightarrow> \<not> ?ex")
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   478
proof
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   479
  assume "wf r"
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   480
  show "\<not> ?ex"
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   481
  proof
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   482
    assume ?ex
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   483
    then obtain f where f: "(f (Suc i), f i) \<in> r" for i
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   484
      by blast
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   485
    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
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   486
      by (auto simp: wf_eq_minimal)
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   487
    let ?Q = "{w. \<exists>i. w = f i}"
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   488
    fix n
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   489
    have "f n \<in> ?Q" by blast
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   490
    from minimal [OF this] obtain j where "(y, f j) \<in> r \<Longrightarrow> y \<notin> ?Q" for y by blast
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   491
    with this [OF \<open>(f (Suc j), f j) \<in> r\<close>] have "f (Suc j) \<notin> ?Q" by simp
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   492
    then show False by blast
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   493
  qed
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   494
next
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   495
  assume "\<not> ?ex"
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   496
  then show "wf r"
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   497
  proof (rule contrapos_np)
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   498
    assume "\<not> wf r"
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   499
    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
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   500
      by (auto simp add: wf_eq_minimal)
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   501
    obtain descend :: "nat \<Rightarrow> 'a"
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   502
      where descend_0: "descend 0 = x"
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   503
        and descend_Suc: "descend (Suc n) = (SOME y. y \<in> Q \<and> (y, descend n) \<in> r)" for n
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   504
      by (rule that [of "rec_nat x (\<lambda>_ rec. (SOME y. y \<in> Q \<and> (y, rec) \<in> r))"]) simp_all
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   505
    have descend_Q: "descend n \<in> Q" for n
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   506
    proof (induct n)
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   507
      case 0
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   508
      with x show ?case by (simp only: descend_0)
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   509
    next
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   510
      case Suc
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   511
      then show ?case by (simp only: descend_Suc) (rule someI2_ex; use rec in blast)
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   512
    qed
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   513
    have "(descend (Suc i), descend i) \<in> r" for i
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   514
      by (simp only: descend_Suc) (rule someI2_ex; use descend_Q rec in blast)
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   515
    then show "\<exists>f. \<forall>i. (f (Suc i), f i) \<in> r" by blast
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   516
  qed
6f7db4f8df4c tuned proofs;
wenzelm
parents: 63980
diff changeset
   517
qed
14760
a08e916f4946 conversion of Hilbert_Choice to Isar script
paulson
parents: 14399
diff changeset
   518
27760
3aa86edac080 added lemma
nipkow
parents: 26748
diff changeset
   519
lemma wf_no_infinite_down_chainE:
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   520
  assumes "wf r"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   521
  obtains k where "(f (Suc k), f k) \<notin> r"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   522
  using assms wf_iff_no_infinite_down_chain[of r] by blast
27760
3aa86edac080 added lemma
nipkow
parents: 26748
diff changeset
   523
3aa86edac080 added lemma
nipkow
parents: 26748
diff changeset
   524
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   525
text \<open>A dynamically-scoped fact for TFL\<close>
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   526
lemma tfl_some: "\<forall>P x. P x \<longrightarrow> P (Eps P)"
12298
wenzelm
parents: 12023
diff changeset
   527
  by (blast intro: someI)
11451
8abfb4f7bd02 partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff changeset
   528
12298
wenzelm
parents: 12023
diff changeset
   529
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60585
diff changeset
   530
subsection \<open>An aside: bounded accessible part\<close>
49948
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   531
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60585
diff changeset
   532
text \<open>Finite monotone eventually stable sequences\<close>
49948
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   533
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   534
lemma finite_mono_remains_stable_implies_strict_prefix:
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   535
  fixes f :: "nat \<Rightarrow> 'a::order"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   536
  assumes S: "finite (range f)" "mono f"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   537
    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: 49739
diff changeset
   538
  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: 49739
diff changeset
   539
  using assms
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   540
proof -
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   541
  have "\<exists>n. f n = f (Suc n)"
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   542
  proof (rule ccontr)
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   543
    assume "\<not> ?thesis"
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   544
    then have "\<And>n. f n \<noteq> f (Suc n)" by auto
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   545
    with \<open>mono f\<close> have "\<And>n. f n < f (Suc n)"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   546
      by (auto simp: le_less mono_iff_le_Suc)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   547
    with lift_Suc_mono_less_iff[of f] have *: "\<And>n m. n < m \<Longrightarrow> f n < f m"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   548
      by auto
55811
aa1acc25126b load Metis a little later
traytel
parents: 55415
diff changeset
   549
    have "inj f"
aa1acc25126b load Metis a little later
traytel
parents: 55415
diff changeset
   550
    proof (intro injI)
aa1acc25126b load Metis a little later
traytel
parents: 55415
diff changeset
   551
      fix x y
aa1acc25126b load Metis a little later
traytel
parents: 55415
diff changeset
   552
      assume "f x = f y"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   553
      then show "x = y"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   554
        by (cases x y rule: linorder_cases) (auto dest: *)
55811
aa1acc25126b load Metis a little later
traytel
parents: 55415
diff changeset
   555
    qed
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60585
diff changeset
   556
    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: 49739
diff changeset
   557
      by (rule finite_imageD)
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   558
    then show False by simp
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   559
  qed
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   560
  then obtain n where n: "f n = f (Suc n)" ..
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62683
diff changeset
   561
  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: 49739
diff changeset
   562
  have N: "f N = f (Suc N)"
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   563
    unfolding N_def using n by (rule LeastI)
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   564
  show ?thesis
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   565
  proof (intro exI[of _ N] conjI allI impI)
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   566
    fix n
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   567
    assume "N \<le> n"
49948
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   568
    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: 49739
diff changeset
   569
    proof (induct rule: dec_induct)
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   570
      case base
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   571
      then show ?case by simp
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   572
    next
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   573
      case (step n)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   574
      then show ?case
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   575
        using eq [rule_format, of "n - 1"] N
49948
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   576
        by (cases n) (auto simp add: le_Suc_eq)
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   577
    qed
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60585
diff changeset
   578
    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: 49739
diff changeset
   579
  next
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   580
    fix n m :: nat
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   581
    assume "m < n" "n \<le> N"
49948
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   582
    then show "f m < f n"
62683
ddd1c864408b clarified rule structure;
wenzelm
parents: 62521
diff changeset
   583
    proof (induct rule: less_Suc_induct)
49948
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   584
      case (1 i)
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   585
      then have "i < N" by simp
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   586
      then have "f i \<noteq> f (Suc i)"
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   587
        unfolding N_def by (rule not_less_Least)
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60585
diff changeset
   588
      with \<open>mono f\<close> show ?case by (simp add: mono_iff_le_Suc less_le)
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   589
    next
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   590
      case 2
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   591
      then show ?case by simp
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   592
    qed
49948
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   593
  qed
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   594
qed
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   595
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   596
lemma finite_mono_strict_prefix_implies_finite_fixpoint:
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   597
  fixes f :: "nat \<Rightarrow> 'a set"
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   598
  assumes S: "\<And>i. f i \<subseteq> S" "finite S"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   599
    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: 49739
diff changeset
   600
  shows "f (card S) = (\<Union>n. f n)"
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   601
proof -
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   602
  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"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   603
    and eq: "\<forall>n\<ge>N. f N = f n"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   604
    by atomize auto
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   605
  have "i \<le> N \<Longrightarrow> i \<le> card (f i)" for i
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   606
  proof (induct i)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   607
    case 0
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   608
    then show ?case by simp
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   609
  next
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   610
    case (Suc i)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   611
    with inj [of "Suc i" i] have "(f i) \<subset> (f (Suc i))" by auto
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   612
    moreover have "finite (f (Suc i))" using S by (rule finite_subset)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   613
    ultimately have "card (f i) < card (f (Suc i))" by (intro psubset_card_mono)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   614
    with Suc inj show ?case by auto
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   615
  qed
49948
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   616
  then have "N \<le> card (f N)" by simp
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   617
  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: 49739
diff changeset
   618
  finally have "f (card S) = f N" using eq by auto
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   619
  then show ?thesis
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   620
    using eq inj [of N]
49948
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   621
    apply auto
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   622
    apply (case_tac "n < N")
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   623
     apply (auto simp: not_less)
49948
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   624
    done
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   625
qed
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   626
744934b818c7 moved quite generic material from theory Enum to more appropriate places
haftmann
parents: 49739
diff changeset
   627
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60585
diff changeset
   628
subsection \<open>More on injections, bijections, and inverses\<close>
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   629
63374
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   630
locale bijection =
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   631
  fixes f :: "'a \<Rightarrow> 'a"
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   632
  assumes bij: "bij f"
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   633
begin
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   634
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   635
lemma bij_inv: "bij (inv f)"
63374
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   636
  using bij by (rule bij_imp_bij_inv)
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   637
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   638
lemma surj [simp]: "surj f"
63374
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   639
  using bij by (rule bij_is_surj)
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   640
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   641
lemma inj: "inj f"
63374
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   642
  using bij by (rule bij_is_inj)
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   643
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   644
lemma surj_inv [simp]: "surj (inv f)"
63374
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   645
  using inj by (rule inj_imp_surj_inv)
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   646
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   647
lemma inj_inv: "inj (inv f)"
63374
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   648
  using surj by (rule surj_imp_inj_inv)
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   649
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   650
lemma eqI: "f a = f b \<Longrightarrow> a = b"
63374
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   651
  using inj by (rule injD)
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   652
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   653
lemma eq_iff [simp]: "f a = f b \<longleftrightarrow> a = b"
63374
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   654
  by (auto intro: eqI)
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   655
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   656
lemma eq_invI: "inv f a = inv f b \<Longrightarrow> a = b"
63374
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   657
  using inj_inv by (rule injD)
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   658
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   659
lemma eq_inv_iff [simp]: "inv f a = inv f b \<longleftrightarrow> a = b"
63374
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   660
  by (auto intro: eq_invI)
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   661
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   662
lemma inv_left [simp]: "inv f (f a) = a"
63374
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   663
  using inj by (simp add: inv_f_eq)
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   664
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   665
lemma inv_comp_left [simp]: "inv f \<circ> f = id"
63374
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   666
  by (simp add: fun_eq_iff)
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   667
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   668
lemma inv_right [simp]: "f (inv f a) = a"
63374
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   669
  using surj by (simp add: surj_f_inv_f)
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   670
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   671
lemma inv_comp_right [simp]: "f \<circ> inv f = id"
63374
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   672
  by (simp add: fun_eq_iff)
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   673
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   674
lemma inv_left_eq_iff [simp]: "inv f a = b \<longleftrightarrow> f b = a"
63374
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   675
  by auto
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   676
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   677
lemma inv_right_eq_iff [simp]: "b = inv f a \<longleftrightarrow> f b = a"
63374
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   678
  by auto
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   679
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   680
end
1a474286f315 dedicated locale for total bijections
haftmann
parents: 63365
diff changeset
   681
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   682
lemma infinite_imp_bij_betw:
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   683
  assumes infinite: "\<not> finite A"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   684
  shows "\<exists>h. bij_betw h A (A - {a})"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   685
proof (cases "a \<in> A")
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   686
  case False
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   687
  then have "A - {a} = A" by blast
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   688
  then show ?thesis
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   689
    using bij_betw_id[of A] by auto
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   690
next
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   691
  case True
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   692
  with infinite have "\<not> finite (A - {a})" by auto
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   693
  with infinite_iff_countable_subset[of "A - {a}"]
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   694
  obtain f :: "nat \<Rightarrow> 'a" where 1: "inj f" and 2: "f ` UNIV \<subseteq> A - {a}" by blast
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   695
  define g where "g n = (if n = 0 then a else f (Suc n))" for n
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   696
  define A' where "A' = g ` UNIV"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   697
  have *: "\<forall>y. f y \<noteq> a" using 2 by blast
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   698
  have 3: "inj_on g UNIV \<and> g ` UNIV \<subseteq> A \<and> a \<in> g ` UNIV"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   699
    apply (auto simp add: True g_def [abs_def])
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   700
     apply (unfold inj_on_def)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   701
     apply (intro ballI impI)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   702
     apply (case_tac "x = 0")
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   703
      apply (auto simp add: 2)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   704
  proof -
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   705
    fix y
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   706
    assume "a = (if y = 0 then a else f (Suc y))"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   707
    then show "y = 0" by (cases "y = 0") (use * in auto)
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   708
  next
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   709
    fix x y
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   710
    assume "f (Suc x) = (if y = 0 then a else f (Suc y))"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   711
    with 1 * show "x = y" by (cases "y = 0") (auto simp: inj_on_def)
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   712
  next
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   713
    fix n
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   714
    from 2 show "f (Suc n) \<in> A" by blast
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   715
  qed
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   716
  then have 4: "bij_betw g UNIV A' \<and> a \<in> A' \<and> A' \<subseteq> A"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   717
    using inj_on_imp_bij_betw[of g] by (auto simp: A'_def)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   718
  then have 5: "bij_betw (inv g) A' UNIV"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   719
    by (auto simp add: bij_betw_inv_into)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   720
  from 3 obtain n where n: "g n = a" by auto
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   721
  have 6: "bij_betw g (UNIV - {n}) (A' - {a})"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   722
    by (rule bij_betw_subset) (use 3 4 n in \<open>auto simp: image_set_diff A'_def\<close>)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   723
  define v where "v m = (if m < n then m else Suc m)" for m
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   724
  have 7: "bij_betw v UNIV (UNIV - {n})"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   725
  proof (unfold bij_betw_def inj_on_def, intro conjI, clarify)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   726
    fix m1 m2
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   727
    assume "v m1 = v m2"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   728
    then show "m1 = m2"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   729
      apply (cases "m1 < n")
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   730
       apply (cases "m2 < n")
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   731
        apply (auto simp: inj_on_def v_def [abs_def])
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   732
      apply (cases "m2 < n")
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   733
       apply auto
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   734
      done
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   735
  next
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   736
    show "v ` UNIV = UNIV - {n}"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   737
    proof (auto simp: v_def [abs_def])
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   738
      fix m
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   739
      assume "m \<noteq> n"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   740
      assume *: "m \<notin> Suc ` {m'. \<not> m' < n}"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   741
      have False if "n \<le> m"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   742
      proof -
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   743
        from \<open>m \<noteq> n\<close> that have **: "Suc n \<le> m" by auto
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   744
        from Suc_le_D [OF this] obtain m' where m': "m = Suc m'" ..
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   745
        with ** have "n \<le> m'" by auto
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   746
        with m' * show ?thesis by auto
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   747
      qed
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   748
      then show "m < n" by force
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   749
    qed
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   750
  qed
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   751
  define h' where "h' = g \<circ> v \<circ> (inv g)"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   752
  with 5 6 7 have 8: "bij_betw h' A' (A' - {a})"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   753
    by (auto simp add: bij_betw_trans)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   754
  define h where "h b = (if b \<in> A' then h' b else b)" for b
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   755
  then have "\<forall>b \<in> A'. h b = h' b" by simp
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   756
  with 8 have "bij_betw h  A' (A' - {a})"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   757
    using bij_betw_cong[of A' h] by auto
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   758
  moreover
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   759
  have "\<forall>b \<in> A - A'. h b = b" by (auto simp: h_def)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   760
  then have "bij_betw h  (A - A') (A - A')"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   761
    using bij_betw_cong[of "A - A'" h id] bij_betw_id[of "A - A'"] by auto
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   762
  moreover
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   763
  from 4 have "(A' \<inter> (A - A') = {} \<and> A' \<union> (A - A') = A) \<and>
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   764
    ((A' - {a}) \<inter> (A - A') = {} \<and> (A' - {a}) \<union> (A - A') = A - {a})"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   765
    by blast
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   766
  ultimately have "bij_betw h A (A - {a})"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   767
    using bij_betw_combine[of h A' "A' - {a}" "A - A'" "A - A'"] by simp
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   768
  then show ?thesis by blast
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   769
qed
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   770
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   771
lemma infinite_imp_bij_betw2:
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   772
  assumes "\<not> finite A"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   773
  shows "\<exists>h. bij_betw h A (A \<union> {a})"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   774
proof (cases "a \<in> A")
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   775
  case True
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   776
  then have "A \<union> {a} = A" by blast
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   777
  then show ?thesis using bij_betw_id[of A] by auto
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   778
next
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   779
  case False
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   780
  let ?A' = "A \<union> {a}"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   781
  from False have "A = ?A' - {a}" by blast
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   782
  moreover from assms have "\<not> finite ?A'" by auto
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   783
  ultimately obtain f where "bij_betw f ?A' A"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   784
    using infinite_imp_bij_betw[of ?A' a] by auto
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   785
  then have "bij_betw (inv_into ?A' f) A ?A'" by (rule bij_betw_inv_into)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   786
  then show ?thesis by auto
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   787
qed
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   788
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   789
lemma bij_betw_inv_into_left: "bij_betw f A A' \<Longrightarrow> a \<in> A \<Longrightarrow> inv_into A f (f a) = a"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   790
  unfolding bij_betw_def by clarify (rule inv_into_f_f)
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   791
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   792
lemma bij_betw_inv_into_right: "bij_betw f A A' \<Longrightarrow> a' \<in> A' \<Longrightarrow> f (inv_into A f a') = a'"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   793
  unfolding bij_betw_def using f_inv_into_f by force
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   794
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   795
lemma bij_betw_inv_into_subset:
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   796
  "bij_betw f A A' \<Longrightarrow> B \<subseteq> A \<Longrightarrow> f ` B = B' \<Longrightarrow> bij_betw (inv_into A f) B' B"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   797
  by (auto simp: bij_betw_def intro: inj_on_inv_into)
55020
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   798
96b05fd2aee4 dissolved 'Fun_More_FP' (a BNF dependency)
blanchet
parents: 54744
diff changeset
   799
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60585
diff changeset
   800
subsection \<open>Specification package -- Hilbertized version\<close>
17893
aef5a6d11c2a added lemma exE_some (from specification_package.ML);
wenzelm
parents: 17702
diff changeset
   801
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 63540
diff changeset
   802
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: 17702
diff changeset
   803
  by (simp only: someI_ex)
aef5a6d11c2a added lemma exE_some (from specification_package.ML);
wenzelm
parents: 17702
diff changeset
   804
48891
c0eafbd55de3 prefer ML_file over old uses;
wenzelm
parents: 47988
diff changeset
   805
ML_file "Tools/choice_specification.ML"
14115
65ec3f73d00b Added package for definition by specification.
skalberg
parents: 13764
diff changeset
   806
67829
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   807
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: 67673
diff changeset
   808
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   809
context complete_distrib_lattice
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   810
begin
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   811
lemma Sup_Inf: "Sup (Inf ` A) = Inf (Sup ` {f ` A | f . (\<forall> Y \<in> A . f Y \<in> Y)})"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   812
proof (rule antisym)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   813
  show "SUPREMUM A Inf \<le> INFIMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} Sup"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   814
    apply (rule Sup_least, rule INF_greatest)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   815
    using Inf_lower2 Sup_upper by auto
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   816
next
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   817
  show "INFIMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} Sup \<le> SUPREMUM A Inf"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   818
  proof (simp add:  Inf_Sup, rule_tac SUP_least, simp, safe)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   819
    fix f
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   820
    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: 67673
diff changeset
   821
    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: 67673
diff changeset
   822
      by auto
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   823
    show "INFIMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} f \<le> SUPREMUM A Inf"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   824
    proof (cases "\<exists> Z \<in> A . INFIMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} f \<le> Inf Z")
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   825
      case True
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   826
      from this obtain Z where [simp]: "Z \<in> A" and A: "INFIMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} f \<le> Inf Z"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   827
        by blast
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   828
      have B: "... \<le> SUPREMUM A Inf"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   829
        by (simp add: SUP_upper)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   830
      from A and B show ?thesis
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   831
        by (drule_tac order_trans, simp_all)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   832
    next
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   833
      case False
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   834
      from this have X: "\<And> Z . Z \<in> A \<Longrightarrow> \<exists> x . x \<in> Z \<and> \<not> INFIMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} f \<le> x"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   835
        using Inf_greatest by blast
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   836
      define F where "F = (\<lambda> Z . SOME x . x \<in> Z \<and> \<not> INFIMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} f \<le> x)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   837
      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: 67673
diff changeset
   838
        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: 67673
diff changeset
   839
      have E: "\<And> Y . Y \<in> A \<Longrightarrow> \<not> INFIMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} f \<le> F Y"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   840
        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: 67673
diff changeset
   841
      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: 67673
diff changeset
   842
        by blast
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   843
      from E and D have W: "\<not> INFIMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} f \<le> F Z"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   844
        by simp
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   845
      from C have "INFIMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} f \<le> f (F ` A)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   846
        by (rule_tac INF_lower, blast)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   847
      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: 67673
diff changeset
   848
        by simp
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   849
    qed
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   850
  qed
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   851
qed
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   852
  
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   853
lemma dual_complete_distrib_lattice:
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   854
  "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: 67673
diff changeset
   855
  apply (rule class.complete_distrib_lattice.intro)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   856
   apply (fact dual_complete_lattice)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   857
  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: 67673
diff changeset
   858
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   859
lemma sup_Inf: "a \<squnion> Inf B = (INF b:B. a \<squnion> b)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   860
proof (rule antisym)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   861
  show "a \<squnion> Inf B \<le> (INF b:B. a \<squnion> b)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   862
    using Inf_lower sup.mono by (rule_tac INF_greatest, fastforce)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   863
next
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   864
  have "(INF b:B. a \<squnion> b) \<le> INFIMUM {{f {a}, f B} |f. f {a} = a \<and> f B \<in> B} Sup"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   865
    by (rule INF_greatest, auto simp add: INF_lower)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   866
  also have "... = a \<squnion> Inf B"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   867
    by (cut_tac A = "{{a}, B}" in Sup_Inf, simp)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   868
  finally show "(INF b:B. a \<squnion> b) \<le> a \<squnion> Inf B"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   869
    by simp
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   870
qed
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   871
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   872
lemma inf_Sup: "a \<sqinter> Sup B = (SUP b:B. a \<sqinter> b)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   873
  using dual_complete_distrib_lattice
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   874
  by (rule complete_distrib_lattice.sup_Inf)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   875
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   876
lemma INF_SUP: "(INF y. SUP x. ((P x y)::'a)) = (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: 67673
diff changeset
   877
proof (rule antisym)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   878
  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: 67673
diff changeset
   879
    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: 67673
diff changeset
   880
next
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   881
  have "(INF y. SUP x. ((P x y))) \<le> Inf (Sup ` {{P x y | x . True} | y . True })" (is "?A \<le> ?B")
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   882
  proof (rule_tac INF_greatest, clarsimp)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   883
    fix y
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   884
    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: 67673
diff changeset
   885
      by (rule INF_lower, simp)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   886
    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: 67673
diff changeset
   887
      by (simp add: full_SetCompr_eq)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   888
    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: 67673
diff changeset
   889
      by simp
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   890
  qed
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   891
  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: 67673
diff changeset
   892
  proof (subst  Inf_Sup, rule_tac SUP_least, clarsimp)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   893
    fix f
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   894
    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: 67673
diff changeset
   895
      
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   896
    have "(INF x:{uu. \<exists>y. uu = {uu. \<exists>x. uu = P x y}}. f x) \<le>  (INF y. P ((\<lambda> y. SOME x . f ({P x y | x. True}) = P x y) y) y)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   897
    proof (rule INF_greatest, clarsimp)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   898
      fix y
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   899
        have "(INF x:{uu. \<exists>y. uu = {uu. \<exists>x. uu = P x y}}. f x) \<le> f {uu. \<exists>x. uu = P x y}"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   900
          by (rule_tac INF_lower, blast)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   901
        also have "... \<le> P (SOME x. f {uu . \<exists>x. uu = P x y} = P x y) y"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   902
          using A by (rule_tac someI2_ex, auto)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   903
        finally show "(INF x:{uu. \<exists>y. uu = {uu. \<exists>x. uu = P x y}}. f x) \<le> P (SOME x. f {uu . \<exists>x. uu = P x y} = P x y) y"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   904
          by simp
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   905
      qed
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   906
      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: 67673
diff changeset
   907
        by (rule SUP_upper, simp)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   908
      finally show "(INF x:{uu. \<exists>y. uu = {uu. \<exists>x. uu = P x y}}. f x) \<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: 67673
diff changeset
   909
        by simp
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   910
    qed
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   911
  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: 67673
diff changeset
   912
    by simp
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   913
qed
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   914
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   915
lemma INF_SUP_set: "(INF x:A. SUP a:x. (g a)) = (SUP x:{f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}. INF a:x. g a)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   916
proof (rule antisym)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   917
  have A: "\<And>f xa. \<forall>Y\<in>A. f Y \<in> Y \<Longrightarrow> xa \<in> A \<Longrightarrow> (\<Sqinter>x\<in>A. g (f x)) \<le> SUPREMUM xa g"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   918
    by (rule_tac i = "(f xa)" in SUP_upper2, simp, rule_tac i = "xa" in INF_lower2, simp_all)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   919
  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)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   920
    apply (rule SUP_least, simp, safe, rule INF_greatest, simp)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   921
    by (rule A)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   922
next
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   923
  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: 67673
diff changeset
   924
  proof (cases "{} \<in> A")
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   925
    case True
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   926
    then show ?thesis 
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   927
      by (rule_tac i = "{}" in INF_lower2, simp_all)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   928
  next
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   929
    case False
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   930
    have [simp]: "\<And>x xa xb. xb \<in> A \<Longrightarrow> x xb \<in> xb \<Longrightarrow> (\<Sqinter>xa. if xa \<in> A then if x xa \<in> xa then g (x xa) else \<bottom> else \<top>) \<le> g (x xb)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   931
      by (rule_tac i = xb in INF_lower2, simp_all)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   932
    have [simp]: " \<And>x xa y. y \<in> A \<Longrightarrow> x y \<notin> y \<Longrightarrow> (\<Sqinter>xa. if xa \<in> A then if x xa \<in> xa then g (x xa) else \<bottom> else \<top>) \<le> g (SOME x. x \<in> y)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   933
      by (rule_tac i = y in INF_lower2, simp_all)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   934
    have [simp]: "\<And>x. (\<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)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   935
      apply (rule_tac i = "(\<lambda> y . if x y \<in> y then x y else (SOME x . x \<in>y)) ` A" in SUP_upper2, simp)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   936
       apply (rule_tac x = "(\<lambda> y . if x y \<in> y then x y else (SOME x . x \<in>y))" in exI, simp)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   937
      using False some_in_eq apply auto[1]
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   938
      by (rule INF_greatest, auto)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   939
    have "\<And>x. (\<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>)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   940
      apply (case_tac "x \<in> A")
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   941
       apply (rule INF_lower2, simp)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   942
      by (rule SUP_least, rule SUP_upper2, auto)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   943
    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: 67673
diff changeset
   944
      by (rule INF_greatest)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   945
    also have "... = (\<Squnion>x. \<Sqinter>xa. if xa \<in> A then if x xa \<in> xa then g (x xa) else \<bottom> else \<top>)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   946
      by (simp add: INF_SUP)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   947
    also have "... \<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: 67673
diff changeset
   948
      by (rule SUP_least, simp)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   949
    finally show ?thesis by simp
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   950
  qed
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   951
qed
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   952
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   953
lemma SUP_INF: "(SUP y. INF x. ((P x y)::'a)) = (INF x. SUP y. P (x y) y)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   954
  using dual_complete_distrib_lattice
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   955
  by (rule complete_distrib_lattice.INF_SUP)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   956
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   957
lemma SUP_INF_set: "(SUP x:A. INF a:x. (g a)) = (INF x:{f ` A |f. \<forall>Y\<in>A. f Y \<in> Y}. SUP a:x. g a)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   958
  using dual_complete_distrib_lattice
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   959
  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: 67673
diff changeset
   960
11451
8abfb4f7bd02 partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff changeset
   961
end
67829
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   962
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   963
(*properties of the former complete_distrib_lattice*)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   964
context complete_distrib_lattice
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   965
begin
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   966
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   967
lemma sup_INF: "a \<squnion> (\<Sqinter>b\<in>B. f b) = (\<Sqinter>b\<in>B. a \<squnion> f b)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   968
  by (simp add: sup_Inf)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   969
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   970
lemma inf_SUP: "a \<sqinter> (\<Squnion>b\<in>B. f b) = (\<Squnion>b\<in>B. a \<sqinter> f b)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   971
  by (simp add: inf_Sup)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   972
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   973
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   974
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: 67673
diff changeset
   975
  by (simp add: sup_Inf sup_commute)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   976
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   977
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: 67673
diff changeset
   978
  by (simp add: inf_Sup inf_commute)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   979
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   980
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: 67673
diff changeset
   981
  by (simp add: sup_INF sup_commute)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   982
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   983
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: 67673
diff changeset
   984
  by (simp add: inf_SUP inf_commute)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   985
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   986
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: 67673
diff changeset
   987
  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: 67673
diff changeset
   988
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   989
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: 67673
diff changeset
   990
  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: 67673
diff changeset
   991
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   992
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: 67673
diff changeset
   993
  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: 67673
diff changeset
   994
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   995
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: 67673
diff changeset
   996
  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: 67673
diff changeset
   997
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   998
end
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
   999
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1000
context complete_boolean_algebra
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1001
begin
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1002
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1003
lemma dual_complete_boolean_algebra:
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1004
  "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: 67673
diff changeset
  1005
  by (rule class.complete_boolean_algebra.intro,
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1006
      rule dual_complete_distrib_lattice,
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1007
      rule dual_boolean_algebra)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1008
end
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1009
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1010
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1011
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1012
instantiation "set" :: (type) complete_distrib_lattice
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1013
begin
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1014
instance proof (standard, clarsimp)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1015
  fix A :: "(('a set) set) set"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1016
  fix x::'a
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1017
  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: 67673
diff changeset
  1018
  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: 67673
diff changeset
  1019
    
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1020
  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: 67673
diff changeset
  1021
    apply (safe, simp add: F_def)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1022
    by (rule someI2_ex, auto)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1023
    
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1024
  have "(\<exists>f. F ` A  = f ` A \<and> (\<forall>Y\<in>A. f Y \<in> Y))"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1025
    apply (rule_tac x = "F" in exI, simp add: F_def, safe)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1026
    using A by (rule_tac someI2_ex, auto)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1027
    
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1028
  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: 67673
diff changeset
  1029
    by auto
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1030
qed
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1031
end
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1032
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1033
instance "set" :: (type) complete_boolean_algebra ..
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1034
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1035
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: 67673
diff changeset
  1036
begin
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1037
instance by standard (simp add: le_fun_def INF_SUP_set)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1038
end
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1039
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1040
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: 67673
diff changeset
  1041
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1042
context complete_linorder
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1043
begin
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1044
  
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1045
subclass complete_distrib_lattice
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1046
proof (standard, rule ccontr)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1047
  fix A
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1048
  assume "\<not> INFIMUM A Sup \<le> SUPREMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} Inf"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1049
  from this have C: "INFIMUM A Sup > SUPREMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} Inf"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1050
    using local.not_le by blast
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1051
  show "False"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1052
    proof (cases "\<exists> z . INFIMUM A Sup > z \<and> z > SUPREMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} Inf")
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1053
      case True
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1054
      from this obtain z where A: "z < INFIMUM A Sup" and X: "SUPREMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} Inf < z"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1055
        by blast
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1056
          
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1057
      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: 67673
diff changeset
  1058
        by (simp add: less_INF_D)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1059
    
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1060
      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: 67673
diff changeset
  1061
        using local.less_Sup_iff by blast
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1062
          
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1063
      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: 67673
diff changeset
  1064
        
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1065
      have D: "\<And> Y . Y \<in> A \<Longrightarrow> z < F Y"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1066
        using B by (simp add: F_def, rule_tac someI2_ex, auto)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1067
    
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1068
      have E: "\<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: 67673
diff changeset
  1069
        using B by (simp add: F_def, rule_tac someI2_ex, auto)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1070
    
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1071
      have "z \<le> Inf (F ` A)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1072
        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: 67673
diff changeset
  1073
    
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1074
      also have "... \<le> SUPREMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} Inf"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1075
        apply (rule SUP_upper, safe)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1076
        using E by blast
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1077
      finally have "z \<le> SUPREMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} Inf"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1078
        by simp
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1079
          
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1080
      from X and this show ?thesis
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1081
        using local.not_less by blast
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1082
    next
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1083
      case False
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1084
      from this have A: "\<And> z . INFIMUM A Sup \<le> z \<or> z \<le> SUPREMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} Inf"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1085
        using local.le_less_linear by blast
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1086
          
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1087
      from C have "\<And> Y . Y \<in> A \<Longrightarrow> SUPREMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} Inf < Sup Y"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1088
        by (simp add: less_INF_D)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1089
    
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1090
      from this have B: "\<And> Y . Y \<in> A \<Longrightarrow> \<exists> k \<in>Y . SUPREMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} Inf < k"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1091
        using local.less_Sup_iff by blast
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1092
          
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1093
      define F where "F = (\<lambda> Y . SOME k . k \<in> Y \<and> SUPREMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} Inf < k)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1094
        
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1095
      have D: "\<And> Y . Y \<in> A \<Longrightarrow> SUPREMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} Inf < F Y"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1096
        using B by (simp add: F_def, rule_tac someI2_ex, auto)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1097
    
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1098
      have E: "\<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: 67673
diff changeset
  1099
        using B by (simp add: F_def, rule_tac someI2_ex, auto)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1100
          
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1101
      have "\<And> Y . Y \<in> A \<Longrightarrow> INFIMUM A Sup \<le> F Y"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1102
        using D False local.leI by blast
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1103
         
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1104
      from this have "INFIMUM A Sup \<le> Inf (F ` A)"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1105
        by (simp add: local.INF_greatest)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1106
          
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1107
      also have "Inf (F ` A) \<le> SUPREMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} Inf"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1108
        apply (rule SUP_upper, safe)
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1109
        using E by blast
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1110
          
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1111
      finally have "INFIMUM A Sup \<le> SUPREMUM {f ` A |f. \<forall>Y\<in>A. f Y \<in> Y} Inf"
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1112
        by simp
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1113
        
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1114
      from C and this show ?thesis
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1115
        using local.not_less by blast
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1116
    qed
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1117
  qed
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1118
end
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1119
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1120
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1121
2a6ef5ba4822 Changes to complete distributive lattices due to Viorel Preoteasa
Manuel Eberl <eberlm@in.tum.de>
parents: 67673
diff changeset
  1122
end