src/HOLCF/Cfun.thy
author huffman
Fri Mar 04 23:23:47 2005 +0100 (2005-03-04)
changeset 15577 e16da3068ad6
parent 15576 efb95d0d01f7
child 15589 69bea57212ef
permissions -rw-r--r--
fix headers
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@15576
    18
typedef (CFun)  ('a, 'b) "->" (infixr 0) = "{f::'a => 'b. cont f}"
huffman@15576
    19
by (rule exI, rule CfunI)
huffman@15576
    20
huffman@15576
    21
(* to make << defineable *)
huffman@15576
    22
instance "->"  :: (cpo,cpo)sq_ord ..
huffman@15576
    23
huffman@15576
    24
syntax
huffman@15576
    25
	Rep_CFun  :: "('a -> 'b) => ('a => 'b)" ("_$_" [999,1000] 999)
huffman@15576
    26
                                                (* application      *)
huffman@15576
    27
        Abs_CFun  :: "('a => 'b) => ('a -> 'b)" (binder "LAM " 10)
huffman@15576
    28
                                                (* abstraction      *)
huffman@15576
    29
        less_cfun :: "[('a -> 'b),('a -> 'b)]=>bool"
huffman@15576
    30
huffman@15576
    31
syntax (xsymbols)
huffman@15576
    32
  "->"		:: "[type, type] => type"      ("(_ \<rightarrow>/ _)" [1,0]0)
huffman@15576
    33
  "LAM "	:: "[idts, 'a => 'b] => ('a -> 'b)"
huffman@15576
    34
					("(3\<Lambda>_./ _)" [0, 10] 10)
huffman@15576
    35
  Rep_CFun      :: "('a -> 'b) => ('a => 'b)"  ("(_\<cdot>_)" [999,1000] 999)
huffman@15576
    36
huffman@15576
    37
syntax (HTML output)
huffman@15576
    38
  Rep_CFun      :: "('a -> 'b) => ('a => 'b)"  ("(_\<cdot>_)" [999,1000] 999)
huffman@15576
    39
huffman@15576
    40
defs (overloaded)
huffman@15576
    41
  less_cfun_def: "(op <<) == (% fo1 fo2. Rep_CFun fo1 << Rep_CFun fo2 )"
huffman@15576
    42
huffman@15576
    43
(* ------------------------------------------------------------------------ *)
huffman@15576
    44
(* derive old type definition rules for Abs_CFun & Rep_CFun
huffman@15576
    45
    *)
huffman@15576
    46
(* Rep_CFun and Abs_CFun should be replaced by Rep_Cfun anf Abs_Cfun in future
huffman@15576
    47
    *)
huffman@15576
    48
(* ------------------------------------------------------------------------ *)
huffman@15576
    49
huffman@15576
    50
lemma Rep_Cfun: "Rep_CFun fo : CFun"
huffman@15576
    51
apply (rule Rep_CFun)
huffman@15576
    52
done
huffman@15576
    53
huffman@15576
    54
lemma Rep_Cfun_inverse: "Abs_CFun (Rep_CFun fo) = fo"
huffman@15576
    55
apply (rule Rep_CFun_inverse)
huffman@15576
    56
done
huffman@15576
    57
huffman@15576
    58
lemma Abs_Cfun_inverse: "f:CFun==>Rep_CFun(Abs_CFun f)=f"
huffman@15576
    59
apply (erule Abs_CFun_inverse)
huffman@15576
    60
done
huffman@15576
    61
huffman@15576
    62
(* ------------------------------------------------------------------------ *)
huffman@15576
    63
(* less_cfun is a partial order on type 'a -> 'b                            *)
huffman@15576
    64
(* ------------------------------------------------------------------------ *)
huffman@15576
    65
huffman@15576
    66
lemma refl_less_cfun: "(f::'a->'b) << f"
huffman@15576
    67
huffman@15576
    68
apply (unfold less_cfun_def)
huffman@15576
    69
apply (rule refl_less)
huffman@15576
    70
done
huffman@15576
    71
huffman@15576
    72
lemma antisym_less_cfun: 
huffman@15576
    73
        "[|(f1::'a->'b) << f2; f2 << f1|] ==> f1 = f2"
huffman@15576
    74
apply (unfold less_cfun_def)
huffman@15576
    75
apply (rule injD)
huffman@15576
    76
apply (rule_tac [2] antisym_less)
huffman@15576
    77
prefer 3 apply (assumption)
huffman@15576
    78
prefer 2 apply (assumption)
huffman@15576
    79
apply (rule inj_on_inverseI)
huffman@15576
    80
apply (rule Rep_Cfun_inverse)
huffman@15576
    81
done
huffman@15576
    82
huffman@15576
    83
lemma trans_less_cfun: 
huffman@15576
    84
        "[|(f1::'a->'b) << f2; f2 << f3|] ==> f1 << f3"
huffman@15576
    85
apply (unfold less_cfun_def)
huffman@15576
    86
apply (erule trans_less)
huffman@15576
    87
apply assumption
huffman@15576
    88
done
huffman@15576
    89
huffman@15576
    90
(* ------------------------------------------------------------------------ *)
huffman@15576
    91
(* lemmas about application of continuous functions                         *)
huffman@15576
    92
(* ------------------------------------------------------------------------ *)
huffman@15576
    93
huffman@15576
    94
lemma cfun_cong: "[| f=g; x=y |] ==> f$x = g$y"
huffman@15576
    95
apply (simp (no_asm_simp))
huffman@15576
    96
done
huffman@15576
    97
huffman@15576
    98
lemma cfun_fun_cong: "f=g ==> f$x = g$x"
huffman@15576
    99
apply (simp (no_asm_simp))
huffman@15576
   100
done
huffman@15576
   101
huffman@15576
   102
lemma cfun_arg_cong: "x=y ==> f$x = f$y"
huffman@15576
   103
apply (simp (no_asm_simp))
huffman@15576
   104
done
huffman@15576
   105
huffman@15576
   106
huffman@15576
   107
(* ------------------------------------------------------------------------ *)
huffman@15576
   108
(* additional lemma about the isomorphism between -> and Cfun               *)
huffman@15576
   109
(* ------------------------------------------------------------------------ *)
huffman@15576
   110
huffman@15576
   111
lemma Abs_Cfun_inverse2: "cont f ==> Rep_CFun (Abs_CFun f) = f"
huffman@15576
   112
apply (rule Abs_Cfun_inverse)
huffman@15576
   113
apply (unfold CFun_def)
huffman@15576
   114
apply (erule mem_Collect_eq [THEN ssubst])
huffman@15576
   115
done
huffman@15576
   116
huffman@15576
   117
(* ------------------------------------------------------------------------ *)
huffman@15576
   118
(* simplification of application                                            *)
huffman@15576
   119
(* ------------------------------------------------------------------------ *)
huffman@15576
   120
huffman@15576
   121
lemma Cfunapp2: "cont f ==> (Abs_CFun f)$x = f x"
huffman@15576
   122
apply (erule Abs_Cfun_inverse2 [THEN fun_cong])
huffman@15576
   123
done
huffman@15576
   124
huffman@15576
   125
(* ------------------------------------------------------------------------ *)
huffman@15576
   126
