src/HOL/Library/Bourbaki_Witt_Fixpoint.thy
author eberlm
Tue, 17 May 2016 17:05:35 +0200
changeset 63099 af0e964aad7b
parent 62647 3cf0edded065
child 63540 f8652d0534fa
permissions -rw-r--r--
Moved material from AFP/Randomised_Social_Choice to distribution
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
62058
1cfd5d604937 updated headers;
wenzelm
parents: 61766
diff changeset
     1
(*  Title:      HOL/Library/Bourbaki_Witt_Fixpoint.thy
1cfd5d604937 updated headers;
wenzelm
parents: 61766
diff changeset
     2
    Author:     Andreas Lochbihler, ETH Zurich
62141
00bfdf4bf237 add reference
Andreas Lochbihler
parents: 62058
diff changeset
     3
00bfdf4bf237 add reference
Andreas Lochbihler
parents: 62058
diff changeset
     4
  Follows G. Smolka, S. Schäfer and C. Doczkal: Transfinite Constructions in
00bfdf4bf237 add reference
Andreas Lochbihler
parents: 62058
diff changeset
     5
  Classical Type Theory. ITP 2015
62058
1cfd5d604937 updated headers;
wenzelm
parents: 61766
diff changeset
     6
*)
61766
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
     7
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
     8
section \<open>The Bourbaki-Witt tower construction for transfinite iteration\<close>
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
     9
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    10
theory Bourbaki_Witt_Fixpoint imports Main begin
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    11
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    12
lemma ChainsI [intro?]:
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    13
  "(\<And>a b. \<lbrakk> a \<in> Y; b \<in> Y \<rbrakk> \<Longrightarrow> (a, b) \<in> r \<or> (b, a) \<in> r) \<Longrightarrow> Y \<in> Chains r"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    14
unfolding Chains_def by blast
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    15
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    16
lemma in_Chains_subset: "\<lbrakk> M \<in> Chains r; M' \<subseteq> M \<rbrakk> \<Longrightarrow> M' \<in> Chains r"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    17
by(auto simp add: Chains_def)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    18
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    19
lemma FieldI1: "(i, j) \<in> R \<Longrightarrow> i \<in> Field R"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    20
  unfolding Field_def by auto
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    21
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    22
lemma Chains_FieldD: "\<lbrakk> M \<in> Chains r; x \<in> M \<rbrakk> \<Longrightarrow> x \<in> Field r"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    23
by(auto simp add: Chains_def intro: FieldI1 FieldI2)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    24
62622
7c56e4a1ad0c add fixpoint induction principle
Andreas Lochbihler
parents: 62390
diff changeset
    25
lemma in_Chains_conv_chain: "M \<in> Chains r \<longleftrightarrow> Complete_Partial_Order.chain (\<lambda>x y. (x, y) \<in> r) M"
7c56e4a1ad0c add fixpoint induction principle
Andreas Lochbihler
parents: 62390
diff changeset
    26
by(simp add: Chains_def chain_def)
7c56e4a1ad0c add fixpoint induction principle
Andreas Lochbihler
parents: 62390
diff changeset
    27
61766
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    28
lemma partial_order_on_trans:
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    29
  "\<lbrakk> partial_order_on A r; (x, y) \<in> r; (y, z) \<in> r \<rbrakk> \<Longrightarrow> (x, z) \<in> r"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    30
by(auto simp add: order_on_defs dest: transD)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    31
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    32
locale bourbaki_witt_fixpoint =
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    33
  fixes lub :: "'a set \<Rightarrow> 'a"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    34
  and leq :: "('a \<times> 'a) set"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    35
  and f :: "'a \<Rightarrow> 'a"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    36
  assumes po: "Partial_order leq"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    37
  and lub_least: "\<lbrakk> M \<in> Chains leq; M \<noteq> {}; \<And>x. x \<in> M \<Longrightarrow> (x, z) \<in> leq \<rbrakk> \<Longrightarrow> (lub M, z) \<in> leq"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    38
  and lub_upper: "\<lbrakk> M \<in> Chains leq; x \<in> M \<rbrakk> \<Longrightarrow> (x, lub M) \<in> leq"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    39
  and lub_in_Field: "\<lbrakk> M \<in> Chains leq; M \<noteq> {} \<rbrakk> \<Longrightarrow> lub M \<in> Field leq"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    40
  and increasing: "\<And>x. x \<in> Field leq \<Longrightarrow> (x, f x) \<in> leq"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    41
