src/HOLCF/Deflation.thy
author huffman
Mon Mar 22 13:27:35 2010 -0700 (2010-03-22)
changeset 35901 12f09bf2c77f
parent 35794 8cd7134275cc
child 36452 d37c6eed8117
permissions -rw-r--r--
fix LaTeX overfull hbox warnings in HOLCF document
huffman@27401
     1
(*  Title:      HOLCF/Deflation.thy
huffman@27401
     2
    Author:     Brian Huffman
huffman@27401
     3
*)
huffman@27401
     4
huffman@35901
     5
header {* Continuous deflations and ep-pairs *}
huffman@27401
     6
huffman@27401
     7
theory Deflation
huffman@27401
     8
imports Cfun
huffman@27401
     9
begin
huffman@27401
    10
huffman@27401
    11
defaultsort cpo
huffman@27401
    12
huffman@27401
    13
subsection {* Continuous deflations *}
huffman@27401
    14
huffman@27401
    15
locale deflation =
huffman@27401
    16
  fixes d :: "'a \<rightarrow> 'a"
huffman@27401
    17
  assumes idem: "\<And>x. d\<cdot>(d\<cdot>x) = d\<cdot>x"
huffman@31076
    18
  assumes below: "\<And>x. d\<cdot>x \<sqsubseteq> x"
huffman@27401
    19
begin
huffman@27401
    20
huffman@31076
    21
lemma below_ID: "d \<sqsubseteq> ID"
huffman@31076
    22
by (rule below_cfun_ext, simp add: below)
huffman@27401
    23
huffman@27401
    24
text {* The set of fixed points is the same as the range. *}
huffman@27401
    25
huffman@27401
    26
lemma fixes_eq_range: "{x. d\<cdot>x = x} = range (\<lambda>x. d\<cdot>x)"
huffman@27401
    27
by (auto simp add: eq_sym_conv idem)
huffman@27401
    28
huffman@27401
    29
lemma range_eq_fixes: "range (\<lambda>x. d\<cdot>x) = {x. d\<cdot>x = x}"
huffman@27401
    30
by (auto simp add: eq_sym_conv idem)
huffman@27401
    31
huffman@27401
    32
text {*
huffman@27401
    33
  The pointwise ordering on deflation functions coincides with
huffman@27401
    34
  the subset ordering of their sets of fixed-points.
huffman@27401
    35
*}
huffman@27401
    36
huffman@31076
    37
lemma belowI:
huffman@27401
    38
  assumes f: "\<And>x. d\<cdot>x = x \<Longrightarrow> f\<cdot>x = x" shows "d \<sqsubseteq> f"
huffman@31076
    39
proof (rule below_cfun_ext)
huffman@27401
    40
  fix x
huffman@31076
    41
  from below have "f\<cdot>(d\<cdot>x) \<sqsubseteq> f\<cdot>x" by (rule monofun_cfun_arg)
huffman@27401
    42
  also from idem have "f\<cdot>(d\<cdot>x) = d\<cdot>x" by (rule f)
huffman@27401
    43
  finally show "d\<cdot>x \<sqsubseteq> f\<cdot>x" .
huffman@27401
    44
qed
huffman@27401
    45
huffman@31076
    46
lemma belowD: "\<lbrakk>f \<sqsubseteq> d; f\<cdot>x = x\<rbrakk> \<Longrightarrow> d\<cdot>x = x"
huffman@31076
    47
proof (rule below_antisym)
huffman@31076
    48
  from below show "d\<cdot>x \<sqsubseteq> x" .
huffman@27401
    49
next
huffman@27401
    50
  assume "f \<sqsubseteq> d"
huffman@27401
    51
  hence "f\<cdot>x \<sqsubseteq> d\<cdot>x" by (rule monofun_cfun_fun)
huffman@27401
    52
  also assume "f\<cdot>x = x"
huffman@27401
    53
  finally show "x \<sqsubseteq> d\<cdot>x" .
huffman@27401
    54
qed
huffman@27401
    55
huffman@27401
    56
end
huffman@27401
    57
huffman@33503
    58
lemma deflation_strict: "deflation d \<Longrightarrow> d\<cdot>\<bottom> = \<bottom>"
huffman@33503
    59
by (rule deflation.below [THEN UU_I])
huffman@33503
    60
huffman@27401
    61
lemma adm_deflation: "adm (\<lambda>d. deflation d)"
huffman@27401
    62
