src/HOLCF/Cfun.thy
author huffman
Thu Mar 31 03:03:22 2005 +0200 (2005-03-31)
changeset 15641 b389f108c485
parent 15600 a59f07556a8d
child 16055 58186c507750
permissions -rw-r--r--
added theorems eta_cfun and cont2cont_eta
huffman@15600
     1
(*  Title:      HOLCF/Cfun.thy
huffman@15576
     2
    ID:         $Id$
huffman@15576
     3
    Author:     Franz Regensburger
huffman@15576
     4
    License:    GPL (GNU GENERAL PUBLIC LICENSE)
huffman@15576
     5
huffman@15576
     6
Definition of the type ->  of continuous functions.
huffman@15576
     7
huffman@15576
     8
*)
huffman@15576
     9
huffman@15576
    10
header {* The type of continuous functions *}
huffman@15576
    11
huffman@15577
    12
theory Cfun
huffman@15577
    13
imports Cont
huffman@15577
    14
begin
huffman@15576
    15
huffman@15576
    16
defaultsort cpo
huffman@15576
    17
huffman@15589
    18
subsection {* Definition of continuous function type *}
huffman@15589
    19
huffman@15576
    20
typedef (CFun)  ('a, 'b) "->" (infixr 0) = "{f::'a => 'b. cont f}"
huffman@15576
    21
by (rule exI, rule CfunI)
huffman@15576
    22
huffman@15576
    23
syntax
huffman@15576
    24
	Rep_CFun  :: "('a -> 'b) => ('a => 'b)" ("_$_" [999,1000] 999)
huffman@15576
    25
                                                (* application      *)
huffman@15576
    26
        Abs_CFun  :: "('a => 'b) => ('a -> 'b)" (binder "LAM " 10)
huffman@15576
    27
                                                (* abstraction      *)
huffman@15576
    28
        less_cfun :: "[('a -> 'b),('a -> 'b)]=>bool"
huffman@15576
    29
huffman@15576
    30
syntax (xsymbols)
huffman@15576
    31
  "->"		:: "[type, type] => type"      ("(_ \<rightarrow>/ _)" [1,0]0)
huffman@15576
    32
  "LAM "	:: "[idts, 'a => 'b] => ('a -> 'b)"
huffman@15576
    33
					("(3\<Lambda>_./ _)" [0, 10] 10)
huffman@15576
    34
  Rep_CFun      :: "('a -> 'b) => ('a => 'b)"  ("(_\<cdot>_)" [999,1000] 999)
huffman@15576
    35
huffman@15576
    36
syntax (HTML output)
huffman@15576
    37
  Rep_CFun      :: "('a -> 'b) => ('a => 'b)"  ("(_\<cdot>_)" [999,1000] 999)
huffman@15576
    38
huffman@15589
    39
text {*
huffman@15589
    40
  Derive old type definition rules for @{term Abs_CFun} \& @{term Rep_CFun}.
huffman@15589
    41
  @{term Rep_CFun} and @{term Abs_CFun} should be replaced by
huffman@15589
    42
  @{term Rep_Cfun} and @{term Abs_Cfun} in future.
huffman@15589
    43
*}
huffman@15576
    44
huffman@15576
    45
lemma Rep_Cfun: "Rep_CFun fo : CFun"
huffman@15589
    46
by (rule Rep_CFun)
huffman@15576
    47
huffman@15576
    48
lemma Rep_Cfun_inverse: "Abs_CFun (Rep_CFun fo) = fo"
huffman@15589
    49
by (rule Rep_CFun_inverse)
huffman@15576
    50
huffman@15576
    51
lemma Abs_Cfun_inverse: "f:CFun==>Rep_CFun(Abs_CFun f)=f"
huffman@15589
    52
by (erule Abs_CFun_inverse)
huffman@15576
    53
huffman@15589
    54
text {* Additional lemma about the isomorphism between
huffman@15589
    55
        @{typ "'a -> 'b"} and @{term Cfun} *}
huffman@15576
    56
huffman@15576
    57
lemma Abs_Cfun_inverse2: "cont f ==> Rep_CFun (Abs_CFun f) = f"
huffman@15576
    58
apply (rule Abs_Cfun_inverse)
huffman@15576
    59
apply (unfold CFun_def)
huffman@15576
    60
apply (erule mem_Collect_eq [THEN ssubst])
huffman@15576
    61
done
huffman@15576
    62
huffman@15589
    63
text {* Simplification of application *}
huffman@15576
    64
huffman@15576
    65
lemma Cfunapp2: "cont f ==> (Abs_CFun f)$x = f x"
huffman@15589
    66
by (erule Abs_Cfun_inverse2 [THEN fun_cong])
huffman@15576
    67
huffman@15589
    68
text {* Beta - equality for continuous functions *}
huffman@15576
    69
huffman@15576
    70
lemma beta_cfun: "cont(c1) ==> (LAM x .c1 x)$u = c1 u"
huffman@15589
    71
by (rule Cfunapp2)
huffman@15589
    72
huffman@15641
    73
text {* Eta - equality for continuous functions *}
huffman@15641
    74
huffman@15641
    75
lemma eta_cfun: "(LAM x. f$x) = f"
huffman@15641
    76
by (rule Rep_CFun_inverse)
huffman@15641
    77
huffman@15589
    78
subsection {* Type @{typ "'a -> 'b"} is a partial order *}
huffman@15589
    79
huffman@15589
    80
instance "->"  :: (cpo, cpo) sq_ord ..
huffman@15576
    81
huffman@15589
    82
defs (overloaded)
huffman@15589
    83
  less_cfun_def: "(op <<) == (% fo1 fo2. Rep_CFun fo1 << Rep_CFun fo2 )"
huffman@15576
    84
huffman@15589
    85
lemma refl_less_cfun: "(f::'a->'b) << f"
huffman@15589
    86
by (unfold less_cfun_def, rule refl_less)
huffman@15576
    87
huffman@15589
    88