(* beta - equality for continuous functions                                 *)
huffman@15576
   127
(* ------------------------------------------------------------------------ *)
huffman@15576
   128
huffman@15576
   129
lemma beta_cfun: "cont(c1) ==> (LAM x .c1 x)$u = c1 u"
huffman@15576
   130
apply (rule Cfunapp2)
huffman@15576
   131
apply assumption
huffman@15576
   132
done
huffman@15576
   133
huffman@15576
   134
huffman@15576
   135
(* Class Instance ->::(cpo,cpo)po *)
huffman@15576
   136
huffman@15576
   137
instance "->"::(cpo,cpo)po
huffman@15576
   138
apply (intro_classes)
huffman@15576
   139
apply (rule refl_less_cfun)
huffman@15576
   140
apply (rule antisym_less_cfun, assumption+)
huffman@15576
   141
apply (rule trans_less_cfun, assumption+)
huffman@15576
   142
done
huffman@15576
   143
huffman@15576
   144
(* Class Instance ->::(cpo,cpo)po *)
huffman@15576
   145
huffman@15576
   146
(* for compatibility with old HOLCF-Version *)
huffman@15576
   147
lemma inst_cfun_po: "(op <<)=(%f1 f2. Rep_CFun f1 << Rep_CFun f2)"
huffman@15576
   148
apply (fold less_cfun_def)
huffman@15576
   149
apply (rule refl)
huffman@15576
   150
done
huffman@15576
   151
huffman@15576
   152
(* ------------------------------------------------------------------------ *)
huffman@15576
   153
(* access to less_cfun in class po                                          *)
huffman@15576
   154
(* ------------------------------------------------------------------------ *)
huffman@15576
   155
huffman@15576
   156
lemma less_cfun: "( f1 << f2 ) = (Rep_CFun(f1) << Rep_CFun(f2))"
huffman@15576
   157
apply (simp (no_asm) add: inst_cfun_po)
huffman@15576
   158
done
huffman@15576
   159
huffman@15576
   160
(* ------------------------------------------------------------------------ *)
huffman@15576
   161
(* Type 'a ->'b  is pointed                                                 *)
huffman@15576
   162
(* ------------------------------------------------------------------------ *)
huffman@15576
   163
huffman@15576
   164
lemma minimal_cfun: "Abs_CFun(% x. UU) << f"
huffman@15576
   165
apply (subst less_cfun)
huffman@15576
   166
apply (subst Abs_Cfun_inverse2)
huffman@15576
   167
apply (rule cont_const)
huffman@15576
   168
apply (rule minimal_fun)
huffman@15576
   169
done
huffman@15576
   170
huffman@15576
   171
lemmas UU_cfun_def = minimal_cfun [THEN minimal2UU, symmetric, standard]
huffman@15576
   172
huffman@15576
   173
lemma least_cfun: "? x::'a->'b::pcpo.!y. x<<y"
huffman@15576
   174
apply (rule_tac x = "Abs_CFun (% x. UU) " in exI)
huffman@15576
   175
apply (rule minimal_cfun [THEN allI])
huffman@15576
   176
done
huffman@15576
   177
huffman@15576
   178
(* ------------------------------------------------------------------------ *)
huffman@15576
   179
(* Rep_CFun yields continuous functions in 'a => 'b                             *)
huffman@15576
   180
(* this is continuity of Rep_CFun in its 'second' argument                      *)
huffman@15576
   181
(* cont_Rep_CFun2 ==> monofun_Rep_CFun2 & contlub_Rep_CFun2                            *)
huffman@15576
   182
(* ------------------------------------------------------------------------ *)
huffman@15576
   183
huffman@15576
   184
lemma cont_Rep_CFun2: "cont(Rep_CFun(fo))"
huffman@15576
   185
apply (rule_tac P = "cont" in CollectD)
huffman@15576
   186
apply (fold CFun_def)
huffman@15576
   187
apply (rule Rep_Cfun)
huffman@15576
   188
done
huffman@15576
   189
huffman@15576
   190
lemmas monofun_Rep_CFun2 = cont_Rep_CFun2 [THEN cont2mono, standard]
huffman@15576
   191
(* monofun(Rep_CFun(?fo1)) *)
huffman@15576
   192
huffman@15576
   193
huffman@15576
   194
lemmas contlub_Rep_CFun2 = cont_Rep_CFun2 [THEN cont2contlub, standard]
huffman@15576
   195
(* contlub(Rep_CFun(?fo1)) *)
huffman@15576
   196
huffman@15576
   197
(* ------------------------------------------------------------------------ *)
huffman@15576
   198
(* expanded thms cont_Rep_CFun2, contlub_Rep_CFun2                                 *)
huffman@15576
   199
(* looks nice with mixfix syntac                                            *)
huffman@15576
   200
(* ------------------------------------------------------------------------ *)
huffman@15576
   201
huffman@15576
   202
lemmas cont_cfun_arg = cont_Rep_CFun2 [THEN contE, THEN spec, THEN mp]
huffman@15576
   203
(* chain(?x1) ==> range (%i. ?fo3$(?x1 i)) <<| ?fo3$(lub (range ?x1))    *)
huffman@15576
   204
 
huffman@15576
   205
lemmas contlub_cfun_arg = contlub_Rep_CFun2 [THEN contlubE, THEN spec, THEN mp]
huffman@15576
   206
(* chain(?x1) ==> ?fo4$(lub (range ?x1)) = lub (range (%i. ?fo4$(?x1 i))) *)
huffman@15576
   207
huffman@15576
   208
huffman@15576
   209
(* ------------------------------------------------------------------------ *)
huffman@15576
   210
(* Rep_CFun is monotone in its 'first' argument                                 *)
huffman@15576
   211
(* ------------------------------------------------------------------------ *)
huffman@15576
   212
huffman@15576
   213
lemma monofun_Rep_CFun1: "monofun(Rep_CFun)"
huffman@15576
   214
apply (unfold monofun)
huffman@15576
   215
apply (intro strip)
huffman@15576
   216
apply (erule less_cfun [THEN subst])
huffman@15576
   217
done
huffman@15576
   218
huffman@15576
   219
huffman@15576
   220
(* ------------------------------------------------------------------------ *)
huffman@15576
   221
(* monotonicity of application Rep_CFun in mixfix syntax [_]_                   *)
huffman@15576
   222
(* ------------------------------------------------------------------------ *)
huffman@15576
   223
huffman@15576
   224
lemma monofun_cfun_fun: "f1 << f2 ==> f1$x << f2$x"
huffman@15576
   225
apply (rule_tac x = "x" in spec)
huffman@15576
   226
apply (rule less_fun [THEN subst])
huffman@15576
   227
apply (erule monofun_Rep_CFun1 [THEN monofunE, THEN spec, THEN spec, THEN mp])
huffman@15576
   228
done
huffman@15576
   229
huffman@15576
   230
huffman@15576
   231
lemmas monofun_cfun_arg = monofun_Rep_CFun2 [THEN monofunE, THEN spec, THEN spec, THEN mp, standard]
huffman@15576
   232
(* ?x2 << ?x1 ==> ?fo5$?x2 << ?fo5$?x1                                      *)
huffman@15576
   233