by (simp add: deflation_def)
huffman@27401
    63
huffman@27401
    64
lemma deflation_ID: "deflation ID"
huffman@27401
    65
by (simp add: deflation.intro)
huffman@27401
    66
huffman@27401
    67
lemma deflation_UU: "deflation \<bottom>"
huffman@27401
    68
by (simp add: deflation.intro)
huffman@27401
    69
huffman@31076
    70
lemma deflation_below_iff:
huffman@27401
    71
  "\<lbrakk>deflation p; deflation q\<rbrakk> \<Longrightarrow> p \<sqsubseteq> q \<longleftrightarrow> (\<forall>x. p\<cdot>x = x \<longrightarrow> q\<cdot>x = x)"
huffman@27401
    72
 apply safe
huffman@31076
    73
  apply (simp add: deflation.belowD)
huffman@31076
    74
 apply (simp add: deflation.belowI)
huffman@27401
    75
done
huffman@27401
    76
huffman@27401
    77
text {*
huffman@27401
    78
  The composition of two deflations is equal to
huffman@27401
    79
  the lesser of the two (if they are comparable).
huffman@27401
    80
*}
huffman@27401
    81
huffman@31076
    82
lemma deflation_below_comp1:
ballarin@28611
    83
  assumes "deflation f"
ballarin@28611
    84
  assumes "deflation g"
huffman@27401
    85
  shows "f \<sqsubseteq> g \<Longrightarrow> f\<cdot>(g\<cdot>x) = f\<cdot>x"
huffman@31076
    86
proof (rule below_antisym)
ballarin@29237
    87
  interpret g: deflation g by fact
huffman@31076
    88
  from g.below show "f\<cdot>(g\<cdot>x) \<sqsubseteq> f\<cdot>x" by (rule monofun_cfun_arg)
huffman@27401
    89
next
ballarin@29237
    90
  interpret f: deflation f by fact
huffman@27401
    91
  assume "f \<sqsubseteq> g" hence "f\<cdot>x \<sqsubseteq> g\<cdot>x" by (rule monofun_cfun_fun)
huffman@27401
    92
  hence "f\<cdot>(f\<cdot>x) \<sqsubseteq> f\<cdot>(g\<cdot>x)" by (rule monofun_cfun_arg)
huffman@27401
    93
  also have "f\<cdot>(f\<cdot>x) = f\<cdot>x" by (rule f.idem)
huffman@27401
    94
  finally show "f\<cdot>x \<sqsubseteq> f\<cdot>(g\<cdot>x)" .
huffman@27401
    95
qed
huffman@27401
    96
huffman@31076
    97
lemma deflation_below_comp2:
huffman@27401
    98
  "\<lbrakk>deflation f; deflation g; f \<sqsubseteq> g\<rbrakk> \<Longrightarrow> g\<cdot>(f\<cdot>x) = f\<cdot>x"
huffman@31076
    99
by (simp only: deflation.belowD deflation.idem)
huffman@27401
   100
huffman@27401
   101
huffman@27401
   102
subsection {* Deflations with finite range *}
huffman@27401
   103
huffman@27401
   104
lemma finite_range_imp_finite_fixes:
huffman@27401
   105
  "finite (range f) \<Longrightarrow> finite {x. f x = x}"
huffman@27401
   106
proof -
huffman@27401
   107
  have "{x. f x = x} \<subseteq> range f"
huffman@27401
   108
    by (clarify, erule subst, rule rangeI)
huffman@27401
   109
  moreover assume "finite (range f)"
huffman@27401
   110
  ultimately show "finite {x. f x = x}"
huffman@27401
   111
    by (rule finite_subset)
huffman@27401
   112
qed
huffman@27401
   113
huffman@27401
   114
locale finite_deflation = deflation +
huffman@27401
   115
  assumes finite_fixes: "finite {x. d\<cdot>x = x}"
huffman@27401
   116
begin
huffman@27401
   117
huffman@27401
   118
lemma finite_range: "finite (range (\<lambda>x. d\<cdot>x))"
huffman@27401
   119
by (simp add: range_eq_fixes finite_fixes)
huffman@27401
   120
huffman@27401
   121
lemma finite_image: "finite ((\<lambda>x. d\<cdot>x) ` A)"
huffman@27401
   122
by (rule finite_subset [OF image_mono [OF subset_UNIV] finite_range])
huffman@27401
   123