lemma antisym_less_cfun: 
huffman@15589
    89
        "[|(f1::'a->'b) << f2; f2 << f1|] ==> f1 = f2"
huffman@15589
    90
by (unfold less_cfun_def, rule Rep_CFun_inject[THEN iffD1], rule antisym_less)
huffman@15576
    91
huffman@15589
    92
lemma trans_less_cfun: 
huffman@15589
    93
        "[|(f1::'a->'b) << f2; f2 << f3|] ==> f1 << f3"
huffman@15589
    94
by (unfold less_cfun_def, rule trans_less)
huffman@15576
    95
huffman@15589
    96
instance "->" :: (cpo, cpo) po
huffman@15589
    97
by intro_classes
huffman@15589
    98
  (assumption | rule refl_less_cfun antisym_less_cfun trans_less_cfun)+
huffman@15589
    99
huffman@15589
   100
text {* for compatibility with old HOLCF-Version *}
huffman@15576
   101
lemma inst_cfun_po: "(op <<)=(%f1 f2. Rep_CFun f1 << Rep_CFun f2)"
huffman@15576
   102
apply (fold less_cfun_def)
huffman@15576
   103
apply (rule refl)
huffman@15576
   104
done
huffman@15576
   105
huffman@15589
   106
text {* lemmas about application of continuous functions *}
huffman@15589
   107
huffman@15589
   108
lemma cfun_cong: "[| f=g; x=y |] ==> f$x = g$y"
huffman@15589
   109
by simp
huffman@15589
   110
huffman@15589
   111
lemma cfun_fun_cong: "f=g ==> f$x = g$x"
huffman@15589
   112
by simp
huffman@15589
   113
huffman@15589
   114
lemma cfun_arg_cong: "x=y ==> f$x = f$y"
huffman@15589
   115
by simp
huffman@15589
   116
huffman@15589
   117
text {* access to @{term less_cfun} in class po *}
huffman@15576
   118
huffman@15576
   119
lemma less_cfun: "( f1 << f2 ) = (Rep_CFun(f1) << Rep_CFun(f2))"
huffman@15589
   120
by (simp add: inst_cfun_po)
huffman@15576
   121
huffman@15589
   122
subsection {* Type @{typ "'a -> 'b"} is pointed *}
huffman@15576
   123
huffman@15576
   124
lemma minimal_cfun: "Abs_CFun(% x. UU) << f"
huffman@15576
   125
apply (subst less_cfun)
huffman@15576
   126
apply (subst Abs_Cfun_inverse2)
huffman@15576
   127
apply (rule cont_const)
huffman@15576
   128
apply (rule minimal_fun)
huffman@15576
   129
done
huffman@15576
   130
huffman@15576
   131
lemmas UU_cfun_def = minimal_cfun [THEN minimal2UU, symmetric, standard]
huffman@15576
   132
huffman@15576
   133
lemma least_cfun: "? x::'a->'b::pcpo.!y. x<<y"
huffman@15576
   134
apply (rule_tac x = "Abs_CFun (% x. UU) " in exI)
huffman@15576
   135
apply (rule minimal_cfun [THEN allI])
huffman@15576
   136
done
huffman@15576
   137
huffman@15589
   138
subsection {* Monotonicity of application *}
huffman@15589
   139
huffman@15589
   140
text {*
huffman@15589
   141
  @{term Rep_CFun} yields continuous functions in @{typ "'a => 'b"}.
huffman@15589
   142
  This is continuity of @{term Rep_CFun} in its 'second' argument:
huffman@15589
   143
  @{prop "cont_Rep_CFun2 ==> monofun_Rep_CFun2 & contlub_Rep_CFun2"}
huffman@15589
   144
*}
huffman@15576
   145
huffman@15576
   146
lemma cont_Rep_CFun2: "cont(Rep_CFun(fo))"
huffman@15576
   147
apply (rule_tac P = "cont" in CollectD)
huffman@15576
   148
apply (fold CFun_def)
huffman@15576
   149
apply (rule Rep_Cfun)
huffman@15576
   150
done
huffman@15576
   151
huffman@15576
   152
lemmas monofun_Rep_CFun2 = cont_Rep_CFun2 [THEN cont2mono, standard]
huffman@15589
   153
 -- {* @{thm monofun_Rep_CFun2} *} (* monofun(Rep_CFun(?fo)) *)
huffman@15576
   154
huffman@15576
   155
lemmas contlub_Rep_CFun2 = cont_Rep_CFun2 [THEN cont2contlub, standard]
huffman@15589
   156
 -- {* @{thm contlub_Rep_CFun2} *} (* contlub(Rep_CFun(?fo)) *)
huffman@15576
   157
huffman@15589
   158
text {* expanded thms @{thm [source] cont_Rep_CFun2}, @{thm [source] contlub_Rep_CFun2} look nice with mixfix syntax *}
huffman@15576
   159
huffman@15576
   160
lemmas cont_cfun_arg = cont_Rep_CFun2 [THEN contE, THEN spec, THEN mp]
huffman@15589
   161
  -- {* @{thm cont_cfun_arg} *} (* chain(x1) ==> range (%i. fo3$(x1 i)) <<| fo3$(lub (range ?x1))    *)
huffman@15576
   162
 
huffman@15576
   163
lemmas contlub_cfun_arg = contlub_Rep_CFun2 [THEN contlubE, THEN spec, THEN mp]
huffman@15589
   164
 -- {* @{thm contlub_cfun_arg} *} (* chain(?x1) ==> ?fo4$(lub (range ?x1)) = lub (range (%i. ?fo4$(?x1 i))) *)
huffman@15576
   165
huffman@15589
   166
text {* @{term Rep_CFun} is monotone in its 'first' argument *}
huffman@15576
   167
huffman@15576
   168
lemma monofun_Rep_CFun1: "monofun(Rep_CFun)"
huffman@15589
   169
apply (rule monofunI [rule_format])
huffman@15576
   170
apply (erule less_cfun [THEN subst])
huffman@15576
   171
done
huffman@15576
   172
huffman@15589
   173