begin
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    42
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    43
lemma leq_trans: "\<lbrakk> (x, y) \<in> leq; (y, z) \<in> leq \<rbrakk> \<Longrightarrow> (x, z) \<in> leq"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    44
by(rule partial_order_on_trans[OF po])
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    45
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    46
lemma leq_refl: "x \<in> Field leq \<Longrightarrow> (x, x) \<in> leq"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    47
using po by(simp add: order_on_defs refl_on_def)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    48
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    49
lemma leq_antisym: "\<lbrakk> (x, y) \<in> leq; (y, x) \<in> leq \<rbrakk> \<Longrightarrow> x = y"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    50
using po by(simp add: order_on_defs antisym_def)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    51
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    52
inductive_set iterates_above :: "'a \<Rightarrow> 'a set"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    53
  for a
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    54
where
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    55
  base: "a \<in> iterates_above a"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    56
| step: "x \<in> iterates_above a \<Longrightarrow> f x \<in> iterates_above a"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    57
| Sup: "\<lbrakk> M \<in> Chains leq; M \<noteq> {}; \<And>x. x \<in> M \<Longrightarrow> x \<in> iterates_above a \<rbrakk> \<Longrightarrow> lub M \<in> iterates_above a"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    58
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    59
definition fixp_above :: "'a \<Rightarrow> 'a"
62647
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
    60
where "fixp_above a = (if a \<in> Field leq then lub (iterates_above a) else a)"
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
    61
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
    62
lemma fixp_above_outside: "a \<notin> Field leq \<Longrightarrow> fixp_above a = a"
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
    63
by(simp add: fixp_above_def)
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
    64
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
    65
lemma fixp_above_inside: "a \<in> Field leq \<Longrightarrow> fixp_above a = lub (iterates_above a)"
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
    66
by(simp add: fixp_above_def)
61766
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    67
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    68
context 
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    69
  notes leq_refl [intro!, simp]
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    70
  and base [intro]
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    71
  and step [intro]
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    72
  and Sup [intro]
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    73
  and leq_trans [trans]
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    74
begin
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    75
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    76
lemma iterates_above_le_f: "\<lbrakk> x \<in> iterates_above a; a \<in> Field leq \<rbrakk> \<Longrightarrow> (x, f x) \<in> leq"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    77
by(induction x rule: iterates_above.induct)(blast intro: increasing FieldI2 lub_in_Field)+
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    78
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    79
lemma iterates_above_Field: "\<lbrakk> x \<in> iterates_above a; a \<in> Field leq \<rbrakk> \<Longrightarrow> x \<in> Field leq"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    80
by(drule (1) iterates_above_le_f)(rule FieldI1)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    81
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    82
lemma iterates_above_ge:
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    83
  assumes y: "y \<in> iterates_above a"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    84
  and a: "a \<in> Field leq"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    85
  shows "(a, y) \<in> leq"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    86
using y by(induction)(auto intro: a increasing iterates_above_le_f leq_trans leq_trans[OF _ lub_upper])
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    87
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    88
lemma iterates_above_lub:
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    89
  assumes M: "M \<in> Chains leq"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    90
  and nempty: "M \<noteq> {}"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    91
  and upper: "\<And>y. y \<in> M \<Longrightarrow> \<exists>z \<in> M. (y, z) \<in> leq \<and> z \<in> iterates_above a"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    92
  shows "lub M \<in> iterates_above a"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    93
proof -
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    94
  let ?M = "M \<inter> iterates_above a"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    95
  from M have M': "?M \<in> Chains leq" by(rule in_Chains_subset)simp
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    96
  have "?M \<noteq> {}" using nempty by(auto dest: upper)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    97
  with M' have "lub ?M \<in> iterates_above a" by(rule Sup) blast
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    98
  also have "lub ?M = lub M" using nempty
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
    99
    by(intro leq_antisym)(blast intro!: lub_least[OF M] lub_least[OF M'] intro: lub_upper[OF M'] lub_upper[OF M] leq_trans dest: upper)+
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   100
  finally show ?thesis .
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   101
qed
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   102
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   103
lemma iterates_above_successor:
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   104
  assumes y: "y \<in> iterates_above a"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   105
  and a: "a \<in> Field leq"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   106
  shows "y = a \<or> y \<in> iterates_above (f a)"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   107
