src/HOL/HOLCF/Completion.thy
author wenzelm
Tue, 05 Jun 2018 18:08:13 +0200
changeset 68383 93a42bd62ede
parent 65380 ae93953746fc
permissions -rw-r--r--
tuned proofs;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42151
4da4fc77664b tuned headers;
wenzelm
parents: 41529
diff changeset
     1
(*  Title:      HOL/HOLCF/Completion.thy
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
     2
    Author:     Brian Huffman
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
     3
*)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
     4
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
     5
section \<open>Defining algebraic domains by ideal completion\<close>
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
     6
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
     7
theory Completion
65380
ae93953746fc eliminated Plain_HOLCF.thy (see also 8e92772bc0e8): it was modeled after HOL/Plain.thy which was discontinued later;
wenzelm
parents: 65379
diff changeset
     8
imports Cfun
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
     9
begin
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    10
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
    11
subsection \<open>Ideals over a preorder\<close>
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    12
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    13
locale preorder =
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    14
  fixes r :: "'a::type \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<preceq>" 50)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    15
  assumes r_refl: "x \<preceq> x"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    16
  assumes r_trans: "\<lbrakk>x \<preceq> y; y \<preceq> z\<rbrakk> \<Longrightarrow> x \<preceq> z"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    17
begin
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    18
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    19
definition
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    20
  ideal :: "'a set \<Rightarrow> bool" where
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    21
  "ideal A = ((\<exists>x. x \<in> A) \<and> (\<forall>x\<in>A. \<forall>y\<in>A. \<exists>z\<in>A. x \<preceq> z \<and> y \<preceq> z) \<and>
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    22
    (\<forall>x y. x \<preceq> y \<longrightarrow> y \<in> A \<longrightarrow> x \<in> A))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    23
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    24
lemma idealI:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    25
  assumes "\<exists>x. x \<in> A"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    26
  assumes "\<And>x y. \<lbrakk>x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. x \<preceq> z \<and> y \<preceq> z"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    27
  assumes "\<And>x y. \<lbrakk>x \<preceq> y; y \<in> A\<rbrakk> \<Longrightarrow> x \<in> A"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    28
  shows "ideal A"
41529
ba60efa2fd08 eliminated global prems;
wenzelm
parents: 41402
diff changeset
    29
unfolding ideal_def using assms by fast
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    30
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    31
lemma idealD1:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    32
  "ideal A \<Longrightarrow> \<exists>x. x \<in> A"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    33
unfolding ideal_def by fast
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    34
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    35
lemma idealD2:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    36
  "\<lbrakk>ideal A; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. x \<preceq> z \<and> y \<preceq> z"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    37
unfolding ideal_def by fast
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    38
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    39
lemma idealD3:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    40
  "\<lbrakk>ideal A; x \<preceq> y; y \<in> A\<rbrakk> \<Longrightarrow> x \<in> A"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    41
unfolding ideal_def by fast
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    42
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    43
lemma ideal_principal: "ideal {x. x \<preceq> z}"
68383
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    44
  apply (rule idealI)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    45
    apply (rule exI [where x = z])
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    46
    apply (fast intro: r_refl)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    47
   apply (rule bexI [where x = z], fast)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    48
   apply (fast intro: r_refl)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    49
  apply (fast intro: r_trans)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    50
  done
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    51
40888
28cd51cff70c reformulate lemma preorder.ex_ideal, and use it for typedefs
huffman
parents: 40774
diff changeset
    52
lemma ex_ideal: "\<exists>A. A \<in> {A. ideal A}"
28cd51cff70c reformulate lemma preorder.ex_ideal, and use it for typedefs
huffman
parents: 40774
diff changeset
    53
by (fast intro: ideal_principal)
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    54
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
    55