text {* monotonicity of application @{term Rep_CFun} in mixfix syntax @{text "[_]_"} *}
huffman@15576
   174
huffman@15576
   175
lemma monofun_cfun_fun: "f1 << f2 ==> f1$x << f2$x"
huffman@15576
   176
apply (rule_tac x = "x" in spec)
huffman@15576
   177
apply (rule less_fun [THEN subst])
huffman@15589
   178
apply (erule monofun_Rep_CFun1 [THEN monofunE [rule_format]])
huffman@15576
   179
done
huffman@15576
   180
huffman@15589
   181
lemmas monofun_cfun_arg = monofun_Rep_CFun2 [THEN monofunE [rule_format], standard]
huffman@15589
   182
 -- {* @{thm monofun_cfun_arg} *} (* ?x2 << ?x1 ==> ?fo5$?x2 << ?fo5$?x1 *)
huffman@15576
   183
huffman@15576
   184
lemma chain_monofun: "chain Y ==> chain (%i. f\<cdot>(Y i))"
huffman@15576
   185
apply (rule chainI)
huffman@15576
   186
apply (rule monofun_cfun_arg)
huffman@15576
   187
apply (erule chainE)
huffman@15576
   188
done
huffman@15576
   189
huffman@15589
   190
text {* monotonicity of @{term Rep_CFun} in both arguments in mixfix syntax @{text "[_]_"} *}
huffman@15576
   191
huffman@15576
   192
lemma monofun_cfun: "[|f1<<f2;x1<<x2|] ==> f1$x1 << f2$x2"
huffman@15576
   193
apply (rule trans_less)
huffman@15576
   194
apply (erule monofun_cfun_arg)
huffman@15576
   195
apply (erule monofun_cfun_fun)
huffman@15576
   196
done
huffman@15576
   197
huffman@15576
   198
lemma strictI: "f$x = UU ==> f$UU = UU"
huffman@15576
   199
apply (rule eq_UU_iff [THEN iffD2])
huffman@15576
   200
apply (erule subst)
huffman@15576
   201
apply (rule minimal [THEN monofun_cfun_arg])
huffman@15576
   202
done
huffman@15576
   203
huffman@15589
   204
subsection {* Type @{typ "'a -> 'b"} is a cpo *}
huffman@15576
   205
huffman@15589
   206
text {* ch2ch - rules for the type @{typ "'a -> 'b"} use MF2 lemmas from Cont.thy *}
huffman@15576
   207
huffman@15576
   208
lemma ch2ch_Rep_CFunR: "chain(Y) ==> chain(%i. f$(Y i))"
huffman@15589
   209
by (erule monofun_Rep_CFun2 [THEN ch2ch_MF2R])
huffman@15576
   210
huffman@15576
   211
lemmas ch2ch_Rep_CFunL = monofun_Rep_CFun1 [THEN ch2ch_MF2L, standard]
huffman@15589
   212
 -- {* @{thm ch2ch_Rep_CFunL} *} (* chain(?F) ==> chain (%i. ?F i$?x) *)
huffman@15576
   213
huffman@15589
   214
text {* the lub of a chain of continous functions is monotone: uses MF2 lemmas from Cont.thy *}
huffman@15576
   215
huffman@15576
   216
lemma lub_cfun_mono: "chain(F) ==> monofun(% x. lub(range(% j.(F j)$x)))"
huffman@15576
   217
apply (rule lub_MF2_mono)
huffman@15576
   218
apply (rule monofun_Rep_CFun1)
huffman@15576
   219
apply (rule monofun_Rep_CFun2 [THEN allI])
huffman@15576
   220
apply assumption
huffman@15576
   221
done
huffman@15576
   222
huffman@15589
   223
text {* a lemma about the exchange of lubs for type @{typ "'a -> 'b"}: uses MF2 lemmas from Cont.thy *}
huffman@15576
   224
huffman@15576
   225
lemma ex_lubcfun: "[| chain(F); chain(Y) |] ==> 
huffman@15576
   226
                lub(range(%j. lub(range(%i. F(j)$(Y i))))) = 
huffman@15576
   227
                lub(range(%i. lub(range(%j. F(j)$(Y i)))))"
huffman@15576
   228
apply (rule ex_lubMF2)
huffman@15576
   229
apply (rule monofun_Rep_CFun1)
huffman@15576
   230
apply (rule monofun_Rep_CFun2 [THEN allI])
huffman@15576
   231
apply assumption
huffman@15576
   232
apply assumption
huffman@15576
   233
done
huffman@15576
   234
huffman@15589
   235
text {* the lub of a chain of cont. functions is continuous *}
huffman@15576
   236
huffman@15576
   237
lemma cont_lubcfun: "chain(F) ==> cont(% x. lub(range(% j. F(j)$x)))"
huffman@15576
   238
apply (rule monocontlub2cont)
huffman@15576
   239
apply (erule lub_cfun_mono)
huffman@15589
   240
apply (rule contlubI [rule_format])
huffman@15576
   241
apply (subst contlub_cfun_arg [THEN ext])
huffman@15576
   242
apply assumption
huffman@15576
   243
apply (erule ex_lubcfun)
huffman@15576
   244
apply assumption
huffman@15576
   245
done
huffman@15576
   246
huffman@15589
   247
text {* type @{typ "'a -> 'b"} is chain complete *}
huffman@15576
   248
huffman@15576
   249
lemma lub_cfun: "chain(CCF) ==> range(CCF) <<| (LAM x. lub(range(% i. CCF(i)$x)))"
huffman@15576
   250
apply (rule is_lubI)
huffman@15576
   251
apply (rule ub_rangeI)
huffman@15576
   252
apply (subst less_cfun)
huffman@15576
   253
apply (subst Abs_Cfun_inverse2)
huffman@15576
   254
apply (erule cont_lubcfun)
huffman@15576
   255
apply (rule lub_fun [THEN is_lubD1, THEN ub_rangeD])
huffman@15576
   256
apply (erule monofun_Rep_CFun1 [THEN ch2ch_monofun])
huffman@15576
   257