huffman@15576
   234
lemma chain_monofun: "chain Y ==> chain (%i. f\<cdot>(Y i))"
huffman@15576
   235
apply (rule chainI)
huffman@15576
   236
apply (rule monofun_cfun_arg)
huffman@15576
   237
apply (erule chainE)
huffman@15576
   238
done
huffman@15576
   239
huffman@15576
   240
huffman@15576
   241
(* ------------------------------------------------------------------------ *)
huffman@15576
   242
(* monotonicity of Rep_CFun in both arguments in mixfix syntax [_]_             *)
huffman@15576
   243
(* ------------------------------------------------------------------------ *)
huffman@15576
   244
huffman@15576
   245
lemma monofun_cfun: "[|f1<<f2;x1<<x2|] ==> f1$x1 << f2$x2"
huffman@15576
   246
apply (rule trans_less)
huffman@15576
   247
apply (erule monofun_cfun_arg)
huffman@15576
   248
apply (erule monofun_cfun_fun)
huffman@15576
   249
done
huffman@15576
   250
huffman@15576
   251
huffman@15576
   252
lemma strictI: "f$x = UU ==> f$UU = UU"
huffman@15576
   253
apply (rule eq_UU_iff [THEN iffD2])
huffman@15576
   254
apply (erule subst)
huffman@15576
   255
apply (rule minimal [THEN monofun_cfun_arg])
huffman@15576
   256
done
huffman@15576
   257
huffman@15576
   258
huffman@15576
   259
(* ------------------------------------------------------------------------ *)
huffman@15576
   260
(* ch2ch - rules for the type 'a -> 'b                                      *)
huffman@15576
   261
(* use MF2 lemmas from Cont.ML                                              *)
huffman@15576
   262
(* ------------------------------------------------------------------------ *)
huffman@15576
   263
huffman@15576
   264
lemma ch2ch_Rep_CFunR: "chain(Y) ==> chain(%i. f$(Y i))"
huffman@15576
   265
apply (erule monofun_Rep_CFun2 [THEN ch2ch_MF2R])
huffman@15576
   266
done
huffman@15576
   267
huffman@15576
   268
huffman@15576
   269
lemmas ch2ch_Rep_CFunL = monofun_Rep_CFun1 [THEN ch2ch_MF2L, standard]
huffman@15576
   270
(* chain(?F) ==> chain (%i. ?F i$?x)                                  *)
huffman@15576
   271
huffman@15576
   272
huffman@15576
   273
(* ------------------------------------------------------------------------ *)
huffman@15576
   274
(*  the lub of a chain of continous functions is monotone                   *)
huffman@15576
   275
(* use MF2 lemmas from Cont.ML                                              *)
huffman@15576
   276
(* ------------------------------------------------------------------------ *)
huffman@15576
   277
huffman@15576
   278
lemma lub_cfun_mono: "chain(F) ==> monofun(% x. lub(range(% j.(F j)$x)))"
huffman@15576
   279
apply (rule lub_MF2_mono)
huffman@15576
   280
apply (rule monofun_Rep_CFun1)
huffman@15576
   281
apply (rule monofun_Rep_CFun2 [THEN allI])
huffman@15576
   282
apply assumption
huffman@15576
   283
done
huffman@15576
   284
huffman@15576
   285
(* ------------------------------------------------------------------------ *)
huffman@15576
   286
(* a lemma about the exchange of lubs for type 'a -> 'b                     *)
huffman@15576
   287
(* use MF2 lemmas from Cont.ML                                              *)
huffman@15576
   288
(* ------------------------------------------------------------------------ *)
huffman@15576
   289
huffman@15576
   290
lemma ex_lubcfun: "[| chain(F); chain(Y) |] ==> 
huffman@15576
   291
                lub(range(%j. lub(range(%i. F(j)$(Y i))))) = 
huffman@15576
   292
                lub(range(%i. lub(range(%j. F(j)$(Y i)))))"
huffman@15576
   293
apply (rule ex_lubMF2)
huffman@15576
   294
apply (rule monofun_Rep_CFun1)
huffman@15576
   295
apply (rule monofun_Rep_CFun2 [THEN allI])
huffman@15576
   296
apply assumption
huffman@15576
   297
apply assumption
huffman@15576
   298
done
huffman@15576
   299
huffman@15576
   300
(* ------------------------------------------------------------------------ *)
huffman@15576
   301
(* the lub of a chain of cont. functions is continuous                      *)
huffman@15576
   302
(* ------------------------------------------------------------------------ *)
huffman@15576
   303
huffman@15576
   304
lemma cont_lubcfun: "chain(F) ==> cont(% x. lub(range(% j. F(j)$x)))"
huffman@15576
   305
apply (rule monocontlub2cont)
huffman@15576
   306
apply (erule lub_cfun_mono)
huffman@15576
   307
apply (rule contlubI)
huffman@15576
   308
apply (intro strip)
huffman@15576
   309
apply (subst contlub_cfun_arg [THEN ext])
huffman@15576
   310
apply assumption
huffman@15576
   311
apply (erule ex_lubcfun)
huffman@15576
   312
apply assumption
huffman@15576
   313
done
huffman@15576
   314
huffman@15576
   315
(* ------------------------------------------------------------------------ *)
huffman@15576
   316
(* type 'a -> 'b is chain complete                                          *)
huffman@15576
   317
(* ------------------------------------------------------------------------ *)
huffman@15576
   318
huffman@15576
   319
lemma lub_cfun: "chain(CCF) ==> range(CCF) <<| (LAM x. lub(range(% i. CCF(i)$x)))"
huffman@15576
   320
apply (rule is_lubI)
huffman@15576
   321
apply (rule ub_rangeI)
huffman@15576
   322
apply (subst less_cfun)
huffman@15576
   323
apply (subst Abs_Cfun_inverse2)
huffman@15576
   324
apply (erule cont_lubcfun)
huffman@15576
   325
apply (rule lub_fun [THEN is_lubD1, THEN ub_rangeD])
huffman@15576
   326
apply (erule monofun_Rep_CFun1 [THEN ch2ch_monofun])
huffman@15576
   327
apply (subst less_cfun)
huffman@15576
   328
apply (subst Abs_Cfun_inverse2)
huffman@15576
   329
apply (erule cont_lubcfun)
huffman@15576
   330
apply (rule lub_fun [THEN is_lub_lub])
huffman@15576
   331
apply (erule monofun_Rep_CFun1 [THEN ch2ch_monofun])
huffman@15576
   332
apply (erule monofun_Rep_CFun1 [THEN ub2ub_monofun])
huffman@15576
   333
done
huffman@15576
   334
huffman@15576
   335
lemmas thelub_cfun = lub_cfun [THEN thelubI, standard]
huffman@15576
   336
(* 
huffman@15576
   337
chain(?CCF1) ==>  lub (range ?CCF1) = (LAM x. lub (range (%i. ?CCF1 i$x)))
huffman@15576
   338
*)
huffman@15576
   339
huffman@15576
   340
lemma cpo_cfun: "chain(CCF::nat=>('a->'b)) ==> ? x. range(CCF) <<| x"
huffman@15576
   341
