src/HOLCF/Up.thy
 author huffman Wed Jun 08 01:40:39 2005 +0200 (2005-06-08) changeset 16319 1ff2965cc2e7 parent 16215 7ff978ca1920 child 16326 50a613925c4e permissions -rw-r--r--
major cleanup: rewrote cpo proofs, removed obsolete lemmas, renamed some lemmas
```     1 (*  Title:      HOLCF/Up.thy
```
```     2     ID:         \$Id\$
```
```     3     Author:     Franz Regensburger and Brian Huffman
```
```     4
```
```     5 Lifting.
```
```     6 *)
```
```     7
```
```     8 header {* The type of lifted values *}
```
```     9
```
```    10 theory Up
```
```    11 imports Cfun Sum_Type Datatype
```
```    12 begin
```
```    13
```
```    14 defaultsort cpo
```
```    15
```
```    16 subsection {* Definition of new type for lifting *}
```
```    17
```
```    18 typedef (Up) 'a u = "UNIV :: 'a option set" ..
```
```    19
```
```    20 consts
```
```    21   Iup         :: "'a \<Rightarrow> 'a u"
```
```    22   Ifup        :: "('a \<rightarrow> 'b::pcpo) \<Rightarrow> 'a u \<Rightarrow> 'b"
```
```    23
```
```    24 defs
```
```    25   Iup_def:     "Iup x \<equiv> Abs_Up (Some x)"
```
```    26   Ifup_def:    "Ifup f x \<equiv> case Rep_Up x of None \<Rightarrow> \<bottom> | Some z \<Rightarrow> f\<cdot>z"
```
```    27
```
```    28 lemma Abs_Up_inverse2: "Rep_Up (Abs_Up y) = y"
```
```    29 by (simp add: Up_def Abs_Up_inverse)
```
```    30
```
```    31 lemma Exh_Up: "z = Abs_Up None \<or> (\<exists>x. z = Iup x)"
```
```    32 apply (unfold Iup_def)
```
```    33 apply (rule Rep_Up_inverse [THEN subst])
```
```    34 apply (case_tac "Rep_Up z")
```
```    35 apply auto
```
```    36 done
```
```    37
```
```    38 lemma inj_Abs_Up: "inj Abs_Up" (* worthless *)
```
```    39 apply (rule inj_on_inverseI)
```
```    40 apply (rule Abs_Up_inverse2)
```
```    41 done
```
```    42
```
```    43 lemma inj_Rep_Up: "inj Rep_Up" (* worthless *)
```
```    44 apply (rule inj_on_inverseI)
```
```    45 apply (rule Rep_Up_inverse)
```
```    46 done
```
```    47
```
```    48 lemma Iup_eq [simp]: "(Iup x = Iup y) = (x = y)"
```
```    49 by (simp add: Iup_def Abs_Up_inject Up_def)
```
```    50
```
```    51 lemma Iup_defined [simp]: "Iup x \<noteq> Abs_Up None"
```
```    52 by (simp add: Iup_def Abs_Up_inject Up_def)
```
```    53
```
```    54 lemma upE: "\<lbrakk>p = Abs_Up None \<Longrightarrow> Q; \<And>x. p = Iup x \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
```
```    55 by (rule Exh_Up [THEN disjE], auto)
```
```    56
```
```    57 lemma Ifup1 [simp]: "Ifup f (Abs_Up None) = \<bottom>"
```
```    58 by (simp add: Ifup_def Abs_Up_inverse2)
```
```    59
```
```    60 lemma Ifup2 [simp]: "Ifup f (Iup x) = f\<cdot>x"
```
```    61 by (simp add: Ifup_def Iup_def Abs_Up_inverse2)
```
```    62
```
```    63 subsection {* Ordering on type @{typ "'a u"} *}
```
```    64
```
```    65 instance u :: (sq_ord) sq_ord ..
```
```    66
```
```    67 defs (overloaded)
```
```    68   less_up_def: "(op \<sqsubseteq>) \<equiv> (\<lambda>x1 x2. case Rep_Up x1 of
```
```    69                None \<Rightarrow> True
```
```    70              | Some y1 \<Rightarrow> (case Rep_Up x2 of None \<Rightarrow> False
```
```    71                                            | Some y2 \<Rightarrow> y1 \<sqsubseteq> y2))"
```
```    72
```
```    73 lemma minimal_up [iff]: "Abs_Up None \<sqsubseteq> z"
```
```    74 by (simp add: less_up_def Abs_Up_inverse2)
```
```    75
```
```    76 lemma not_Iup_less [iff]: "\<not> Iup x \<sqsubseteq> Abs_Up None"
```
```    77 by (simp add: Iup_def less_up_def Abs_Up_inverse2)
```
```    78
```
```    79 lemma Iup_less [iff]: "(Iup x \<sqsubseteq> Iup y) = (x \<sqsubseteq> y)"
```
```    80 by (simp add: Iup_def less_up_def Abs_Up_inverse2)
```
```    81
```
```    82 subsection {* Type @{typ "'a u"} is a partial order *}
```
```    83
```
```    84 lemma refl_less_up: "(p::'a u) \<sqsubseteq> p"
```
```    85 by (rule_tac p = "p" in upE, auto)
```
```    86
```
```    87 lemma antisym_less_up: "\<lbrakk>(p1::'a u) \<sqsubseteq> p2; p2 \<sqsubseteq> p1\<rbrakk> \<Longrightarrow> p1 = p2"
```
```    88 apply (rule_tac p = "p1" in upE)
```
```    89 apply (rule_tac p = "p2" in upE)
```
```    90 apply simp
```
```    91 apply simp
```
```    92 apply (rule_tac p = "p2" in upE)
```
```    93 apply simp
```
```    94 apply simp
```
```    95 apply (drule antisym_less, assumption)
```
```    96 apply simp
```
```    97 done
```
```    98
```
```    99 lemma trans_less_up: "\<lbrakk>(p1::'a u) \<sqsubseteq> p2; p2 \<sqsubseteq> p3\<rbrakk> \<Longrightarrow> p1 \<sqsubseteq> p3"
```
```   100 apply (rule_tac p = "p1" in upE)
```
```   101 apply simp
```
```   102 apply (rule_tac p = "p2" in upE)
```
```   103 apply simp
```
```   104 apply (rule_tac p = "p3" in upE)
```
```   105 apply simp
```
```   106 apply (auto elim: trans_less)
```
```   107 done
```
```   108
```
```   109 instance u :: (cpo) po
```
```   110 by intro_classes
```
```   111   (assumption | rule refl_less_up antisym_less_up trans_less_up)+
```
```   112
```
```   113 subsection {* Type @{typ "'a u"} is a cpo *}
```
```   114
```
```   115 lemma is_lub_Iup:
```
```   116   "range S <<| x \<Longrightarrow> range (\<lambda>i. Iup (S i)) <<| Iup x"
```
```   117 apply (rule is_lubI)
```
```   118 apply (rule ub_rangeI)
```
```   119 apply (subst Iup_less)
```
```   120 apply (erule is_ub_lub)
```
```   121 apply (rule_tac p="u" in upE)
```
```   122 apply (drule ub_rangeD)
```
```   123 apply simp
```
```   124 apply simp
```
```   125 apply (erule is_lub_lub)
```
```   126 apply (rule ub_rangeI)
```
```   127 apply (drule_tac i=i in ub_rangeD)
```
```   128 apply simp
```
```   129 done
```
```   130
```
```   131 text {* Now some lemmas about chains of @{typ "'a u"} elements *}
```
```   132
```
```   133 lemma up_lemma1: "z \<noteq> Abs_Up None \<Longrightarrow> Iup (THE a. Iup a = z) = z"
```
```   134 by (rule_tac p="z" in upE, simp_all)
```
```   135
```
```   136 lemma up_lemma2:
```
```   137   "\<lbrakk>chain Y; Y j \<noteq> Abs_Up None\<rbrakk> \<Longrightarrow> Y (i + j) \<noteq> Abs_Up None"
```
```   138 apply (erule contrapos_nn)
```
```   139 apply (drule_tac x="j" and y="i + j" in chain_mono3)
```
```   140 apply (rule le_add2)
```
```   141 apply (rule_tac p="Y j" in upE)
```
```   142 apply assumption
```
```   143 apply simp
```
```   144 done
```
```   145
```
```   146 lemma up_lemma3:
```
```   147   "\<lbrakk>chain Y; Y j \<noteq> Abs_Up None\<rbrakk> \<Longrightarrow> Iup (THE a. Iup a = Y (i + j)) = Y (i + j)"
```
```   148 by (rule up_lemma1 [OF up_lemma2])
```
```   149
```
```   150 lemma up_lemma4:
```
```   151   "\<lbrakk>chain Y; Y j \<noteq> Abs_Up None\<rbrakk> \<Longrightarrow> chain (\<lambda>i. THE a. Iup a = Y (i + j))"
```
```   152 apply (rule chainI)
```
```   153 apply (rule Iup_less [THEN iffD1])
```
```   154 apply (subst up_lemma3, assumption+)+
```
```   155 apply (simp add: chainE)
```
```   156 done
```
```   157
```
```   158 lemma up_lemma5:
```
```   159   "\<lbrakk>chain Y; Y j \<noteq> Abs_Up None\<rbrakk> \<Longrightarrow>
```
```   160     (\<lambda>i. Y (i + j)) = (\<lambda>i. Iup (THE a. Iup a = Y (i + j)))"
```
```   161 by (rule ext, rule up_lemma3 [symmetric])
```
```   162
```
```   163 lemma up_lemma6:
```
```   164   "\<lbrakk>chain Y; Y j \<noteq> Abs_Up None\<rbrakk>
```
```   165       \<Longrightarrow> range Y <<| Iup (\<Squnion>i. THE a. Iup a = Y(i + j))"
```
```   166 apply (rule_tac j1="j" in is_lub_range_shift [THEN iffD1])
```
```   167 apply assumption
```
```   168 apply (subst up_lemma5, assumption+)
```
```   169 apply (rule is_lub_Iup)
```
```   170 apply (rule thelubE [OF _ refl])
```
```   171 apply (rule up_lemma4, assumption+)
```
```   172 done
```
```   173
```
```   174 lemma up_chain_cases:
```
```   175   "chain Y \<Longrightarrow>
```
```   176    (\<exists>A. chain A \<and> lub (range Y) = Iup (lub (range A)) \<and>
```
```   177    (\<exists>j. \<forall>i. Y (i + j) = Iup (A i))) \<or> (Y = (\<lambda>i. Abs_Up None))"
```
```   178 apply (rule disjCI)
```
```   179 apply (simp add: expand_fun_eq)
```
```   180 apply (erule exE, rename_tac j)
```
```   181 apply (rule_tac x="\<lambda>i. THE a. Iup a = Y (i + j)" in exI)
```
```   182 apply (rule conjI)
```
```   183 apply (simp add: up_lemma4)
```
```   184 apply (rule conjI)
```
```   185 apply (simp add: up_lemma6 [THEN thelubI])
```
```   186 apply (rule_tac x=j in exI)
```
```   187 apply (simp add: up_lemma3)
```
```   188 done
```
```   189
```
```   190 lemma cpo_up: "chain (Y::nat \<Rightarrow> 'a u) \<Longrightarrow> \<exists>x. range Y <<| x"
```
```   191 apply (frule up_chain_cases, safe)
```
```   192 apply (rule_tac x="Iup (lub (range A))" in exI)
```
```   193 apply (erule_tac j1="j" in is_lub_range_shift [THEN iffD1])
```
```   194 apply (simp add: is_lub_Iup thelubE)
```
```   195 apply (rule_tac x="Abs_Up None" in exI)
```
```   196 apply (rule lub_const)
```
```   197 done
```
```   198
```
```   199 instance u :: (cpo) cpo
```
```   200 by intro_classes (rule cpo_up)
```
```   201
```
```   202 subsection {* Type @{typ "'a u"} is pointed *}
```
```   203
```
```   204 lemma least_up: "EX x::'a u. ALL y. x\<sqsubseteq>y"
```
```   205 apply (rule_tac x = "Abs_Up None" in exI)
```
```   206 apply (rule minimal_up [THEN allI])
```
```   207 done
```
```   208
```
```   209 instance u :: (cpo) pcpo
```
```   210 by intro_classes (rule least_up)
```
```   211
```
```   212 text {* for compatibility with old HOLCF-Version *}
```
```   213 lemma inst_up_pcpo: "\<bottom> = Abs_Up None"
```
```   214 by (rule minimal_up [THEN UU_I, symmetric])
```
```   215
```
```   216 text {* some lemmas restated for class pcpo *}
```
```   217
```
```   218 lemma less_up3b: "~ Iup(x) \<sqsubseteq> \<bottom>"
```
```   219 apply (subst inst_up_pcpo)
```
```   220 apply simp
```
```   221 done
```
```   222
```
```   223 lemma defined_Iup2 [iff]: "Iup(x) ~= \<bottom>"
```
```   224 apply (subst inst_up_pcpo)
```
```   225 apply (rule Iup_defined)
```
```   226 done
```
```   227
```
```   228 subsection {* Continuity of @{term Iup} and @{term Ifup} *}
```
```   229
```
```   230 text {* continuity for @{term Iup} *}
```
```   231
```
```   232 lemma cont_Iup: "cont Iup"
```
```   233 apply (rule contI)
```
```   234 apply (rule is_lub_Iup)
```
```   235 apply (erule thelubE [OF _ refl])
```
```   236 done
```
```   237
```
```   238 text {* continuity for @{term Ifup} *}
```
```   239
```
```   240 lemma cont_Ifup1: "cont (\<lambda>f. Ifup f x)"
```
```   241 apply (rule contI)
```
```   242 apply (rule_tac p="x" in upE)
```
```   243 apply (simp add: lub_const)
```
```   244 apply (simp add: cont_cfun_fun)
```
```   245 done
```
```   246
```
```   247 lemma monofun_Ifup2: "monofun (\<lambda>x. Ifup f x)"
```
```   248 apply (rule monofunI)
```
```   249 apply (rule_tac p="x" in upE)
```
```   250 apply simp
```
```   251 apply (rule_tac p="y" in upE)
```
```   252 apply simp
```
```   253 apply (simp add: monofun_cfun_arg)
```
```   254 done
```
```   255
```
```   256 lemma cont_Ifup2: "cont (\<lambda>x. Ifup f x)"
```
```   257 apply (rule contI)
```
```   258 apply (frule up_chain_cases, safe)
```
```   259 apply (rule_tac j1="j" in is_lub_range_shift [THEN iffD1])
```
```   260 apply (erule monofun_Ifup2 [THEN ch2ch_monofun])
```
```   261 apply (simp add: cont_cfun_arg)
```
```   262 apply (simp add: thelub_const lub_const)
```
```   263 done
```
```   264
```
```   265 subsection {* Continuous versions of constants *}
```
```   266
```
```   267 constdefs
```
```   268   up  :: "'a \<rightarrow> 'a u"
```
```   269   "up \<equiv> \<Lambda> x. Iup x"
```
```   270
```
```   271   fup :: "('a \<rightarrow> 'b::pcpo) \<rightarrow> 'a u \<rightarrow> 'b"
```
```   272   "fup \<equiv> \<Lambda> f p. Ifup f p"
```
```   273
```
```   274 translations
```
```   275 "case l of up\<cdot>x => t1" == "fup\<cdot>(LAM x. t1)\<cdot>l"
```
```   276
```
```   277 text {* continuous versions of lemmas for @{typ "('a)u"} *}
```
```   278
```
```   279 lemma Exh_Up1: "z = \<bottom> \<or> (\<exists>x. z = up\<cdot>x)"
```
```   280 apply (rule_tac p="z" in upE)
```
```   281 apply (simp add: inst_up_pcpo)
```
```   282 apply (simp add: up_def cont_Iup)
```
```   283 done
```
```   284
```
```   285 lemma up_inject: "up\<cdot>x = up\<cdot>y \<Longrightarrow> x = y"
```
```   286 by (simp add: up_def cont_Iup)
```
```   287
```
```   288 lemma up_eq: "(up\<cdot>x = up\<cdot>y) = (x = y)"
```
```   289 by (rule iffI, erule up_inject, simp)
```
```   290
```
```   291 lemma up_defined [simp]: " up\<cdot>x \<noteq> \<bottom>"
```
```   292 by (simp add: up_def cont_Iup inst_up_pcpo)
```
```   293
```
```   294 lemma not_up_less_UU [simp]: "\<not> up\<cdot>x \<sqsubseteq> \<bottom>"
```
```   295 by (simp add: eq_UU_iff [symmetric])
```
```   296
```
```   297 lemma up_less: "(up\<cdot>x \<sqsubseteq> up\<cdot>y) = (x \<sqsubseteq> y)"
```
```   298 by (simp add: up_def cont_Iup)
```
```   299
```
```   300 lemma upE1: "\<lbrakk>p = \<bottom> \<Longrightarrow> Q; \<And>x. p = up\<cdot>x \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
```
```   301 apply (rule_tac p="p" in upE)
```
```   302 apply (simp add: inst_up_pcpo)
```
```   303 apply (simp add: up_def cont_Iup)
```
```   304 done
```
```   305
```
```   306 lemma fup1 [simp]: "fup\<cdot>f\<cdot>\<bottom> = \<bottom>"
```
```   307 by (simp add: fup_def cont_Ifup1 cont_Ifup2 inst_up_pcpo)
```
```   308
```
```   309 lemma fup2 [simp]: "fup\<cdot>f\<cdot>(up\<cdot>x) = f\<cdot>x"
```
```   310 by (simp add: up_def fup_def cont_Iup cont_Ifup1 cont_Ifup2 )
```
```   311
```
```   312 lemma fup3: "fup\<cdot>up\<cdot>x = x"
```
```   313 by (rule_tac p=x in upE1, simp_all)
```
```   314
```
```   315 end
```