src/HOLCF/cprod3.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/cprod3.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
Lemmas for Cprod3.thy 
nipkow@243
     7
*)
nipkow@243
     8
nipkow@243
     9
open Cprod3;
nipkow@243
    10
nipkow@243
    11
(* ------------------------------------------------------------------------ *)
nipkow@243
    12
(* continuity of <_,_> , fst, snd                                           *)
nipkow@243
    13
(* ------------------------------------------------------------------------ *)
nipkow@243
    14
nipkow@243
    15
val Cprod3_lemma1 = prove_goal Cprod3.thy 
nipkow@243
    16
"is_chain(Y::(nat=>'a)) ==>\
nipkow@243
    17
\ <lub(range(Y)),(x::'b)> =\
nipkow@243
    18
\ <lub(range(%i. fst(<Y(i),x>))),lub(range(%i. snd(<Y(i),x>)))>"
nipkow@243
    19
 (fn prems =>
nipkow@243
    20
	[
nipkow@243
    21
	(cut_facts_tac prems 1),
nipkow@243
    22
	(res_inst_tac [("f1","Pair")] (arg_cong RS cong) 1),
nipkow@243
    23
	(rtac lub_equal 1),
nipkow@243
    24
	(atac 1),
nipkow@243
    25
	(rtac (monofun_fst RS ch2ch_monofun) 1),
nipkow@243
    26
	(rtac ch2ch_fun 1),
nipkow@243
    27
	(rtac (monofun_pair1 RS ch2ch_monofun) 1),
nipkow@243
    28
	(atac 1),
nipkow@243
    29
	(rtac allI 1),
nipkow@243
    30
	(simp_tac pair_ss 1),
nipkow@243
    31
	(rtac sym 1),
nipkow@243
    32
	(simp_tac pair_ss 1),
nipkow@243
    33
	(rtac (lub_const RS thelubI) 1)
nipkow@243
    34
	]);
nipkow@243
    35
nipkow@243
    36
val contlub_pair1 = prove_goal Cprod3.thy "contlub(Pair)"
nipkow@243
    37
 (fn prems =>
nipkow@243
    38
	[
nipkow@243
    39
	(rtac contlubI 1),
nipkow@243
    40
	(strip_tac 1),
nipkow@243
    41
	(rtac (expand_fun_eq RS iffD2) 1),
nipkow@243
    42
	(strip_tac 1),
nipkow@243
    43
	(rtac (lub_fun RS thelubI RS ssubst) 1),
nipkow@243
    44
	(etac (monofun_pair1 RS ch2ch_monofun) 1),
nipkow@243
    45
	(rtac trans 1),
nipkow@243
    46
	(rtac (thelub_cprod RS sym) 2),
nipkow@243
    47
	(rtac ch2ch_fun 2),
nipkow@243
    48
	(etac (monofun_pair1 RS ch2ch_monofun) 2),
nipkow@243
    49
	(etac Cprod3_lemma1 1)
nipkow@243
    50
	]);
nipkow@243
    51
nipkow@243
    52
val Cprod3_lemma2 = prove_goal Cprod3.thy 
nipkow@243
    53
"is_chain(Y::(nat=>'a)) ==>\
nipkow@243
    54
\ <(x::'b),lub(range(Y))> =\
nipkow@243
    55
\ <lub(range(%i. fst(<x,Y(i)>))),lub(range(%i. snd(<x,Y(i)>)))>"
nipkow@243
    56
 (fn prems =>
nipkow@243
    57
	[
nipkow@243
    58
	(cut_facts_tac prems 1),
nipkow@243
    59
	(res_inst_tac [("f1","Pair")] (arg_cong RS cong) 1),
nipkow@243
    60
	(rtac sym 1),
nipkow@243
    61
	(simp_tac pair_ss 1),
nipkow@243
    62
	(rtac (lub_const RS thelubI) 1),
nipkow@243
    63
	(rtac lub_equal 1),
nipkow@243
    64
	(atac 1),
nipkow@243
    65
	(rtac (monofun_snd RS ch2ch_monofun) 1),
nipkow@243
    66
	(rtac (monofun_pair2 RS ch2ch_monofun) 1),
nipkow@243
    67
	(atac 1),
nipkow@243
    68
	(rtac allI 1),
nipkow@243
    69
	(simp_tac pair_ss 1)
nipkow@243
    70
	]);
nipkow@243
    71
nipkow@243
    72
val contlub_pair2 = prove_goal Cprod3.thy "contlub(Pair(x))"
nipkow@243
    73
 (fn prems =>
nipkow@243
    74
	[
nipkow@243
    75
	(rtac contlubI 1),
nipkow@243
    76
	(strip_tac 1),
nipkow@243
    77
	(rtac trans 1),
nipkow@243
    78
	(rtac (thelub_cprod RS sym) 2),
nipkow@243
    79
	(etac (monofun_pair2 RS ch2ch_monofun) 2),
nipkow@243
    80
	(etac Cprod3_lemma2 1)
nipkow@243
    81
	]);
nipkow@243
    82
nipkow@243
    83
val contX_pair1 = prove_goal Cprod3.thy "contX(Pair)"
nipkow@243
    84
(fn prems =>
nipkow@243
    85
	[
nipkow@243
    86
	(rtac monocontlub2contX 1),
nipkow@243
    87
	(rtac monofun_pair1 1),
nipkow@243
    88
	(rtac contlub_pair1 1)
nipkow@243
    89
	]);
nipkow@243
    90
nipkow@243
    91
val contX_pair2 = prove_goal Cprod3.thy "contX(Pair(x))"
nipkow@243
    92
(fn prems =>
nipkow@243
    93
	[
nipkow@243
    94
	(rtac monocontlub2contX 1),
nipkow@243
    95
	(rtac monofun_pair2 1),
nipkow@243
    96
	(rtac contlub_pair2 1)
nipkow@243
    97
	]);
nipkow@243
    98
nipkow@243
    99
val contlub_fst = prove_goal Cprod3.thy "contlub(fst)"
nipkow@243
   100
 (fn prems =>
nipkow@243
   101
	[
nipkow@243
   102
	(rtac contlubI 1),
nipkow@243
   103
	(strip_tac 1),
nipkow@243
   104
	(rtac (lub_cprod RS thelubI RS ssubst) 1),
nipkow@243
   105
	(atac 1),
nipkow@243
   106
	(simp_tac pair_ss 1)
nipkow@243
   107
	]);
nipkow@243
   108
nipkow@243
   109
val contlub_snd = prove_goal Cprod3.thy "contlub(snd)"
nipkow@243
   110
 (fn prems =>
nipkow@243
   111
	[
nipkow@243
   112
	(rtac contlubI 1),
nipkow@243
   113
	(strip_tac 1),
nipkow@243
   114
	(rtac (lub_cprod RS thelubI RS ssubst) 1),
nipkow@243
   115
	(atac 1),
nipkow@243
   116
	(simp_tac pair_ss 1)
nipkow@243
   117
	]);
nipkow@243
   118
nipkow@243
   119
val contX_fst = prove_goal Cprod3.thy "contX(fst)"
nipkow@243
   120
(fn prems =>
nipkow@243
   121
	[
nipkow@243
   122
	(rtac monocontlub2contX 1),
nipkow@243
   123
	(rtac monofun_fst 1),
nipkow@243
   124
	(rtac contlub_fst 1)
nipkow@243
   125
	]);
nipkow@243
   126
nipkow@243
   127
val contX_snd = prove_goal Cprod3.thy "contX(snd)"
nipkow@243
   128
(fn prems =>
nipkow@243
   129
	[
nipkow@243
   130
	(rtac monocontlub2contX 1),
nipkow@243
   131
	(rtac monofun_snd 1),
nipkow@243
   132
	(rtac contlub_snd 1)
nipkow@243
   133
	]);
nipkow@243
   134
nipkow@243
   135
(* 
nipkow@243
   136
 -------------------------------------------------------------------------- 
nipkow@243
   137
 more lemmas for Cprod3.thy 
nipkow@243
   138
 
nipkow@243
   139
 -------------------------------------------------------------------------- 
nipkow@243
   140
*)
nipkow@243
   141
nipkow@243
   142
(* ------------------------------------------------------------------------ *)
nipkow@243
   143
(* convert all lemmas to the continuous versions                            *)
nipkow@243
   144
(* ------------------------------------------------------------------------ *)
nipkow@243
   145
nipkow@243
   146
val beta_cfun_cprod = prove_goalw Cprod3.thy [cpair_def]
nipkow@243
   147
	"(LAM x y.<x,y>)[a][b] = <a,b>"
nipkow@243
   148
 (fn prems =>
nipkow@243
   149
	[
nipkow@243
   150
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   151
	(contX_tac 1),
nipkow@243
   152
	(rtac contX_pair2 1),
nipkow@243
   153
	(rtac contX2contX_CF1L 1),
nipkow@243
   154
	(rtac contX_pair1 1),
nipkow@243
   155
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   156
	(rtac contX_pair2 1),
nipkow@243
   157
	(rtac refl 1)
nipkow@243
   158
	]);
nipkow@243
   159
nipkow@243
   160
val inject_cpair = prove_goalw Cprod3.thy [cpair_def]
nipkow@243
   161
	" (a#b)=(aa#ba)  ==> a=aa & b=ba"
nipkow@243
   162
 (fn prems =>
nipkow@243
   163
	[
nipkow@243
   164
	(cut_facts_tac prems 1),
nipkow@243
   165
	(dtac (beta_cfun_cprod RS subst) 1),
nipkow@243
   166
	(dtac (beta_cfun_cprod RS subst) 1),
nipkow@243
   167
	(etac Pair_inject 1),
nipkow@243
   168
	(fast_tac HOL_cs 1)
nipkow@243
   169
	]);
nipkow@243
   170
nipkow@243
   171
val inst_cprod_pcpo2 = prove_goalw Cprod3.thy [cpair_def] "UU = (UU#UU)"
nipkow@243
   172
 (fn prems =>
nipkow@243
   173
	[
nipkow@243
   174
	(rtac sym 1),
nipkow@243
   175
	(rtac trans 1),
nipkow@243
   176
	(rtac beta_cfun_cprod 1),
nipkow@243
   177
	(rtac sym 1),
nipkow@243
   178
	(rtac inst_cprod_pcpo 1)
nipkow@243
   179
	]);
nipkow@243
   180
nipkow@243
   181
val defined_cpair_rev = prove_goal Cprod3.thy
nipkow@243
   182
 "(a#b) = UU ==> a = UU & b = UU"
nipkow@243
   183
 (fn prems =>
nipkow@243
   184
	[
nipkow@243
   185
	(cut_facts_tac prems 1),
nipkow@243
   186
	(dtac (inst_cprod_pcpo2 RS subst) 1),
nipkow@243
   187
	(etac inject_cpair 1)
nipkow@243
   188
	]);
nipkow@243
   189
nipkow@243
   190
val Exh_Cprod2 = prove_goalw Cprod3.thy [cpair_def]
nipkow@243
   191
	"? a b. z=(a#b) "
nipkow@243
   192
 (fn prems =>
nipkow@243
   193
	[
nipkow@243
   194
	(rtac PairE 1),
nipkow@243
   195
	(rtac exI 1),
nipkow@243
   196
	(rtac exI 1),
nipkow@243
   197
	(etac (beta_cfun_cprod RS ssubst) 1)
nipkow@243
   198
	]);
nipkow@243
   199
nipkow@243
   200
val cprodE = prove_goalw Cprod3.thy [cpair_def]
nipkow@243
   201
"[|!!x y. [|p=(x#y) |] ==> Q|] ==> Q"
nipkow@243
   202
 (fn prems =>
nipkow@243
   203
	[
nipkow@243
   204
	(rtac PairE 1),
nipkow@243
   205
	(resolve_tac prems 1),
nipkow@243
   206
	(etac (beta_cfun_cprod RS ssubst) 1)
nipkow@243
   207
	]);
nipkow@243
   208
nipkow@243
   209
val cfst2 = prove_goalw Cprod3.thy [cfst_def,cpair_def] 
nipkow@243
   210
	"cfst[x#y]=x"
nipkow@243
   211
 (fn prems =>
nipkow@243
   212
	[
nipkow@243
   213
	(cut_facts_tac prems 1),
nipkow@243
   214
	(rtac (beta_cfun_cprod RS ssubst) 1),
nipkow@243
   215
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   216
	(rtac contX_fst 1),
nipkow@243
   217
	(simp_tac pair_ss  1)
nipkow@243
   218
	]);
nipkow@243
   219
nipkow@243
   220
val csnd2 = prove_goalw Cprod3.thy [csnd_def,cpair_def] 
nipkow@243
   221
	"csnd[x#y]=y"
nipkow@243
   222
 (fn prems =>
nipkow@243
   223
	[
nipkow@243
   224
	(cut_facts_tac prems 1),
nipkow@243
   225
	(rtac (beta_cfun_cprod RS ssubst) 1),
nipkow@243
   226
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   227
	(rtac contX_snd 1),
nipkow@243
   228
	(simp_tac pair_ss  1)
nipkow@243
   229
	]);
nipkow@243
   230
nipkow@243
   231
val surjective_pairing_Cprod2 = prove_goalw Cprod3.thy 
nipkow@243
   232
	[cfst_def,csnd_def,cpair_def] "(cfst[p] # csnd[p]) = p"
nipkow@243
   233
 (fn prems =>
nipkow@243
   234
	[
nipkow@243
   235
	(rtac (beta_cfun_cprod RS ssubst) 1),
nipkow@243
   236
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   237
	(rtac contX_snd 1),
nipkow@243
   238
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   239
	(rtac contX_fst 1),
nipkow@243
   240
	(rtac (surjective_pairing RS sym) 1)
nipkow@243
   241
	]);
nipkow@243
   242
nipkow@243
   243
nipkow@243
   244
val less_cprod5b = prove_goalw Cprod3.thy [cfst_def,csnd_def,cpair_def]
nipkow@243
   245
 " (p1 << p2) = (cfst[p1]<<cfst[p2] & csnd[p1]<<csnd[p2])"
nipkow@243
   246
 (fn prems =>
nipkow@243
   247
	[
nipkow@243
   248
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   249
	(rtac contX_snd 1),
nipkow@243
   250
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   251
	(rtac contX_snd 1),
nipkow@243
   252
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   253
	(rtac contX_fst 1),
nipkow@243
   254
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   255
	(rtac contX_fst 1),
nipkow@243
   256
	(rtac less_cprod3b 1)
nipkow@243
   257
	]);
nipkow@243
   258
nipkow@243
   259
val less_cprod5c = prove_goalw Cprod3.thy [cfst_def,csnd_def,cpair_def]
nipkow@243
   260
 "xa#ya << x#y ==>xa<<x & ya << y"
nipkow@243
   261
 (fn prems =>
nipkow@243
   262
	[
nipkow@243
   263
	(cut_facts_tac prems 1),
nipkow@243
   264
	(rtac less_cprod4c 1),
nipkow@243
   265
	(dtac (beta_cfun_cprod RS subst) 1),
nipkow@243
   266
	(dtac (beta_cfun_cprod RS subst) 1),
nipkow@243
   267
	(atac 1)
nipkow@243
   268
	]);
nipkow@243
   269
nipkow@243
   270
nipkow@243
   271
val lub_cprod2 = prove_goalw Cprod3.thy [cfst_def,csnd_def,cpair_def]
nipkow@243
   272
"[|is_chain(S)|] ==> range(S) <<| \
nipkow@243
   273
\ (lub(range(%i.cfst[S(i)])) # lub(range(%i.csnd[S(i)])))"
nipkow@243
   274
 (fn prems =>
nipkow@243
   275
	[
nipkow@243
   276
	(cut_facts_tac prems 1),
nipkow@243
   277
	(rtac (beta_cfun_cprod RS ssubst) 1),
nipkow@243
   278
	(rtac (beta_cfun RS ext RS ssubst) 1),
nipkow@243
   279
	(rtac contX_snd 1),
nipkow@243
   280
	(rtac (beta_cfun RS ext RS ssubst) 1),
nipkow@243
   281
	(rtac contX_fst 1),
nipkow@243
   282
	(rtac lub_cprod 1),
nipkow@243
   283
	(atac 1)
nipkow@243
   284
	]);
nipkow@243
   285
nipkow@243
   286
val thelub_cprod2 = (lub_cprod2 RS thelubI);
nipkow@243
   287
(*  "is_chain(?S1) ==> lub(range(?S1)) =                         *)
nipkow@243
   288
(*    lub(range(%i. cfst[?S1(i)]))#lub(range(%i. csnd[?S1(i)]))" *)
nipkow@243
   289
nipkow@243
   290
val csplit2 = prove_goalw Cprod3.thy [csplit_def]
nipkow@243
   291
	"csplit[f][x#y]=f[x][y]"
nipkow@243
   292
 (fn prems =>
nipkow@243
   293
	[
nipkow@243
   294
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   295
	(contX_tacR 1),
nipkow@243
   296
	(simp_tac Cfun_ss 1),
nipkow@243
   297
	(simp_tac (Cfun_ss addsimps [cfst2,csnd2]) 1)
nipkow@243
   298
	]);
nipkow@243
   299
nipkow@243
   300
val csplit3 = prove_goalw Cprod3.thy [csplit_def]
nipkow@243
   301
  "csplit[cpair][z]=z"
nipkow@243
   302
 (fn prems =>
nipkow@243
   303
	[
nipkow@243
   304
	(rtac (beta_cfun RS ssubst) 1),
nipkow@243
   305
	(contX_tacR 1),
nipkow@243
   306
	(simp_tac (Cfun_ss addsimps [surjective_pairing_Cprod2]) 1)
nipkow@243
   307
	]);
nipkow@243
   308
nipkow@243
   309
(* ------------------------------------------------------------------------ *)
nipkow@243
   310
(* install simplifier for Cprod                                             *)
nipkow@243
   311
(* ------------------------------------------------------------------------ *)
nipkow@243
   312
nipkow@243
   313
val Cprod_rews = [cfst2,csnd2,csplit2];
nipkow@243
   314
nipkow@243
   315
val Cprod_ss = Cfun_ss addsimps Cprod_rews;