src/HOLCF/cfun3.ML
author paulson
Mon Dec 07 18:26:25 1998 +0100 (1998-12-07)
changeset 6019 0e55c2fb2ebb
parent 243 c22b85994e17
permissions -rw-r--r--
tidying
nipkow@243
     1
(*  Title: 	HOLCF/cfun3.ML
nipkow@243
     2
    ID:         $Id$
nipkow@243
     3
    Author: 	Franz Regensburger
nipkow@243
     4
    Copyright   1993 Technische Universitaet Muenchen
nipkow@243
     5
*)
nipkow@243
     6
nipkow@243
     7
open Cfun3;
nipkow@243
     8
nipkow@243
     9
(* ------------------------------------------------------------------------ *)
nipkow@243
    10
(* the contlub property for fapp its 'first' argument                       *)
nipkow@243
    11
(* ------------------------------------------------------------------------ *)
nipkow@243
    12
nipkow@243
    13
val contlub_fapp1 = prove_goal Cfun3.thy "contlub(fapp)"
nipkow@243
    14
(fn prems =>
nipkow@243
    15
	[
nipkow@243
    16
	(rtac contlubI 1),
nipkow@243
    17
	(strip_tac 1),
nipkow@243
    18
	(rtac (expand_fun_eq RS iffD2) 1),
nipkow@243
    19
	(strip_tac 1),
nipkow@243
    20
	(rtac (lub_cfun RS thelubI RS ssubst) 1),
nipkow@243
    21
	(atac 1),
nipkow@243
    22
	(rtac (Cfunapp2 RS ssubst) 1),
nipkow@243
    23
	(etac contX_lubcfun 1),
nipkow@243
    24
	(rtac (lub_fun RS thelubI RS ssubst) 1),
nipkow@243
    25
	(etac (monofun_fapp1 RS ch2ch_monofun) 1),
nipkow@243
    26
	(rtac refl 1)
nipkow@243
    27
	]);
nipkow@243
    28
nipkow@243
    29
nipkow@243
    30
(* ------------------------------------------------------------------------ *)
nipkow@243
    31
(* the contX property for fapp in its first argument                        *)
nipkow@243
    32
(* ------------------------------------------------------------------------ *)
nipkow@243
    33
nipkow@243
    34
val contX_fapp1 = prove_goal Cfun3.thy "contX(fapp)"
nipkow@243
    35
(fn prems =>
nipkow@243
    36
	[
nipkow@243
    37
	(rtac monocontlub2contX 1),
nipkow@243
    38
	(rtac monofun_fapp1 1),
nipkow@243
    39
	(rtac contlub_fapp1 1)
nipkow@243
    40
	]);
nipkow@243
    41
nipkow@243
    42
nipkow@243
    43
(* ------------------------------------------------------------------------ *)
nipkow@243
    44
(* contlub, contX properties of fapp in its first argument in mixfix _[_]   *)
nipkow@243
    45
(* ------------------------------------------------------------------------ *)
nipkow@243
    46
nipkow@243
    47
val contlub_cfun_fun = prove_goal Cfun3.thy 
nipkow@243
    48
"is_chain(FY) ==>\
nipkow@243
    49
\ lub(range(FY))[x] = lub(range(%i.FY(i)[x]))"
nipkow@243
    50
(fn prems =>
nipkow@243
    51
	[
nipkow@243
    52
	(cut_facts_tac prems 1),
nipkow@243
    53
	(rtac trans 1),
nipkow@243
    54
	(etac (contlub_fapp1 RS contlubE RS spec RS mp RS fun_cong) 1),
nipkow@243
    55
	(rtac (thelub_fun RS ssubst) 1),
nipkow@243
    56
	(etac (monofun_fapp1 RS ch2ch_monofun) 1),
nipkow@243
    57
	(rtac refl 1)
nipkow@243
    58
	]);
nipkow@243
    59
nipkow@243
    60
nipkow@243
    61
val contX_cfun_fun = prove_goal Cfun3.thy 
nipkow@243
    62
"is_chain(FY) ==>\
nipkow@243
    63
\ range(%i.FY(i)[x]) <<| lub(range(FY))[x]"
nipkow@243
    64