huffman@27401
   124
lemma compact: "compact (d\<cdot>x)"
huffman@27401
   125
proof (rule compactI2)
huffman@27401
   126
  fix Y :: "nat \<Rightarrow> 'a"
huffman@27401
   127
  assume Y: "chain Y"
huffman@27401
   128
  have "finite_chain (\<lambda>i. d\<cdot>(Y i))"
huffman@27401
   129
  proof (rule finite_range_imp_finch)
huffman@27401
   130
    show "chain (\<lambda>i. d\<cdot>(Y i))"
huffman@27401
   131
      using Y by simp
huffman@27401
   132
    have "range (\<lambda>i. d\<cdot>(Y i)) \<subseteq> range (\<lambda>x. d\<cdot>x)"
huffman@27401
   133
      by clarsimp
huffman@27401
   134
    thus "finite (range (\<lambda>i. d\<cdot>(Y i)))"
huffman@27401
   135
      using finite_range by (rule finite_subset)
huffman@27401
   136
  qed
huffman@27401
   137
  hence "\<exists>j. (\<Squnion>i. d\<cdot>(Y i)) = d\<cdot>(Y j)"
huffman@27401
   138
    by (simp add: finite_chain_def maxinch_is_thelub Y)
huffman@27401
   139
  then obtain j where j: "(\<Squnion>i. d\<cdot>(Y i)) = d\<cdot>(Y j)" ..
huffman@27401
   140
huffman@27401
   141
  assume "d\<cdot>x \<sqsubseteq> (\<Squnion>i. Y i)"
huffman@27401
   142
  hence "d\<cdot>(d\<cdot>x) \<sqsubseteq> d\<cdot>(\<Squnion>i. Y i)"
huffman@27401
   143
    by (rule monofun_cfun_arg)
huffman@27401
   144
  hence "d\<cdot>x \<sqsubseteq> (\<Squnion>i. d\<cdot>(Y i))"
huffman@27401
   145
    by (simp add: contlub_cfun_arg Y idem)
huffman@27401
   146
  hence "d\<cdot>x \<sqsubseteq> d\<cdot>(Y j)"
huffman@27401
   147
    using j by simp
huffman@27401
   148
  hence "d\<cdot>x \<sqsubseteq> Y j"
huffman@31076
   149
    using below by (rule below_trans)
huffman@27401
   150
  thus "\<exists>j. d\<cdot>x \<sqsubseteq> Y j" ..
huffman@27401
   151
qed
huffman@27401
   152
huffman@27401
   153
end
huffman@27401
   154
huffman@27401
   155
huffman@27401
   156
subsection {* Continuous embedding-projection pairs *}
huffman@27401
   157
huffman@27401
   158
locale ep_pair =
huffman@27401
   159
  fixes e :: "'a \<rightarrow> 'b" and p :: "'b \<rightarrow> 'a"
huffman@27401
   160
  assumes e_inverse [simp]: "\<And>x. p\<cdot>(e\<cdot>x) = x"
huffman@31076
   161
  and e_p_below: "\<And>y. e\<cdot>(p\<cdot>y) \<sqsubseteq> y"
huffman@27401
   162
begin
huffman@27401
   163
huffman@31076
   164
lemma e_below_iff [simp]: "e\<cdot>x \<sqsubseteq> e\<cdot>y \<longleftrightarrow> x \<sqsubseteq> y"
huffman@27401
   165
proof
huffman@27401
   166
  assume "e\<cdot>x \<sqsubseteq> e\<cdot>y"
huffman@27401
   167
  hence "p\<cdot>(e\<cdot>x) \<sqsubseteq> p\<cdot>(e\<cdot>y)" by (rule monofun_cfun_arg)
huffman@27401
   168
  thus "x \<sqsubseteq> y" by simp
huffman@27401
   169
next
huffman@27401
   170
  assume "x \<sqsubseteq> y"
huffman@27401
   171
  thus "e\<cdot>x \<sqsubseteq> e\<cdot>y" by (rule monofun_cfun_arg)
huffman@27401
   172
qed
huffman@27401
   173
huffman@27401
   174
lemma e_eq_iff [simp]: "e\<cdot>x = e\<cdot>y \<longleftrightarrow> x = y"
huffman@31076
   175
unfolding po_eq_conv e_below_iff ..
huffman@27401
   176
huffman@27401
   177
