src/HOLCF/Cfun2.ML
author wenzelm
Sat Nov 03 01:41:26 2001 +0100 (2001-11-03)
changeset 12030 46d57d0290a2
parent 11341 100edbd42dba
child 12484 7ad150f5fc10
permissions -rw-r--r--
GPLed;
paulson@9245
     1
(*  Title:      HOLCF/Cfun2
nipkow@243
     2
    ID:         $Id$
clasohm@1461
     3
    Author:     Franz Regensburger
wenzelm@12030
     4
    License:    GPL (GNU GENERAL PUBLIC LICENSE)
nipkow@243
     5
paulson@9245
     6
Class Instance ->::(cpo,cpo)po
nipkow@243
     7
*)
nipkow@243
     8
slotosch@2640
     9
(* for compatibility with old HOLCF-Version *)
paulson@9248
    10
Goal "(op <<)=(%f1 f2. Rep_CFun f1 << Rep_CFun f2)";
paulson@9245
    11
by (fold_goals_tac [less_cfun_def]);
paulson@9245
    12
by (rtac refl 1);
paulson@9245
    13
qed "inst_cfun_po";
slotosch@2640
    14
nipkow@243
    15
(* ------------------------------------------------------------------------ *)
nipkow@243
    16
(* access to less_cfun in class po                                          *)
nipkow@243
    17
(* ------------------------------------------------------------------------ *)
nipkow@243
    18
paulson@9248
    19
Goal "( f1 << f2 ) = (Rep_CFun(f1) << Rep_CFun(f2))";
paulson@9245
    20
by (simp_tac (simpset() addsimps [inst_cfun_po]) 1);
paulson@9245
    21
qed "less_cfun";
nipkow@243
    22
nipkow@243
    23
(* ------------------------------------------------------------------------ *)
nipkow@243
    24
(* Type 'a ->'b  is pointed                                                 *)
nipkow@243
    25
(* ------------------------------------------------------------------------ *)
nipkow@243
    26
paulson@9248
    27
Goal "Abs_CFun(% x. UU) << f";
paulson@9245
    28
by (stac less_cfun 1);
paulson@9245
    29
by (stac Abs_Cfun_inverse2 1);
paulson@9245
    30
by (rtac cont_const 1);
paulson@9245
    31
by (rtac minimal_fun 1);
paulson@9245
    32
qed "minimal_cfun";
nipkow@243
    33
slotosch@2640
    34
bind_thm ("UU_cfun_def",minimal_cfun RS minimal2UU RS sym);
slotosch@2640
    35
paulson@9248
    36
Goal "? x::'a->'b::pcpo.!y. x<<y";
paulson@9245
    37
by (res_inst_tac [("x","Abs_CFun(% x. UU)")] exI 1);
paulson@9245
    38
by (rtac (minimal_cfun RS allI) 1);
paulson@9245
    39
qed "least_cfun";
slotosch@2640
    40
nipkow@243
    41
(* ------------------------------------------------------------------------ *)
slotosch@5291
    42
(* Rep_CFun yields continuous functions in 'a => 'b                             *)
slotosch@5291
    43
(* this is continuity of Rep_CFun in its 'second' argument                      *)
slotosch@5291
    44
(* cont_Rep_CFun2 ==> monofun_Rep_CFun2 & contlub_Rep_CFun2                            *)
nipkow@243
    45
(* ------------------------------------------------------------------------ *)
nipkow@243
    46
paulson@9248
    47
Goal "cont(Rep_CFun(fo))";
paulson@9245
    48
by (res_inst_tac [("P","cont")] CollectD 1);
paulson@9245
    49
by (fold_goals_tac [CFun_def]);
paulson@9245
    50
by (rtac Rep_Cfun 1);
paulson@9245
    51
qed "cont_Rep_CFun2";
nipkow@243
    52
slotosch@5291
    53
bind_thm ("monofun_Rep_CFun2", cont_Rep_CFun2 RS cont2mono);
slotosch@5291
    54
(* monofun(Rep_CFun(?fo1)) *)
nipkow@243
    55
nipkow@243
    56
slotosch@5291
    57
bind_thm ("contlub_Rep_CFun2", cont_Rep_CFun2 RS cont2contlub);
slotosch@5291
    58
(* contlub(Rep_CFun(?fo1)) *)
nipkow@243
    59
nipkow@243
    60
(* ------------------------------------------------------------------------ *)
slotosch@5291
    61
