define 'a u with datatype package;
authorhuffman
Fri Jul 08 02:41:19 2005 +0200 (2005-07-08)
changeset 16753fb6801c926d2
parent 16752 270ec60cc9e8
child 16754 1b979f8b7e8e
define 'a u with datatype package;
removed obsolete lemmas;
renamed upE1 to upE and Exh_Up1 to Exh_Up;
cleaned up
src/HOLCF/Up.ML
src/HOLCF/Up.thy
     1.1 --- a/src/HOLCF/Up.ML	Fri Jul 08 02:39:53 2005 +0200
     1.2 +++ b/src/HOLCF/Up.ML	Fri Jul 08 02:41:19 2005 +0200
     1.3 @@ -1,11 +1,7 @@
     1.4  
     1.5  (* legacy ML bindings *)
     1.6  
     1.7 -val Iup_def = thm "Iup_def";
     1.8 -val Ifup_def = thm "Ifup_def";
     1.9  val less_up_def = thm "less_up_def";
    1.10 -val Ifup1 = thm "Ifup1";
    1.11 -val Ifup2 = thm "Ifup2";
    1.12  val refl_less_up = thm "refl_less_up";
    1.13  val antisym_less_up = thm "antisym_less_up";
    1.14  val trans_less_up = thm "trans_less_up";
    1.15 @@ -20,12 +16,12 @@
    1.16  val cont_Iup = thm "cont_Iup";
    1.17  val cont_Ifup1 = thm "cont_Ifup1";
    1.18  val cont_Ifup2 = thm "cont_Ifup2";
    1.19 -val Exh_Up1 = thm "Exh_Up1";
    1.20 +val Exh_Up = thm "Exh_Up";
    1.21  val up_inject = thm "up_inject";
    1.22  val up_eq = thm "up_eq";
    1.23  val up_defined = thm "up_defined";
    1.24  val up_less = thm "up_less";
    1.25 -val upE1 = thm "upE1";
    1.26 +val upE = thm "upE";
    1.27  val fup1 = thm "fup1";
    1.28  val fup2 = thm "fup2";
    1.29  val fup3 = thm "fup3";
     2.1 --- a/src/HOLCF/Up.thy	Fri Jul 08 02:39:53 2005 +0200
     2.2 +++ b/src/HOLCF/Up.thy	Fri Jul 08 02:41:19 2005 +0200
     2.3 @@ -15,95 +15,46 @@
     2.4  
     2.5  subsection {* Definition of new type for lifting *}
     2.6  
     2.7 -typedef (Up) 'a u = "UNIV :: 'a option set" ..
     2.8 +datatype 'a u = Ibottom | Iup 'a
     2.9  
    2.10  consts
    2.11 -  Iup         :: "'a \<Rightarrow> 'a u"
    2.12 -  Ifup        :: "('a \<rightarrow> 'b::pcpo) \<Rightarrow> 'a u \<Rightarrow> 'b"
    2.13 -
    2.14 -defs
    2.15 -  Iup_def:     "Iup x \<equiv> Abs_Up (Some x)"
    2.16 -  Ifup_def:    "Ifup f x \<equiv> case Rep_Up x of None \<Rightarrow> \<bottom> | Some z \<Rightarrow> f\<cdot>z"
    2.17 -
    2.18 -lemma Abs_Up_inverse2: "Rep_Up (Abs_Up y) = y"
    2.19 -by (simp add: Up_def Abs_Up_inverse)
    2.20 -
    2.21 -lemma Exh_Up: "z = Abs_Up None \<or> (\<exists>x. z = Iup x)"
    2.22 -apply (unfold Iup_def)
    2.23 -apply (rule Rep_Up_inverse [THEN subst])
    2.24 -apply (case_tac "Rep_Up z")
    2.25 -apply auto
    2.26 -done
    2.27 +  Ifup :: "('a \<rightarrow> 'b::pcpo) \<Rightarrow> 'a u \<Rightarrow> 'b"
    2.28  
    2.29 -lemma inj_Abs_Up: "inj Abs_Up" (* worthless *)
    2.30 -apply (rule inj_on_inverseI)
    2.31 -apply (rule Abs_Up_inverse2)
    2.32 -done
    2.33 -
    2.34 -lemma inj_Rep_Up: "inj Rep_Up" (* worthless *)
    2.35 -apply (rule inj_on_inverseI)
    2.36 -apply (rule Rep_Up_inverse)
    2.37 -done
    2.38 -
    2.39 -lemma Iup_eq [simp]: "(Iup x = Iup y) = (x = y)"
    2.40 -by (simp add: Iup_def Abs_Up_inject Up_def)
    2.41 -
    2.42 -lemma Iup_defined [simp]: "Iup x \<noteq> Abs_Up None"
    2.43 -by (simp add: Iup_def Abs_Up_inject Up_def)
    2.44 -
    2.45 -lemma upE: "\<lbrakk>p = Abs_Up None \<Longrightarrow> Q; \<And>x. p = Iup x \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
    2.46 -by (rule Exh_Up [THEN disjE], auto)
    2.47 -
    2.48 -lemma Ifup1 [simp]: "Ifup f (Abs_Up None) = \<bottom>"
    2.49 -by (simp add: Ifup_def Abs_Up_inverse2)
    2.50 -
    2.51 -lemma Ifup2 [simp]: "Ifup f (Iup x) = f\<cdot>x"
    2.52 -by (simp add: Ifup_def Iup_def Abs_Up_inverse2)
    2.53 +primrec
    2.54 +  "Ifup f Ibottom = \<bottom>"
    2.55 +  "Ifup f (Iup x) = f\<cdot>x"
    2.56  
    2.57  subsection {* Ordering on type @{typ "'a u"} *}
    2.58  
    2.59  instance u :: (sq_ord) sq_ord ..
    2.60  
    2.61  defs (overloaded)
    2.62 -  less_up_def: "(op \<sqsubseteq>) \<equiv> (\<lambda>x1 x2. case Rep_Up x1 of
    2.63 -               None \<Rightarrow> True
    2.64 -             | Some y1 \<Rightarrow> (case Rep_Up x2 of None \<Rightarrow> False
    2.65 -                                           | Some y2 \<Rightarrow> y1 \<sqsubseteq> y2))"
    2.66 +  less_up_def:
    2.67 +    "(op \<sqsubseteq>) \<equiv> (\<lambda>x y. case x of Ibottom \<Rightarrow> True | Iup a \<Rightarrow>
    2.68 +      (case y of Ibottom \<Rightarrow> False | Iup b \<Rightarrow> a \<sqsubseteq> b))"
    2.69  
    2.70 -lemma minimal_up [iff]: "Abs_Up None \<sqsubseteq> z"
    2.71 -by (simp add: less_up_def Abs_Up_inverse2)
    2.72 +lemma minimal_up [iff]: "Ibottom \<sqsubseteq> z"
    2.73 +by (simp add: less_up_def)
    2.74  
    2.75 -lemma not_Iup_less [iff]: "\<not> Iup x \<sqsubseteq> Abs_Up None"
    2.76 -by (simp add: Iup_def less_up_def Abs_Up_inverse2)
    2.77 +lemma not_Iup_less [iff]: "\<not> Iup x \<sqsubseteq> Ibottom"
    2.78 +by (simp add: less_up_def)
    2.79  
    2.80  lemma Iup_less [iff]: "(Iup x \<sqsubseteq> Iup y) = (x \<sqsubseteq> y)"
    2.81 -by (simp add: Iup_def less_up_def Abs_Up_inverse2)
    2.82 +by (simp add: less_up_def)
    2.83  
    2.84  subsection {* Type @{typ "'a u"} is a partial order *}
    2.85  
    2.86 -lemma refl_less_up: "(p::'a u) \<sqsubseteq> p"
    2.87 -by (rule_tac p = "p" in upE, auto)
    2.88 +lemma refl_less_up: "(x::'a u) \<sqsubseteq> x"
    2.89 +by (simp add: less_up_def split: u.split)
    2.90  
    2.91 -lemma antisym_less_up: "\<lbrakk>(p1::'a u) \<sqsubseteq> p2; p2 \<sqsubseteq> p1\<rbrakk> \<Longrightarrow> p1 = p2"
    2.92 -apply (rule_tac p = "p1" in upE)
    2.93 -apply (rule_tac p = "p2" in upE)
    2.94 -apply simp
    2.95 -apply simp
    2.96 -apply (rule_tac p = "p2" in upE)
    2.97 -apply simp
    2.98 -apply simp
    2.99 -apply (drule antisym_less, assumption)
   2.100 -apply simp
   2.101 +lemma antisym_less_up: "\<lbrakk>(x::'a u) \<sqsubseteq> y; y \<sqsubseteq> x\<rbrakk> \<Longrightarrow> x = y"
   2.102 +apply (simp add: less_up_def split: u.split_asm)
   2.103 +apply (erule (1) antisym_less)
   2.104  done
   2.105  
   2.106 -lemma trans_less_up: "\<lbrakk>(p1::'a u) \<sqsubseteq> p2; p2 \<sqsubseteq> p3\<rbrakk> \<Longrightarrow> p1 \<sqsubseteq> p3"
   2.107 -apply (rule_tac p = "p1" in upE)
   2.108 -apply simp
   2.109 -apply (rule_tac p = "p2" in upE)
   2.110 -apply simp
   2.111 -apply (rule_tac p = "p3" in upE)
   2.112 -apply simp
   2.113 -apply (auto elim: trans_less)
   2.114 +lemma trans_less_up: "\<lbrakk>(x::'a u) \<sqsubseteq> y; y \<sqsubseteq> z\<rbrakk> \<Longrightarrow> x \<sqsubseteq> z"
   2.115 +apply (simp add: less_up_def split: u.split_asm)
   2.116 +apply (erule (1) trans_less)
   2.117  done
   2.118  
   2.119  instance u :: (cpo) po
   2.120 @@ -118,7 +69,7 @@
   2.121  apply (rule ub_rangeI)
   2.122  apply (subst Iup_less)
   2.123  apply (erule is_ub_lub)
   2.124 -apply (rule_tac p="u" in upE)
   2.125 +apply (case_tac u)
   2.126  apply (drule ub_rangeD)
   2.127  apply simp
   2.128  apply simp
   2.129 @@ -130,25 +81,25 @@
   2.130  
   2.131  text {* Now some lemmas about chains of @{typ "'a u"} elements *}
   2.132  
   2.133 -lemma up_lemma1: "z \<noteq> Abs_Up None \<Longrightarrow> Iup (THE a. Iup a = z) = z"
   2.134 -by (rule_tac p="z" in upE, simp_all)
   2.135 +lemma up_lemma1: "z \<noteq> Ibottom \<Longrightarrow> Iup (THE a. Iup a = z) = z"
   2.136 +by (case_tac z, simp_all)
   2.137  
   2.138  lemma up_lemma2:
   2.139 -  "\<lbrakk>chain Y; Y j \<noteq> Abs_Up None\<rbrakk> \<Longrightarrow> Y (i + j) \<noteq> Abs_Up None"
   2.140 +  "\<lbrakk>chain Y; Y j \<noteq> Ibottom\<rbrakk> \<Longrightarrow> Y (i + j) \<noteq> Ibottom"
   2.141  apply (erule contrapos_nn)
   2.142  apply (drule_tac x="j" and y="i + j" in chain_mono3)
   2.143  apply (rule le_add2)
   2.144 -apply (rule_tac p="Y j" in upE)
   2.145 +apply (case_tac "Y j")
   2.146  apply assumption
   2.147  apply simp
   2.148  done
   2.149  
   2.150  lemma up_lemma3:
   2.151 -  "\<lbrakk>chain Y; Y j \<noteq> Abs_Up None\<rbrakk> \<Longrightarrow> Iup (THE a. Iup a = Y (i + j)) = Y (i + j)"
   2.152 +  "\<lbrakk>chain Y; Y j \<noteq> Ibottom\<rbrakk> \<Longrightarrow> Iup (THE a. Iup a = Y (i + j)) = Y (i + j)"
   2.153  by (rule up_lemma1 [OF up_lemma2])
   2.154  
   2.155  lemma up_lemma4:
   2.156 -  "\<lbrakk>chain Y; Y j \<noteq> Abs_Up None\<rbrakk> \<Longrightarrow> chain (\<lambda>i. THE a. Iup a = Y (i + j))"
   2.157 +  "\<lbrakk>chain Y; Y j \<noteq> Ibottom\<rbrakk> \<Longrightarrow> chain (\<lambda>i. THE a. Iup a = Y (i + j))"
   2.158  apply (rule chainI)
   2.159  apply (rule Iup_less [THEN iffD1])
   2.160  apply (subst up_lemma3, assumption+)+
   2.161 @@ -156,25 +107,25 @@
   2.162  done
   2.163  
   2.164  lemma up_lemma5:
   2.165 -  "\<lbrakk>chain Y; Y j \<noteq> Abs_Up None\<rbrakk> \<Longrightarrow>
   2.166 +  "\<lbrakk>chain Y; Y j \<noteq> Ibottom\<rbrakk> \<Longrightarrow>
   2.167      (\<lambda>i. Y (i + j)) = (\<lambda>i. Iup (THE a. Iup a = Y (i + j)))"
   2.168  by (rule ext, rule up_lemma3 [symmetric])
   2.169  
   2.170  lemma up_lemma6:
   2.171 -  "\<lbrakk>chain Y; Y j \<noteq> Abs_Up None\<rbrakk>  
   2.172 +  "\<lbrakk>chain Y; Y j \<noteq> Ibottom\<rbrakk>  
   2.173        \<Longrightarrow> range Y <<| Iup (\<Squnion>i. THE a. Iup a = Y(i + j))"
   2.174  apply (rule_tac j1="j" in is_lub_range_shift [THEN iffD1])
   2.175  apply assumption
   2.176  apply (subst up_lemma5, assumption+)
   2.177  apply (rule is_lub_Iup)
   2.178  apply (rule thelubE [OF _ refl])
   2.179 -apply (rule up_lemma4, assumption+)
   2.180 +apply (erule (1) up_lemma4)
   2.181  done
   2.182  
   2.183  lemma up_chain_cases:
   2.184    "chain Y \<Longrightarrow>
   2.185     (\<exists>A. chain A \<and> lub (range Y) = Iup (lub (range A)) \<and>
   2.186 -   (\<exists>j. \<forall>i. Y (i + j) = Iup (A i))) \<or> (Y = (\<lambda>i. Abs_Up None))"
   2.187 +   (\<exists>j. \<forall>i. Y (i + j) = Iup (A i))) \<or> (Y = (\<lambda>i. Ibottom))"
   2.188  apply (rule disjCI)
   2.189  apply (simp add: expand_fun_eq)
   2.190  apply (erule exE, rename_tac j)
   2.191 @@ -192,7 +143,7 @@
   2.192  apply (rule_tac x="Iup (lub (range A))" in exI)
   2.193  apply (erule_tac j1="j" in is_lub_range_shift [THEN iffD1])
   2.194  apply (simp add: is_lub_Iup thelubE)
   2.195 -apply (rule_tac x="Abs_Up None" in exI)
   2.196 +apply (rule_tac x="Ibottom" in exI)
   2.197  apply (rule lub_const)
   2.198  done
   2.199  
   2.200 @@ -202,7 +153,7 @@
   2.201  subsection {* Type @{typ "'a u"} is pointed *}
   2.202  
   2.203  lemma least_up: "EX x::'a u. ALL y. x\<sqsubseteq>y"
   2.204 -apply (rule_tac x = "Abs_Up None" in exI)
   2.205 +apply (rule_tac x = "Ibottom" in exI)
   2.206  apply (rule minimal_up [THEN allI])
   2.207  done
   2.208  
   2.209 @@ -210,21 +161,9 @@
   2.210  by intro_classes (rule least_up)
   2.211  
   2.212  text {* for compatibility with old HOLCF-Version *}
   2.213 -lemma inst_up_pcpo: "\<bottom> = Abs_Up None"
   2.214 +lemma inst_up_pcpo: "\<bottom> = Ibottom"
   2.215  by (rule minimal_up [THEN UU_I, symmetric])
   2.216  
   2.217 -text {* some lemmas restated for class pcpo *}
   2.218 -
   2.219 -lemma less_up3b: "~ Iup(x) \<sqsubseteq> \<bottom>"
   2.220 -apply (subst inst_up_pcpo)
   2.221 -apply simp
   2.222 -done
   2.223 -
   2.224 -lemma defined_Iup2 [iff]: "Iup(x) ~= \<bottom>"
   2.225 -apply (subst inst_up_pcpo)
   2.226 -apply (rule Iup_defined)
   2.227 -done
   2.228 -
   2.229  subsection {* Continuity of @{term Iup} and @{term Ifup} *}
   2.230  
   2.231  text {* continuity for @{term Iup} *}
   2.232 @@ -238,18 +177,12 @@
   2.233  text {* continuity for @{term Ifup} *}
   2.234  
   2.235  lemma cont_Ifup1: "cont (\<lambda>f. Ifup f x)"
   2.236 -apply (rule contI)
   2.237 -apply (rule_tac p="x" in upE)
   2.238 -apply (simp add: lub_const)
   2.239 -apply (simp add: cont_cfun_fun)
   2.240 -done
   2.241 +by (induct x, simp_all)
   2.242  
   2.243  lemma monofun_Ifup2: "monofun (\<lambda>x. Ifup f x)"
   2.244  apply (rule monofunI)
   2.245 -apply (rule_tac p="x" in upE)
   2.246 -apply simp
   2.247 -apply (rule_tac p="y" in upE)
   2.248 -apply simp
   2.249 +apply (case_tac x, simp)
   2.250 +apply (case_tac y, simp)
   2.251  apply (simp add: monofun_cfun_arg)
   2.252  done
   2.253  
   2.254 @@ -272,21 +205,21 @@
   2.255    "fup \<equiv> \<Lambda> f p. Ifup f p"
   2.256  
   2.257  translations
   2.258 -"case l of up\<cdot>x => t1" == "fup\<cdot>(LAM x. t1)\<cdot>l"
   2.259 +"case l of up\<cdot>x \<Rightarrow> t" == "fup\<cdot>(LAM x. t)\<cdot>l"
   2.260  
   2.261  text {* continuous versions of lemmas for @{typ "('a)u"} *}
   2.262  
   2.263 -lemma Exh_Up1: "z = \<bottom> \<or> (\<exists>x. z = up\<cdot>x)"
   2.264 -apply (rule_tac p="z" in upE)
   2.265 +lemma Exh_Up: "z = \<bottom> \<or> (\<exists>x. z = up\<cdot>x)"
   2.266 +apply (induct z)
   2.267  apply (simp add: inst_up_pcpo)
   2.268  apply (simp add: up_def cont_Iup)
   2.269  done
   2.270  
   2.271 -lemma up_inject: "up\<cdot>x = up\<cdot>y \<Longrightarrow> x = y"
   2.272 +lemma up_eq [simp]: "(up\<cdot>x = up\<cdot>y) = (x = y)"
   2.273  by (simp add: up_def cont_Iup)
   2.274  
   2.275 -lemma up_eq [simp]: "(up\<cdot>x = up\<cdot>y) = (x = y)"
   2.276 -by (rule iffI, erule up_inject, simp)
   2.277 +lemma up_inject: "up\<cdot>x = up\<cdot>y \<Longrightarrow> x = y"
   2.278 +by simp
   2.279  
   2.280  lemma up_defined [simp]: " up\<cdot>x \<noteq> \<bottom>"
   2.281  by (simp add: up_def cont_Iup inst_up_pcpo)
   2.282 @@ -297,8 +230,8 @@
   2.283  lemma up_less [simp]: "(up\<cdot>x \<sqsubseteq> up\<cdot>y) = (x \<sqsubseteq> y)"
   2.284  by (simp add: up_def cont_Iup)
   2.285  
   2.286 -lemma upE1: "\<lbrakk>p = \<bottom> \<Longrightarrow> Q; \<And>x. p = up\<cdot>x \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
   2.287 -apply (rule_tac p="p" in upE)
   2.288 +lemma upE: "\<lbrakk>p = \<bottom> \<Longrightarrow> Q; \<And>x. p = up\<cdot>x \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
   2.289 +apply (case_tac p)
   2.290  apply (simp add: inst_up_pcpo)
   2.291  apply (simp add: up_def cont_Iup)
   2.292  done
   2.293 @@ -307,9 +240,9 @@
   2.294  by (simp add: fup_def cont_Ifup1 cont_Ifup2 inst_up_pcpo)
   2.295  
   2.296  lemma fup2 [simp]: "fup\<cdot>f\<cdot>(up\<cdot>x) = f\<cdot>x"
   2.297 -by (simp add: up_def fup_def cont_Iup cont_Ifup1 cont_Ifup2 )
   2.298 +by (simp add: up_def fup_def cont_Iup cont_Ifup1 cont_Ifup2)
   2.299  
   2.300  lemma fup3 [simp]: "fup\<cdot>up\<cdot>x = x"
   2.301 -by (rule_tac p=x in upE1, simp_all)
   2.302 +by (rule_tac p=x in upE, simp_all)
   2.303  
   2.304  end