lemma p_eq_iff:
huffman@27401
   178
  "\<lbrakk>e\<cdot>(p\<cdot>x) = x; e\<cdot>(p\<cdot>y) = y\<rbrakk> \<Longrightarrow> p\<cdot>x = p\<cdot>y \<longleftrightarrow> x = y"
huffman@27401
   179
by (safe, erule subst, erule subst, simp)
huffman@27401
   180
huffman@27401
   181
lemma p_inverse: "(\<exists>x. y = e\<cdot>x) = (e\<cdot>(p\<cdot>y) = y)"
huffman@27401
   182
by (auto, rule exI, erule sym)
huffman@27401
   183
huffman@31076
   184
lemma e_below_iff_below_p: "e\<cdot>x \<sqsubseteq> y \<longleftrightarrow> x \<sqsubseteq> p\<cdot>y"
huffman@27401
   185
proof
huffman@27401
   186
  assume "e\<cdot>x \<sqsubseteq> y"
huffman@27401
   187
  then have "p\<cdot>(e\<cdot>x) \<sqsubseteq> p\<cdot>y" by (rule monofun_cfun_arg)
huffman@27401
   188
  then show "x \<sqsubseteq> p\<cdot>y" by simp
huffman@27401
   189
next
huffman@27401
   190
  assume "x \<sqsubseteq> p\<cdot>y"
huffman@27401
   191
  then have "e\<cdot>x \<sqsubseteq> e\<cdot>(p\<cdot>y)" by (rule monofun_cfun_arg)
huffman@31076
   192
  then show "e\<cdot>x \<sqsubseteq> y" using e_p_below by (rule below_trans)
huffman@27401
   193
qed
huffman@27401
   194
huffman@27401
   195
lemma compact_e_rev: "compact (e\<cdot>x) \<Longrightarrow> compact x"
huffman@27401
   196
proof -
huffman@27401
   197
  assume "compact (e\<cdot>x)"
huffman@27401
   198
  hence "adm (\<lambda>y. \<not> e\<cdot>x \<sqsubseteq> y)" by (rule compactD)
huffman@27401
   199
  hence "adm (\<lambda>y. \<not> e\<cdot>x \<sqsubseteq> e\<cdot>y)" by (rule adm_subst [OF cont_Rep_CFun2])
huffman@27401
   200
  hence "adm (\<lambda>y. \<not> x \<sqsubseteq> y)" by simp
huffman@27401
   201
  thus "compact x" by (rule compactI)
huffman@27401
   202
qed
huffman@27401
   203
huffman@27401
   204
lemma compact_e: "compact x \<Longrightarrow> compact (e\<cdot>x)"
huffman@27401
   205
proof -
huffman@27401
   206
  assume "compact x"
huffman@27401
   207
  hence "adm (\<lambda>y. \<not> x \<sqsubseteq> y)" by (rule compactD)
huffman@27401
   208
  hence "adm (\<lambda>y. \<not> x \<sqsubseteq> p\<cdot>y)" by (rule adm_subst [OF cont_Rep_CFun2])
huffman@31076
   209
  hence "adm (\<lambda>y. \<not> e\<cdot>x \<sqsubseteq> y)" by (simp add: e_below_iff_below_p)
huffman@27401
   210
  thus "compact (e\<cdot>x)" by (rule compactI)
huffman@27401
   211
qed
huffman@27401
   212
huffman@27401
   213
lemma compact_e_iff: "compact (e\<cdot>x) \<longleftrightarrow> compact x"
huffman@27401
   214
by (rule iffI [OF compact_e_rev compact_e])
huffman@27401
   215
huffman@27401
   216
text {* Deflations from ep-pairs *}
huffman@27401
   217
huffman@27401
   218
lemma deflation_e_p: "deflation (e oo p)"
huffman@31076
   219
by (simp add: deflation.intro e_p_below)
huffman@27401
   220
huffman@27401
   221
lemma deflation_e_d_p:
ballarin@28611
   222
  assumes "deflation d"
huffman@27401
   223
  shows "deflation (e oo d oo p)"
huffman@27401
   224
proof
ballarin@29237
   225
  interpret deflation d by fact
huffman@27401
   226
  fix x :: 'b
huffman@27401
   227
  show "(e oo d oo p)\<cdot>((e oo d oo p)\<cdot>x) = (e oo d oo p)\<cdot>x"
huffman@27401
   228
    by (simp add: idem)