(fn prems =>
nipkow@243
    65
	[
nipkow@243
    66
	(cut_facts_tac prems 1),
nipkow@243
    67
	(rtac thelubE 1),
nipkow@243
    68
	(etac ch2ch_fappL 1),
nipkow@243
    69
	(etac (contlub_cfun_fun RS sym) 1)
nipkow@243
    70
	]);
nipkow@243
    71
nipkow@243
    72
nipkow@243
    73
(* ------------------------------------------------------------------------ *)
nipkow@243
    74
(* contlub, contX  properties of fapp in both argument in mixfix _[_]       *)
nipkow@243
    75
(* ------------------------------------------------------------------------ *)
nipkow@243
    76
nipkow@243
    77
val contlub_cfun = prove_goal Cfun3.thy 
nipkow@243
    78
"[|is_chain(FY);is_chain(TY)|] ==>\
nipkow@243
    79
\ lub(range(FY))[lub(range(TY))] = lub(range(%i.FY(i)[TY(i)]))"
nipkow@243
    80
(fn prems =>
nipkow@243
    81
	[
nipkow@243
    82
	(cut_facts_tac prems 1),
nipkow@243
    83
	(rtac contlub_CF2 1),
nipkow@243
    84
	(rtac contX_fapp1 1),
nipkow@243
    85
	(rtac allI 1),
nipkow@243
    86
	(rtac contX_fapp2 1),
nipkow@243
    87
	(atac 1),
nipkow@243
    88
	(atac 1)
nipkow@243
    89
	]);
nipkow@243
    90
nipkow@243
    91
val contX_cfun = prove_goal Cfun3.thy 
nipkow@243
    92
"[|is_chain(FY);is_chain(TY)|] ==>\
nipkow@243
    93
\ range(%i.FY(i)[TY(i)]) <<| lub(range(FY))[lub(range(TY))]"
nipkow@243
    94
(fn prems =>
nipkow@243
    95
	[
nipkow@243
    96
	(cut_facts_tac prems 1),
nipkow@243
    97
	(rtac thelubE 1),
nipkow@243
    98
	(rtac (monofun_fapp1 RS ch2ch_MF2LR) 1),
nipkow@243
    99
	(rtac allI 1),
nipkow@243
   100
	(rtac monofun_fapp2 1),
nipkow@243
   101
	(atac 1),
nipkow@243
   102
	(atac 1),
nipkow@243
   103
	(etac (contlub_cfun RS sym) 1),
nipkow@243
   104
	(atac 1)
nipkow@243
   105
	]);
nipkow@243
   106
nipkow@243
   107
nipkow@243
   108
(* ------------------------------------------------------------------------ *)
nipkow@243
   109
(* contX2contX lemma for fapp                                               *)
nipkow@243
   110
(* ------------------------------------------------------------------------ *)
nipkow@243
   111
nipkow@243
   112
val contX2contX_fapp = prove_goal Cfun3.thy 
nipkow@243
   113
	"[|contX(%x.ft(x));contX(%x.tt(x))|] ==> contX(%x.(ft(x))[tt(x)])"
nipkow@243
   114
 (fn prems =>
nipkow@243
   115
	[
nipkow@243
   116
	(cut_facts_tac prems 1),
nipkow@243
   117
	(rtac contX2contX_app2 1),
nipkow@243
   118
	(rtac contX2contX_app2 1),
nipkow@243
   119
	(rtac contX_const 1),
nipkow@243
   120
	(rtac contX_fapp1 1),
nipkow@243
   121
	(atac 1),
nipkow@243
   122
	(rtac contX_fapp2 1),
nipkow@243
   123
	(atac 1)
nipkow@243
   124
	]);
nipkow@243
   125
nipkow@243
   126
nipkow@243
   127
nipkow@243
   128
(* ------------------------------------------------------------------------ *)
nipkow@243
   129
(* contX2mono Lemma for %x. LAM y. c1(x,y)                                  *)
nipkow@243
   130
(* ------------------------------------------------------------------------ *)
nipkow@243
   131
nipkow@243
   132
val contX2mono_LAM = prove_goal Cfun3.thy 
nipkow@243
   133
 "[|!x.contX(c1(x)); !y.monofun(%x.c1(x,y))|] ==>\
nipkow@243
   134