using y
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   108
proof induction
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   109
  case base thus ?case by simp
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   110
next
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   111
  case (step x) thus ?case by auto
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   112
next
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   113
  case (Sup M)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   114
  show ?case
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   115
  proof(cases "\<exists>x. M \<subseteq> {x}")
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   116
    case True
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   117
    with \<open>M \<noteq> {}\<close> obtain y where M: "M = {y}" by auto
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   118
    have "lub M = y"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   119
      by(rule leq_antisym)(auto intro!: lub_upper Sup lub_least ChainsI simp add: a M Sup.hyps(3)[of y, THEN iterates_above_Field] dest: iterates_above_Field)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   120
    with Sup.IH[of y] M show ?thesis by simp
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   121
  next
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   122
    case False
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   123
    from Sup(1-2) have "lub M \<in> iterates_above (f a)"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   124
    proof(rule iterates_above_lub)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   125
      fix y
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   126
      assume y: "y \<in> M"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   127
      from Sup.IH[OF this] show "\<exists>z\<in>M. (y, z) \<in> leq \<and> z \<in> iterates_above (f a)"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   128
      proof
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   129
        assume "y = a"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   130
        from y False obtain z where z: "z \<in> M" and neq: "y \<noteq> z" by (metis insertI1 subsetI)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   131
        with Sup.IH[OF z] \<open>y = a\<close> Sup.hyps(3)[OF z]
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   132
        show ?thesis by(auto dest: iterates_above_ge intro: a)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   133
      next
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   134
        assume "y \<in> iterates_above (f a)"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   135
        moreover with increasing[OF a] have "y \<in> Field leq"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   136
          by(auto dest!: iterates_above_Field intro: FieldI2)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   137
        ultimately show ?thesis using y by(auto)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   138
      qed
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   139
    qed
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   140
    thus ?thesis by simp
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   141
  qed
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   142
qed
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   143
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   144
lemma iterates_above_Sup_aux:
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   145
  assumes M: "M \<in> Chains leq" "M \<noteq> {}"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   146
  and M': "M' \<in> Chains leq" "M' \<noteq> {}"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   147
  and comp: "\<And>x. x \<in> M \<Longrightarrow> x \<in> iterates_above (lub M') \<or> lub M' \<in> iterates_above x"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   148
  shows "(lub M, lub M') \<in> leq \<or> lub M \<in> iterates_above (lub M')"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   149
proof(cases "\<exists>x \<in> M. x \<in> iterates_above (lub M')")
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   150
  case True
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   151
  then obtain x where x: "x \<in> M" "x \<in> iterates_above (lub M')" by blast
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   152
  have lub_M': "lub M' \<in> Field leq" using M' by(rule lub_in_Field)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   153
  have "lub M \<in> iterates_above (lub M')" using M
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   154
  proof(rule iterates_above_lub)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   155
    fix y
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   156
    assume y: "y \<in> M"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   157
    from comp[OF y] show "\<exists>z\<in>M. (y, z) \<in> leq \<and> z \<in> iterates_above (lub M')"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   158
    proof
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   159
      assume "y \<in> iterates_above (lub M')"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   160
      from this iterates_above_Field[OF this] y lub_M' show ?thesis by blast
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   161
    next
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   162
      assume "lub M' \<in> iterates_above y"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   163
      hence "(y, lub M') \<in> leq" using Chains_FieldD[OF M(1) y] by(rule iterates_above_ge)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   164
      also have "(lub M', x) \<in> leq" using x(2) lub_M' by(rule iterates_above_ge)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   165
      finally show ?thesis using x by blast
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   166
    qed
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   167
  qed
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   168
  thus ?thesis ..
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   169
next
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   170
  case False
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   171
  have "(lub M, lub M') \<in> leq" using M
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   172
  proof(rule lub_least)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   173
    fix x
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   174
    assume x: "x \<in> M"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   175
    from comp[OF x] x False have "lub M' \<in> iterates_above x" by auto
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   176
    moreover from M(1) x have "x \<in> Field leq" by(rule Chains_FieldD)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   177
    ultimately show "(x, lub M') \<in> leq" by(rule iterates_above_ge)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   178
  qed
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   179
  thus ?thesis ..
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   180
qed
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   181
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   182
lemma iterates_above_triangle:
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   183
  assumes x: "x \<in> iterates_above a"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   184
  and y: "y \<in> iterates_above a"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   185
  and a: "a \<in> Field leq"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   186
  shows "x \<in> iterates_above y \<or> y \<in> iterates_above x"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   187
using x y
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   188
proof(induction arbitrary: y)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   189
  case base then show ?case by simp
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   190
next
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   191
  case (step x) thus ?case using a
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   192
    by(auto dest: iterates_above_successor intro: iterates_above_Field)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   193