huffman@27401
   229
  show "(e oo d oo p)\<cdot>x \<sqsubseteq> x"
huffman@31076
   230
    by (simp add: e_below_iff_below_p below)
huffman@27401
   231
qed
huffman@27401
   232
huffman@27401
   233
lemma finite_deflation_e_d_p:
ballarin@28611
   234
  assumes "finite_deflation d"
huffman@27401
   235
  shows "finite_deflation (e oo d oo p)"
huffman@27401
   236
proof
ballarin@29237
   237
  interpret finite_deflation d by fact
huffman@27401
   238
  fix x :: 'b
huffman@27401
   239
  show "(e oo d oo p)\<cdot>((e oo d oo p)\<cdot>x) = (e oo d oo p)\<cdot>x"
huffman@27401
   240
    by (simp add: idem)
huffman@27401
   241
  show "(e oo d oo p)\<cdot>x \<sqsubseteq> x"
huffman@31076
   242
    by (simp add: e_below_iff_below_p below)
huffman@27401
   243
  have "finite ((\<lambda>x. e\<cdot>x) ` (\<lambda>x. d\<cdot>x) ` range (\<lambda>x. p\<cdot>x))"
huffman@27401
   244
    by (simp add: finite_image)
huffman@27401
   245
  hence "finite (range (\<lambda>x. (e oo d oo p)\<cdot>x))"
huffman@27401
   246
    by (simp add: image_image)
huffman@27401
   247
  thus "finite {x. (e oo d oo p)\<cdot>x = x}"
huffman@27401
   248
    by (rule finite_range_imp_finite_fixes)
huffman@27401
   249
qed
huffman@27401
   250
huffman@27401
   251
lemma deflation_p_d_e:
ballarin@28611
   252
  assumes "deflation d"
huffman@27401
   253
  assumes d: "\<And>x. d\<cdot>x \<sqsubseteq> e\<cdot>(p\<cdot>x)"
huffman@27401
   254
  shows "deflation (p oo d oo e)"
ballarin@28611
   255
proof -
ballarin@29237
   256
  interpret d: deflation d by fact
huffman@28613
   257
  {
huffman@28613
   258
    fix x
huffman@28613
   259
    have "d\<cdot>(e\<cdot>x) \<sqsubseteq> e\<cdot>x"
huffman@31076
   260
      by (rule d.below)
huffman@28613
   261
    hence "p\<cdot>(d\<cdot>(e\<cdot>x)) \<sqsubseteq> p\<cdot>(e\<cdot>x)"
huffman@28613
   262
      by (rule monofun_cfun_arg)
huffman@28613
   263
    hence "(p oo d oo e)\<cdot>x \<sqsubseteq> x"
huffman@28613
   264
      by simp
huffman@28613
   265
  }
huffman@31076
   266
  note p_d_e_below = this
ballarin@28611
   267
  show ?thesis
huffman@28613
   268
  proof
huffman@28613
   269
    fix x
huffman@28613
   270
    show "(p oo d oo e)\<cdot>x \<sqsubseteq> x"
huffman@31076
   271
      by (rule p_d_e_below)
huffman@28613
   272
  next
huffman@28613
   273
    fix x
huffman@28613
   274
    show "(p oo d oo e)\<cdot>((p oo d oo e)\<cdot>x) = (p oo d oo e)\<cdot>x"
huffman@31076
   275
    proof (rule below_antisym)
huffman@28613
   276
      show "(p oo d oo e)\<cdot>((p oo d oo e)\<cdot>x) \<sqsubseteq> (p oo d oo e)\<cdot>x"
huffman@31076
   277
        by (rule p_d_e_below)
huffman@28613
   278
      have "p\<cdot>(d\<cdot>(d\<cdot>(d\<cdot>(e\<cdot>x)))) \<sqsubseteq> p\<cdot>(d\<cdot>(e\<cdot>(p\<cdot>(d\<cdot>(e\<cdot>x)))))"
huffman@28613
   279
        by (intro monofun_cfun_arg d)
huffman@28613
   280
      hence "p\<cdot>(d\<cdot>(e\<cdot>x)) \<sqsubseteq> p\<cdot>(d\<cdot>(e\<cdot>(p\<cdot>(d\<cdot>(e\<cdot>x)))))"
huffman@28613
   281
        by (simp only: d.idem)
huffman@28613
   282
      thus "(p oo d oo e)\<cdot>x \<sqsubseteq> (p oo d oo e)\<cdot>((p oo d oo e)\<cdot>x)"