(* expanded thms cont_Rep_CFun2, contlub_Rep_CFun2                                 *)
regensbu@1168
    62
(* looks nice with mixfix syntac                                            *)
nipkow@243
    63
(* ------------------------------------------------------------------------ *)
nipkow@243
    64
slotosch@5291
    65
bind_thm ("cont_cfun_arg", (cont_Rep_CFun2 RS contE RS spec RS mp));
nipkow@10834
    66
(* chain(?x1) ==> range (%i. ?fo3$(?x1 i)) <<| ?fo3$(lub (range ?x1))    *)
nipkow@243
    67
 
slotosch@5291
    68
bind_thm ("contlub_cfun_arg", (contlub_Rep_CFun2 RS contlubE RS spec RS mp));
nipkow@10834
    69
(* chain(?x1) ==> ?fo4$(lub (range ?x1)) = lub (range (%i. ?fo4$(?x1 i))) *)
nipkow@243
    70
nipkow@243
    71
nipkow@243
    72
(* ------------------------------------------------------------------------ *)
slotosch@5291
    73
(* Rep_CFun is monotone in its 'first' argument                                 *)
nipkow@243
    74
(* ------------------------------------------------------------------------ *)
nipkow@243
    75
paulson@9248
    76
Goalw [monofun] "monofun(Rep_CFun)";
paulson@9245
    77
by (strip_tac 1);
paulson@9245
    78
by (etac (less_cfun RS subst) 1);
paulson@9245
    79
qed "monofun_Rep_CFun1";
nipkow@243
    80
nipkow@243
    81
nipkow@243
    82
(* ------------------------------------------------------------------------ *)
slotosch@5291
    83
(* monotonicity of application Rep_CFun in mixfix syntax [_]_                   *)
nipkow@243
    84
(* ------------------------------------------------------------------------ *)
nipkow@243
    85
nipkow@10834
    86
Goal  "f1 << f2 ==> f1$x << f2$x";
paulson@9245
    87
by (res_inst_tac [("x","x")] spec 1);
paulson@9245
    88
by (rtac (less_fun RS subst) 1);
paulson@9245
    89
by (etac (monofun_Rep_CFun1 RS monofunE RS spec RS spec RS mp) 1);
paulson@9245
    90
qed "monofun_cfun_fun";
nipkow@243
    91
nipkow@243
    92
slotosch@5291
    93
bind_thm ("monofun_cfun_arg", monofun_Rep_CFun2 RS monofunE RS spec RS spec RS mp);
nipkow@10834
    94
(* ?x2 << ?x1 ==> ?fo5$?x2 << ?fo5$?x1                                      *)
nipkow@243
    95
oheimb@11341
    96
Goal "chain Y ==> chain (%i. f\\<cdot>(Y i))";
oheimb@11341
    97
br chainI 1;
oheimb@11341
    98
br monofun_cfun_arg 1;
oheimb@11341
    99
be chainE 1;
oheimb@11341
   100
qed "chain_monofun";
oheimb@11341
   101
oheimb@11341
   102
nipkow@243
   103
(* ------------------------------------------------------------------------ *)
slotosch@5291
   104
(* monotonicity of Rep_CFun in both arguments in mixfix syntax [_]_             *)
nipkow@243
   105
(* ------------------------------------------------------------------------ *)
nipkow@243
   106
nipkow@10834
   107
Goal "[|f1<<f2;x1<<x2|] ==> f1$x1 << f2$x2";
paulson@9245
   108
by (rtac trans_less 1);
paulson@9245
   109
by (etac monofun_cfun_arg 1);
paulson@9245
   110
by (etac monofun_cfun_fun 1);
paulson@9245
   111
qed "monofun_cfun";
nipkow@243
   112
nipkow@243
   113
nipkow@10834
   114
Goal "f$x = UU ==> f$UU = UU";
paulson@9245
   115
by (rtac (eq_UU_iff RS iffD2) 1);
paulson@9245
   116
by (etac subst 1);
paulson@9245
   117
by (rtac (minimal RS monofun_cfun_arg) 1);
paulson@9245
   118
qed "strictI";
oheimb@1989
   119
oheimb@1989
   120
nipkow@243
   121
(* ------------------------------------------------------------------------ *)
nipkow@243
   122
(* ch2ch - rules for the type 'a -> 'b                                      *)
nipkow@243
   123