next
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   194
  case x: (Sup M)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   195
  hence lub: "lub M \<in> iterates_above a" by blast
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   196
  from \<open>y \<in> iterates_above a\<close> show ?case
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   197
  proof(induction)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   198
    case base show ?case using lub by simp
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   199
  next
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   200
    case (step y) thus ?case using a
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   201
      by(auto dest: iterates_above_successor intro: iterates_above_Field)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   202
  next
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   203
    case y: (Sup M')
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   204
    hence lub': "lub M' \<in> iterates_above a" by blast
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   205
    have *: "x \<in> iterates_above (lub M') \<or> lub M' \<in> iterates_above x" if "x \<in> M" for x
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   206
      using that lub' by(rule x.IH)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   207
    with x(1-2) y(1-2) have "(lub M, lub M') \<in> leq \<or> lub M \<in> iterates_above (lub M')"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   208
      by(rule iterates_above_Sup_aux)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   209
    moreover from y(1-2) x(1-2) have "(lub M', lub M) \<in> leq \<or> lub M' \<in> iterates_above (lub M)"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   210
      by(rule iterates_above_Sup_aux)(blast dest: y.IH)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   211
    ultimately show ?case by(auto 4 3 dest: leq_antisym)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   212
  qed
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   213
qed
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   214
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   215
lemma chain_iterates_above: 
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   216
  assumes a: "a \<in> Field leq"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   217
  shows "iterates_above a \<in> Chains leq" (is "?C \<in> _")
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   218
proof (rule ChainsI)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   219
  fix x y
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   220
  assume "x \<in> ?C" "y \<in> ?C"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   221
  hence "x \<in> iterates_above y \<or> y \<in> iterates_above x" using a by(rule iterates_above_triangle)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   222
  moreover from \<open>x \<in> ?C\<close> a have "x \<in> Field leq" by(rule iterates_above_Field)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   223
  moreover from \<open>y \<in> ?C\<close> a have "y \<in> Field leq" by(rule iterates_above_Field)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   224
  ultimately show "(x, y) \<in> leq \<or> (y, x) \<in> leq" by(auto dest: iterates_above_ge)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   225
qed
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   226
62647
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
   227
lemma fixp_iterates_above: "fixp_above a \<in> iterates_above a"
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
   228
by(auto intro: chain_iterates_above simp add: fixp_above_def)
61766
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   229
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   230
lemma fixp_above_Field: "a \<in> Field leq \<Longrightarrow> fixp_above a \<in> Field leq"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   231
using fixp_iterates_above by(rule iterates_above_Field)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   232
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   233
lemma fixp_above_unfold:
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   234
  assumes a: "a \<in> Field leq"
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   235
  shows "fixp_above a = f (fixp_above a)" (is "?a = f ?a")
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   236
proof(rule leq_antisym)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   237
  show "(?a, f ?a) \<in> leq" using fixp_above_Field[OF a] by(rule increasing)
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   238
  
62647
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
   239
  have "f ?a \<in> iterates_above a" using fixp_iterates_above by(rule iterates_above.step)
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
   240
  with chain_iterates_above[OF a] show "(f ?a, ?a) \<in> leq"
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
   241
    by(simp add: fixp_above_inside assms lub_upper)
61766
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   242
qed
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   243
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   244
end
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   245
62647
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
   246
lemma fixp_induct [case_names adm base step]:
62622
7c56e4a1ad0c add fixpoint induction principle
Andreas Lochbihler
parents: 62390
diff changeset
   247
  assumes adm: "ccpo.admissible lub (\<lambda>x y. (x, y) \<in> leq) P"
7c56e4a1ad0c add fixpoint induction principle
Andreas Lochbihler
parents: 62390
diff changeset
   248
  and base: "P a"
7c56e4a1ad0c add fixpoint induction principle
Andreas Lochbihler
parents: 62390
diff changeset
   249
  and step: "\<And>x. P x \<Longrightarrow> P (f x)"
7c56e4a1ad0c add fixpoint induction principle
Andreas Lochbihler
parents: 62390
diff changeset
   250
  shows "P (fixp_above a)"
62647
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
   251
proof(cases "a \<in> Field leq")
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
   252
  case True
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
   253
  from adm chain_iterates_above[OF True]
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
   254
  show ?thesis unfolding fixp_above_inside[OF True] in_Chains_conv_chain
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
   255
  proof(rule ccpo.admissibleD)
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
   256
    have "a \<in> iterates_above a" ..
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
   257
    then show "iterates_above a \<noteq> {}" by(auto)
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
   258
    show "P x" if "x \<in> iterates_above a" for x using that
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
   259
      by induction(auto intro: base step simp add: in_Chains_conv_chain dest: ccpo.admissibleD[OF adm])
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
   260
  qed
3cf0edded065 less preconditions
Andreas Lochbihler
parents: 62622
diff changeset
   261
qed(simp add: fixp_above_outside base)
62622
7c56e4a1ad0c add fixpoint induction principle
Andreas Lochbihler
parents: 62390
diff changeset
   262
61766
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   263
end
507b39df1a57 add formalisation of Bourbaki-Witt fixpoint theorem
Andreas Lochbihler
parents:
diff changeset
   264
62390
842917225d56 more canonical names
nipkow
parents: 62141
diff changeset
   265
end