src/HOLCF/Cfun.thy
author huffman
Fri Jan 18 20:34:28 2008 +0100 (2008-01-18)
changeset 25927 9c544dac6269
parent 25921 0ca392ab7f37
child 26025 ca6876116bb4
permissions -rw-r--r--
add space to binder syntax
     1 (*  Title:      HOLCF/Cfun.thy
     2     ID:         $Id$
     3     Author:     Franz Regensburger
     4 
     5 Definition of the type ->  of continuous functions.
     6 *)
     7 
     8 header {* The type of continuous functions *}
     9 
    10 theory Cfun
    11 imports Pcpodef Ffun
    12 uses ("Tools/cont_proc.ML")
    13 begin
    14 
    15 defaultsort cpo
    16 
    17 subsection {* Definition of continuous function type *}
    18 
    19 lemma Ex_cont: "\<exists>f. cont f"
    20 by (rule exI, rule cont_const)
    21 
    22 lemma adm_cont: "adm cont"
    23 by (rule admI, rule cont_lub_fun)
    24 
    25 cpodef (CFun)  ('a, 'b) "->" (infixr "->" 0) = "{f::'a => 'b. cont f}"
    26 by (simp add: Ex_cont adm_cont)
    27 
    28 syntax (xsymbols)
    29   "->"     :: "[type, type] => type"      ("(_ \<rightarrow>/ _)" [1,0]0)
    30 
    31 notation
    32   Rep_CFun  ("(_$/_)" [999,1000] 999)
    33 
    34 notation (xsymbols)
    35   Rep_CFun  ("(_\<cdot>/_)" [999,1000] 999)
    36 
    37 notation (HTML output)
    38   Rep_CFun  ("(_\<cdot>/_)" [999,1000] 999)
    39 
    40 subsection {* Syntax for continuous lambda abstraction *}
    41 
    42 syntax "_cabs" :: "'a"
    43 
    44 parse_translation {*
    45 (* rewrites (_cabs x t) => (Abs_CFun (%x. t)) *)
    46   [mk_binder_tr ("_cabs", @{const_syntax Abs_CFun})];
    47 *}
    48 
    49 text {* To avoid eta-contraction of body: *}
    50 typed_print_translation {*
    51   let
    52     fun cabs_tr' _ _ [Abs abs] = let
    53           val (x,t) = atomic_abs_tr' abs
    54         in Syntax.const "_cabs" $ x $ t end
    55 
    56       | cabs_tr' _ T [t] = let
    57           val xT = domain_type (domain_type T);
    58           val abs' = ("x",xT,(incr_boundvars 1 t)$Bound 0);
    59           val (x,t') = atomic_abs_tr' abs';
    60         in Syntax.const "_cabs" $ x $ t' end;
    61 
    62   in [(@{const_syntax Abs_CFun}, cabs_tr')] end;
    63 *}
    64 
    65 text {* Syntax for nested abstractions *}
    66 
    67 syntax
    68   "_Lambda" :: "[cargs, 'a] \<Rightarrow> logic"  ("(3LAM _./ _)" [1000, 10] 10)
    69 
    70 syntax (xsymbols)
    71   "_Lambda" :: "[cargs, 'a] \<Rightarrow> logic" ("(3\<Lambda> _./ _)" [1000, 10] 10)
    72 
    73 parse_ast_translation {*
    74 (* rewrites (LAM x y z. t) => (_cabs x (_cabs y (_cabs z t))) *)
    75 (* cf. Syntax.lambda_ast_tr from Syntax/syn_trans.ML *)
    76   let
    77     fun Lambda_ast_tr [pats, body] =
    78           Syntax.fold_ast_p "_cabs" (Syntax.unfold_ast "_cargs" pats, body)
    79       | Lambda_ast_tr asts = raise Syntax.AST ("Lambda_ast_tr", asts);
    80   in [("_Lambda", Lambda_ast_tr)] end;
    81 *}
    82 
    83 print_ast_translation {*
    84 (* rewrites (_cabs x (_cabs y (_cabs z t))) => (LAM x y z. t) *)
    85 (* cf. Syntax.abs_ast_tr' from Syntax/syn_trans.ML *)
    86   let
    87     fun cabs_ast_tr' asts =
    88       (case Syntax.unfold_ast_p "_cabs"
    89           (Syntax.Appl (Syntax.Constant "_cabs" :: asts)) of
    90         ([], _) => raise Syntax.AST ("cabs_ast_tr'", asts)
    91       | (xs, body) => Syntax.Appl
    92           [Syntax.Constant "_Lambda", Syntax.fold_ast "_cargs" xs, body]);
    93   in [("_cabs", cabs_ast_tr')] end;
    94 *}
    95 
    96 text {* Dummy patterns for continuous abstraction *}
    97 translations
    98   "\<Lambda> _. t" => "CONST Abs_CFun (\<lambda> _. t)"
    99 
   100 
   101 subsection {* Continuous function space is pointed *}
   102 
   103 lemma UU_CFun: "\<bottom> \<in> CFun"
   104 by (simp add: CFun_def inst_fun_pcpo cont_const)
   105 
   106 instance "->" :: (finite_po, finite_po) finite_po
   107 by (rule typedef_finite_po [OF type_definition_CFun])
   108 
   109 instance "->" :: (finite_po, chfin) chfin
   110 by (rule typedef_chfin [OF type_definition_CFun less_CFun_def])
   111 
   112 instance "->" :: (cpo, pcpo) pcpo
   113 by (rule typedef_pcpo [OF type_definition_CFun less_CFun_def UU_CFun])
   114 
   115 lemmas Rep_CFun_strict =
   116   typedef_Rep_strict [OF type_definition_CFun less_CFun_def UU_CFun]
   117 
   118 lemmas Abs_CFun_strict =
   119   typedef_Abs_strict [OF type_definition_CFun less_CFun_def UU_CFun]
   120 
   121 text {* function application is strict in its first argument *}
   122 
   123 lemma Rep_CFun_strict1 [simp]: "\<bottom>\<cdot>x = \<bottom>"
   124 by (simp add: Rep_CFun_strict)
   125 
   126 text {* for compatibility with old HOLCF-Version *}
   127 lemma inst_cfun_pcpo: "\<bottom> = (\<Lambda> x. \<bottom>)"
   128 by (simp add: inst_fun_pcpo [symmetric] Abs_CFun_strict)
   129 
   130 subsection {* Basic properties of continuous functions *}
   131 
   132 text {* Beta-equality for continuous functions *}
   133 
   134 lemma Abs_CFun_inverse2: "cont f \<Longrightarrow> Rep_CFun (Abs_CFun f) = f"
   135 by (simp add: Abs_CFun_inverse CFun_def)
   136 
   137 lemma beta_cfun [simp]: "cont f \<Longrightarrow> (\<Lambda> x. f x)\<cdot>u = f u"
   138 by (simp add: Abs_CFun_inverse2)
   139 
   140 text {* Eta-equality for continuous functions *}
   141 
   142 lemma eta_cfun: "(\<Lambda> x. f\<cdot>x) = f"
   143 by (rule Rep_CFun_inverse)
   144 
   145 text {* Extensionality for continuous functions *}
   146 
   147 lemma expand_cfun_eq: "(f = g) = (\<forall>x. f\<cdot>x = g\<cdot>x)"
   148 by (simp add: Rep_CFun_inject [symmetric] expand_fun_eq)
   149 
   150 lemma ext_cfun: "(\<And>x. f\<cdot>x = g\<cdot>x) \<Longrightarrow> f = g"
   151 by (simp add: expand_cfun_eq)
   152 
   153 text {* Extensionality wrt. ordering for continuous functions *}
   154 
   155 lemma expand_cfun_less: "f \<sqsubseteq> g = (\<forall>x. f\<cdot>x \<sqsubseteq> g\<cdot>x)" 
   156 by (simp add: less_CFun_def expand_fun_less)
   157 
   158 lemma less_cfun_ext: "(\<And>x. f\<cdot>x \<sqsubseteq> g\<cdot>x) \<Longrightarrow> f \<sqsubseteq> g"
   159 by (simp add: expand_cfun_less)
   160 
   161 text {* Congruence for continuous function application *}
   162 
   163 lemma cfun_cong: "\<lbrakk>f = g; x = y\<rbrakk> \<Longrightarrow> f\<cdot>x = g\<cdot>y"
   164 by simp
   165 
   166 lemma cfun_fun_cong: "f = g \<Longrightarrow> f\<cdot>x = g\<cdot>x"
   167 by simp
   168 
   169 lemma cfun_arg_cong: "x = y \<Longrightarrow> f\<cdot>x = f\<cdot>y"
   170 by simp
   171 
   172 subsection {* Continuity of application *}
   173 
   174 lemma cont_Rep_CFun1: "cont (\<lambda>f. f\<cdot>x)"
   175 by (rule cont_Rep_CFun [THEN cont2cont_fun])
   176 
   177 lemma cont_Rep_CFun2: "cont (\<lambda>x. f\<cdot>x)"
   178 apply (cut_tac x=f in Rep_CFun)
   179 apply (simp add: CFun_def)
   180 done
   181 
   182 lemmas monofun_Rep_CFun = cont_Rep_CFun [THEN cont2mono]
   183 lemmas contlub_Rep_CFun = cont_Rep_CFun [THEN cont2contlub]
   184 
   185 lemmas monofun_Rep_CFun1 = cont_Rep_CFun1 [THEN cont2mono, standard]
   186 lemmas contlub_Rep_CFun1 = cont_Rep_CFun1 [THEN cont2contlub, standard]
   187 lemmas monofun_Rep_CFun2 = cont_Rep_CFun2 [THEN cont2mono, standard]
   188 lemmas contlub_Rep_CFun2 = cont_Rep_CFun2 [THEN cont2contlub, standard]
   189 
   190 text {* contlub, cont properties of @{term Rep_CFun} in each argument *}
   191 
   192 lemma contlub_cfun_arg: "chain Y \<Longrightarrow> f\<cdot>(lub (range Y)) = (\<Squnion>i. f\<cdot>(Y i))"
   193 by (rule contlub_Rep_CFun2 [THEN contlubE])
   194 
   195 lemma cont_cfun_arg: "chain Y \<Longrightarrow> range (\<lambda>i. f\<cdot>(Y i)) <<| f\<cdot>(lub (range Y))"
   196 by (rule cont_Rep_CFun2 [THEN contE])
   197 
   198 lemma contlub_cfun_fun: "chain F \<Longrightarrow> lub (range F)\<cdot>x = (\<Squnion>i. F i\<cdot>x)"
   199 by (rule contlub_Rep_CFun1 [THEN contlubE])
   200 
   201 lemma cont_cfun_fun: "chain F \<Longrightarrow> range (\<lambda>i. F i\<cdot>x) <<| lub (range F)\<cdot>x"
   202 by (rule cont_Rep_CFun1 [THEN contE])
   203 
   204 text {* monotonicity of application *}
   205 
   206 lemma monofun_cfun_fun: "f \<sqsubseteq> g \<Longrightarrow> f\<cdot>x \<sqsubseteq> g\<cdot>x"
   207 by (simp add: expand_cfun_less)
   208 
   209 lemma monofun_cfun_arg: "x \<sqsubseteq> y \<Longrightarrow> f\<cdot>x \<sqsubseteq> f\<cdot>y"
   210 by (rule monofun_Rep_CFun2 [THEN monofunE])
   211 
   212 lemma monofun_cfun: "\<lbrakk>f \<sqsubseteq> g; x \<sqsubseteq> y\<rbrakk> \<Longrightarrow> f\<cdot>x \<sqsubseteq> g\<cdot>y"
   213 by (rule trans_less [OF monofun_cfun_fun monofun_cfun_arg])
   214 
   215 text {* ch2ch - rules for the type @{typ "'a -> 'b"} *}
   216 
   217 lemma chain_monofun: "chain Y \<Longrightarrow> chain (\<lambda>i. f\<cdot>(Y i))"
   218 by (erule monofun_Rep_CFun2 [THEN ch2ch_monofun])
   219 
   220 lemma ch2ch_Rep_CFunR: "chain Y \<Longrightarrow> chain (\<lambda>i. f\<cdot>(Y i))"
   221 by (rule monofun_Rep_CFun2 [THEN ch2ch_monofun])
   222 
   223 lemma ch2ch_Rep_CFunL: "chain F \<Longrightarrow> chain (\<lambda>i. (F i)\<cdot>x)"
   224 by (rule monofun_Rep_CFun1 [THEN ch2ch_monofun])
   225 
   226 lemma ch2ch_Rep_CFun [simp]:
   227   "\<lbrakk>chain F; chain Y\<rbrakk> \<Longrightarrow> chain (\<lambda>i. (F i)\<cdot>(Y i))"
   228 by (simp add: chain_def monofun_cfun)
   229 
   230 lemma ch2ch_LAM [simp]:
   231   "\<lbrakk>\<And>x. chain (\<lambda>i. S i x); \<And>i. cont (\<lambda>x. S i x)\<rbrakk> \<Longrightarrow> chain (\<lambda>i. \<Lambda> x. S i x)"
   232 by (simp add: chain_def expand_cfun_less)
   233 
   234 text {* contlub, cont properties of @{term Rep_CFun} in both arguments *}
   235 
   236 lemma contlub_cfun: 
   237   "\<lbrakk>chain F; chain Y\<rbrakk> \<Longrightarrow> (\<Squnion>i. F i)\<cdot>(\<Squnion>i. Y i) = (\<Squnion>i. F i\<cdot>(Y i))"
   238 by (simp add: contlub_cfun_fun contlub_cfun_arg diag_lub)
   239 
   240 lemma cont_cfun: 
   241   "\<lbrakk>chain F; chain Y\<rbrakk> \<Longrightarrow> range (\<lambda>i. F i\<cdot>(Y i)) <<| (\<Squnion>i. F i)\<cdot>(\<Squnion>i. Y i)"
   242 apply (rule thelubE)
   243 apply (simp only: ch2ch_Rep_CFun)
   244 apply (simp only: contlub_cfun)
   245 done
   246 
   247 lemma contlub_LAM:
   248   "\<lbrakk>\<And>x. chain (\<lambda>i. F i x); \<And>i. cont (\<lambda>x. F i x)\<rbrakk>
   249     \<Longrightarrow> (\<Lambda> x. \<Squnion>i. F i x) = (\<Squnion>i. \<Lambda> x. F i x)"
   250 apply (simp add: thelub_CFun)
   251 apply (simp add: Abs_CFun_inverse2)
   252 apply (simp add: thelub_fun ch2ch_lambda)
   253 done
   254 
   255 lemmas lub_distribs = 
   256   contlub_cfun [symmetric]
   257   contlub_LAM [symmetric]
   258 
   259 text {* strictness *}
   260 
   261 lemma strictI: "f\<cdot>x = \<bottom> \<Longrightarrow> f\<cdot>\<bottom> = \<bottom>"
   262 apply (rule UU_I)
   263 apply (erule subst)
   264 apply (rule minimal [THEN monofun_cfun_arg])
   265 done
   266 
   267 text {* the lub of a chain of continous functions is monotone *}
   268 
   269 lemma lub_cfun_mono: "chain F \<Longrightarrow> monofun (\<lambda>x. \<Squnion>i. F i\<cdot>x)"
   270 apply (drule ch2ch_monofun [OF monofun_Rep_CFun])
   271 apply (simp add: thelub_fun [symmetric])
   272 apply (erule monofun_lub_fun)
   273 apply (simp add: monofun_Rep_CFun2)
   274 done
   275 
   276 text {* a lemma about the exchange of lubs for type @{typ "'a -> 'b"} *}
   277 
   278 lemma ex_lub_cfun:
   279   "\<lbrakk>chain F; chain Y\<rbrakk> \<Longrightarrow> (\<Squnion>j. \<Squnion>i. F j\<cdot>(Y i)) = (\<Squnion>i. \<Squnion>j. F j\<cdot>(Y i))"
   280 by (simp add: diag_lub)
   281 
   282 text {* the lub of a chain of cont. functions is continuous *}
   283 
   284 lemma cont_lub_cfun: "chain F \<Longrightarrow> cont (\<lambda>x. \<Squnion>i. F i\<cdot>x)"
   285 apply (rule cont2cont_lub)
   286 apply (erule monofun_Rep_CFun [THEN ch2ch_monofun])
   287 apply (rule cont_Rep_CFun2)
   288 done
   289 
   290 text {* type @{typ "'a -> 'b"} is chain complete *}
   291 
   292 lemma lub_cfun: "chain F \<Longrightarrow> range F <<| (\<Lambda> x. \<Squnion>i. F i\<cdot>x)"
   293 by (simp only: contlub_cfun_fun [symmetric] eta_cfun thelubE)
   294 
   295 lemma thelub_cfun: "chain F \<Longrightarrow> lub (range F) = (\<Lambda> x. \<Squnion>i. F i\<cdot>x)"
   296 by (rule lub_cfun [THEN thelubI])
   297 
   298 subsection {* Continuity simplification procedure *}
   299 
   300 text {* cont2cont lemma for @{term Rep_CFun} *}
   301 
   302 lemma cont2cont_Rep_CFun:
   303   "\<lbrakk>cont f; cont t\<rbrakk> \<Longrightarrow> cont (\<lambda>x. (f x)\<cdot>(t x))"
   304 by (best intro: cont2cont_app2 cont_const cont_Rep_CFun cont_Rep_CFun2)
   305 
   306 text {* cont2mono Lemma for @{term "%x. LAM y. c1(x)(y)"} *}
   307 
   308 lemma cont2mono_LAM:
   309 assumes p1: "!!x. cont(c1 x)"
   310 assumes p2: "!!y. monofun(%x. c1 x y)"
   311 shows "monofun(%x. LAM y. c1 x y)"
   312 apply (rule monofunI)
   313 apply (rule less_cfun_ext)
   314 apply (simp add: p1)
   315 apply (erule p2 [THEN monofunE])
   316 done
   317 
   318 text {* cont2cont Lemma for @{term "%x. LAM y. c1 x y"} *}
   319 
   320 lemma cont2cont_LAM:
   321 assumes p1: "!!x. cont(c1 x)"
   322 assumes p2: "!!y. cont(%x. c1 x y)"
   323 shows "cont(%x. LAM y. c1 x y)"
   324 apply (rule cont_Abs_CFun)
   325 apply (simp add: p1 CFun_def)
   326 apply (simp add: p2 cont2cont_lambda)
   327 done
   328 
   329 text {* continuity simplification procedure *}
   330 
   331 lemmas cont_lemmas1 =
   332   cont_const cont_id cont_Rep_CFun2 cont2cont_Rep_CFun cont2cont_LAM
   333 
   334 use "Tools/cont_proc.ML";
   335 setup ContProc.setup;
   336 
   337 (*val cont_tac = (fn i => (resolve_tac cont_lemmas i));*)
   338 (*val cont_tacR = (fn i => (REPEAT (cont_tac i)));*)
   339 
   340 subsection {* Miscellaneous *}
   341 
   342 text {* Monotonicity of @{term Abs_CFun} *}
   343 
   344 lemma semi_monofun_Abs_CFun:
   345   "\<lbrakk>cont f; cont g; f \<sqsubseteq> g\<rbrakk> \<Longrightarrow> Abs_CFun f \<sqsubseteq> Abs_CFun g"
   346 by (simp add: less_CFun_def Abs_CFun_inverse2)
   347 
   348 text {* some lemmata for functions with flat/chfin domain/range types *}
   349 
   350 lemma chfin_Rep_CFunR: "chain (Y::nat => 'a::cpo->'b::chfin)  
   351       ==> !s. ? n. lub(range(Y))$s = Y n$s"
   352 apply (rule allI)
   353 apply (subst contlub_cfun_fun)
   354 apply assumption
   355 apply (fast intro!: thelubI chfin lub_finch2 chfin2finch ch2ch_Rep_CFunL)
   356 done
   357 
   358 lemma adm_chfindom: "adm (\<lambda>(u::'a::cpo \<rightarrow> 'b::chfin). P(u\<cdot>s))"
   359 by (rule adm_subst, simp, rule adm_chfin)
   360 
   361 subsection {* Continuous injection-retraction pairs *}
   362 
   363 text {* Continuous retractions are strict. *}
   364 
   365 lemma retraction_strict:
   366   "\<forall>x. f\<cdot>(g\<cdot>x) = x \<Longrightarrow> f\<cdot>\<bottom> = \<bottom>"
   367 apply (rule UU_I)
   368 apply (drule_tac x="\<bottom>" in spec)
   369 apply (erule subst)
   370 apply (rule monofun_cfun_arg)
   371 apply (rule minimal)
   372 done
   373 
   374 lemma injection_eq:
   375   "\<forall>x. f\<cdot>(g\<cdot>x) = x \<Longrightarrow> (g\<cdot>x = g\<cdot>y) = (x = y)"
   376 apply (rule iffI)
   377 apply (drule_tac f=f in cfun_arg_cong)
   378 apply simp
   379 apply simp
   380 done
   381 
   382 lemma injection_less:
   383   "\<forall>x. f\<cdot>(g\<cdot>x) = x \<Longrightarrow> (g\<cdot>x \<sqsubseteq> g\<cdot>y) = (x \<sqsubseteq> y)"
   384 apply (rule iffI)
   385 apply (drule_tac f=f in monofun_cfun_arg)
   386 apply simp
   387 apply (erule monofun_cfun_arg)
   388 done
   389 
   390 lemma injection_defined_rev:
   391   "\<lbrakk>\<forall>x. f\<cdot>(g\<cdot>x) = x; g\<cdot>z = \<bottom>\<rbrakk> \<Longrightarrow> z = \<bottom>"
   392 apply (drule_tac f=f in cfun_arg_cong)
   393 apply (simp add: retraction_strict)
   394 done
   395 
   396 lemma injection_defined:
   397   "\<lbrakk>\<forall>x. f\<cdot>(g\<cdot>x) = x; z \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> g\<cdot>z \<noteq> \<bottom>"
   398 by (erule contrapos_nn, rule injection_defined_rev)
   399 
   400 text {* propagation of flatness and chain-finiteness by retractions *}
   401 
   402 lemma chfin2chfin:
   403   "\<forall>y. (f::'a::chfin \<rightarrow> 'b)\<cdot>(g\<cdot>y) = y
   404     \<Longrightarrow> \<forall>Y::nat \<Rightarrow> 'b. chain Y \<longrightarrow> (\<exists>n. max_in_chain n Y)"
   405 apply clarify
   406 apply (drule_tac f=g in chain_monofun)
   407 apply (drule chfin)
   408 apply (unfold max_in_chain_def)
   409 apply (simp add: injection_eq)
   410 done
   411 
   412 lemma flat2flat:
   413   "\<forall>y. (f::'a::flat \<rightarrow> 'b::pcpo)\<cdot>(g\<cdot>y) = y
   414     \<Longrightarrow> \<forall>x y::'b. x \<sqsubseteq> y \<longrightarrow> x = \<bottom> \<or> x = y"
   415 apply clarify
   416 apply (drule_tac f=g in monofun_cfun_arg)
   417 apply (drule ax_flat)
   418 apply (erule disjE)
   419 apply (simp add: injection_defined_rev)
   420 apply (simp add: injection_eq)
   421 done
   422 
   423 text {* a result about functions with flat codomain *}
   424 
   425 lemma flat_eqI: "\<lbrakk>(x::'a::flat) \<sqsubseteq> y; x \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> x = y"
   426 by (drule ax_flat, simp)
   427 
   428 lemma flat_codom:
   429   "f\<cdot>x = (c::'b::flat) \<Longrightarrow> f\<cdot>\<bottom> = \<bottom> \<or> (\<forall>z. f\<cdot>z = c)"
   430 apply (case_tac "f\<cdot>x = \<bottom>")
   431 apply (rule disjI1)
   432 apply (rule UU_I)
   433 apply (erule_tac t="\<bottom>" in subst)
   434 apply (rule minimal [THEN monofun_cfun_arg])
   435 apply clarify
   436 apply (rule_tac a = "f\<cdot>\<bottom>" in refl [THEN box_equals])
   437 apply (erule minimal [THEN monofun_cfun_arg, THEN flat_eqI])
   438 apply (erule minimal [THEN monofun_cfun_arg, THEN flat_eqI])
   439 done
   440 
   441 
   442 subsection {* Identity and composition *}
   443 
   444 definition
   445   ID :: "'a \<rightarrow> 'a" where
   446   "ID = (\<Lambda> x. x)"
   447 
   448 definition
   449   cfcomp  :: "('b \<rightarrow> 'c) \<rightarrow> ('a \<rightarrow> 'b) \<rightarrow> 'a \<rightarrow> 'c" where
   450   oo_def: "cfcomp = (\<Lambda> f g x. f\<cdot>(g\<cdot>x))"
   451 
   452 abbreviation
   453   cfcomp_syn :: "['b \<rightarrow> 'c, 'a \<rightarrow> 'b] \<Rightarrow> 'a \<rightarrow> 'c"  (infixr "oo" 100)  where
   454   "f oo g == cfcomp\<cdot>f\<cdot>g"
   455 
   456 lemma ID1 [simp]: "ID\<cdot>x = x"
   457 by (simp add: ID_def)
   458 
   459 lemma cfcomp1: "(f oo g) = (\<Lambda> x. f\<cdot>(g\<cdot>x))"
   460 by (simp add: oo_def)
   461 
   462 lemma cfcomp2 [simp]: "(f oo g)\<cdot>x = f\<cdot>(g\<cdot>x)"
   463 by (simp add: cfcomp1)
   464 
   465 lemma cfcomp_strict [simp]: "\<bottom> oo f = \<bottom>"
   466 by (simp add: expand_cfun_eq)
   467 
   468 text {*
   469   Show that interpretation of (pcpo,@{text "_->_"}) is a category.
   470   The class of objects is interpretation of syntactical class pcpo.
   471   The class of arrows  between objects @{typ 'a} and @{typ 'b} is interpret. of @{typ "'a -> 'b"}.
   472   The identity arrow is interpretation of @{term ID}.
   473   The composition of f and g is interpretation of @{text "oo"}.
   474 *}
   475 
   476 lemma ID2 [simp]: "f oo ID = f"
   477 by (rule ext_cfun, simp)
   478 
   479 lemma ID3 [simp]: "ID oo f = f"
   480 by (rule ext_cfun, simp)
   481 
   482 lemma assoc_oo: "f oo (g oo h) = (f oo g) oo h"
   483 by (rule ext_cfun, simp)
   484 
   485 
   486 subsection {* Strictified functions *}
   487 
   488 defaultsort pcpo
   489 
   490 definition
   491   strictify  :: "('a \<rightarrow> 'b) \<rightarrow> 'a \<rightarrow> 'b" where
   492   "strictify = (\<Lambda> f x. if x = \<bottom> then \<bottom> else f\<cdot>x)"
   493 
   494 text {* results about strictify *}
   495 
   496 lemma cont_strictify1: "cont (\<lambda>f. if x = \<bottom> then \<bottom> else f\<cdot>x)"
   497 by (simp add: cont_if)
   498 
   499 lemma monofun_strictify2: "monofun (\<lambda>x. if x = \<bottom> then \<bottom> else f\<cdot>x)"
   500 apply (rule monofunI)
   501 apply (auto simp add: monofun_cfun_arg)
   502 done
   503 
   504 (*FIXME: long proof*)
   505 lemma contlub_strictify2: "contlub (\<lambda>x. if x = \<bottom> then \<bottom> else f\<cdot>x)"
   506 apply (rule contlubI)
   507 apply (case_tac "lub (range Y) = \<bottom>")
   508 apply (drule (1) chain_UU_I)
   509 apply simp
   510 apply (simp del: if_image_distrib)
   511 apply (simp only: contlub_cfun_arg)
   512 apply (rule lub_equal2)
   513 apply (rule chain_mono2 [THEN exE])
   514 apply (erule chain_UU_I_inverse2)
   515 apply (assumption)
   516 apply (rule_tac x=x in exI, clarsimp)
   517 apply (erule chain_monofun)
   518 apply (erule monofun_strictify2 [THEN ch2ch_monofun])
   519 done
   520 
   521 lemmas cont_strictify2 =
   522   monocontlub2cont [OF monofun_strictify2 contlub_strictify2, standard]
   523 
   524 lemma strictify_conv_if: "strictify\<cdot>f\<cdot>x = (if x = \<bottom> then \<bottom> else f\<cdot>x)"
   525 by (unfold strictify_def, simp add: cont_strictify1 cont_strictify2)
   526 
   527 lemma strictify1 [simp]: "strictify\<cdot>f\<cdot>\<bottom> = \<bottom>"
   528 by (simp add: strictify_conv_if)
   529 
   530 lemma strictify2 [simp]: "x \<noteq> \<bottom> \<Longrightarrow> strictify\<cdot>f\<cdot>x = f\<cdot>x"
   531 by (simp add: strictify_conv_if)
   532 
   533 subsection {* Continuous let-bindings *}
   534 
   535 definition
   536   CLet :: "'a \<rightarrow> ('a \<rightarrow> 'b) \<rightarrow> 'b" where
   537   "CLet = (\<Lambda> s f. f\<cdot>s)"
   538 
   539 syntax
   540   "_CLet" :: "[letbinds, 'a] => 'a" ("(Let (_)/ in (_))" 10)
   541 
   542 translations
   543   "_CLet (_binds b bs) e" == "_CLet b (_CLet bs e)"
   544   "Let x = a in e" == "CONST CLet\<cdot>a\<cdot>(\<Lambda> x. e)"
   545 
   546 end