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