apply (rule exI)
huffman@15576
   342
apply (erule lub_cfun)
huffman@15576
   343
done
huffman@15576
   344
huffman@15576
   345
huffman@15576
   346
(* ------------------------------------------------------------------------ *)
huffman@15576
   347
(* Extensionality in 'a -> 'b                                               *)
huffman@15576
   348
(* ------------------------------------------------------------------------ *)
huffman@15576
   349
huffman@15576
   350
lemma ext_cfun: "(!!x. f$x = g$x) ==> f = g"
huffman@15576
   351
apply (rule_tac t = "f" in Rep_Cfun_inverse [THEN subst])
huffman@15576
   352
apply (rule_tac t = "g" in Rep_Cfun_inverse [THEN subst])
huffman@15576
   353
apply (rule_tac f = "Abs_CFun" in arg_cong)
huffman@15576
   354
apply (rule ext)
huffman@15576
   355
apply simp
huffman@15576
   356
done
huffman@15576
   357
huffman@15576
   358
(* ------------------------------------------------------------------------ *)
huffman@15576
   359
(* Monotonicity of Abs_CFun                                                     *)
huffman@15576
   360
(* ------------------------------------------------------------------------ *)
huffman@15576
   361
huffman@15576
   362
lemma semi_monofun_Abs_CFun: "[| cont(f); cont(g); f<<g|] ==> Abs_CFun(f)<<Abs_CFun(g)"
huffman@15576
   363
apply (rule less_cfun [THEN iffD2])
huffman@15576
   364
apply (subst Abs_Cfun_inverse2)
huffman@15576
   365
apply assumption
huffman@15576
   366
apply (subst Abs_Cfun_inverse2)
huffman@15576
   367
apply assumption
huffman@15576
   368
apply assumption
huffman@15576
   369
done
huffman@15576
   370
huffman@15576
   371
(* ------------------------------------------------------------------------ *)
huffman@15576
   372
(* Extenionality wrt. << in 'a -> 'b                                        *)
huffman@15576
   373
(* ------------------------------------------------------------------------ *)
huffman@15576
   374
huffman@15576
   375
lemma less_cfun2: "(!!x. f$x << g$x) ==> f << g"
huffman@15576
   376
apply (rule_tac t = "f" in Rep_Cfun_inverse [THEN subst])
huffman@15576
   377
apply (rule_tac t = "g" in Rep_Cfun_inverse [THEN subst])
huffman@15576
   378
apply (rule semi_monofun_Abs_CFun)
huffman@15576
   379
apply (rule cont_Rep_CFun2)
huffman@15576
   380
apply (rule cont_Rep_CFun2)
huffman@15576
   381
apply (rule less_fun [THEN iffD2])
huffman@15576
   382
apply (rule allI)
huffman@15576
   383
apply simp
huffman@15576
   384
done
huffman@15576
   385
huffman@15576
   386
(* Class instance of  -> for class pcpo *)
huffman@15576
   387
huffman@15576
   388
instance "->" :: (cpo,cpo)cpo
huffman@15576
   389
by (intro_classes, rule cpo_cfun)
huffman@15576
   390
huffman@15576
   391
instance "->" :: (cpo,pcpo)pcpo
huffman@15576
   392
by (intro_classes, rule least_cfun)
huffman@15576
   393
huffman@15576
   394
defaultsort pcpo
huffman@15576
   395
huffman@15576
   396
consts  
huffman@15576
   397
        Istrictify   :: "('a->'b)=>'a=>'b"
huffman@15576
   398
        strictify    :: "('a->'b)->'a->'b"
huffman@15576
   399
defs
huffman@15576
   400
huffman@15576
   401
Istrictify_def:  "Istrictify f x == if x=UU then UU else f$x"    
huffman@15576
   402
strictify_def:   "strictify == (LAM f x. Istrictify f x)"
huffman@15576
   403
huffman@15576
   404
consts
huffman@15576
   405
        ID      :: "('a::cpo) -> 'a"
huffman@15576
   406
        cfcomp  :: "('b->'c)->(('a::cpo)->('b::cpo))->'a->('c::cpo)"
huffman@15576
   407
huffman@15576
   408
syntax  "@oo"   :: "('b->'c)=>('a->'b)=>'a->'c" ("_ oo _" [101,100] 100)
huffman@15576
   409
     
huffman@15576
   410
translations    "f1 oo f2" == "cfcomp$f1$f2"
huffman@15576
   411
huffman@15576
   412
defs
huffman@15576
   413
huffman@15576
   414
  ID_def:        "ID ==(LAM x. x)"
huffman@15576
   415
  oo_def:        "cfcomp == (LAM f g x. f$(g$x))" 
huffman@15576
   416
huffman@15576
   417
(* for compatibility with old HOLCF-Version *)
huffman@15576
   418
lemma inst_cfun_pcpo: "UU = Abs_CFun(%x. UU)"
huffman@15576
   419
apply (simp add: UU_def UU_cfun_def)
huffman@15576
   420
done
huffman@15576
   421
huffman@15576
   422
(* ------------------------------------------------------------------------ *)
huffman@15576
   423
(* the contlub property for Rep_CFun its 'first' argument                       *)
huffman@15576
   424
(* ------------------------------------------------------------------------ *)
huffman@15576
   425
huffman@15576
   426
lemma contlub_Rep_CFun1: "contlub(Rep_CFun)"
huffman@15576
   427
apply (rule contlubI)
huffman@15576
   428
apply (intro strip)
huffman@15576
   429
apply (rule expand_fun_eq [THEN iffD2])
huffman@15576
   430
apply (intro strip)
huffman@15576
   431
apply (subst thelub_cfun)
huffman@15576
   432
apply assumption
huffman@15576
   433
apply (subst Cfunapp2)
huffman@15576
   434
apply (erule cont_lubcfun)
huffman@15576
   435
apply (subst thelub_fun)
huffman@15576
   436
apply (erule monofun_Rep_CFun1 [THEN ch2ch_monofun])
huffman@15576
   437
apply (rule refl)
huffman@15576
   438
done
huffman@15576
   439
huffman@15576
   440
huffman@15576
   441
(* ------------------------------------------------------------------------ *)
huffman@15576
   442
(* the cont property for Rep_CFun in its first argument                        *)
huffman@15576
   443
(* ------------------------------------------------------------------------ *)
huffman@15576
   444
huffman@15576
   445
lemma cont_Rep_CFun1: "cont(Rep_CFun)"
huffman@15576
   446
apply (rule monocontlub2cont)
huffman@15576
   447
apply (rule monofun_Rep_CFun1)
huffman@15576
   448
apply (rule contlub_Rep_CFun1)
huffman@15576
   449
done
huffman@15576
   450
huffman@15576
   451
huffman@15576
   452
(* ------------------------------------------------------------------------ *)
huffman@15576
   453
(* contlub, cont properties of Rep_CFun in its first argument in mixfix _[_]   *)
huffman@15576
   454
(* ------------------------------------------------------------------------ *)
huffman@15576
   455
huffman@15576
   456
lemma contlub_cfun_fun: 
huffman@15576
   457