(* use MF2 lemmas from Cont.ML                                              *)
nipkow@243
   124
(* ------------------------------------------------------------------------ *)
nipkow@243
   125
nipkow@10834
   126
Goal "chain(Y) ==> chain(%i. f$(Y i))";
paulson@9245
   127
by (etac (monofun_Rep_CFun2 RS ch2ch_MF2R) 1);
paulson@9245
   128
qed "ch2ch_Rep_CFunR";
nipkow@243
   129
nipkow@243
   130
slotosch@5291
   131
bind_thm ("ch2ch_Rep_CFunL", monofun_Rep_CFun1 RS ch2ch_MF2L);
nipkow@10834
   132
(* chain(?F) ==> chain (%i. ?F i$?x)                                  *)
nipkow@243
   133
nipkow@243
   134
nipkow@243
   135
(* ------------------------------------------------------------------------ *)
nipkow@243
   136
(*  the lub of a chain of continous functions is monotone                   *)
nipkow@243
   137
(* use MF2 lemmas from Cont.ML                                              *)
nipkow@243
   138
(* ------------------------------------------------------------------------ *)
nipkow@243
   139
nipkow@10834
   140
Goal "chain(F) ==> monofun(% x. lub(range(% j.(F j)$x)))";
paulson@9245
   141
by (rtac lub_MF2_mono 1);
paulson@9245
   142
by (rtac monofun_Rep_CFun1 1);
paulson@9245
   143
by (rtac (monofun_Rep_CFun2 RS allI) 1);
paulson@9245
   144
by (atac 1);
paulson@9245
   145
qed "lub_cfun_mono";
nipkow@243
   146
nipkow@243
   147
(* ------------------------------------------------------------------------ *)
nipkow@243
   148
(* a lemma about the exchange of lubs for type 'a -> 'b                     *)
nipkow@243
   149
(* use MF2 lemmas from Cont.ML                                              *)
nipkow@243
   150
(* ------------------------------------------------------------------------ *)
nipkow@243
   151
paulson@9248
   152
Goal "[| chain(F); chain(Y) |] ==>\
nipkow@10834
   153
\               lub(range(%j. lub(range(%i. F(j)$(Y i))))) =\
nipkow@10834
   154
\               lub(range(%i. lub(range(%j. F(j)$(Y i)))))";
paulson@9245
   155
by (rtac ex_lubMF2 1);
paulson@9245
   156
by (rtac monofun_Rep_CFun1 1);
paulson@9245
   157
by (rtac (monofun_Rep_CFun2 RS allI) 1);
paulson@9245
   158
by (atac 1);
paulson@9245
   159
by (atac 1);
paulson@9245
   160
qed "ex_lubcfun";
nipkow@243
   161
nipkow@243
   162
(* ------------------------------------------------------------------------ *)
nipkow@243
   163
(* the lub of a chain of cont. functions is continuous                      *)
nipkow@243
   164
(* ------------------------------------------------------------------------ *)
nipkow@243
   165
nipkow@10834
   166
Goal "chain(F) ==> cont(% x. lub(range(% j. F(j)$x)))";
paulson@9245
   167
by (rtac monocontlub2cont 1);
paulson@9245
   168
by (etac lub_cfun_mono 1);
paulson@9245
   169
by (rtac contlubI 1);
paulson@9245
   170
by (strip_tac 1);
paulson@9245
   171
by (stac (contlub_cfun_arg RS ext) 1);
paulson@9245
   172
by (atac 1);
paulson@9245
   173
by (etac ex_lubcfun 1);
paulson@9245
   174
by (atac 1);
paulson@9245
   175
qed "cont_lubcfun";
nipkow@243
   176
nipkow@243
   177
(* ------------------------------------------------------------------------ *)
nipkow@243
   178
(* type 'a -> 'b is chain complete                                          *)
nipkow@243
   179
(* ------------------------------------------------------------------------ *)
nipkow@243
   180
nipkow@10834
   181
Goal "chain(CCF) ==> range(CCF) <<| (LAM x. lub(range(% i. CCF(i)$x)))";
paulson@9245
   182
by (rtac is_lubI 1);
paulson@9245
   183
by (rtac ub_rangeI 1);
paulson@9245
   184
by (stac less_cfun 1);
paulson@9245
   185
by (stac Abs_Cfun_inverse2 1);
paulson@9245
   186
by (etac cont_lubcfun 1);
paulson@9248
   187