\	 		monofun(%x. LAM y. c1(x,y))"
nipkow@243
   135
(fn prems =>
nipkow@243
   136
	[
nipkow@243
   137
	(cut_facts_tac prems 1),
nipkow@243
   138
	(rtac monofunI 1),
nipkow@243
   139
	(strip_tac 1),
nipkow@243
   140
	(rtac (less_cfun RS ssubst) 1),
nipkow@243
   141
	(rtac (less_fun RS ssubst) 1),
nipkow@243
   142
	(rtac allI 1),
nipkow@243
   143
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   144
	(etac spec 1),
nipkow@243
   145
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   146
	(etac spec 1),
nipkow@243
   147
	(etac ((hd (tl prems)) RS spec RS monofunE RS spec RS spec RS mp) 1)
nipkow@243
   148
	]);
nipkow@243
   149
nipkow@243
   150
(* ------------------------------------------------------------------------ *)
nipkow@243
   151
(* contX2contX Lemma for %x. LAM y. c1(x,y)                                 *)
nipkow@243
   152
(* ------------------------------------------------------------------------ *)
nipkow@243
   153
nipkow@243
   154
val contX2contX_LAM = prove_goal Cfun3.thy 
nipkow@243
   155
 "[| !x.contX(c1(x)); !y.contX(%x.c1(x,y)) |] ==> contX(%x. LAM y. c1(x,y))"
nipkow@243
   156
(fn prems =>
nipkow@243
   157
	[
nipkow@243
   158
	(cut_facts_tac prems 1),
nipkow@243
   159
	(rtac monocontlub2contX 1),
nipkow@243
   160
	(etac contX2mono_LAM 1),
nipkow@243
   161
	(rtac (contX2mono RS allI) 1),
nipkow@243
   162
	(etac spec 1),
nipkow@243
   163
	(rtac contlubI 1),
nipkow@243
   164
	(strip_tac 1),
nipkow@243
   165
	(rtac (thelub_cfun RS ssubst) 1),
nipkow@243
   166
	(rtac (contX2mono_LAM RS ch2ch_monofun) 1),
nipkow@243
   167
	(atac 1),
nipkow@243
   168
	(rtac (contX2mono RS allI) 1),
nipkow@243
   169
	(etac spec 1),
nipkow@243
   170
	(atac 1),
nipkow@243
   171
	(res_inst_tac [("f","fabs")] arg_cong 1),
nipkow@243
   172
	(rtac ext 1),
nipkow@243
   173
	(rtac (beta_cfun RS ext RS ssubst) 1),
nipkow@243
   174
	(etac spec 1),
nipkow@243
   175
	(rtac (contX2contlub RS contlubE 
nipkow@243
   176
		RS spec RS mp ) 1),
nipkow@243
   177
	(etac spec 1),
nipkow@243
   178
	(atac 1)
nipkow@243
   179
	]);
nipkow@243
   180
nipkow@243
   181
(* ------------------------------------------------------------------------ *)
nipkow@243
   182
(* elimination of quantifier in premisses of contX2contX_LAM yields good    *)
nipkow@243
   183
(* lemma for the contX tactic                                               *)
nipkow@243
   184
(* ------------------------------------------------------------------------ *)
nipkow@243
   185
nipkow@243
   186
val contX2contX_LAM2 = (allI RSN (2,(allI RS contX2contX_LAM)));
nipkow@243
   187
(*
nipkow@243
   188
	[| !!x. contX(?c1.0(x)); !!y. contX(%x. ?c1.0(x,y)) |] ==>
nipkow@243
   189
					contX(%x. LAM y. ?c1.0(x,y))
nipkow@243
   190
*)
nipkow@243
   191
nipkow@243
   192
(* ------------------------------------------------------------------------ *)
nipkow@243
   193
(* contX2contX tactic                                                       *)
nipkow@243
   194
(* ------------------------------------------------------------------------ *)
nipkow@243
   195
nipkow@243
   196
val contX_lemmas = [contX_const, contX_id, contX_fapp2,
nipkow@243
   197
			contX2contX_fapp,contX2contX_LAM2];