apply (subst less_cfun)
huffman@15576
   258
apply (subst Abs_Cfun_inverse2)
huffman@15576
   259
apply (erule cont_lubcfun)
huffman@15576
   260
apply (rule lub_fun [THEN is_lub_lub])
huffman@15576
   261
apply (erule monofun_Rep_CFun1 [THEN ch2ch_monofun])
huffman@15576
   262
apply (erule monofun_Rep_CFun1 [THEN ub2ub_monofun])
huffman@15576
   263
done
huffman@15576
   264
huffman@15576
   265
lemmas thelub_cfun = lub_cfun [THEN thelubI, standard]
huffman@15589
   266
 -- {* @{thm thelub_cfun} *} (* 
huffman@15576
   267
chain(?CCF1) ==>  lub (range ?CCF1) = (LAM x. lub (range (%i. ?CCF1 i$x)))
huffman@15576
   268
*)
huffman@15576
   269
huffman@15576
   270
lemma cpo_cfun: "chain(CCF::nat=>('a->'b)) ==> ? x. range(CCF) <<| x"
huffman@15576
   271
apply (rule exI)
huffman@15576
   272
apply (erule lub_cfun)
huffman@15576
   273
done
huffman@15576
   274
huffman@15589
   275
instance "->" :: (cpo, cpo) cpo
huffman@15589
   276
by intro_classes (rule cpo_cfun)
huffman@15576
   277
huffman@15589
   278
subsection {* Miscellaneous *}
huffman@15589
   279
huffman@15589
   280
text {* Extensionality in @{typ "'a -> 'b"} *}
huffman@15576
   281
huffman@15576
   282
lemma ext_cfun: "(!!x. f$x = g$x) ==> f = g"
huffman@15589
   283
apply (rule Rep_CFun_inject [THEN iffD1])
huffman@15576
   284
apply (rule ext)
huffman@15576
   285
apply simp
huffman@15576
   286
done
huffman@15576
   287
huffman@15589
   288
text {* Monotonicity of @{term Abs_CFun} *}
huffman@15576
   289
huffman@15576
   290
lemma semi_monofun_Abs_CFun: "[| cont(f); cont(g); f<<g|] ==> Abs_CFun(f)<<Abs_CFun(g)"
huffman@15589
   291
by (simp add: less_cfun Abs_Cfun_inverse2)
huffman@15576
   292
huffman@15589
   293
text {* Extensionality wrt. @{term "op <<"} in @{typ "'a -> 'b"} *}
huffman@15576
   294
huffman@15576
   295
lemma less_cfun2: "(!!x. f$x << g$x) ==> f << g"
huffman@15576
   296
apply (rule_tac t = "f" in Rep_Cfun_inverse [THEN subst])
huffman@15576
   297
apply (rule_tac t = "g" in Rep_Cfun_inverse [THEN subst])
huffman@15576
   298
apply (rule semi_monofun_Abs_CFun)
huffman@15576
   299
apply (rule cont_Rep_CFun2)
huffman@15576
   300
apply (rule cont_Rep_CFun2)
huffman@15576
   301
apply (rule less_fun [THEN iffD2])
huffman@15576
   302
apply simp
huffman@15576
   303
done
huffman@15576
   304
huffman@15589
   305
subsection {* Class instance of @{typ "'a -> 'b"} for class pcpo *}
huffman@15576
   306
huffman@15589
   307
instance "->" :: (cpo, pcpo) pcpo
huffman@15576
   308
by (intro_classes, rule least_cfun)
huffman@15576
   309
huffman@15589
   310
text {* for compatibility with old HOLCF-Version *}
huffman@15576
   311
lemma inst_cfun_pcpo: "UU = Abs_CFun(%x. UU)"
huffman@15576
   312
apply (simp add: UU_def UU_cfun_def)
huffman@15576
   313
done
huffman@15576
   314
huffman@15589
   315
defaultsort pcpo
huffman@15589
   316
huffman@15589
   317
subsection {* Continuity of application *}
huffman@15589
   318
huffman@15589
   319
text {* the contlub property for @{term Rep_CFun} its 'first' argument *}
huffman@15576
   320
huffman@15576
   321
lemma contlub_Rep_CFun1: "contlub(Rep_CFun)"
huffman@15589
   322
apply (rule contlubI [rule_format])
huffman@15589
   323
apply (rule ext)
huffman@15576
   324
apply (subst thelub_cfun)
huffman@15576
   325
apply assumption
huffman@15576
   326
apply (subst Cfunapp2)
huffman@15576
   327
apply (erule cont_lubcfun)
huffman@15576
   328
apply (subst thelub_fun)
huffman@15576
   329
apply (erule monofun_Rep_CFun1 [THEN ch2ch_monofun])
huffman@15576
   330
apply (rule refl)
huffman@15576
   331
done
huffman@15576
   332
huffman@15589
   333
text {* the cont property for @{term Rep_CFun} in its first argument *}
huffman@15576
   334
huffman@15576
   335
lemma cont_Rep_CFun1: "cont(Rep_CFun)"
huffman@15576
   336
apply (rule monocontlub2cont)
huffman@15576
   337
apply (rule monofun_Rep_CFun1)
huffman@15576
   338
apply (rule contlub_Rep_CFun1)
huffman@15576
   339
done
huffman@15576
   340
huffman@15589
   341
text {* contlub, cont properties of @{term Rep_CFun} in its first argument in mixfix @{text "_[_]"} *}
huffman@15576
   342
huffman@15576
   343
lemma contlub_cfun_fun: 
huffman@15576
   344
"chain(FY) ==> 
huffman@15576
   345
  lub(range FY)$x = lub(range (%i. FY(i)$x))"
huffman@15576
   346
apply (rule trans)
huffman@15576
   347
apply (erule contlub_Rep_CFun1 [THEN contlubE, THEN spec, THEN mp, THEN fun_cong])
huffman@15576
   348
apply (subst thelub_fun)
huffman@15576
   349