text \<open>The set of ideals is a cpo\<close>
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    56
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    57
lemma ideal_UN:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    58
  fixes A :: "nat \<Rightarrow> 'a set"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    59
  assumes ideal_A: "\<And>i. ideal (A i)"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    60
  assumes chain_A: "\<And>i j. i \<le> j \<Longrightarrow> A i \<subseteq> A j"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    61
  shows "ideal (\<Union>i. A i)"
68383
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    62
  apply (rule idealI)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    63
  using idealD1 [OF ideal_A] apply fast
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    64
   apply (clarify)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    65
  subgoal for i j
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    66
    apply (drule subsetD [OF chain_A [OF max.cobounded1]])
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    67
    apply (drule subsetD [OF chain_A [OF max.cobounded2]])
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    68
    apply (drule (1) idealD2 [OF ideal_A])
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    69
    apply blast
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    70
    done
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    71
  apply clarify
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    72
  apply (drule (1) idealD3 [OF ideal_A])
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    73
  apply fast
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
    74
  done
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    75
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    76
lemma typedef_ideal_po:
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
    77
  fixes Abs :: "'a set \<Rightarrow> 'b::below"
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    78
  assumes type: "type_definition Rep Abs {S. ideal S}"
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
    79
  assumes below: "\<And>x y. x \<sqsubseteq> y \<longleftrightarrow> Rep x \<subseteq> Rep y"
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    80
  shows "OFCLASS('b, po_class)"
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
    81
 apply (intro_classes, unfold below)
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    82
   apply (rule subset_refl)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    83
  apply (erule (1) subset_trans)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    84
 apply (rule type_definition.Rep_inject [OF type, THEN iffD1])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    85
 apply (erule (1) subset_antisym)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    86
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    87
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    88
lemma
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    89
  fixes Abs :: "'a set \<Rightarrow> 'b::po"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    90
  assumes type: "type_definition Rep Abs {S. ideal S}"
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
    91
  assumes below: "\<And>x y. x \<sqsubseteq> y \<longleftrightarrow> Rep x \<subseteq> Rep y"
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    92
  assumes S: "chain S"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    93
  shows typedef_ideal_lub: "range S <<| Abs (\<Union>i. Rep (S i))"