nipkow@243
   198
nipkow@243
   199
nipkow@243
   200
val contX_tac = (fn i => (resolve_tac contX_lemmas i));
nipkow@243
   201
nipkow@243
   202
val contX_tacR = (fn i => (REPEAT (contX_tac i)));
nipkow@243
   203
nipkow@243
   204
(* ------------------------------------------------------------------------ *)
nipkow@243
   205
(* function application _[_]  is strict in its first arguments              *)
nipkow@243
   206
(* ------------------------------------------------------------------------ *)
nipkow@243
   207
nipkow@243
   208
val strict_fapp1 = prove_goal Cfun3.thy "UU[x] = UU"
nipkow@243
   209
 (fn prems =>
nipkow@243
   210
	[
nipkow@243
   211
	(rtac (inst_cfun_pcpo RS ssubst) 1),
nipkow@243
   212
	(rewrite_goals_tac [UU_cfun_def]),
nipkow@243
   213
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   214
	(contX_tac 1),
nipkow@243
   215
	(rtac refl 1)
nipkow@243
   216
	]);
nipkow@243
   217
nipkow@243
   218
nipkow@243
   219
(* ------------------------------------------------------------------------ *)
nipkow@243
   220
(* results about strictify                                                  *)
nipkow@243
   221
(* ------------------------------------------------------------------------ *)
nipkow@243
   222
nipkow@243
   223
val Istrictify1 = prove_goalw Cfun3.thy [Istrictify_def]
nipkow@243
   224
	"Istrictify(f)(UU)=UU"
nipkow@243
   225
 (fn prems =>
nipkow@243
   226
	[
nipkow@243
   227
	(rtac select_equality 1),
nipkow@243
   228
	(fast_tac HOL_cs 1),
nipkow@243
   229
	(fast_tac HOL_cs 1)
nipkow@243
   230
	]);
nipkow@243
   231
nipkow@243
   232
val Istrictify2 = prove_goalw Cfun3.thy [Istrictify_def]
nipkow@243
   233
	"~x=UU ==> Istrictify(f)(x)=f[x]"
nipkow@243
   234
 (fn prems =>
nipkow@243
   235
	[
nipkow@243
   236
	(cut_facts_tac prems 1),
nipkow@243
   237
	(rtac select_equality 1),
nipkow@243
   238
	(fast_tac HOL_cs 1),
nipkow@243
   239
	(fast_tac HOL_cs 1)
nipkow@243
   240
	]);
nipkow@243
   241
nipkow@243
   242
val monofun_Istrictify1 = prove_goal Cfun3.thy "monofun(Istrictify)"
nipkow@243
   243
 (fn prems =>
nipkow@243
   244
	[
nipkow@243
   245
	(rtac monofunI 1),
nipkow@243
   246
	(strip_tac 1),
nipkow@243
   247
	(rtac (less_fun RS iffD2) 1),
nipkow@243
   248
	(strip_tac 1),
nipkow@243
   249
	(res_inst_tac [("Q","xa=UU")] (excluded_middle RS disjE) 1),
nipkow@243
   250
	(rtac (Istrictify2 RS ssubst) 1),
nipkow@243
   251
	(atac 1),
nipkow@243
   252
	(rtac (Istrictify2 RS ssubst) 1),
nipkow@243
   253
	(atac 1),
nipkow@243
   254
	(rtac monofun_cfun_fun 1),
nipkow@243
   255
	(atac 1),
nipkow@243
   256
	(hyp_subst_tac 1),
nipkow@243
   257
	(rtac (Istrictify1 RS ssubst) 1),
nipkow@243
   258
	(rtac (Istrictify1 RS ssubst) 1),
nipkow@243
   259
	(rtac refl_less 1)
nipkow@243
   260
	]);
nipkow@243
   261
nipkow@243
   262