"chain(FY) ==> 
huffman@15576
   458
  lub(range FY)$x = lub(range (%i. FY(i)$x))"
huffman@15576
   459
apply (rule trans)
huffman@15576
   460
apply (erule contlub_Rep_CFun1 [THEN contlubE, THEN spec, THEN mp, THEN fun_cong])
huffman@15576
   461
apply (subst thelub_fun)
huffman@15576
   462
apply (erule monofun_Rep_CFun1 [THEN ch2ch_monofun])
huffman@15576
   463
apply (rule refl)
huffman@15576
   464
done
huffman@15576
   465
huffman@15576
   466
huffman@15576
   467
lemma cont_cfun_fun: 
huffman@15576
   468
"chain(FY) ==> 
huffman@15576
   469
  range(%i. FY(i)$x) <<| lub(range FY)$x"
huffman@15576
   470
apply (rule thelubE)
huffman@15576
   471
apply (erule ch2ch_Rep_CFunL)
huffman@15576
   472
apply (erule contlub_cfun_fun [symmetric])
huffman@15576
   473
done
huffman@15576
   474
huffman@15576
   475
huffman@15576
   476
(* ------------------------------------------------------------------------ *)
huffman@15576
   477
(* contlub, cont  properties of Rep_CFun in both argument in mixfix _[_]       *)
huffman@15576
   478
(* ------------------------------------------------------------------------ *)
huffman@15576
   479
huffman@15576
   480
lemma contlub_cfun: 
huffman@15576
   481
"[|chain(FY);chain(TY)|] ==> 
huffman@15576
   482
  (lub(range FY))$(lub(range TY)) = lub(range(%i. FY(i)$(TY i)))"
huffman@15576
   483
apply (rule contlub_CF2)
huffman@15576
   484
apply (rule cont_Rep_CFun1)
huffman@15576
   485
apply (rule allI)
huffman@15576
   486
apply (rule cont_Rep_CFun2)
huffman@15576
   487
apply assumption
huffman@15576
   488
apply assumption
huffman@15576
   489
done
huffman@15576
   490
huffman@15576
   491
lemma cont_cfun: 
huffman@15576
   492
"[|chain(FY);chain(TY)|] ==> 
huffman@15576
   493
  range(%i.(FY i)$(TY i)) <<| (lub (range FY))$(lub(range TY))"
huffman@15576
   494
apply (rule thelubE)
huffman@15576
   495
apply (rule monofun_Rep_CFun1 [THEN ch2ch_MF2LR])
huffman@15576
   496
apply (rule allI)
huffman@15576
   497
apply (rule monofun_Rep_CFun2)
huffman@15576
   498
apply assumption
huffman@15576
   499
apply assumption
huffman@15576
   500
apply (erule contlub_cfun [symmetric])
huffman@15576
   501
apply assumption
huffman@15576
   502
done
huffman@15576
   503
huffman@15576
   504
huffman@15576
   505
(* ------------------------------------------------------------------------ *)
huffman@15576
   506
(* cont2cont lemma for Rep_CFun                                               *)
huffman@15576
   507
(* ------------------------------------------------------------------------ *)
huffman@15576
   508
huffman@15576
   509
lemma cont2cont_Rep_CFun: "[|cont(%x. ft x);cont(%x. tt x)|] ==> cont(%x. (ft x)$(tt x))"
huffman@15576
   510
apply (best intro: cont2cont_app2 cont_const cont_Rep_CFun1 cont_Rep_CFun2)
huffman@15576
   511
done
huffman@15576
   512
huffman@15576
   513
huffman@15576
   514
huffman@15576
   515
(* ------------------------------------------------------------------------ *)
huffman@15576
   516
(* cont2mono Lemma for %x. LAM y. c1(x)(y)                                  *)
huffman@15576
   517
(* ------------------------------------------------------------------------ *)
huffman@15576
   518
huffman@15576
   519
lemma cont2mono_LAM:
huffman@15576
   520
assumes p1: "!!x. cont(c1 x)"
huffman@15576
   521
assumes p2: "!!y. monofun(%x. c1 x y)"
huffman@15576
   522
shows "monofun(%x. LAM y. c1 x y)"
huffman@15576
   523
apply (rule monofunI)
huffman@15576
   524
apply (intro strip)
huffman@15576
   525
apply (subst less_cfun)
huffman@15576
   526
apply (subst less_fun)
huffman@15576
   527
apply (rule allI)
huffman@15576
   528
apply (subst beta_cfun)
huffman@15576
   529
apply (rule p1)
huffman@15576
   530
apply (subst beta_cfun)
huffman@15576
   531
apply (rule p1)
huffman@15576
   532
apply (erule p2 [THEN monofunE, THEN spec, THEN spec, THEN mp])
huffman@15576
   533
done
huffman@15576
   534
huffman@15576
   535
(* ------------------------------------------------------------------------ *)
huffman@15576
   536
(* cont2cont Lemma for %x. LAM y. c1 x y)                                 *)
huffman@15576
   537
(* ------------------------------------------------------------------------ *)
huffman@15576
   538
huffman@15576
   539
lemma cont2cont_LAM:
huffman@15576
   540
assumes p1: "!!x. cont(c1 x)"
huffman@15576
   541
assumes p2: "!!y. cont(%x. c1 x y)"
huffman@15576
   542
shows "cont(%x. LAM y. c1 x y)"
huffman@15576
   543
apply (rule monocontlub2cont)
huffman@15576
   544
apply (rule p1 [THEN cont2mono_LAM])
huffman@15576
   545
apply (rule p2 [THEN cont2mono])
huffman@15576
   546
apply (rule contlubI)
huffman@15576
   547
apply (intro strip)
huffman@15576
   548
apply (subst thelub_cfun)
huffman@15576
   549
apply (rule p1 [THEN cont2mono_LAM, THEN ch2ch_monofun])
huffman@15576
   550
apply (rule p2 [THEN cont2mono])
huffman@15576
   551
apply assumption
huffman@15576
   552
apply (rule_tac f = "Abs_CFun" in arg_cong)
huffman@15576
   553
apply (rule ext)
huffman@15576
   554
apply (subst p1 [THEN beta_cfun, THEN ext])
huffman@15576
   555
apply (erule p2 [THEN cont2contlub, THEN contlubE, THEN spec, THEN mp])
huffman@15576
   556
done
huffman@15576
   557
huffman@15576
   558
(* ------------------------------------------------------------------------ *)
huffman@15576
   559
(* cont2cont tactic                                                       *)
huffman@15576
   560
(* ------------------------------------------------------------------------ *)
huffman@15576
   561
huffman@15576
   562
lemmas cont_lemmas1 = cont_const cont_id cont_Rep_CFun2
huffman@15576
   563
                    cont2cont_Rep_CFun cont2cont_LAM
huffman@15576
   564
huffman@15576
   565
declare cont_lemmas1 [simp]
huffman@15576
   566
huffman@15576
   567
(* HINT: cont_tac is now installed in simplifier in Lift.ML ! *)
huffman@15576
   568
huffman@15576
   569
(*val cont_tac = (fn i => (resolve_tac cont_lemmas i));*)
huffman@15576
   570
(*val cont_tacR = (fn i => (REPEAT (cont_tac i)));*)
huffman@15576
   571