huffman@28613
   283
        by simp
huffman@28613
   284
    qed
huffman@28613
   285
  qed
ballarin@28611
   286
qed
huffman@27401
   287
huffman@27401
   288
lemma finite_deflation_p_d_e:
ballarin@28611
   289
  assumes "finite_deflation d"
huffman@27401
   290
  assumes d: "\<And>x. d\<cdot>x \<sqsubseteq> e\<cdot>(p\<cdot>x)"
huffman@27401
   291
  shows "finite_deflation (p oo d oo e)"
ballarin@28611
   292
proof -
ballarin@29237
   293
  interpret d: finite_deflation d by fact
ballarin@28611
   294
  show ?thesis
huffman@28613
   295
  proof (intro_locales)
huffman@28613
   296
    have "deflation d" ..
huffman@28613
   297
    thus "deflation (p oo d oo e)"
huffman@28613
   298
      using d by (rule deflation_p_d_e)
huffman@28613
   299
  next
huffman@28613
   300
    show "finite_deflation_axioms (p oo d oo e)"
huffman@28613
   301
    proof
huffman@28613
   302
      have "finite ((\<lambda>x. d\<cdot>x) ` range (\<lambda>x. e\<cdot>x))"
huffman@28613
   303
        by (rule d.finite_image)
huffman@28613
   304
      hence "finite ((\<lambda>x. p\<cdot>x) ` (\<lambda>x. d\<cdot>x) ` range (\<lambda>x. e\<cdot>x))"
huffman@28613
   305
        by (rule finite_imageI)
huffman@28613
   306
      hence "finite (range (\<lambda>x. (p oo d oo e)\<cdot>x))"
huffman@28613
   307
        by (simp add: image_image)
huffman@28613
   308
      thus "finite {x. (p oo d oo e)\<cdot>x = x}"
huffman@28613
   309
        by (rule finite_range_imp_finite_fixes)
huffman@28613
   310
    qed
huffman@28613
   311
  qed
ballarin@28611
   312
qed
huffman@27401
   313
huffman@27401
   314
end
huffman@27401
   315
huffman@27401
   316
subsection {* Uniqueness of ep-pairs *}
huffman@27401
   317
huffman@28613
   318
lemma ep_pair_unique_e_lemma:
huffman@35168
   319
  assumes 1: "ep_pair e1 p" and 2: "ep_pair e2 p"
huffman@28613
   320
  shows "e1 \<sqsubseteq> e2"
huffman@31076
   321
proof (rule below_cfun_ext)
huffman@28613
   322
  fix x
huffman@28613
   323
  have "e1\<cdot>(p\<cdot>(e2\<cdot>x)) \<sqsubseteq> e2\<cdot>x"
huffman@35168
   324
    by (rule ep_pair.e_p_below [OF 1])
huffman@28613
   325
  thus "e1\<cdot>x \<sqsubseteq> e2\<cdot>x"
huffman@35168
   326
    by (simp only: ep_pair.e_inverse [OF 2])
huffman@28613
   327
qed
huffman@28613
   328
huffman@27401
   329
lemma ep_pair_unique_e:
huffman@27401
   330
  "\<lbrakk>ep_pair e1 p; ep_pair e2 p\<rbrakk> \<Longrightarrow> e1 = e2"
huffman@31076
   331
by (fast intro: below_antisym elim: ep_pair_unique_e_lemma)
huffman@28613
   332
huffman@28613
   333
lemma ep_pair_unique_p_lemma:
huffman@35168
   334
  assumes 1: "ep_pair e p1" and 2: "ep_pair e p2"
huffman@28613
   335
  shows "p1 \<sqsubseteq> p2"
huffman@31076
   336
proof (rule below_cfun_ext)
huffman@28613
   337
  fix x
huffman@28613
   338
  have "e\<cdot>(p1\<cdot>x) \<sqsubseteq> x"
huffman@35168
   339
    by (rule ep_pair.e_p_below [OF 1])
huffman@28613
   340
  hence "p2\<cdot>(e\<cdot>(p1\<cdot>x)) \<sqsubseteq> p2\<cdot>x"
huffman@28613
   341
    by (rule monofun_cfun_arg)
huffman@28613
   342
  thus "p1\<cdot>x \<sqsubseteq> p2\<cdot>x"