val monofun_Istrictify2 = prove_goal Cfun3.thy "monofun(Istrictify(f))"
nipkow@243
   263
 (fn prems =>
nipkow@243
   264
	[
nipkow@243
   265
	(rtac monofunI 1),
nipkow@243
   266
	(strip_tac 1),
nipkow@243
   267
	(res_inst_tac [("Q","x=UU")] (excluded_middle RS disjE) 1),
nipkow@243
   268
	(rtac (Istrictify2 RS ssubst) 1),
nipkow@243
   269
	(etac notUU_I 1),
nipkow@243
   270
	(atac 1),
nipkow@243
   271
	(rtac (Istrictify2 RS ssubst) 1),
nipkow@243
   272
	(atac 1),
nipkow@243
   273
	(rtac monofun_cfun_arg 1),
nipkow@243
   274
	(atac 1),
nipkow@243
   275
	(hyp_subst_tac 1),
nipkow@243
   276
	(rtac (Istrictify1 RS ssubst) 1),
nipkow@243
   277
	(rtac minimal 1)
nipkow@243
   278
	]);
nipkow@243
   279
nipkow@243
   280
nipkow@243
   281
val contlub_Istrictify1 = prove_goal Cfun3.thy "contlub(Istrictify)"
nipkow@243
   282
 (fn prems =>
nipkow@243
   283
	[
nipkow@243
   284
	(rtac contlubI 1),
nipkow@243
   285
	(strip_tac 1),
nipkow@243
   286
	(rtac (expand_fun_eq RS iffD2) 1),
nipkow@243
   287
	(strip_tac 1),
nipkow@243
   288
	(rtac (thelub_fun RS ssubst) 1),
nipkow@243
   289
	(etac (monofun_Istrictify1 RS ch2ch_monofun) 1),
nipkow@243
   290
	(res_inst_tac [("Q","x=UU")] (excluded_middle RS disjE) 1),
nipkow@243
   291
	(rtac (Istrictify2 RS ssubst) 1),
nipkow@243
   292
	(atac 1),
nipkow@243
   293
	(rtac (Istrictify2 RS ext RS ssubst) 1),
nipkow@243
   294
	(atac 1),
nipkow@243
   295
	(rtac (thelub_cfun RS ssubst) 1),
nipkow@243
   296
	(atac 1),
nipkow@243
   297
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   298
	(rtac contX_lubcfun 1),
nipkow@243
   299
	(atac 1),
nipkow@243
   300
	(rtac refl 1),
nipkow@243
   301
	(hyp_subst_tac 1),
nipkow@243
   302
	(rtac (Istrictify1 RS ssubst) 1),
nipkow@243
   303
	(rtac (Istrictify1 RS ext RS ssubst) 1),
nipkow@243
   304
	(rtac (chain_UU_I_inverse RS sym) 1),
nipkow@243
   305
	(rtac (refl RS allI) 1)
nipkow@243
   306
	]);
nipkow@243
   307
nipkow@243
   308
val contlub_Istrictify2 = prove_goal Cfun3.thy "contlub(Istrictify(f))"
nipkow@243
   309
 (fn prems =>
nipkow@243
   310
	[
nipkow@243
   311
	(rtac contlubI 1),
nipkow@243
   312
	(strip_tac 1),
nipkow@243
   313
	(res_inst_tac [("Q","lub(range(Y))=UU")] classical2 1),
nipkow@243
   314
	(res_inst_tac [("t","lub(range(Y))")] subst 1),
nipkow@243
   315
	(rtac sym 1),
nipkow@243
   316
	(atac 1),
nipkow@243
   317
	(rtac (Istrictify1 RS ssubst) 1),
nipkow@243
   318
	(rtac sym 1),
nipkow@243
   319
	(rtac chain_UU_I_inverse 1),
nipkow@243
   320
	(strip_tac 1),
nipkow@243
   321
	(res_inst_tac [("t","Y(i)"),("s","UU")] subst 1),
nipkow@243
   322
	(rtac sym 1),
nipkow@243
   323
	(rtac (chain_UU_I RS spec) 1),
nipkow@243
   324
	(atac 1),
nipkow@243
   325
	(atac 1),
nipkow@243
   326
	(rtac Istrictify1 1),
nipkow@243
   327
	(rtac (Istrictify2 RS ssubst) 1),
nipkow@243
   328
	(atac 1),
nipkow@243
   329
	(res_inst_tac [("s","lub(range(%i. f[Y(i)]))")] trans 1),
nipkow@243
   330
	(rtac contlub_cfun_arg 1),
nipkow@243
   331
	(atac 1),
nipkow@243
   332
	(rtac lub_equal2 1),
nipkow@243
   333
	(rtac (chain_mono2 RS exE) 1),
nipkow@243
   334
	(atac 2),
nipkow@243
   335
	(rtac chain_UU_I_inverse2 1),
nipkow@243
   336
	(atac 1),
nipkow@243
   337
	(rtac exI 1),
nipkow@243
   338
	(strip_tac 1),
nipkow@243
   339
	(rtac (Istrictify2 RS sym) 1),
nipkow@243
   340
	(fast_tac HOL_cs 1),
nipkow@243
   341
	(rtac ch2ch_monofun 1),
nipkow@243
   342
	(rtac monofun_fapp2 1),
nipkow@243
   343
	(atac 1),
nipkow@243
   344
	(rtac ch2ch_monofun 1),
nipkow@243
   345
	(rtac monofun_Istrictify2 1),
nipkow@243
   346
	(atac 1)
nipkow@243
   347
	]);