huffman@15576
   572
(* ------------------------------------------------------------------------ *)
huffman@15576
   573
(* function application _[_]  is strict in its first arguments              *)
huffman@15576
   574
(* ------------------------------------------------------------------------ *)
huffman@15576
   575
huffman@15576
   576
lemma strict_Rep_CFun1: "(UU::'a::cpo->'b)$x = (UU::'b)"
huffman@15576
   577
apply (subst inst_cfun_pcpo)
huffman@15576
   578
apply (subst beta_cfun)
huffman@15576
   579
apply (simp (no_asm))
huffman@15576
   580
apply (rule refl)
huffman@15576
   581
done
huffman@15576
   582
huffman@15576
   583
huffman@15576
   584
(* ------------------------------------------------------------------------ *)
huffman@15576
   585
(* results about strictify                                                  *)
huffman@15576
   586
(* ------------------------------------------------------------------------ *)
huffman@15576
   587
huffman@15576
   588
lemma Istrictify1: 
huffman@15576
   589
        "Istrictify(f)(UU)= (UU)"
huffman@15576
   590
apply (unfold Istrictify_def)
huffman@15576
   591
apply (simp (no_asm))
huffman@15576
   592
done
huffman@15576
   593
huffman@15576
   594
lemma Istrictify2: 
huffman@15576
   595
        "~x=UU ==> Istrictify(f)(x)=f$x"
huffman@15576
   596
apply (unfold Istrictify_def)
huffman@15576
   597
apply (simp (no_asm_simp))
huffman@15576
   598
done
huffman@15576
   599
huffman@15576
   600
lemma monofun_Istrictify1: "monofun(Istrictify)"
huffman@15576
   601
apply (rule monofunI)
huffman@15576
   602
apply (intro strip)
huffman@15576
   603
apply (rule less_fun [THEN iffD2])
huffman@15576
   604
apply (intro strip)
huffman@15576
   605
apply (rule_tac Q = "xa=UU" in excluded_middle [THEN disjE])
huffman@15576
   606
apply (subst Istrictify2)
huffman@15576
   607
apply assumption
huffman@15576
   608
apply (subst Istrictify2)
huffman@15576
   609
apply assumption
huffman@15576
   610
apply (rule monofun_cfun_fun)
huffman@15576
   611
apply assumption
huffman@15576
   612
apply (erule ssubst)
huffman@15576
   613
apply (subst Istrictify1)
huffman@15576
   614
apply (subst Istrictify1)
huffman@15576
   615
apply (rule refl_less)
huffman@15576
   616
done
huffman@15576
   617
huffman@15576
   618
lemma monofun_Istrictify2: "monofun(Istrictify(f))"
huffman@15576
   619
apply (rule monofunI)
huffman@15576
   620
apply (intro strip)
huffman@15576
   621
apply (rule_tac Q = "x=UU" in excluded_middle [THEN disjE])
huffman@15576
   622
apply (simplesubst Istrictify2)
huffman@15576
   623
apply (erule notUU_I)
huffman@15576
   624
apply assumption
huffman@15576
   625
apply (subst Istrictify2)
huffman@15576
   626
apply assumption
huffman@15576
   627
apply (rule monofun_cfun_arg)
huffman@15576
   628
apply assumption
huffman@15576
   629
apply (erule ssubst)
huffman@15576
   630
apply (subst Istrictify1)
huffman@15576
   631
apply (rule minimal)
huffman@15576
   632
done
huffman@15576
   633
huffman@15576
   634
huffman@15576
   635
lemma contlub_Istrictify1: "contlub(Istrictify)"
huffman@15576
   636
apply (rule contlubI)
huffman@15576
   637
apply (intro strip)
huffman@15576
   638
apply (rule expand_fun_eq [THEN iffD2])
huffman@15576
   639
apply (intro strip)
huffman@15576
   640
apply (subst thelub_fun)
huffman@15576
   641
apply (erule monofun_Istrictify1 [THEN ch2ch_monofun])
huffman@15576
   642
apply (rule_tac Q = "x=UU" in excluded_middle [THEN disjE])
huffman@15576
   643
apply (subst Istrictify2)
huffman@15576
   644
apply assumption
huffman@15576
   645
apply (subst Istrictify2 [THEN ext])
huffman@15576
   646
apply assumption
huffman@15576
   647
apply (subst thelub_cfun)
huffman@15576
   648
apply assumption
huffman@15576
   649
apply (subst beta_cfun)
huffman@15576
   650
apply (rule cont_lubcfun)
huffman@15576
   651
apply assumption
huffman@15576
   652
apply (rule refl)
huffman@15576
   653
apply (erule ssubst)
huffman@15576
   654
apply (subst Istrictify1)
huffman@15576
   655
apply (subst Istrictify1 [THEN ext])
huffman@15576
   656
apply (rule chain_UU_I_inverse [symmetric])
huffman@15576
   657
apply (rule refl [THEN allI])
huffman@15576
   658
done
huffman@15576
   659
huffman@15576
   660
lemma contlub_Istrictify2: "contlub(Istrictify(f::'a -> 'b))"
huffman@15576
   661
apply (rule contlubI)
huffman@15576
   662
apply (intro strip)
huffman@15576
   663
apply (case_tac "lub (range (Y))= (UU::'a) ")
huffman@15576
   664
apply (simp (no_asm_simp) add: Istrictify1 chain_UU_I_inverse chain_UU_I Istrictify1)
huffman@15576
   665
apply (subst Istrictify2)
huffman@15576
   666
apply assumption
huffman@15576
   667
apply (rule_tac s = "lub (range (%i. f$ (Y i))) " in trans)
huffman@15576
   668
apply (rule contlub_cfun_arg)
huffman@15576
   669
apply assumption
huffman@15576
   670
apply (rule lub_equal2)
huffman@15576
   671
prefer 3 apply (best intro: ch2ch_monofun monofun_Istrictify2)
huffman@15576
   672
prefer 2 apply (best intro: ch2ch_monofun monofun_Rep_CFun2)
huffman@15576
   673
apply (rule chain_mono2 [THEN exE])
huffman@15576
   674
prefer 2 apply (assumption)
huffman@15576
   675
apply (erule chain_UU_I_inverse2)
huffman@15576
   676
apply (blast intro: Istrictify2 [symmetric])
huffman@15576
   677
done
huffman@15576
   678
huffman@15576
   679
huffman@15576
   680
lemmas cont_Istrictify1 = contlub_Istrictify1 [THEN monofun_Istrictify1 [THEN monocontlub2cont], standard]
huffman@15576
   681
huffman@15576
   682
lemmas cont_Istrictify2 = contlub_Istrictify2 [THEN monofun_Istrictify2 [THEN monocontlub2cont], standard]
huffman@15576
   683
huffman@15576
   684
huffman@15576
   685
lemma strictify1: "strictify$f$UU=UU"
huffman@15576
   686
apply (unfold strictify_def)
huffman@15576
   687
apply (subst beta_cfun)
huffman@15576
   688
apply (simp (no_asm) add: cont_Istrictify2 cont_Istrictify1 cont2cont_CF1L)
huffman@15576
   689