apply (erule monofun_Rep_CFun1 [THEN ch2ch_monofun])
huffman@15576
   350
apply (rule refl)
huffman@15576
   351
done
huffman@15576
   352
huffman@15576
   353
lemma cont_cfun_fun: 
huffman@15576
   354
"chain(FY) ==> 
huffman@15576
   355
  range(%i. FY(i)$x) <<| lub(range FY)$x"
huffman@15576
   356
apply (rule thelubE)
huffman@15576
   357
apply (erule ch2ch_Rep_CFunL)
huffman@15576
   358
apply (erule contlub_cfun_fun [symmetric])
huffman@15576
   359
done
huffman@15576
   360
huffman@15589
   361
text {* contlub, cont  properties of @{term Rep_CFun} in both argument in mixfix @{text "_[_]"} *}
huffman@15576
   362
huffman@15576
   363
lemma contlub_cfun: 
huffman@15576
   364
"[|chain(FY);chain(TY)|] ==> 
huffman@15576
   365
  (lub(range FY))$(lub(range TY)) = lub(range(%i. FY(i)$(TY i)))"
huffman@15576
   366
apply (rule contlub_CF2)
huffman@15576
   367
apply (rule cont_Rep_CFun1)
huffman@15576
   368
apply (rule allI)
huffman@15576
   369
apply (rule cont_Rep_CFun2)
huffman@15576
   370
apply assumption
huffman@15576
   371
apply assumption
huffman@15576
   372
done
huffman@15576
   373
huffman@15576
   374
lemma cont_cfun: 
huffman@15576
   375
"[|chain(FY);chain(TY)|] ==> 
huffman@15576
   376
  range(%i.(FY i)$(TY i)) <<| (lub (range FY))$(lub(range TY))"
huffman@15576
   377
apply (rule thelubE)
huffman@15576
   378
apply (rule monofun_Rep_CFun1 [THEN ch2ch_MF2LR])
huffman@15576
   379
apply (rule allI)
huffman@15576
   380
apply (rule monofun_Rep_CFun2)
huffman@15576
   381
apply assumption
huffman@15576
   382
apply assumption
huffman@15576
   383
apply (erule contlub_cfun [symmetric])
huffman@15576
   384
apply assumption
huffman@15576
   385
done
huffman@15576
   386
huffman@15589
   387
text {* cont2cont lemma for @{term Rep_CFun} *}
huffman@15576
   388
huffman@15576
   389
lemma cont2cont_Rep_CFun: "[|cont(%x. ft x);cont(%x. tt x)|] ==> cont(%x. (ft x)$(tt x))"
huffman@15576
   390
apply (best intro: cont2cont_app2 cont_const cont_Rep_CFun1 cont_Rep_CFun2)
huffman@15576
   391
done
huffman@15576
   392
huffman@15589
   393
text {* cont2mono Lemma for @{term "%x. LAM y. c1(x)(y)"} *}
huffman@15576
   394
huffman@15576
   395
lemma cont2mono_LAM:
huffman@15576
   396
assumes p1: "!!x. cont(c1 x)"
huffman@15576
   397
assumes p2: "!!y. monofun(%x. c1 x y)"
huffman@15576
   398
shows "monofun(%x. LAM y. c1 x y)"
huffman@15576
   399
apply (rule monofunI)
huffman@15576
   400
apply (intro strip)
huffman@15576
   401
apply (subst less_cfun)
huffman@15576
   402
apply (subst less_fun)
huffman@15576
   403
apply (rule allI)
huffman@15576
   404
apply (subst beta_cfun)
huffman@15576
   405
apply (rule p1)
huffman@15576
   406
apply (subst beta_cfun)
huffman@15576
   407
apply (rule p1)
huffman@15576
   408
apply (erule p2 [THEN monofunE, THEN spec, THEN spec, THEN mp])
huffman@15576
   409
done
huffman@15576
   410
huffman@15589
   411
text {* cont2cont Lemma for @{term "%x. LAM y. c1 x y"} *}
huffman@15576
   412
huffman@15576
   413
lemma cont2cont_LAM:
huffman@15576
   414
assumes p1: "!!x. cont(c1 x)"
huffman@15576
   415
assumes p2: "!!y. cont(%x. c1 x y)"
huffman@15576
   416
shows "cont(%x. LAM y. c1 x y)"
huffman@15576
   417
apply (rule monocontlub2cont)
huffman@15576
   418
apply (rule p1 [THEN cont2mono_LAM])
huffman@15576
   419
apply (rule p2 [THEN cont2mono])
huffman@15576
   420
apply (rule contlubI)
huffman@15576
   421
apply (intro strip)
huffman@15576
   422
apply (subst thelub_cfun)
huffman@15576
   423
apply (rule p1 [THEN cont2mono_LAM, THEN ch2ch_monofun])
huffman@15576
   424
apply (rule p2 [THEN cont2mono])
huffman@15576
   425
apply assumption
huffman@15576
   426
apply (rule_tac f = "Abs_CFun" in arg_cong)
huffman@15576
   427
apply (rule ext)
huffman@15576
   428
apply (subst p1 [THEN beta_cfun, THEN ext])
huffman@15576
   429
apply (erule p2 [THEN cont2contlub, THEN contlubE, THEN spec, THEN mp])
huffman@15576
   430
done
huffman@15576
   431
huffman@15641
   432
text {* cont2cont Lemma for @{term "%x. LAM y. c1 x$y"} *}
huffman@15641
   433
huffman@15641
   434
lemma cont2cont_eta: "cont c1 ==> cont (%x. LAM y. c1 x$y)"
huffman@15641
   435
by (simp only: eta_cfun)
huffman@15641
   436
huffman@15589
   437
text {* cont2cont tactic *}
huffman@15576
   438
huffman@15576
   439
lemmas cont_lemmas1 = cont_const cont_id cont_Rep_CFun2
huffman@15576
   440
                    cont2cont_Rep_CFun cont2cont_LAM
huffman@15576
   441
huffman@15576
   442
declare cont_lemmas1 [simp]
huffman@15576
   443