by (rtac (lub_fun RS is_lubD1 RS ub_rangeD) 1);
paulson@9245
   188
by (etac (monofun_Rep_CFun1 RS ch2ch_monofun) 1);
paulson@9245
   189
by (stac less_cfun 1);
paulson@9245
   190
by (stac Abs_Cfun_inverse2 1);
paulson@9245
   191
by (etac cont_lubcfun 1);
paulson@9248
   192
by (rtac (lub_fun RS is_lub_lub) 1);
paulson@9245
   193
by (etac (monofun_Rep_CFun1 RS ch2ch_monofun) 1);
paulson@9245
   194
by (etac (monofun_Rep_CFun1 RS ub2ub_monofun) 1);
paulson@9245
   195
qed "lub_cfun";
nipkow@243
   196
oheimb@1779
   197
bind_thm ("thelub_cfun", lub_cfun RS thelubI);
nipkow@243
   198
(* 
nipkow@10834
   199
chain(?CCF1) ==>  lub (range ?CCF1) = (LAM x. lub (range (%i. ?CCF1 i$x)))
nipkow@243
   200
*)
nipkow@243
   201
paulson@9248
   202
Goal "chain(CCF::nat=>('a->'b)) ==> ? x. range(CCF) <<| x";
paulson@9245
   203
by (rtac exI 1);
paulson@9245
   204
by (etac lub_cfun 1);
paulson@9245
   205
qed "cpo_cfun";
nipkow@243
   206
nipkow@243
   207
nipkow@243
   208
(* ------------------------------------------------------------------------ *)
nipkow@243
   209
(* Extensionality in 'a -> 'b                                               *)
nipkow@243
   210
(* ------------------------------------------------------------------------ *)
nipkow@243
   211
nipkow@10834
   212
val prems = Goal "(!!x. f$x = g$x) ==> f = g";
paulson@9245
   213
by (res_inst_tac [("t","f")] (Rep_Cfun_inverse RS subst) 1);
paulson@9245
   214
by (res_inst_tac [("t","g")] (Rep_Cfun_inverse RS subst) 1);
paulson@9245
   215
by (res_inst_tac [("f","Abs_CFun")] arg_cong 1);
paulson@9245
   216
by (rtac ext 1);
paulson@9245
   217
by (resolve_tac prems 1);
paulson@9245
   218
qed "ext_cfun";
nipkow@243
   219
nipkow@243
   220
(* ------------------------------------------------------------------------ *)
slotosch@5291
   221
(* Monotonicity of Abs_CFun                                                     *)
nipkow@243
   222
(* ------------------------------------------------------------------------ *)
nipkow@243
   223
paulson@9248
   224
Goal "[| cont(f); cont(g); f<<g|] ==> Abs_CFun(f)<<Abs_CFun(g)";
paulson@9245
   225
by (rtac (less_cfun RS iffD2) 1);
paulson@9245
   226
by (stac Abs_Cfun_inverse2 1);
paulson@9248
   227
by (assume_tac 1);
paulson@9245
   228
by (stac Abs_Cfun_inverse2 1);
paulson@9248
   229
by (assume_tac 1);
paulson@9248
   230
by (assume_tac 1);
paulson@9245
   231
qed "semi_monofun_Abs_CFun";
nipkow@243
   232
nipkow@243
   233
(* ------------------------------------------------------------------------ *)
nipkow@243
   234
(* Extenionality wrt. << in 'a -> 'b                                        *)
nipkow@243
   235
(* ------------------------------------------------------------------------ *)
nipkow@243
   236
nipkow@10834
   237
val prems = Goal "(!!x. f$x << g$x) ==> f << g";
paulson@9245
   238
by (res_inst_tac [("t","f")] (Rep_Cfun_inverse RS subst) 1);
paulson@9245
   239
by (res_inst_tac [("t","g")] (Rep_Cfun_inverse RS subst) 1);
paulson@9245
   240
by (rtac semi_monofun_Abs_CFun 1);
paulson@9245
   241
by (rtac cont_Rep_CFun2 1);
paulson@9245
   242
by (rtac cont_Rep_CFun2 1);
paulson@9245
   243
by (rtac (less_fun RS iffD2) 1);
paulson@9245
   244
by (rtac allI 1);
paulson@9245
   245
by (resolve_tac prems 1);
paulson@9245
   246
qed "less_cfun2";
nipkow@243
   247
nipkow@243
   248