nipkow@243
   348
nipkow@243
   349
nipkow@243
   350
val contX_Istrictify1 =	(contlub_Istrictify1 RS 
nipkow@243
   351
	(monofun_Istrictify1 RS monocontlub2contX)); 
nipkow@243
   352
nipkow@243
   353
val contX_Istrictify2 = (contlub_Istrictify2 RS 
nipkow@243
   354
	(monofun_Istrictify2 RS monocontlub2contX)); 
nipkow@243
   355
nipkow@243
   356
nipkow@243
   357
val strictify1 = prove_goalw Cfun3.thy [strictify_def]
nipkow@243
   358
	"strictify[f][UU]=UU"
nipkow@243
   359
 (fn prems =>
nipkow@243
   360
	[
nipkow@243
   361
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   362
	(contX_tac 1),
nipkow@243
   363
	(rtac contX_Istrictify2 1),
nipkow@243
   364
	(rtac contX2contX_CF1L 1),
nipkow@243
   365
	(rtac contX_Istrictify1 1),
nipkow@243
   366
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   367
	(rtac contX_Istrictify2 1),
nipkow@243
   368
	(rtac Istrictify1 1)
nipkow@243
   369
	]);
nipkow@243
   370
nipkow@243
   371
val strictify2 = prove_goalw Cfun3.thy [strictify_def]
nipkow@243
   372
	"~x=UU ==> strictify[f][x]=f[x]"
nipkow@243
   373
 (fn prems =>
nipkow@243
   374
	[
nipkow@243
   375
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   376
	(contX_tac 1),
nipkow@243
   377
	(rtac contX_Istrictify2 1),
nipkow@243
   378
	(rtac contX2contX_CF1L 1),
nipkow@243
   379
	(rtac contX_Istrictify1 1),
nipkow@243
   380
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   381
	(rtac contX_Istrictify2 1),
nipkow@243
   382
	(rtac Istrictify2 1),
nipkow@243
   383
	(resolve_tac prems 1)
nipkow@243
   384
	]);
nipkow@243
   385
nipkow@243
   386
nipkow@243
   387
(* ------------------------------------------------------------------------ *)
nipkow@243
   388
(* Instantiate the simplifier                                               *)
nipkow@243
   389
(* ------------------------------------------------------------------------ *)
nipkow@243
   390
nipkow@243
   391
val Cfun_rews  = [minimal,refl_less,beta_cfun,strict_fapp1,strictify1,
nipkow@243
   392
		strictify2];
nipkow@243
   393
nipkow@243
   394
(* ------------------------------------------------------------------------ *)
nipkow@243
   395
(* use contX_tac as autotac.                                                *)
nipkow@243
   396
(* ------------------------------------------------------------------------ *)
nipkow@243
   397
nipkow@243
   398
val Cfun_ss = HOL_ss 
nipkow@243
   399
	addsimps  Cfun_rews 
nipkow@243
   400
	setsolver 
nipkow@243
   401
	(fn thms => (resolve_tac (TrueI::refl::thms)) ORELSE' atac ORELSE'
nipkow@243
   402
		    (fn i => DEPTH_SOLVE_1 (contX_tac i))
nipkow@243
   403
	);