huffman@15589
   444
text {* HINT: @{text cont_tac} is now installed in simplifier in Lift.ML ! *}
huffman@15576
   445
huffman@15576
   446
(*val cont_tac = (fn i => (resolve_tac cont_lemmas i));*)
huffman@15576
   447
(*val cont_tacR = (fn i => (REPEAT (cont_tac i)));*)
huffman@15576
   448
huffman@15589
   449
text {* function application @{text "_[_]"} is strict in its first arguments *}
huffman@15576
   450
huffman@15589
   451
lemma strict_Rep_CFun1 [simp]: "(UU::'a::cpo->'b)$x = (UU::'b)"
huffman@15589
   452
by (simp add: inst_cfun_pcpo beta_cfun)
huffman@15576
   453
huffman@15589
   454
text {* Instantiate the simplifier *}
huffman@15589
   455
huffman@15589
   456
declare beta_cfun [simp]
huffman@15576
   457
huffman@15589
   458
text {* use @{text cont_tac} as autotac. *}
huffman@15576
   459
huffman@15589
   460
text {* HINT: @{text cont_tac} is now installed in simplifier in Lift.ML ! *}
huffman@15576
   461
(*simpset_ref() := simpset() addsolver (K (DEPTH_SOLVE_1 o cont_tac));*)
huffman@15576
   462
huffman@15589
   463
text {* some lemmata for functions with flat/chfin domain/range types *}
huffman@15576
   464
huffman@15576
   465
lemma chfin_Rep_CFunR: "chain (Y::nat => 'a::cpo->'b::chfin)  
huffman@15576
   466
      ==> !s. ? n. lub(range(Y))$s = Y n$s"
huffman@15576
   467
apply (rule allI)
huffman@15576
   468
apply (subst contlub_cfun_fun)
huffman@15576
   469
apply assumption
huffman@15576
   470
apply (fast intro!: thelubI chfin lub_finch2 chfin2finch ch2ch_Rep_CFunL)
huffman@15576
   471
done
huffman@15576
   472
huffman@15589
   473
subsection {* Continuous isomorphisms *}
huffman@15589
   474
huffman@15589
   475
text {* Continuous isomorphisms are strict. A proof for embedding projection pairs is similar. *}
huffman@15576
   476
huffman@15576
   477
lemma iso_strict: 
huffman@15576
   478
"!!f g.[|!y. f$(g$y)=(y::'b) ; !x. g$(f$x)=(x::'a) |]  
huffman@15576
   479
  ==> f$UU=UU & g$UU=UU"
huffman@15576
   480
apply (rule conjI)
huffman@15576
   481
apply (rule UU_I)
huffman@15576
   482
apply (rule_tac s = "f$ (g$ (UU::'b))" and t = "UU::'b" in subst)
huffman@15576
   483
apply (erule spec)
huffman@15576
   484
apply (rule minimal [THEN monofun_cfun_arg])
huffman@15576
   485
apply (rule UU_I)
huffman@15576
   486
apply (rule_tac s = "g$ (f$ (UU::'a))" and t = "UU::'a" in subst)
huffman@15576
   487
apply (erule spec)
huffman@15576
   488
apply (rule minimal [THEN monofun_cfun_arg])
huffman@15576
   489
done
huffman@15576
   490
huffman@15576
   491
lemma isorep_defined: "[|!x. rep$(ab$x)=x;!y. ab$(rep$y)=y; z~=UU|] ==> rep$z ~= UU"
huffman@15576
   492
apply (erule contrapos_nn)
huffman@15576
   493
apply (drule_tac f = "ab" in cfun_arg_cong)
huffman@15576
   494
apply (erule box_equals)
huffman@15576
   495
apply fast
huffman@15576
   496
apply (erule iso_strict [THEN conjunct1])
huffman@15576
   497
apply assumption
huffman@15576
   498
done
huffman@15576
   499
huffman@15576
   500
lemma isoabs_defined: "[|!x. rep$(ab$x) = x;!y. ab$(rep$y)=y ; z~=UU|] ==> ab$z ~= UU"
huffman@15576
   501
apply (erule contrapos_nn)
huffman@15576
   502
apply (drule_tac f = "rep" in cfun_arg_cong)
huffman@15576
   503
apply (erule box_equals)
huffman@15576
   504
apply fast
huffman@15576
   505
apply (erule iso_strict [THEN conjunct2])
huffman@15576
   506
apply assumption
huffman@15576
   507
done
huffman@15576
   508
huffman@15589
   509
text {* propagation of flatness and chain-finiteness by continuous isomorphisms *}
huffman@15576
   510
huffman@15589
   511
lemma chfin2chfin: "!!f g.[|! Y::nat=>'a. chain Y --> (? n. max_in_chain n Y);
huffman@15576
   512
  !y. f$(g$y)=(y::'b) ; !x. g$(f$x)=(x::'a::chfin) |]  
huffman@15576
   513
  ==> ! Y::nat=>'b. chain Y --> (? n. max_in_chain n Y)"
huffman@15576
   514
apply (unfold max_in_chain_def)
huffman@15589
   515
apply (clarify)
huffman@15576
   516
apply (rule exE)
huffman@15576
   517
apply (rule_tac P = "chain (%i. g$ (Y i))" in mp)
huffman@15576
   518
apply (erule spec)
huffman@15576
   519
apply (erule ch2ch_Rep_CFunR)
huffman@15576
   520
apply (rule exI)
huffman@15589
   521
apply (clarify)
huffman@15576
   522
apply (rule_tac s = "f$ (g$ (Y x))" and t = "Y (x) " in subst)
huffman@15576
   523
apply (erule spec)
huffman@15576
   524
apply (rule_tac s = "f$ (g$ (Y j))" and t = "Y (j) " in subst)
huffman@15576
   525
apply (erule spec)
huffman@15576
   526
apply (rule cfun_arg_cong)
huffman@15576
   527
apply (rule mp)
huffman@15576
   528
apply (erule spec)
huffman@15576
   529