40769
3af9b0df3521 rename rep_contlub lemmas to rep_lub
huffman
parents: 40502
diff changeset
    94
    and typedef_ideal_rep_lub: "Rep (\<Squnion>i. S i) = (\<Union>i. Rep (S i))"
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    95
proof -
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    96
  have 1: "ideal (\<Union>i. Rep (S i))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    97
    apply (rule ideal_UN)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    98
     apply (rule type_definition.Rep [OF type, unfolded mem_Collect_eq])
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
    99
    apply (subst below [symmetric])
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   100
    apply (erule chain_mono [OF S])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   101
    done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   102
  hence 2: "Rep (Abs (\<Union>i. Rep (S i))) = (\<Union>i. Rep (S i))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   103
    by (simp add: type_definition.Abs_inverse [OF type])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   104
  show 3: "range S <<| Abs (\<Union>i. Rep (S i))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   105
    apply (rule is_lubI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   106
     apply (rule is_ubI)
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
   107
     apply (simp add: below 2, fast)
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
   108
    apply (simp add: below 2 is_ub_def, fast)
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   109
    done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   110
  hence 4: "(\<Squnion>i. S i) = Abs (\<Union>i. Rep (S i))"
40771
1c6f7d4b110e renamed several HOLCF theorems (listed in NEWS)
huffman
parents: 40769
diff changeset
   111
    by (rule lub_eqI)
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   112
  show 5: "Rep (\<Squnion>i. S i) = (\<Union>i. Rep (S i))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   113
    by (simp add: 4 2)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   114
qed
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   115
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   116
lemma typedef_ideal_cpo:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   117
  fixes Abs :: "'a set \<Rightarrow> 'b::po"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   118
  assumes type: "type_definition Rep Abs {S. ideal S}"
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
   119
  assumes below: "\<And>x y. x \<sqsubseteq> y \<longleftrightarrow> Rep x \<subseteq> Rep y"
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   120
  shows "OFCLASS('b, cpo_class)"
61169
4de9ff3ea29a tuned proofs -- less legacy;
wenzelm
parents: 58880
diff changeset
   121
  by standard (rule exI, erule typedef_ideal_lub [OF type below])
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   122
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   123
end
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   124
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
   125
interpretation below: preorder "below :: 'a::po \<Rightarrow> 'a \<Rightarrow> bool"
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   126
apply unfold_locales
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
   127
apply (rule below_refl)
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
   128
apply (erule (1) below_trans)
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   129
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   130
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   131
subsection \<open>Lemmas about least upper bounds\<close>
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   132
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   133
lemma is_ub_thelub_ex: "\<lbrakk>\<exists>u. S <<| u; x \<in> S\<rbrakk> \<Longrightarrow> x \<sqsubseteq> lub S"
40771
1c6f7d4b110e renamed several HOLCF theorems (listed in NEWS)
huffman
parents: 40769
diff changeset
   134
apply (erule exE, drule is_lub_lub)
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   135
apply (drule is_lubD1)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   136
apply (erule (1) is_ubD)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   137
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   138
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   139
lemma is_lub_thelub_ex: "\<lbrakk>\<exists>u. S <<| u; S <| x\<rbrakk> \<Longrightarrow> lub S \<sqsubseteq> x"
40771
1c6f7d4b110e renamed several HOLCF theorems (listed in NEWS)
huffman
parents: 40769
diff changeset
   140
by (erule exE, drule is_lub_lub, erule is_lubD2)
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   141
65379
76a96e32bd23 tuned (see also 1fa1023b13b9);
wenzelm
parents: 63040
diff changeset
   142
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   143
subsection \<open>Locale for ideal completion\<close>
28133
218252dfd81e reorganize subsections
huffman
parents: 28053
diff changeset
   144
65379
76a96e32bd23 tuned (see also 1fa1023b13b9);
wenzelm
parents: 63040
diff changeset
   145
hide_const (open) Filter.principal
76a96e32bd23 tuned (see also 1fa1023b13b9);
wenzelm
parents: 63040
diff changeset
   146
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   147
locale ideal_completion = preorder +
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   148
  fixes principal :: "'a::type \<Rightarrow> 'b::cpo"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   149
  fixes rep :: "'b::cpo \<Rightarrow> 'a::type set"
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   150
  assumes ideal_rep: "\<And>x. ideal (rep x)"
40769
3af9b0df3521 rename rep_contlub lemmas to rep_lub
huffman
parents: 40502
diff changeset
   151
  assumes rep_lub: "\<And>Y. chain Y \<Longrightarrow> rep (\<Squnion>i. Y i) = (\<Union>i. rep (Y i))"
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   152
  assumes rep_principal: "\<And>a. rep (principal a) = {b. b \<preceq> a}"
41033
7a67a8832da8 simplify ideal completion proofs
huffman
parents: 40888
diff changeset
   153
  assumes belowI: "\<And>x y. rep x \<subseteq> rep y \<Longrightarrow> x \<sqsubseteq> y"
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   154
  assumes countable: "\<exists>f::'a \<Rightarrow> nat. inj f"
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   155
begin
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   156
28133
218252dfd81e reorganize subsections
huffman
parents: 28053
diff changeset
   157
lemma rep_mono: "x \<sqsubseteq> y \<Longrightarrow> rep x \<subseteq> rep y"
218252dfd81e reorganize subsections
huffman
parents: 28053
diff changeset
   158
apply (frule bin_chain)
40769
3af9b0df3521 rename rep_contlub lemmas to rep_lub
huffman
parents: 40502
diff changeset
   159
apply (drule rep_lub)
40771
1c6f7d4b110e renamed several HOLCF theorems (listed in NEWS)
huffman
parents: 40769
diff changeset
   160
apply (simp only: lub_eqI [OF is_lub_bin_chain])
28133
218252dfd81e reorganize subsections
huffman
parents: 28053
diff changeset
   161
apply (rule subsetI, rule UN_I [where a=0], simp_all)
218252dfd81e reorganize subsections
huffman
parents: 28053
diff changeset
   162
done
218252dfd81e reorganize subsections
huffman
parents: 28053
diff changeset
   163
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
   164
lemma below_def: "x \<sqsubseteq> y \<longleftrightarrow> rep x \<subseteq> rep y"
41033
7a67a8832da8 simplify ideal completion proofs
huffman
parents: 40888
diff changeset
   165
by (rule iffI [OF rep_mono belowI])
28133
218252dfd81e reorganize subsections
huffman
parents: 28053
diff changeset
   166
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
   167
lemma principal_below_iff_mem_rep: "principal a \<sqsubseteq> x \<longleftrightarrow> a \<in> rep x"
41033
7a67a8832da8 simplify ideal completion proofs
huffman
parents: 40888
diff changeset
   168
unfolding below_def rep_principal
7a67a8832da8 simplify ideal completion proofs
huffman
parents: 40888
diff changeset
   169
by (auto intro: r_refl elim: idealD3 [OF ideal_rep])
28133
218252dfd81e reorganize subsections
huffman
parents: 28053
diff changeset
   170
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
   171
lemma principal_below_iff [simp]: "principal a \<sqsubseteq> principal b \<longleftrightarrow> a \<preceq> b"
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
   172
by (simp add: principal_below_iff_mem_rep rep_principal)
28133
218252dfd81e reorganize subsections
huffman
parents: 28053
diff changeset
   173
218252dfd81e reorganize subsections
huffman
parents: 28053
diff changeset
   174
lemma principal_eq_iff: "principal a = principal b \<longleftrightarrow> a \<preceq> b \<and> b \<preceq> a"
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
   175
unfolding po_eq_conv [where 'a='b] principal_below_iff ..
28133
218252dfd81e reorganize subsections
huffman
parents: 28053
diff changeset
   176
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   177
lemma eq_iff: "x = y \<longleftrightarrow> rep x = rep y"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   178
unfolding po_eq_conv below_def by auto
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   179
28133
218252dfd81e reorganize subsections
huffman
parents: 28053
diff changeset
   180
lemma principal_mono: "a \<preceq> b \<Longrightarrow> principal a \<sqsubseteq> principal b"
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
   181
by (simp only: principal_below_iff)
28133
218252dfd81e reorganize subsections
huffman
parents: 28053
diff changeset
   182
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   183
lemma ch2ch_principal [simp]:
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   184
  "\<forall>i. Y i \<preceq> Y (Suc i) \<Longrightarrow> chain (\<lambda>i. principal (Y i))"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   185
by (simp add: chainI principal_mono)
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   186
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   187
subsubsection \<open>Principal ideals approximate all elements\<close>
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   188
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   189
lemma compact_principal [simp]: "compact (principal a)"
40769
3af9b0df3521 rename rep_contlub lemmas to rep_lub
huffman
parents: 40502
diff changeset
   190
by (rule compactI2, simp add: principal_below_iff_mem_rep rep_lub)
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   191
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   192
text \<open>Construct a chain whose lub is the same as a given ideal\<close>
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   193
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   194
lemma obtain_principal_chain:
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   195
  obtains Y where "\<forall>i. Y i \<preceq> Y (Suc i)" and "x = (\<Squnion>i. principal (Y i))"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   196
proof -
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   197
  obtain count :: "'a \<Rightarrow> nat" where inj: "inj count"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   198
    using countable ..
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62175
diff changeset
   199
  define enum where "enum i = (THE a. count a = i)" for i
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   200
  have enum_count [simp]: "\<And>x. enum (count x) = x"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   201
    unfolding enum_def by (simp add: inj_eq [OF inj])
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62175
diff changeset
   202
  define a where "a = (LEAST i. enum i \<in> rep x)"
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62175
diff changeset
   203
  define b where "b i = (LEAST j. enum j \<in> rep x \<and> \<not> enum j \<preceq> enum i)" for i
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62175
diff changeset
   204
  define c where "c i j = (LEAST k. enum k \<in> rep x \<and> enum i \<preceq> enum k \<and> enum j \<preceq> enum k)" for i j
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62175
diff changeset
   205
  define P where "P i \<longleftrightarrow> (\<exists>j. enum j \<in> rep x \<and> \<not> enum j \<preceq> enum i)" for i
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62175
diff changeset
   206
  define X where "X = rec_nat a (\<lambda>n i. if P i then c i (b i) else i)"
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   207
  have X_0: "X 0 = a" unfolding X_def by simp
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   208
  have X_Suc: "\<And>n. X (Suc n) = (if P (X n) then c (X n) (b (X n)) else X n)"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   209
    unfolding X_def by simp
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   210
  have a_mem: "enum a \<in> rep x"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   211
    unfolding a_def
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   212
    apply (rule LeastI_ex)
68383
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   213
    apply (insert ideal_rep [of x])
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   214
    apply (drule idealD1)
68383
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   215
    apply (clarify)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   216
    subgoal for a by (rule exI [where x="count a"]) simp
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   217
    done
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   218
  have b: "\<And>i. P i \<Longrightarrow> enum i \<in> rep x
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   219
    \<Longrightarrow> enum (b i) \<in> rep x \<and> \<not> enum (b i) \<preceq> enum i"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   220
    unfolding P_def b_def by (erule LeastI2_ex, simp)
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   221
  have c: "\<And>i j. enum i \<in> rep x \<Longrightarrow> enum j \<in> rep x
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   222
    \<Longrightarrow> enum (c i j) \<in> rep x \<and> enum i \<preceq> enum (c i j) \<and> enum j \<preceq> enum (c i j)"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   223
    unfolding c_def
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   224
    apply (drule (1) idealD2 [OF ideal_rep], clarify)
68383
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   225
    subgoal for \<dots> z by (rule LeastI2 [where a="count z"], simp, simp)
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   226
    done
68383
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   227
  have X_mem: "enum (X n) \<in> rep x" for n
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   228
  proof (induct n)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   229
    case 0
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   230
    then show ?case by (simp add: X_0 a_mem)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   231
  next
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   232
    case (Suc n)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   233
    with b c show ?case by (auto simp: X_Suc)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   234
  qed
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   235
  have X_chain: "\<And>n. enum (X n) \<preceq> enum (X (Suc n))"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   236
    apply (clarsimp simp add: X_Suc r_refl)
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   237
    apply (simp add: b c X_mem)
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   238
    done
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   239
  have less_b: "\<And>n i. n < b i \<Longrightarrow> enum n \<in> rep x \<Longrightarrow> enum n \<preceq> enum i"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   240
    unfolding b_def by (drule not_less_Least, simp)
68383
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   241
  have X_covers: "\<forall>k\<le>n. enum k \<in> rep x \<longrightarrow> enum k \<preceq> enum (X n)" for n
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   242
  proof (induct n)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   243
    case 0
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   244
    then show ?case
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   245
      apply (clarsimp simp add: X_0 a_def)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   246
      apply (drule Least_le [where k=0], simp add: r_refl)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   247
      done
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   248
  next
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   249
    case (Suc n)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   250
    then show ?case
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   251
      apply clarsimp
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   252
      apply (erule le_SucE)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   253
       apply (rule r_trans [OF _ X_chain], simp)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   254
      apply (cases "P (X n)", simp add: X_Suc)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   255
       apply (rule linorder_cases [where x="b (X n)" and y="Suc n"])
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   256
         apply (simp only: less_Suc_eq_le)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   257
         apply (drule spec, drule (1) mp, simp add: b X_mem)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   258
        apply (simp add: c X_mem)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   259
       apply (drule (1) less_b)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   260
       apply (erule r_trans)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   261
       apply (simp add: b c X_mem)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   262
      apply (simp add: X_Suc)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   263
      apply (simp add: P_def)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   264
      done
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   265
  qed
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   266
  have 1: "\<forall>i. enum (X i) \<preceq> enum (X (Suc i))"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   267
    by (simp add: X_chain)
68383
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   268
  have "x = (\<Squnion>n. principal (enum (X n)))"
40769
3af9b0df3521 rename rep_contlub lemmas to rep_lub
huffman
parents: 40502
diff changeset
   269
    apply (simp add: eq_iff rep_lub 1 rep_principal)
68383
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   270
    apply auto
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   271
    subgoal for a
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   272
      apply (subgoal_tac "\<exists>i. a = enum i", erule exE)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   273
       apply (rule_tac x=i in exI, simp add: X_covers)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   274
      apply (rule_tac x="count a" in exI, simp)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   275
      done
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   276
    subgoal
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   277
      apply (erule idealD3 [OF ideal_rep])
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   278
      apply (rule X_mem)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   279
      done
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   280
    done
68383
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   281
  with 1 show ?thesis ..
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   282
qed
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   283
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   284
lemma principal_induct:
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   285
  assumes adm: "adm P"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   286
  assumes P: "\<And>a. P (principal a)"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   287
  shows "P x"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   288
apply (rule obtain_principal_chain [of x])
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   289
apply (simp add: admD [OF adm] P)
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   290
done
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   291
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   292
lemma compact_imp_principal: "compact x \<Longrightarrow> \<exists>a. x = principal a"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   293
apply (rule obtain_principal_chain [of x])
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   294
apply (drule adm_compact_neq [OF _ cont_id])
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   295
apply (subgoal_tac "chain (\<lambda>i. principal (Y i))")
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   296
apply (drule (2) admD2, fast, simp)
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   297
done
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   298
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   299
subsection \<open>Defining functions in terms of basis elements\<close>
28133
218252dfd81e reorganize subsections
huffman
parents: 28053
diff changeset
   300
218252dfd81e reorganize subsections
huffman
parents: 28053
diff changeset
   301
definition
41394
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41182
diff changeset
   302
  extension :: "('a::type \<Rightarrow> 'c::cpo) \<Rightarrow> 'b \<rightarrow> 'c" where
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41182
diff changeset
   303
  "extension = (\<lambda>f. (\<Lambda> x. lub (f ` rep x)))"
28133
218252dfd81e reorganize subsections
huffman
parents: 28053
diff changeset
   304
41394
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41182
diff changeset
   305
lemma extension_lemma:
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   306
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   307
  assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   308
  shows "\<exists>u. f ` rep x <<| u"
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   309
proof -
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   310
  obtain Y where Y: "\<forall>i. Y i \<preceq> Y (Suc i)"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   311
  and x: "x = (\<Squnion>i. principal (Y i))"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   312
    by (rule obtain_principal_chain [of x])
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   313
  have chain: "chain (\<lambda>i. f (Y i))"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   314
    by (rule chainI, simp add: f_mono Y)
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   315
  have rep_x: "rep x = (\<Union>n. {a. a \<preceq> Y n})"
40769
3af9b0df3521 rename rep_contlub lemmas to rep_lub
huffman
parents: 40502
diff changeset
   316
    by (simp add: x rep_lub Y rep_principal)
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   317
  have "f ` rep x <<| (\<Squnion>n. f (Y n))"
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   318
    apply (rule is_lubI)
68383
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   319
     apply (rule ub_imageI)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   320
    subgoal for a
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   321
      apply (clarsimp simp add: rep_x)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   322
      apply (drule f_mono)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   323
      apply (erule below_lub [OF chain])
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   324
      done
40500
ee9c8d36318e add lemmas lub_below, below_lub; simplify some proofs; remove some unused lemmas
huffman
parents: 40002
diff changeset
   325
    apply (rule lub_below [OF chain])
68383
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   326
    subgoal for \<dots> n
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   327
      apply (drule ub_imageD [where x="Y n"])
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   328
       apply (simp add: rep_x, fast intro: r_refl)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   329
      apply assumption
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   330
      done
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   331
    done
68383
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   332
  then show ?thesis ..
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   333
qed
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   334
41394
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41182
diff changeset
   335
lemma extension_beta:
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   336
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   337
  assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"
41394
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41182
diff changeset
   338
  shows "extension f\<cdot>x = lub (f ` rep x)"
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41182
diff changeset
   339
unfolding extension_def
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   340
proof (rule beta_cfun)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   341
  have lub: "\<And>x. \<exists>u. f ` rep x <<| u"
41394
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41182
diff changeset
   342
    using f_mono by (rule extension_lemma)
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   343
  show cont: "cont (\<lambda>x. lub (f ` rep x))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   344
    apply (rule contI2)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   345
     apply (rule monofunI)
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   346
     apply (rule is_lub_thelub_ex [OF lub ub_imageI])
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   347
     apply (rule is_ub_thelub_ex [OF lub imageI])
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   348
     apply (erule (1) subsetD [OF rep_mono])
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   349
    apply (rule is_lub_thelub_ex [OF lub ub_imageI])
40769
3af9b0df3521 rename rep_contlub lemmas to rep_lub
huffman
parents: 40502
diff changeset
   350
    apply (simp add: rep_lub, clarify)
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
   351
    apply (erule rev_below_trans [OF is_ub_thelub])
39974
b525988432e9 major reorganization/simplification of HOLCF type classes:
huffman
parents: 39967
diff changeset
   352
    apply (erule is_ub_thelub_ex [OF lub imageI])
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   353
    done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   354
qed
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   355
41394
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41182
diff changeset
   356
lemma extension_principal:
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   357
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   358
  assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"
41394
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41182
diff changeset
   359
  shows "extension f\<cdot>(principal a) = f a"
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41182
diff changeset
   360
apply (subst extension_beta, erule f_mono)
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   361
apply (subst rep_principal)
41033
7a67a8832da8 simplify ideal completion proofs
huffman
parents: 40888
diff changeset
   362
apply (rule lub_eqI)
7a67a8832da8 simplify ideal completion proofs
huffman
parents: 40888
diff changeset
   363
apply (rule is_lub_maximal)
7a67a8832da8 simplify ideal completion proofs
huffman
parents: 40888
diff changeset
   364
apply (rule ub_imageI)
7a67a8832da8 simplify ideal completion proofs
huffman
parents: 40888
diff changeset
   365
apply (simp add: f_mono)
7a67a8832da8 simplify ideal completion proofs
huffman
parents: 40888
diff changeset
   366
apply (rule imageI)
7a67a8832da8 simplify ideal completion proofs
huffman
parents: 40888
diff changeset
   367
apply (simp add: r_refl)
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   368
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   369
41394
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41182
diff changeset
   370
lemma extension_mono:
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   371
  assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   372
  assumes g_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> g a \<sqsubseteq> g b"
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 30729
diff changeset
   373
  assumes below: "\<And>a. f a \<sqsubseteq> g a"
41394
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41182
diff changeset
   374
  shows "extension f \<sqsubseteq> extension g"
68383
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   375
  apply (rule cfun_belowI)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   376
  apply (simp only: extension_beta f_mono g_mono)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   377
  apply (rule is_lub_thelub_ex)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   378
   apply (rule extension_lemma, erule f_mono)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   379
  apply (rule ub_imageI)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   380
  subgoal for x a
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   381
    apply (rule below_trans [OF below])
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   382
    apply (rule is_ub_thelub_ex)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   383
     apply (rule extension_lemma, erule g_mono)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   384
    apply (erule imageI)
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   385
    done
93a42bd62ede tuned proofs;
wenzelm
parents: 65380
diff changeset
   386
  done
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   387
41394
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41182
diff changeset
   388
lemma cont_extension:
41182
717404c7d59a add notsqsubseteq syntax
huffman
parents: 41033
diff changeset
   389
  assumes f_mono: "\<And>a b x. a \<preceq> b \<Longrightarrow> f x a \<sqsubseteq> f x b"
717404c7d59a add notsqsubseteq syntax
huffman
parents: 41033
diff changeset
   390
  assumes f_cont: "\<And>a. cont (\<lambda>x. f x a)"
41394
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41182
diff changeset
   391
  shows "cont (\<lambda>x. extension (\<lambda>a. f x a))"
41182
717404c7d59a add notsqsubseteq syntax
huffman
parents: 41033
diff changeset
   392
 apply (rule contI2)
717404c7d59a add notsqsubseteq syntax
huffman
parents: 41033
diff changeset
   393
  apply (rule monofunI)
41394
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41182
diff changeset
   394
  apply (rule extension_mono, erule f_mono, erule f_mono)
41182
717404c7d59a add notsqsubseteq syntax
huffman
parents: 41033
diff changeset
   395
  apply (erule cont2monofunE [OF f_cont])
717404c7d59a add notsqsubseteq syntax
huffman
parents: 41033
diff changeset
   396
 apply (rule cfun_belowI)
717404c7d59a add notsqsubseteq syntax
huffman
parents: 41033
diff changeset
   397
 apply (rule principal_induct, simp)
717404c7d59a add notsqsubseteq syntax
huffman
parents: 41033
diff changeset
   398
 apply (simp only: contlub_cfun_fun)
41394
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41182
diff changeset
   399
 apply (simp only: extension_principal f_mono)
41182
717404c7d59a add notsqsubseteq syntax
huffman
parents: 41033
diff changeset
   400
 apply (simp add: cont2contlubE [OF f_cont])
717404c7d59a add notsqsubseteq syntax
huffman
parents: 41033
diff changeset
   401
done
717404c7d59a add notsqsubseteq syntax
huffman
parents: 41033
diff changeset
   402
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   403
end
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   404
39984
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   405
lemma (in preorder) typedef_ideal_completion:
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   406
  fixes Abs :: "'a set \<Rightarrow> 'b::cpo"
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   407
  assumes type: "type_definition Rep Abs {S. ideal S}"
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   408
  assumes below: "\<And>x y. x \<sqsubseteq> y \<longleftrightarrow> Rep x \<subseteq> Rep y"
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   409
  assumes principal: "\<And>a. principal a = Abs {b. b \<preceq> a}"
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   410
  assumes countable: "\<exists>f::'a \<Rightarrow> nat. inj f"
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   411
  shows "ideal_completion r principal Rep"
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   412
proof
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   413
  interpret type_definition Rep Abs "{S. ideal S}" by fact
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   414
  fix a b :: 'a and x y :: 'b and Y :: "nat \<Rightarrow> 'b"
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   415
  show "ideal (Rep x)"
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   416
    using Rep [of x] by simp
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   417
  show "chain Y \<Longrightarrow> Rep (\<Squnion>i. Y i) = (\<Union>i. Rep (Y i))"
40769
3af9b0df3521 rename rep_contlub lemmas to rep_lub
huffman
parents: 40502
diff changeset
   418
    using type below by (rule typedef_ideal_rep_lub)
39984
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   419
  show "Rep (principal a) = {b. b \<preceq> a}"
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   420
    by (simp add: principal Abs_inverse ideal_principal)
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   421
  show "Rep x \<subseteq> Rep y \<Longrightarrow> x \<sqsubseteq> y"
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   422
    by (simp only: below)
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   423
  show "\<exists>f::'a \<Rightarrow> nat. inj f"
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   424
    by (rule countable)
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   425
qed
0300d5170622 add lemma typedef_ideal_completion
huffman
parents: 39983
diff changeset
   426
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   427
end