src/HOLCF/Up.thy
changeset 16753 fb6801c926d2
parent 16553 aa36d41e4263
child 16933 91ded127f5f7
     1.1 --- a/src/HOLCF/Up.thy	Fri Jul 08 02:39:53 2005 +0200
     1.2 +++ b/src/HOLCF/Up.thy	Fri Jul 08 02:41:19 2005 +0200
     1.3 @@ -15,95 +15,46 @@
     1.4  
     1.5  subsection {* Definition of new type for lifting *}
     1.6  
     1.7 -typedef (Up) 'a u = "UNIV :: 'a option set" ..
     1.8 +datatype 'a u = Ibottom | Iup 'a
     1.9  
    1.10  consts
    1.11 -  Iup         :: "'a \<Rightarrow> 'a u"
    1.12 -  Ifup        :: "('a \<rightarrow> 'b::pcpo) \<Rightarrow> 'a u \<Rightarrow> 'b"
    1.13 -
    1.14 -defs
    1.15 -  Iup_def:     "Iup x \<equiv> Abs_Up (Some x)"
    1.16 -  Ifup_def:    "Ifup f x \<equiv> case Rep_Up x of None \<Rightarrow> \<bottom> | Some z \<Rightarrow> f\<cdot>z"
    1.17 -
    1.18 -lemma Abs_Up_inverse2: "Rep_Up (Abs_Up y) = y"
    1.19 -by (simp add: Up_def Abs_Up_inverse)
    1.20 -
    1.21 -lemma Exh_Up: "z = Abs_Up None \<or> (\<exists>x. z = Iup x)"
    1.22 -apply (unfold Iup_def)
    1.23 -apply (rule Rep_Up_inverse [THEN subst])
    1.24 -apply (case_tac "Rep_Up z")
    1.25 -apply auto
    1.26 -done
    1.27 +  Ifup :: "('a \<rightarrow> 'b::pcpo) \<Rightarrow> 'a u \<Rightarrow> 'b"
    1.28  
    1.29 -lemma inj_Abs_Up: "inj Abs_Up" (* worthless *)
    1.30 -apply (rule inj_on_inverseI)
    1.31 -apply (rule Abs_Up_inverse2)
    1.32 -done
    1.33 -
    1.34 -lemma inj_Rep_Up: "inj Rep_Up" (* worthless *)
    1.35 -apply (rule inj_on_inverseI)
    1.36 -apply (rule Rep_Up_inverse)
    1.37 -done
    1.38 -
    1.39 -lemma Iup_eq [simp]: "(Iup x = Iup y) = (x = y)"
    1.40 -by (simp add: Iup_def Abs_Up_inject Up_def)
    1.41 -
    1.42 -lemma Iup_defined [simp]: "Iup x \<noteq> Abs_Up None"
    1.43 -by (simp add: Iup_def Abs_Up_inject Up_def)
    1.44 -
    1.45 -lemma upE: "\<lbrakk>p = Abs_Up None \<Longrightarrow> Q; \<And>x. p = Iup x \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
    1.46 -by (rule Exh_Up [THEN disjE], auto)
    1.47 -
    1.48 -lemma Ifup1 [simp]: "Ifup f (Abs_Up None) = \<bottom>"
    1.49 -by (simp add: Ifup_def Abs_Up_inverse2)
    1.50 -
    1.51 -lemma Ifup2 [simp]: "Ifup f (Iup x) = f\<cdot>x"
    1.52 -by (simp add: Ifup_def Iup_def Abs_Up_inverse2)
    1.53 +primrec
    1.54 +  "Ifup f Ibottom = \<bottom>"
    1.55 +  "Ifup f (Iup x) = f\<cdot>x"
    1.56  
    1.57  subsection {* Ordering on type @{typ "'a u"} *}
    1.58  
    1.59  instance u :: (sq_ord) sq_ord ..
    1.60  
    1.61  defs (overloaded)
    1.62 -  less_up_def: "(op \<sqsubseteq>) \<equiv> (\<lambda>x1 x2. case Rep_Up x1 of
    1.63 -               None \<Rightarrow> True
    1.64 -             | Some y1 \<Rightarrow> (case Rep_Up x2 of None \<Rightarrow> False
    1.65 -                                           | Some y2 \<Rightarrow> y1 \<sqsubseteq> y2))"
    1.66 +  less_up_def:
    1.67 +    "(op \<sqsubseteq>) \<equiv> (\<lambda>x y. case x of Ibottom \<Rightarrow> True | Iup a \<Rightarrow>
    1.68 +      (case y of Ibottom \<Rightarrow> False | Iup b \<Rightarrow> a \<sqsubseteq> b))"
    1.69  
    1.70 -lemma minimal_up [iff]: "Abs_Up None \<sqsubseteq> z"
    1.71 -by (simp add: less_up_def Abs_Up_inverse2)
    1.72 +lemma minimal_up [iff]: "Ibottom \<sqsubseteq> z"
    1.73 +by (simp add: less_up_def)
    1.74  
    1.75 -lemma not_Iup_less [iff]: "\<not> Iup x \<sqsubseteq> Abs_Up None"
    1.76 -by (simp add: Iup_def less_up_def Abs_Up_inverse2)
    1.77 +lemma not_Iup_less [iff]: "\<not> Iup x \<sqsubseteq> Ibottom"
    1.78 +by (simp add: less_up_def)
    1.79  
    1.80  lemma Iup_less [iff]: "(Iup x \<sqsubseteq> Iup y) = (x \<sqsubseteq> y)"
    1.81 -by (simp add: Iup_def less_up_def Abs_Up_inverse2)
    1.82 +by (simp add: less_up_def)
    1.83  
    1.84  subsection {* Type @{typ "'a u"} is a partial order *}
    1.85  
    1.86 -lemma refl_less_up: "(p::'a u) \<sqsubseteq> p"
    1.87 -by (rule_tac p = "p" in upE, auto)
    1.88 +lemma refl_less_up: "(x::'a u) \<sqsubseteq> x"
    1.89 +by (simp add: less_up_def split: u.split)
    1.90  
    1.91 -lemma antisym_less_up: "\<lbrakk>(p1::'a u) \<sqsubseteq> p2; p2 \<sqsubseteq> p1\<rbrakk> \<Longrightarrow> p1 = p2"
    1.92 -apply (rule_tac p = "p1" in upE)
    1.93 -apply (rule_tac p = "p2" in upE)
    1.94 -apply simp
    1.95 -apply simp
    1.96 -apply (rule_tac p = "p2" in upE)
    1.97 -apply simp
    1.98 -apply simp
    1.99 -apply (drule antisym_less, assumption)
   1.100 -apply simp
   1.101 +lemma antisym_less_up: "\<lbrakk>(x::'a u) \<sqsubseteq> y; y \<sqsubseteq> x\<rbrakk> \<Longrightarrow> x = y"
   1.102 +apply (simp add: less_up_def split: u.split_asm)
   1.103 +apply (erule (1) antisym_less)
   1.104  done
   1.105  
   1.106 -lemma trans_less_up: "\<lbrakk>(p1::'a u) \<sqsubseteq> p2; p2 \<sqsubseteq> p3\<rbrakk> \<Longrightarrow> p1 \<sqsubseteq> p3"
   1.107 -apply (rule_tac p = "p1" in upE)
   1.108 -apply simp
   1.109 -apply (rule_tac p = "p2" in upE)
   1.110 -apply simp
   1.111 -apply (rule_tac p = "p3" in upE)
   1.112 -apply simp
   1.113 -apply (auto elim: trans_less)
   1.114 +lemma trans_less_up: "\<lbrakk>(x::'a u) \<sqsubseteq> y; y \<sqsubseteq> z\<rbrakk> \<Longrightarrow> x \<sqsubseteq> z"
   1.115 +apply (simp add: less_up_def split: u.split_asm)
   1.116 +apply (erule (1) trans_less)
   1.117  done
   1.118  
   1.119  instance u :: (cpo) po
   1.120 @@ -118,7 +69,7 @@
   1.121  apply (rule ub_rangeI)
   1.122  apply (subst Iup_less)
   1.123  apply (erule is_ub_lub)
   1.124 -apply (rule_tac p="u" in upE)
   1.125 +apply (case_tac u)
   1.126  apply (drule ub_rangeD)
   1.127  apply simp
   1.128  apply simp
   1.129 @@ -130,25 +81,25 @@
   1.130  
   1.131  text {* Now some lemmas about chains of @{typ "'a u"} elements *}
   1.132  
   1.133 -lemma up_lemma1: "z \<noteq> Abs_Up None \<Longrightarrow> Iup (THE a. Iup a = z) = z"
   1.134 -by (rule_tac p="z" in upE, simp_all)
   1.135 +lemma up_lemma1: "z \<noteq> Ibottom \<Longrightarrow> Iup (THE a. Iup a = z) = z"
   1.136 +by (case_tac z, simp_all)
   1.137  
   1.138  lemma up_lemma2:
   1.139 -  "\<lbrakk>chain Y; Y j \<noteq> Abs_Up None\<rbrakk> \<Longrightarrow> Y (i + j) \<noteq> Abs_Up None"
   1.140 +  "\<lbrakk>chain Y; Y j \<noteq> Ibottom\<rbrakk> \<Longrightarrow> Y (i + j) \<noteq> Ibottom"
   1.141  apply (erule contrapos_nn)
   1.142  apply (drule_tac x="j" and y="i + j" in chain_mono3)
   1.143  apply (rule le_add2)
   1.144 -apply (rule_tac p="Y j" in upE)
   1.145 +apply (case_tac "Y j")
   1.146  apply assumption
   1.147  apply simp
   1.148  done
   1.149  
   1.150  lemma up_lemma3:
   1.151 -  "\<lbrakk>chain Y; Y j \<noteq> Abs_Up None\<rbrakk> \<Longrightarrow> Iup (THE a. Iup a = Y (i + j)) = Y (i + j)"
   1.152 +  "\<lbrakk>chain Y; Y j \<noteq> Ibottom\<rbrakk> \<Longrightarrow> Iup (THE a. Iup a = Y (i + j)) = Y (i + j)"
   1.153  by (rule up_lemma1 [OF up_lemma2])
   1.154  
   1.155  lemma up_lemma4:
   1.156 -  "\<lbrakk>chain Y; Y j \<noteq> Abs_Up None\<rbrakk> \<Longrightarrow> chain (\<lambda>i. THE a. Iup a = Y (i + j))"
   1.157 +  "\<lbrakk>chain Y; Y j \<noteq> Ibottom\<rbrakk> \<Longrightarrow> chain (\<lambda>i. THE a. Iup a = Y (i + j))"
   1.158  apply (rule chainI)
   1.159  apply (rule Iup_less [THEN iffD1])
   1.160  apply (subst up_lemma3, assumption+)+
   1.161 @@ -156,25 +107,25 @@
   1.162  done
   1.163  
   1.164  lemma up_lemma5:
   1.165 -  "\<lbrakk>chain Y; Y j \<noteq> Abs_Up None\<rbrakk> \<Longrightarrow>
   1.166 +  "\<lbrakk>chain Y; Y j \<noteq> Ibottom\<rbrakk> \<Longrightarrow>
   1.167      (\<lambda>i. Y (i + j)) = (\<lambda>i. Iup (THE a. Iup a = Y (i + j)))"
   1.168  by (rule ext, rule up_lemma3 [symmetric])
   1.169  
   1.170  lemma up_lemma6:
   1.171 -  "\<lbrakk>chain Y; Y j \<noteq> Abs_Up None\<rbrakk>  
   1.172 +  "\<lbrakk>chain Y; Y j \<noteq> Ibottom\<rbrakk>  
   1.173        \<Longrightarrow> range Y <<| Iup (\<Squnion>i. THE a. Iup a = Y(i + j))"
   1.174  apply (rule_tac j1="j" in is_lub_range_shift [THEN iffD1])
   1.175  apply assumption
   1.176  apply (subst up_lemma5, assumption+)
   1.177  apply (rule is_lub_Iup)
   1.178  apply (rule thelubE [OF _ refl])
   1.179 -apply (rule up_lemma4, assumption+)
   1.180 +apply (erule (1) up_lemma4)
   1.181  done
   1.182  
   1.183  lemma up_chain_cases:
   1.184    "chain Y \<Longrightarrow>
   1.185     (\<exists>A. chain A \<and> lub (range Y) = Iup (lub (range A)) \<and>
   1.186 -   (\<exists>j. \<forall>i. Y (i + j) = Iup (A i))) \<or> (Y = (\<lambda>i. Abs_Up None))"
   1.187 +   (\<exists>j. \<forall>i. Y (i + j) = Iup (A i))) \<or> (Y = (\<lambda>i. Ibottom))"
   1.188  apply (rule disjCI)
   1.189  apply (simp add: expand_fun_eq)
   1.190  apply (erule exE, rename_tac j)
   1.191 @@ -192,7 +143,7 @@
   1.192  apply (rule_tac x="Iup (lub (range A))" in exI)
   1.193  apply (erule_tac j1="j" in is_lub_range_shift [THEN iffD1])
   1.194  apply (simp add: is_lub_Iup thelubE)
   1.195 -apply (rule_tac x="Abs_Up None" in exI)
   1.196 +apply (rule_tac x="Ibottom" in exI)
   1.197  apply (rule lub_const)
   1.198  done
   1.199  
   1.200 @@ -202,7 +153,7 @@
   1.201  subsection {* Type @{typ "'a u"} is pointed *}
   1.202  
   1.203  lemma least_up: "EX x::'a u. ALL y. x\<sqsubseteq>y"
   1.204 -apply (rule_tac x = "Abs_Up None" in exI)
   1.205 +apply (rule_tac x = "Ibottom" in exI)
   1.206  apply (rule minimal_up [THEN allI])
   1.207  done
   1.208  
   1.209 @@ -210,21 +161,9 @@
   1.210  by intro_classes (rule least_up)
   1.211  
   1.212  text {* for compatibility with old HOLCF-Version *}
   1.213 -lemma inst_up_pcpo: "\<bottom> = Abs_Up None"
   1.214 +lemma inst_up_pcpo: "\<bottom> = Ibottom"
   1.215  by (rule minimal_up [THEN UU_I, symmetric])
   1.216  
   1.217 -text {* some lemmas restated for class pcpo *}
   1.218 -
   1.219 -lemma less_up3b: "~ Iup(x) \<sqsubseteq> \<bottom>"
   1.220 -apply (subst inst_up_pcpo)
   1.221 -apply simp
   1.222 -done
   1.223 -
   1.224 -lemma defined_Iup2 [iff]: "Iup(x) ~= \<bottom>"
   1.225 -apply (subst inst_up_pcpo)
   1.226 -apply (rule Iup_defined)
   1.227 -done
   1.228 -
   1.229  subsection {* Continuity of @{term Iup} and @{term Ifup} *}
   1.230  
   1.231  text {* continuity for @{term Iup} *}
   1.232 @@ -238,18 +177,12 @@
   1.233  text {* continuity for @{term Ifup} *}
   1.234  
   1.235  lemma cont_Ifup1: "cont (\<lambda>f. Ifup f x)"
   1.236 -apply (rule contI)
   1.237 -apply (rule_tac p="x" in upE)
   1.238 -apply (simp add: lub_const)
   1.239 -apply (simp add: cont_cfun_fun)
   1.240 -done
   1.241 +by (induct x, simp_all)
   1.242  
   1.243  lemma monofun_Ifup2: "monofun (\<lambda>x. Ifup f x)"
   1.244  apply (rule monofunI)
   1.245 -apply (rule_tac p="x" in upE)
   1.246 -apply simp
   1.247 -apply (rule_tac p="y" in upE)
   1.248 -apply simp
   1.249 +apply (case_tac x, simp)
   1.250 +apply (case_tac y, simp)
   1.251  apply (simp add: monofun_cfun_arg)
   1.252  done
   1.253  
   1.254 @@ -272,21 +205,21 @@
   1.255    "fup \<equiv> \<Lambda> f p. Ifup f p"
   1.256  
   1.257  translations
   1.258 -"case l of up\<cdot>x => t1" == "fup\<cdot>(LAM x. t1)\<cdot>l"
   1.259 +"case l of up\<cdot>x \<Rightarrow> t" == "fup\<cdot>(LAM x. t)\<cdot>l"
   1.260  
   1.261  text {* continuous versions of lemmas for @{typ "('a)u"} *}
   1.262  
   1.263 -lemma Exh_Up1: "z = \<bottom> \<or> (\<exists>x. z = up\<cdot>x)"
   1.264 -apply (rule_tac p="z" in upE)
   1.265 +lemma Exh_Up: "z = \<bottom> \<or> (\<exists>x. z = up\<cdot>x)"
   1.266 +apply (induct z)
   1.267  apply (simp add: inst_up_pcpo)
   1.268  apply (simp add: up_def cont_Iup)
   1.269  done
   1.270  
   1.271 -lemma up_inject: "up\<cdot>x = up\<cdot>y \<Longrightarrow> x = y"
   1.272 +lemma up_eq [simp]: "(up\<cdot>x = up\<cdot>y) = (x = y)"
   1.273  by (simp add: up_def cont_Iup)
   1.274  
   1.275 -lemma up_eq [simp]: "(up\<cdot>x = up\<cdot>y) = (x = y)"
   1.276 -by (rule iffI, erule up_inject, simp)
   1.277 +lemma up_inject: "up\<cdot>x = up\<cdot>y \<Longrightarrow> x = y"
   1.278 +by simp
   1.279  
   1.280  lemma up_defined [simp]: " up\<cdot>x \<noteq> \<bottom>"
   1.281  by (simp add: up_def cont_Iup inst_up_pcpo)
   1.282 @@ -297,8 +230,8 @@
   1.283  lemma up_less [simp]: "(up\<cdot>x \<sqsubseteq> up\<cdot>y) = (x \<sqsubseteq> y)"
   1.284  by (simp add: up_def cont_Iup)
   1.285  
   1.286 -lemma upE1: "\<lbrakk>p = \<bottom> \<Longrightarrow> Q; \<And>x. p = up\<cdot>x \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
   1.287 -apply (rule_tac p="p" in upE)
   1.288 +lemma upE: "\<lbrakk>p = \<bottom> \<Longrightarrow> Q; \<And>x. p = up\<cdot>x \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
   1.289 +apply (case_tac p)
   1.290  apply (simp add: inst_up_pcpo)
   1.291  apply (simp add: up_def cont_Iup)
   1.292  done
   1.293 @@ -307,9 +240,9 @@
   1.294  by (simp add: fup_def cont_Ifup1 cont_Ifup2 inst_up_pcpo)
   1.295  
   1.296  lemma fup2 [simp]: "fup\<cdot>f\<cdot>(up\<cdot>x) = f\<cdot>x"
   1.297 -by (simp add: up_def fup_def cont_Iup cont_Ifup1 cont_Ifup2 )
   1.298 +by (simp add: up_def fup_def cont_Iup cont_Ifup1 cont_Ifup2)
   1.299  
   1.300  lemma fup3 [simp]: "fup\<cdot>up\<cdot>x = x"
   1.301 -by (rule_tac p=x in upE1, simp_all)
   1.302 +by (rule_tac p=x in upE, simp_all)
   1.303  
   1.304  end