apply assumption
huffman@15576
   530
done
huffman@15576
   531
huffman@15576
   532
lemma flat2flat: "!!f g.[|!x y::'a. x<<y --> x=UU | x=y;  
huffman@15576
   533
  !y. f$(g$y)=(y::'b); !x. g$(f$x)=(x::'a)|] ==> !x y::'b. x<<y --> x=UU | x=y"
huffman@15576
   534
apply (intro strip)
huffman@15576
   535
apply (rule disjE)
huffman@15576
   536
apply (rule_tac P = "g$x<<g$y" in mp)
huffman@15576
   537
apply (erule_tac [2] monofun_cfun_arg)
huffman@15576
   538
apply (drule spec)
huffman@15576
   539
apply (erule spec)
huffman@15576
   540
apply (rule disjI1)
huffman@15576
   541
apply (rule trans)
huffman@15576
   542
apply (rule_tac s = "f$ (g$x) " and t = "x" in subst)
huffman@15576
   543
apply (erule spec)
huffman@15576
   544
apply (erule cfun_arg_cong)
huffman@15576
   545
apply (rule iso_strict [THEN conjunct1])
huffman@15576
   546
apply assumption
huffman@15576
   547
apply assumption
huffman@15576
   548
apply (rule disjI2)
huffman@15576
   549
apply (rule_tac s = "f$ (g$x) " and t = "x" in subst)
huffman@15576
   550
apply (erule spec)
huffman@15576
   551
apply (rule_tac s = "f$ (g$y) " and t = "y" in subst)
huffman@15576
   552
apply (erule spec)
huffman@15576
   553
apply (erule cfun_arg_cong)
huffman@15576
   554
done
huffman@15576
   555
huffman@15589
   556
text {* a result about functions with flat codomain *}
huffman@15576
   557
huffman@15576
   558
lemma flat_codom: "f$(x::'a)=(c::'b::flat) ==> f$(UU::'a)=(UU::'b) | (!z. f$(z::'a)=c)"
huffman@15576
   559
apply (case_tac "f$ (x::'a) = (UU::'b) ")
huffman@15576
   560
apply (rule disjI1)
huffman@15576
   561
apply (rule UU_I)
huffman@15576
   562
apply (rule_tac s = "f$ (x) " and t = "UU::'b" in subst)
huffman@15576
   563
apply assumption
huffman@15576
   564
apply (rule minimal [THEN monofun_cfun_arg])
huffman@15576
   565
apply (case_tac "f$ (UU::'a) = (UU::'b) ")
huffman@15576
   566
apply (erule disjI1)
huffman@15576
   567
apply (rule disjI2)
huffman@15576
   568
apply (rule allI)
huffman@15576
   569
apply (erule subst)
huffman@15576
   570
apply (rule_tac a = "f$ (UU::'a) " in refl [THEN box_equals])
huffman@15576
   571
apply (rule_tac fo5 = "f" in minimal [THEN monofun_cfun_arg, THEN ax_flat [THEN spec, THEN spec, THEN mp], THEN disjE])
huffman@15576
   572
apply simp
huffman@15576
   573
apply assumption
huffman@15576
   574
apply (rule_tac fo5 = "f" in minimal [THEN monofun_cfun_arg, THEN ax_flat [THEN spec, THEN spec, THEN mp], THEN disjE])
huffman@15576
   575
apply simp
huffman@15576
   576
apply assumption
huffman@15576
   577
done
huffman@15576
   578
huffman@15589
   579
subsection {* Strictified functions *}
huffman@15576
   580
huffman@15589
   581
consts  
huffman@15589
   582
        Istrictify   :: "('a->'b)=>'a=>'b"
huffman@15589
   583
        strictify    :: "('a->'b)->'a->'b"
huffman@15589
   584
defs
huffman@15589
   585
huffman@15589
   586
Istrictify_def:  "Istrictify f x == if x=UU then UU else f$x"    
huffman@15589
   587
strictify_def:   "strictify == (LAM f x. Istrictify f x)"
huffman@15589
   588
huffman@15589
   589
text {* results about strictify *}
huffman@15589
   590
huffman@15589
   591
lemma Istrictify1: 
huffman@15589
   592
        "Istrictify(f)(UU)= (UU)"
huffman@15589
   593
apply (unfold Istrictify_def)
huffman@15589
   594
apply (simp (no_asm))
huffman@15589
   595
done
huffman@15589
   596
huffman@15589
   597
lemma Istrictify2: 
huffman@15589
   598
        "~x=UU ==> Istrictify(f)(x)=f$x"
huffman@15589
   599
by (simp add: Istrictify_def)
huffman@15589
   600
huffman@15589
   601
lemma monofun_Istrictify1: "monofun(Istrictify)"
huffman@15589
   602
apply (rule monofunI [rule_format])
huffman@15589
   603
apply (rule less_fun [THEN iffD2, rule_format])
huffman@15589
   604
apply (case_tac "xa=UU")
huffman@15589
   605
apply (simp add: Istrictify1)
huffman@15589
   606
apply (simp add: Istrictify2)
huffman@15589
   607
apply (erule monofun_cfun_fun)
huffman@15589
   608
done
huffman@15589
   609
huffman@15589
   610
lemma monofun_Istrictify2: "monofun(Istrictify(f))"
huffman@15589
   611
apply (rule monofunI [rule_format])
huffman@15589
   612
apply (case_tac "x=UU")
huffman@15589
   613
apply (simp add: Istrictify1)
huffman@15589
   614
apply (frule notUU_I)
huffman@15589
   615
apply assumption
huffman@15589
   616
apply (simp add: Istrictify2)
huffman@15589
   617
apply (erule monofun_cfun_arg)
huffman@15589
   618
done
huffman@15589
   619
huffman@15589
   620
lemma contlub_Istrictify1: "contlub(Istrictify)"
huffman@15589
   621
apply (rule contlubI [rule_format])
huffman@15589
   622
apply (rule ext)
huffman@15589
   623
apply (subst thelub_fun)
huffman@15589
   624