apply (subst beta_cfun)
huffman@15576
   690
apply (rule cont_Istrictify2)
huffman@15576
   691
apply (rule Istrictify1)
huffman@15576
   692
done
huffman@15576
   693
huffman@15576
   694
lemma strictify2: "~x=UU ==> strictify$f$x=f$x"
huffman@15576
   695
apply (unfold strictify_def)
huffman@15576
   696
apply (subst beta_cfun)
huffman@15576
   697
apply (simp (no_asm) add: cont_Istrictify2 cont_Istrictify1 cont2cont_CF1L)
huffman@15576
   698
apply (subst beta_cfun)
huffman@15576
   699
apply (rule cont_Istrictify2)
huffman@15576
   700
apply (erule Istrictify2)
huffman@15576
   701
done
huffman@15576
   702
huffman@15576
   703
huffman@15576
   704
(* ------------------------------------------------------------------------ *)
huffman@15576
   705
(* Instantiate the simplifier                                               *)
huffman@15576
   706
(* ------------------------------------------------------------------------ *)
huffman@15576
   707
huffman@15576
   708
declare minimal [simp] refl_less [simp] beta_cfun [simp] strict_Rep_CFun1 [simp] strictify1 [simp] strictify2 [simp]
huffman@15576
   709
huffman@15576
   710
huffman@15576
   711
(* ------------------------------------------------------------------------ *)
huffman@15576
   712
(* use cont_tac as autotac.                                                *)
huffman@15576
   713
(* ------------------------------------------------------------------------ *)
huffman@15576
   714
huffman@15576
   715
(* HINT: cont_tac is now installed in simplifier in Lift.ML ! *)
huffman@15576
   716
(*simpset_ref() := simpset() addsolver (K (DEPTH_SOLVE_1 o cont_tac));*)
huffman@15576
   717
huffman@15576
   718
(* ------------------------------------------------------------------------ *)
huffman@15576
   719
(* some lemmata for functions with flat/chfin domain/range types	    *)
huffman@15576
   720
(* ------------------------------------------------------------------------ *)
huffman@15576
   721
huffman@15576
   722
lemma chfin_Rep_CFunR: "chain (Y::nat => 'a::cpo->'b::chfin)  
huffman@15576
   723
      ==> !s. ? n. lub(range(Y))$s = Y n$s"
huffman@15576
   724
apply (rule allI)
huffman@15576
   725
apply (subst contlub_cfun_fun)
huffman@15576
   726
apply assumption
huffman@15576
   727
apply (fast intro!: thelubI chfin lub_finch2 chfin2finch ch2ch_Rep_CFunL)
huffman@15576
   728
done
huffman@15576
   729
huffman@15576
   730
(* ------------------------------------------------------------------------ *)
huffman@15576
   731
(* continuous isomorphisms are strict                                       *)
huffman@15576
   732
(* a prove for embedding projection pairs is similar                        *)
huffman@15576
   733
(* ------------------------------------------------------------------------ *)
huffman@15576
   734
huffman@15576
   735
lemma iso_strict: 
huffman@15576
   736
"!!f g.[|!y. f$(g$y)=(y::'b) ; !x. g$(f$x)=(x::'a) |]  
huffman@15576
   737
  ==> f$UU=UU & g$UU=UU"
huffman@15576
   738
apply (rule conjI)
huffman@15576
   739
apply (rule UU_I)
huffman@15576
   740
apply (rule_tac s = "f$ (g$ (UU::'b))" and t = "UU::'b" in subst)
huffman@15576
   741
apply (erule spec)
huffman@15576
   742
apply (rule minimal [THEN monofun_cfun_arg])
huffman@15576
   743
apply (rule UU_I)
huffman@15576
   744
apply (rule_tac s = "g$ (f$ (UU::'a))" and t = "UU::'a" in subst)
huffman@15576
   745
apply (erule spec)
huffman@15576
   746
apply (rule minimal [THEN monofun_cfun_arg])
huffman@15576
   747
done
huffman@15576
   748
huffman@15576
   749
huffman@15576
   750
lemma isorep_defined: "[|!x. rep$(ab$x)=x;!y. ab$(rep$y)=y; z~=UU|] ==> rep$z ~= UU"
huffman@15576
   751
apply (erule contrapos_nn)
huffman@15576
   752
apply (drule_tac f = "ab" in cfun_arg_cong)
huffman@15576
   753
apply (erule box_equals)
huffman@15576
   754
apply fast
huffman@15576
   755
apply (erule iso_strict [THEN conjunct1])
huffman@15576
   756
apply assumption
huffman@15576
   757
done
huffman@15576
   758
huffman@15576
   759
lemma isoabs_defined: "[|!x. rep$(ab$x) = x;!y. ab$(rep$y)=y ; z~=UU|] ==> ab$z ~= UU"
huffman@15576
   760
apply (erule contrapos_nn)
huffman@15576
   761
apply (drule_tac f = "rep" in cfun_arg_cong)
huffman@15576
   762
apply (erule box_equals)
huffman@15576
   763
apply fast
huffman@15576
   764
apply (erule iso_strict [THEN conjunct2])
huffman@15576
   765
apply assumption
huffman@15576
   766
done
huffman@15576
   767
huffman@15576
   768
(* ------------------------------------------------------------------------ *)
huffman@15576
   769
(* propagation of flatness and chainfiniteness by continuous isomorphisms   *)
huffman@15576
   770
(* ------------------------------------------------------------------------ *)
huffman@15576
   771
huffman@15576
   772
lemma chfin2chfin: "!!f g.[|! Y::nat=>'a. chain Y --> (? n. max_in_chain n Y);  
huffman@15576
   773
  !y. f$(g$y)=(y::'b) ; !x. g$(f$x)=(x::'a::chfin) |]  
huffman@15576
   774
  ==> ! Y::nat=>'b. chain Y --> (? n. max_in_chain n Y)"
huffman@15576
   775
apply (unfold max_in_chain_def)
huffman@15576
   776
apply (intro strip)
huffman@15576
   777
apply (rule exE)
huffman@15576
   778
apply (rule_tac P = "chain (%i. g$ (Y i))" in mp)
huffman@15576
   779
apply (erule spec)
huffman@15576
   780
apply (erule ch2ch_Rep_CFunR)
huffman@15576
   781
apply (rule exI)
huffman@15576
   782
apply (intro strip)
huffman@15576
   783
apply (rule_tac s = "f$ (g$ (Y x))" and t = "Y (x) " in subst)
huffman@15576
   784
apply (erule spec)
huffman@15576
   785
apply (rule_tac s = "f$ (g$ (Y j))" and t = "Y (j) " in subst)
huffman@15576
   786
apply (erule spec)
huffman@15576
   787
apply (rule cfun_arg_cong)
huffman@15576
   788
apply (rule mp)
huffman@15576
   789
apply (erule spec)
huffman@15576
   790
apply assumption
huffman@15576
   791
done
huffman@15576
   792
huffman@15576
   793
huffman@15576
   794
lemma flat2flat: "!!f g.[|!x y::'a. x<<y --> x=UU | x=y;  
huffman@15576
   795
  !y. f$(g$y)=(y::'b); !x. g$(f$x)=(x::'a)|] ==> !x y::'b. x<<y --> x=UU | x=y"