huffman@35168
   343
    by (simp only: ep_pair.e_inverse [OF 2])
huffman@28613
   344
qed
huffman@27401
   345
huffman@27401
   346
lemma ep_pair_unique_p:
huffman@27401
   347
  "\<lbrakk>ep_pair e p1; ep_pair e p2\<rbrakk> \<Longrightarrow> p1 = p2"
huffman@31076
   348
by (fast intro: below_antisym elim: ep_pair_unique_p_lemma)
huffman@27401
   349
huffman@27401
   350
subsection {* Composing ep-pairs *}
huffman@27401
   351
huffman@27401
   352
lemma ep_pair_ID_ID: "ep_pair ID ID"
huffman@27401
   353
by default simp_all
huffman@27401
   354
huffman@27401
   355
lemma ep_pair_comp:
huffman@28613
   356
  assumes "ep_pair e1 p1" and "ep_pair e2 p2"
huffman@28613
   357
  shows "ep_pair (e2 oo e1) (p1 oo p2)"
huffman@28613
   358
proof
ballarin@29237
   359
  interpret ep1: ep_pair e1 p1 by fact
ballarin@29237
   360
  interpret ep2: ep_pair e2 p2 by fact
huffman@28613
   361
  fix x y
huffman@28613
   362
  show "(p1 oo p2)\<cdot>((e2 oo e1)\<cdot>x) = x"
huffman@28613
   363
    by simp
huffman@28613
   364
  have "e1\<cdot>(p1\<cdot>(p2\<cdot>y)) \<sqsubseteq> p2\<cdot>y"
huffman@31076
   365
    by (rule ep1.e_p_below)
huffman@28613
   366
  hence "e2\<cdot>(e1\<cdot>(p1\<cdot>(p2\<cdot>y))) \<sqsubseteq> e2\<cdot>(p2\<cdot>y)"
huffman@28613
   367
    by (rule monofun_cfun_arg)
huffman@28613
   368
  also have "e2\<cdot>(p2\<cdot>y) \<sqsubseteq> y"
huffman@31076
   369
    by (rule ep2.e_p_below)
huffman@28613
   370
  finally show "(e2 oo e1)\<cdot>((p1 oo p2)\<cdot>y) \<sqsubseteq> y"
huffman@28613
   371
    by simp
huffman@28613
   372
qed
huffman@27401
   373
haftmann@27681
   374
locale pcpo_ep_pair = ep_pair +
huffman@27401
   375
  constrains e :: "'a::pcpo \<rightarrow> 'b::pcpo"
huffman@27401
   376
  constrains p :: "'b::pcpo \<rightarrow> 'a::pcpo"
huffman@27401
   377
begin
huffman@27401
   378
huffman@27401
   379
lemma e_strict [simp]: "e\<cdot>\<bottom> = \<bottom>"
huffman@27401
   380
proof -
huffman@27401
   381
  have "\<bottom> \<sqsubseteq> p\<cdot>\<bottom>" by (rule minimal)
huffman@27401
   382
  hence "e\<cdot>\<bottom> \<sqsubseteq> e\<cdot>(p\<cdot>\<bottom>)" by (rule monofun_cfun_arg)
huffman@31076
   383
  also have "e\<cdot>(p\<cdot>\<bottom>) \<sqsubseteq> \<bottom>" by (rule e_p_below)
huffman@27401
   384
  finally show "e\<cdot>\<bottom> = \<bottom>" by simp
huffman@27401
   385
qed
huffman@27401
   386
huffman@27401
   387
lemma e_defined_iff [simp]: "e\<cdot>x = \<bottom> \<longleftrightarrow> x = \<bottom>"
huffman@27401
   388
by (rule e_eq_iff [where y="\<bottom>", unfolded e_strict])
huffman@27401
   389
huffman@27401
   390
lemma e_defined: "x \<noteq> \<bottom> \<Longrightarrow> e\<cdot>x \<noteq> \<bottom>"
huffman@27401
   391
by simp
huffman@27401
   392
huffman@27401
   393
lemma p_strict [simp]: "p\<cdot>\<bottom> = \<bottom>"
huffman@27401
   394
by (rule e_inverse [where x="\<bottom>", unfolded e_strict])
huffman@27401
   395
huffman@27401
   396
lemmas stricts = e_strict p_strict
huffman@27401
   397
huffman@27401
   398
end
huffman@27401
   399
huffman@27401
   400
end