apply (erule monofun_Istrictify1 [THEN ch2ch_monofun])
huffman@15589
   625
apply (case_tac "x=UU")
huffman@15589
   626
apply (simp add: Istrictify1)
huffman@15589
   627
apply (simp add: lub_const [THEN thelubI])
huffman@15589
   628
apply (simp add: Istrictify2)
huffman@15589
   629
apply (erule contlub_cfun_fun)
huffman@15589
   630
done
huffman@15576
   631
huffman@15589
   632
lemma contlub_Istrictify2: "contlub(Istrictify(f::'a -> 'b))"
huffman@15589
   633
apply (rule contlubI [rule_format])
huffman@15589
   634
apply (case_tac "lub (range (Y))=UU")
huffman@15589
   635
apply (simp add: Istrictify1 chain_UU_I)
huffman@15589
   636
apply (simp add: lub_const [THEN thelubI])
huffman@15589
   637
apply (simp add: Istrictify2)
huffman@15589
   638
apply (rule_tac s = "lub (range (%i. f$ (Y i)))" in trans)
huffman@15589
   639
apply (erule contlub_cfun_arg)
huffman@15589
   640
apply (rule lub_equal2)
huffman@15589
   641
apply (rule chain_mono2 [THEN exE])
huffman@15589
   642
apply (erule chain_UU_I_inverse2)
huffman@15589
   643
apply (assumption)
huffman@15589
   644
apply (blast intro: Istrictify2 [symmetric])
huffman@15589
   645
apply (erule chain_monofun)
huffman@15589
   646
apply (erule monofun_Istrictify2 [THEN ch2ch_monofun])
huffman@15589
   647
done
huffman@15576
   648
huffman@15589
   649
lemmas cont_Istrictify1 = contlub_Istrictify1 [THEN monofun_Istrictify1 [THEN monocontlub2cont], standard]
huffman@15589
   650
huffman@15589
   651
lemmas cont_Istrictify2 = contlub_Istrictify2 [THEN monofun_Istrictify2 [THEN monocontlub2cont], standard]
huffman@15589
   652
huffman@15589
   653
lemma strictify1 [simp]: "strictify$f$UU=UU"
huffman@15589
   654
apply (unfold strictify_def)
huffman@15589
   655
apply (subst beta_cfun)
huffman@15589
   656
apply (simp add: cont_Istrictify2 cont_Istrictify1 cont2cont_CF1L)
huffman@15589
   657
apply (subst beta_cfun)
huffman@15589
   658
apply (rule cont_Istrictify2)
huffman@15589
   659
apply (rule Istrictify1)
huffman@15589
   660
done
huffman@15589
   661
huffman@15589
   662
lemma strictify2 [simp]: "~x=UU ==> strictify$f$x=f$x"
huffman@15589
   663
apply (unfold strictify_def)
huffman@15589
   664
apply (subst beta_cfun)
huffman@15589
   665
apply (simp add: cont_Istrictify2 cont_Istrictify1 cont2cont_CF1L)
huffman@15589
   666
apply (subst beta_cfun)
huffman@15589
   667
apply (rule cont_Istrictify2)
huffman@15589
   668
apply (erule Istrictify2)
huffman@15589
   669
done
huffman@15589
   670
huffman@15589
   671
subsection {* Identity and composition *}
huffman@15589
   672
huffman@15589
   673
consts
huffman@15589
   674
        ID      :: "('a::cpo) -> 'a"
huffman@15589
   675
        cfcomp  :: "('b->'c)->(('a::cpo)->('b::cpo))->'a->('c::cpo)"
huffman@15589
   676
huffman@15589
   677
syntax  "@oo"   :: "('b->'c)=>('a->'b)=>'a->'c" ("_ oo _" [101,100] 100)
huffman@15589
   678
     
huffman@15589
   679
translations    "f1 oo f2" == "cfcomp$f1$f2"
huffman@15589
   680
huffman@15589
   681
defs
huffman@15589
   682
  ID_def:        "ID ==(LAM x. x)"
huffman@15589
   683
  oo_def:        "cfcomp == (LAM f g x. f$(g$x))" 
huffman@15589
   684
huffman@15589
   685
lemma ID1 [simp]: "ID$x=x"
huffman@15576
   686
apply (unfold ID_def)
huffman@15576
   687
apply (subst beta_cfun)
huffman@15576
   688
apply (rule cont_id)
huffman@15576
   689
apply (rule refl)
huffman@15576
   690
done
huffman@15576
   691
huffman@15576
   692
lemma cfcomp1: "(f oo g)=(LAM x. f$(g$x))"
huffman@15589
   693
by (simp add: oo_def)
huffman@15576
   694
huffman@15589
   695
lemma cfcomp2 [simp]: "(f oo g)$x=f$(g$x)"
huffman@15589
   696
by (simp add: cfcomp1)
huffman@15576
   697
huffman@15589
   698
text {*
huffman@15589
   699
  Show that interpretation of (pcpo,@{text "_->_"}) is a category.
huffman@15589
   700
  The class of objects is interpretation of syntactical class pcpo.
huffman@15589
   701
  The class of arrows  between objects @{typ 'a} and @{typ 'b} is interpret. of @{typ "'a -> 'b"}.
huffman@15589
   702
  The identity arrow is interpretation of @{term ID}.
huffman@15589
   703
  The composition of f and g is interpretation of @{text "oo"}.
huffman@15589
   704
*}
huffman@15576
   705
huffman@15589
   706
lemma ID2 [simp]: "f oo ID = f "
huffman@15589
   707
by (rule ext_cfun, simp)
huffman@15576
   708
huffman@15589
   709
lemma ID3 [simp]: "ID oo f = f "
huffman@15589
   710
by (rule ext_cfun, simp)
huffman@15576
   711
huffman@15576
   712
lemma assoc_oo: "f oo (g oo h) = (f oo g) oo h"
huffman@15589
   713
by (rule ext_cfun, simp)
huffman@15576
   714
huffman@15576
   715
end