huffman@15576
   796
apply (intro strip)
huffman@15576
   797
apply (rule disjE)
huffman@15576
   798
apply (rule_tac P = "g$x<<g$y" in mp)
huffman@15576
   799
apply (erule_tac [2] monofun_cfun_arg)
huffman@15576
   800
apply (drule spec)
huffman@15576
   801
apply (erule spec)
huffman@15576
   802
apply (rule disjI1)
huffman@15576
   803
apply (rule trans)
huffman@15576
   804
apply (rule_tac s = "f$ (g$x) " and t = "x" in subst)
huffman@15576
   805
apply (erule spec)
huffman@15576
   806
apply (erule cfun_arg_cong)
huffman@15576
   807
apply (rule iso_strict [THEN conjunct1])
huffman@15576
   808
apply assumption
huffman@15576
   809
apply assumption
huffman@15576
   810
apply (rule disjI2)
huffman@15576
   811
apply (rule_tac s = "f$ (g$x) " and t = "x" in subst)
huffman@15576
   812
apply (erule spec)
huffman@15576
   813
apply (rule_tac s = "f$ (g$y) " and t = "y" in subst)
huffman@15576
   814
apply (erule spec)
huffman@15576
   815
apply (erule cfun_arg_cong)
huffman@15576
   816
done
huffman@15576
   817
huffman@15576
   818
(* ------------------------------------------------------------------------- *)
huffman@15576
   819
(* a result about functions with flat codomain                               *)
huffman@15576
   820
(* ------------------------------------------------------------------------- *)
huffman@15576
   821
huffman@15576
   822
lemma flat_codom: "f$(x::'a)=(c::'b::flat) ==> f$(UU::'a)=(UU::'b) | (!z. f$(z::'a)=c)"
huffman@15576
   823
apply (case_tac "f$ (x::'a) = (UU::'b) ")
huffman@15576
   824
apply (rule disjI1)
huffman@15576
   825
apply (rule UU_I)
huffman@15576
   826
apply (rule_tac s = "f$ (x) " and t = "UU::'b" in subst)
huffman@15576
   827
apply assumption
huffman@15576
   828
apply (rule minimal [THEN monofun_cfun_arg])
huffman@15576
   829
apply (case_tac "f$ (UU::'a) = (UU::'b) ")
huffman@15576
   830
apply (erule disjI1)
huffman@15576
   831
apply (rule disjI2)
huffman@15576
   832
apply (rule allI)
huffman@15576
   833
apply (erule subst)
huffman@15576
   834
apply (rule_tac a = "f$ (UU::'a) " in refl [THEN box_equals])
huffman@15576
   835
apply (rule_tac fo5 = "f" in minimal [THEN monofun_cfun_arg, THEN ax_flat [THEN spec, THEN spec, THEN mp], THEN disjE])
huffman@15576
   836
apply simp
huffman@15576
   837
apply assumption
huffman@15576
   838
apply (rule_tac fo5 = "f" in minimal [THEN monofun_cfun_arg, THEN ax_flat [THEN spec, THEN spec, THEN mp], THEN disjE])
huffman@15576
   839
apply simp
huffman@15576
   840
apply assumption
huffman@15576
   841
done
huffman@15576
   842
huffman@15576
   843
huffman@15576
   844
(* ------------------------------------------------------------------------ *)
huffman@15576
   845
(* Access to definitions                                                    *)
huffman@15576
   846
(* ------------------------------------------------------------------------ *)
huffman@15576
   847
huffman@15576
   848
huffman@15576
   849
lemma ID1: "ID$x=x"
huffman@15576
   850
apply (unfold ID_def)
huffman@15576
   851
apply (subst beta_cfun)
huffman@15576
   852
apply (rule cont_id)
huffman@15576
   853
apply (rule refl)
huffman@15576
   854
done
huffman@15576
   855
huffman@15576
   856
lemma cfcomp1: "(f oo g)=(LAM x. f$(g$x))"
huffman@15576
   857
apply (unfold oo_def)
huffman@15576
   858
apply (subst beta_cfun)
huffman@15576
   859
apply (simp (no_asm))
huffman@15576
   860
apply (subst beta_cfun)
huffman@15576
   861
apply (simp (no_asm))
huffman@15576
   862
apply (rule refl)
huffman@15576
   863
done
huffman@15576
   864
huffman@15576
   865
lemma cfcomp2: "(f oo g)$x=f$(g$x)"
huffman@15576
   866
apply (subst cfcomp1)
huffman@15576
   867
apply (subst beta_cfun)
huffman@15576
   868
apply (simp (no_asm))
huffman@15576
   869
apply (rule refl)
huffman@15576
   870
done
huffman@15576
   871
huffman@15576
   872
huffman@15576
   873
(* ------------------------------------------------------------------------ *)
huffman@15576
   874
(* Show that interpretation of (pcpo,_->_) is a category                    *)
huffman@15576
   875
(* The class of objects is interpretation of syntactical class pcpo         *)
huffman@15576
   876
(* The class of arrows  between objects 'a and 'b is interpret. of 'a -> 'b *)
huffman@15576
   877
(* The identity arrow is interpretation of ID                               *)
huffman@15576
   878
(* The composition of f and g is interpretation of oo                       *)
huffman@15576
   879
(* ------------------------------------------------------------------------ *)
huffman@15576
   880
huffman@15576
   881
huffman@15576
   882
lemma ID2: "f oo ID = f "
huffman@15576
   883
apply (rule ext_cfun)
huffman@15576
   884
apply (subst cfcomp2)
huffman@15576
   885
apply (subst ID1)
huffman@15576
   886
apply (rule refl)
huffman@15576
   887
done
huffman@15576
   888
huffman@15576
   889
lemma ID3: "ID oo f = f "
huffman@15576
   890
apply (rule ext_cfun)
huffman@15576
   891
apply (subst cfcomp2)
huffman@15576
   892
apply (subst ID1)
huffman@15576
   893
apply (rule refl)
huffman@15576
   894
done
huffman@15576
   895
huffman@15576
   896
huffman@15576
   897
lemma assoc_oo: "f oo (g oo h) = (f oo g) oo h"
huffman@15576
   898
apply (rule ext_cfun)
huffman@15576
   899
apply (rule_tac s = "f$ (g$ (h$x))" in trans)
huffman@15576
   900
apply (subst cfcomp2)
huffman@15576
   901
apply (subst cfcomp2)
huffman@15576
   902
apply (rule refl)
huffman@15576
   903
apply (subst cfcomp2)
huffman@15576
   904
apply (subst cfcomp2)
huffman@15576
   905
apply (rule refl)
huffman@15576
   906
done
huffman@15576
   907
huffman@15576
   908
(* ------------------------------------------------------------------------ *)
huffman@15576
   909
(* Merge the different rewrite rules for the simplifier                     *)
huffman@15576
   910
(* ------------------------------------------------------------------------ *)
huffman@15576
   911
huffman@15576
   912
declare  ID1[simp] ID2[simp] ID3[simp] cfcomp2[simp]
huffman@15576
   913
huffman@15576
   914
end