src/HOLCF/sprod0.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/sprod0.thy
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 theory sprod0.thy
nipkow@243
     7
*)
nipkow@243
     8
nipkow@243
     9
open Sprod0;
nipkow@243
    10
nipkow@243
    11
(* ------------------------------------------------------------------------ *)
nipkow@243
    12
(* A non-emptyness result for Sprod                                         *)
nipkow@243
    13
(* ------------------------------------------------------------------------ *)
nipkow@243
    14
nipkow@243
    15
val SprodI = prove_goalw Sprod0.thy [Sprod_def]
nipkow@243
    16
	"Spair_Rep(a,b):Sprod"
nipkow@243
    17
(fn prems =>
nipkow@243
    18
	[
nipkow@243
    19
	(EVERY1 [rtac CollectI, rtac exI,rtac exI, rtac refl])
nipkow@243
    20
	]);
nipkow@243
    21
nipkow@243
    22
nipkow@243
    23
val inj_onto_Abs_Sprod = prove_goal Sprod0.thy 
nipkow@243
    24
	"inj_onto(Abs_Sprod,Sprod)"
nipkow@243
    25
(fn prems =>
nipkow@243
    26
	[
nipkow@243
    27
	(rtac inj_onto_inverseI 1),
nipkow@243
    28
	(etac Abs_Sprod_inverse 1)
nipkow@243
    29
	]);
nipkow@243
    30
nipkow@243
    31
nipkow@243
    32
(* ------------------------------------------------------------------------ *)
nipkow@243
    33
(* Strictness and definedness of Spair_Rep                                  *)
nipkow@243
    34
(* ------------------------------------------------------------------------ *)
nipkow@243
    35
nipkow@243
    36
nipkow@243
    37
val strict_Spair_Rep = prove_goalw Sprod0.thy [Spair_Rep_def]
nipkow@243
    38
 "(a=UU | b=UU) ==> (Spair_Rep(a,b) = Spair_Rep(UU,UU))"
nipkow@243
    39
 (fn prems =>
nipkow@243
    40
	[
nipkow@243
    41
	(cut_facts_tac prems 1),
nipkow@243
    42
	(rtac ext 1),
nipkow@243
    43
	(rtac ext 1),
nipkow@243
    44
	(rtac iffI 1),
nipkow@243
    45
	(fast_tac HOL_cs 1),
nipkow@243
    46
	(fast_tac HOL_cs 1)
nipkow@243
    47
	]);
nipkow@243
    48
nipkow@243
    49
val defined_Spair_Rep_rev = prove_goalw Sprod0.thy [Spair_Rep_def]
nipkow@243
    50
 "(Spair_Rep(a,b) = Spair_Rep(UU,UU)) ==> (a=UU | b=UU)"
nipkow@243
    51
 (fn prems =>
nipkow@243
    52
	[
nipkow@243
    53
	(res_inst_tac [("Q","a=UU|b=UU")] classical2 1),
nipkow@243
    54
	(atac 1),
nipkow@243
    55
	(rtac disjI1 1),
nipkow@243
    56
	(rtac ((hd prems) RS fun_cong RS fun_cong RS iffD2 RS mp RS 
nipkow@243
    57
	conjunct1 RS sym) 1),
nipkow@243
    58
	(fast_tac HOL_cs 1),
nipkow@243
    59
	(fast_tac HOL_cs 1)
nipkow@243
    60
	]);
nipkow@243
    61
nipkow@243
    62
nipkow@243
    63
(* ------------------------------------------------------------------------ *)
nipkow@243
    64
(* injectivity of Spair_Rep and Ispair                                      *)
nipkow@243
    65
(* ------------------------------------------------------------------------ *)
nipkow@243
    66
nipkow@243
    67
val inject_Spair_Rep = prove_goalw Sprod0.thy [Spair_Rep_def]
nipkow@243
    68
"[|~aa=UU ; ~ba=UU ; Spair_Rep(a,b)=Spair_Rep(aa,ba) |] ==> a=aa & b=ba"
nipkow@243
    69
 (fn prems =>
nipkow@243
    70
	[
nipkow@243
    71
	(cut_facts_tac prems 1),
nipkow@243
    72
	(rtac ((nth_elem (2,prems)) RS fun_cong  RS fun_cong 
nipkow@243
    73
		RS iffD1 RS mp) 1),
nipkow@243
    74
	(fast_tac HOL_cs 1),
nipkow@243
    75
	(fast_tac HOL_cs 1)
nipkow@243
    76
	]);
nipkow@243
    77
nipkow@243
    78
nipkow@243
    79
val inject_Ispair =  prove_goalw Sprod0.thy [Ispair_def]
nipkow@243
    80
	"[|~aa=UU ; ~ba=UU ; Ispair(a,b)=Ispair(aa,ba) |] ==> a=aa & b=ba"
nipkow@243
    81
(fn prems =>
nipkow@243
    82
	[
nipkow@243
    83
	(cut_facts_tac prems 1),
nipkow@243
    84
	(etac inject_Spair_Rep 1),
nipkow@243
    85
	(atac 1),
nipkow@243
    86
	(etac (inj_onto_Abs_Sprod  RS inj_ontoD) 1),
nipkow@243
    87
	(rtac SprodI 1),
nipkow@243
    88
	(rtac SprodI 1)
nipkow@243
    89
	]);
nipkow@243
    90
nipkow@243
    91
nipkow@243
    92
(* ------------------------------------------------------------------------ *)
nipkow@243
    93
(* strictness and definedness of Ispair                                     *)
nipkow@243
    94
(* ------------------------------------------------------------------------ *)
nipkow@243
    95
nipkow@243
    96
val strict_Ispair = prove_goalw Sprod0.thy [Ispair_def] 
nipkow@243
    97
 "(a=UU | b=UU) ==> Ispair(a,b)=Ispair(UU,UU)"
nipkow@243
    98
(fn prems =>
nipkow@243
    99
	[
nipkow@243
   100
	(cut_facts_tac prems 1),
nipkow@243
   101
	(etac (strict_Spair_Rep RS arg_cong) 1)
nipkow@243
   102
	]);
nipkow@243
   103
nipkow@243
   104
val strict_Ispair1 = prove_goalw Sprod0.thy [Ispair_def]
nipkow@243
   105
	"Ispair(UU,b) = Ispair(UU,UU)"
nipkow@243
   106
(fn prems =>
nipkow@243
   107
	[
nipkow@243
   108
	(rtac (strict_Spair_Rep RS arg_cong) 1),
nipkow@243
   109
	(rtac disjI1 1),
nipkow@243
   110
	(rtac refl 1)
nipkow@243
   111
	]);
nipkow@243
   112
nipkow@243
   113
val strict_Ispair2 = prove_goalw Sprod0.thy [Ispair_def]
nipkow@243
   114
	"Ispair(a,UU) = Ispair(UU,UU)"
nipkow@243
   115
(fn prems =>
nipkow@243
   116
	[
nipkow@243
   117
	(rtac (strict_Spair_Rep RS arg_cong) 1),
nipkow@243
   118
	(rtac disjI2 1),
nipkow@243
   119
	(rtac refl 1)
nipkow@243
   120
	]);
nipkow@243
   121
nipkow@243
   122
val strict_Ispair_rev = prove_goal Sprod0.thy 
nipkow@243
   123
	"~Ispair(x,y)=Ispair(UU,UU) ==> ~x=UU & ~y=UU"
nipkow@243
   124
(fn prems =>
nipkow@243
   125
	[
nipkow@243
   126
	(cut_facts_tac prems 1),
nipkow@243
   127
	(rtac (de_morgan1 RS ssubst) 1),
nipkow@243
   128
	(etac contrapos 1),
nipkow@243
   129
	(etac strict_Ispair 1)
nipkow@243
   130
	]);
nipkow@243
   131
nipkow@243
   132
val defined_Ispair_rev = prove_goalw Sprod0.thy [Ispair_def]
nipkow@243
   133
	"Ispair(a,b) = Ispair(UU,UU) ==> (a = UU | b = UU)"
nipkow@243
   134
(fn prems =>
nipkow@243
   135
	[
nipkow@243
   136
	(cut_facts_tac prems 1),
nipkow@243
   137
	(rtac defined_Spair_Rep_rev 1),
nipkow@243
   138
	(rtac (inj_onto_Abs_Sprod  RS inj_ontoD) 1),
nipkow@243
   139
	(atac 1),
nipkow@243
   140
	(rtac SprodI 1),
nipkow@243
   141
	(rtac SprodI 1)
nipkow@243
   142
	]);
nipkow@243
   143
nipkow@243
   144
val defined_Ispair = prove_goal Sprod0.thy  
nipkow@243
   145
"[|~a=UU; ~b=UU|] ==> ~(Ispair(a,b) = Ispair(UU,UU))" 
nipkow@243
   146
(fn prems =>
nipkow@243
   147
	[
nipkow@243
   148
	(cut_facts_tac prems 1),
nipkow@243
   149
	(rtac contrapos 1),
nipkow@243
   150
	(etac defined_Ispair_rev 2),
nipkow@243
   151
	(rtac (de_morgan1 RS iffD1) 1),
nipkow@243
   152
	(etac conjI 1),
nipkow@243
   153
	(atac 1)
nipkow@243
   154
	]);
nipkow@243
   155
nipkow@243
   156
nipkow@243
   157
(* ------------------------------------------------------------------------ *)
nipkow@243
   158
(* Exhaustion of the strict product **                                      *)
nipkow@243
   159
(* ------------------------------------------------------------------------ *)
nipkow@243
   160
nipkow@243
   161
val Exh_Sprod = prove_goalw Sprod0.thy [Ispair_def]
nipkow@243
   162
	"z=Ispair(UU,UU) | (? a b. z=Ispair(a,b) & ~a=UU & ~b=UU)"
nipkow@243
   163
(fn prems =>
nipkow@243
   164
	[
nipkow@243
   165
	(rtac (rewrite_rule [Sprod_def] Rep_Sprod RS CollectE) 1),
nipkow@243
   166
	(etac exE 1),
nipkow@243
   167
	(etac exE 1),
nipkow@243
   168
	(rtac (excluded_middle RS disjE) 1),
nipkow@243
   169
	(rtac disjI2 1),
nipkow@243
   170
	(rtac exI 1),
nipkow@243
   171
	(rtac exI 1),
nipkow@243
   172
	(rtac conjI 1),
nipkow@243
   173
	(rtac (Rep_Sprod_inverse RS sym RS trans) 1),
nipkow@243
   174
	(etac arg_cong 1),
nipkow@243
   175
	(rtac (de_morgan1 RS ssubst) 1),
nipkow@243
   176
	(atac 1),
nipkow@243
   177
	(rtac disjI1 1),
nipkow@243
   178
	(rtac (Rep_Sprod_inverse RS sym RS trans) 1),
nipkow@243
   179
	(res_inst_tac [("f","Abs_Sprod")] arg_cong 1),
nipkow@243
   180
	(etac trans 1),
nipkow@243
   181
	(etac strict_Spair_Rep 1)
nipkow@243
   182
	]);
nipkow@243
   183
nipkow@243
   184
(* ------------------------------------------------------------------------ *)
nipkow@243
   185
(* general elimination rule for strict product                              *)
nipkow@243
   186
(* ------------------------------------------------------------------------ *)
nipkow@243
   187
nipkow@243
   188
val IsprodE = prove_goal Sprod0.thy
nipkow@243
   189
"[|p=Ispair(UU,UU) ==> Q ;!!x y. [|p=Ispair(x,y); ~x=UU ; ~y=UU|] ==> Q|] ==> Q"
nipkow@243
   190
(fn prems =>
nipkow@243
   191
	[
nipkow@243
   192
	(rtac (Exh_Sprod RS disjE) 1),
nipkow@243
   193
	(etac (hd prems) 1),
nipkow@243
   194
	(etac exE 1),
nipkow@243
   195
	(etac exE 1),
nipkow@243
   196
	(etac conjE 1),
nipkow@243
   197
	(etac conjE 1),
nipkow@243
   198
	(etac (hd (tl prems)) 1),
nipkow@243
   199
	(atac 1),
nipkow@243
   200
	(atac 1)
nipkow@243
   201
	]);
nipkow@243
   202
nipkow@243
   203
nipkow@243
   204
(* ------------------------------------------------------------------------ *)
nipkow@243
   205
(* some results about the selectors Isfst, Issnd                            *)
nipkow@243
   206
(* ------------------------------------------------------------------------ *)
nipkow@243
   207
nipkow@243
   208
val strict_Isfst = prove_goalw Sprod0.thy [Isfst_def] 
nipkow@243
   209
	"p=Ispair(UU,UU)==>Isfst(p)=UU"
nipkow@243
   210
(fn prems =>
nipkow@243
   211
	[
nipkow@243
   212
	(cut_facts_tac prems 1),
nipkow@243
   213
	(rtac  select_equality 1),
nipkow@243
   214
	(rtac conjI 1),
nipkow@243
   215
	(fast_tac HOL_cs  1),
nipkow@243
   216
	(strip_tac 1),
nipkow@243
   217
	(res_inst_tac [("P","Ispair(UU,UU) = Ispair(a,b)")] notE 1),
nipkow@243
   218
	(rtac not_sym 1),
nipkow@243
   219
	(rtac defined_Ispair 1),
nipkow@243
   220
	(REPEAT (fast_tac HOL_cs  1))
nipkow@243
   221
	]);
nipkow@243
   222
nipkow@243
   223
nipkow@243
   224
val strict_Isfst1 =  prove_goal Sprod0.thy
nipkow@243
   225
	"Isfst(Ispair(UU,y)) = UU"
nipkow@243
   226
(fn prems =>
nipkow@243
   227
	[
nipkow@243
   228
	(rtac (strict_Ispair1 RS ssubst) 1),
nipkow@243
   229
	(rtac strict_Isfst 1),
nipkow@243
   230
	(rtac refl 1)
nipkow@243
   231
	]);
nipkow@243
   232
nipkow@243
   233
val strict_Isfst2 =  prove_goal Sprod0.thy
nipkow@243
   234
	"Isfst(Ispair(x,UU)) = UU"
nipkow@243
   235
(fn prems =>
nipkow@243
   236
	[
nipkow@243
   237
	(rtac (strict_Ispair2 RS ssubst) 1),
nipkow@243
   238
	(rtac strict_Isfst 1),
nipkow@243
   239
	(rtac refl 1)
nipkow@243
   240
	]);
nipkow@243
   241
nipkow@243
   242
nipkow@243
   243
val strict_Issnd = prove_goalw Sprod0.thy [Issnd_def] 
nipkow@243
   244
	"p=Ispair(UU,UU)==>Issnd(p)=UU"
nipkow@243
   245
(fn prems =>
nipkow@243
   246
	[
nipkow@243
   247
	(cut_facts_tac prems 1),
nipkow@243
   248
	(rtac  select_equality 1),
nipkow@243
   249
	(rtac conjI 1),
nipkow@243
   250
	(fast_tac HOL_cs  1),
nipkow@243
   251
	(strip_tac 1),
nipkow@243
   252
	(res_inst_tac [("P","Ispair(UU,UU) = Ispair(a,b)")] notE 1),
nipkow@243
   253
	(rtac not_sym 1),
nipkow@243
   254
	(rtac defined_Ispair 1),
nipkow@243
   255
	(REPEAT (fast_tac HOL_cs  1))
nipkow@243
   256
	]);
nipkow@243
   257
nipkow@243
   258
val strict_Issnd1 =  prove_goal Sprod0.thy
nipkow@243
   259
	"Issnd(Ispair(UU,y)) = UU"
nipkow@243
   260
(fn prems =>
nipkow@243
   261
	[
nipkow@243
   262
	(rtac (strict_Ispair1 RS ssubst) 1),
nipkow@243
   263
	(rtac strict_Issnd 1),
nipkow@243
   264
	(rtac refl 1)
nipkow@243
   265
	]);
nipkow@243
   266
nipkow@243
   267
val strict_Issnd2 =  prove_goal Sprod0.thy
nipkow@243
   268
	"Issnd(Ispair(x,UU)) = UU"
nipkow@243
   269
(fn prems =>
nipkow@243
   270
	[
nipkow@243
   271
	(rtac (strict_Ispair2 RS ssubst) 1),
nipkow@243
   272
	(rtac strict_Issnd 1),
nipkow@243
   273
	(rtac refl 1)
nipkow@243
   274
	]);
nipkow@243
   275
nipkow@243
   276
val Isfst = prove_goalw Sprod0.thy [Isfst_def]
nipkow@243
   277
	"[|~x=UU ;~y=UU |] ==> Isfst(Ispair(x,y)) = x"
nipkow@243
   278
(fn prems =>
nipkow@243
   279
	[
nipkow@243
   280
	(cut_facts_tac prems 1),
nipkow@243
   281
	(rtac  select_equality 1),
nipkow@243
   282
	(rtac conjI 1),
nipkow@243
   283
	(strip_tac 1),
nipkow@243
   284
	(res_inst_tac [("P","Ispair(x,y) = Ispair(UU,UU)")] notE 1),
nipkow@243
   285
	(etac defined_Ispair 1),
nipkow@243
   286
	(atac 1),
nipkow@243
   287
	(atac 1),
nipkow@243
   288
	(strip_tac 1),
nipkow@243
   289
	(rtac (inject_Ispair RS conjunct1) 1),
nipkow@243
   290
	(fast_tac HOL_cs  3),
nipkow@243
   291
	(fast_tac HOL_cs  1),
nipkow@243
   292
	(fast_tac HOL_cs  1),
nipkow@243
   293
	(fast_tac HOL_cs  1)
nipkow@243
   294
	]);
nipkow@243
   295
nipkow@243
   296
val Issnd = prove_goalw Sprod0.thy [Issnd_def]
nipkow@243
   297
	"[|~x=UU ;~y=UU |] ==> Issnd(Ispair(x,y)) = y"
nipkow@243
   298
(fn prems =>
nipkow@243
   299
	[
nipkow@243
   300
	(cut_facts_tac prems 1),
nipkow@243
   301
	(rtac  select_equality 1),
nipkow@243
   302
	(rtac conjI 1),
nipkow@243
   303
	(strip_tac 1),
nipkow@243
   304
	(res_inst_tac [("P","Ispair(x,y) = Ispair(UU,UU)")] notE 1),
nipkow@243
   305
	(etac defined_Ispair 1),
nipkow@243
   306
	(atac 1),
nipkow@243
   307
	(atac 1),
nipkow@243
   308
	(strip_tac 1),
nipkow@243
   309
	(rtac (inject_Ispair RS conjunct2) 1),
nipkow@243
   310
	(fast_tac HOL_cs  3),
nipkow@243
   311
	(fast_tac HOL_cs  1),
nipkow@243
   312
	(fast_tac HOL_cs  1),
nipkow@243
   313
	(fast_tac HOL_cs  1)
nipkow@243
   314
	]);
nipkow@243
   315
nipkow@243
   316
val Isfst2 = prove_goal Sprod0.thy "~y=UU ==>Isfst(Ispair(x,y))=x"
nipkow@243
   317
(fn prems =>
nipkow@243
   318
	[
nipkow@243
   319
	(cut_facts_tac prems 1),
nipkow@243
   320
	(res_inst_tac [("Q","x=UU")] (excluded_middle RS disjE) 1),
nipkow@243
   321
	(etac Isfst 1),
nipkow@243
   322
	(atac 1),
nipkow@243
   323
	(hyp_subst_tac 1),
nipkow@243
   324
	(rtac strict_Isfst1 1)
nipkow@243
   325
	]);
nipkow@243
   326
nipkow@243
   327
val Issnd2 = prove_goal Sprod0.thy "~x=UU ==>Issnd(Ispair(x,y))=y"
nipkow@243
   328
(fn prems =>
nipkow@243
   329
	[
nipkow@243
   330
	(cut_facts_tac prems 1),
nipkow@243
   331
	(res_inst_tac [("Q","y=UU")] (excluded_middle RS disjE) 1),
nipkow@243
   332
	(etac Issnd 1),
nipkow@243
   333
	(atac 1),
nipkow@243
   334
	(hyp_subst_tac 1),
nipkow@243
   335
	(rtac strict_Issnd2 1)
nipkow@243
   336
	]);
nipkow@243
   337
nipkow@243
   338
nipkow@243
   339
(* ------------------------------------------------------------------------ *)
nipkow@243
   340
(* instantiate the simplifier                                               *)
nipkow@243
   341
(* ------------------------------------------------------------------------ *)
nipkow@243
   342
nipkow@243
   343
val Sprod_ss = 
nipkow@243
   344
	HOL_ss 
nipkow@243
   345
	addsimps [strict_Isfst1,strict_Isfst2,strict_Issnd1,strict_Issnd2,
nipkow@243
   346
		 Isfst2,Issnd2];
nipkow@243
   347
nipkow@243
   348
nipkow@243
   349
val defined_IsfstIssnd = prove_goal Sprod0.thy 
nipkow@243
   350
	"~p=Ispair(UU,UU) ==> ~Isfst(p)=UU & ~Issnd(p)=UU"
nipkow@243
   351
 (fn prems =>
nipkow@243
   352
	[
nipkow@243
   353
	(cut_facts_tac prems 1),
nipkow@243
   354
	(res_inst_tac [("p","p")] IsprodE 1),
nipkow@243
   355
	(contr_tac 1),
nipkow@243
   356
	(hyp_subst_tac 1),
nipkow@243
   357
	(rtac conjI 1),
nipkow@243
   358
	(asm_simp_tac Sprod_ss 1),
nipkow@243
   359
	(asm_simp_tac Sprod_ss 1)
nipkow@243
   360
	]);
nipkow@243
   361
nipkow@243
   362
nipkow@243
   363
(* ------------------------------------------------------------------------ *)
nipkow@243
   364
(* Surjective pairing: equivalent to Exh_Sprod                              *)
nipkow@243
   365
(* ------------------------------------------------------------------------ *)
nipkow@243
   366
nipkow@243
   367
val surjective_pairing_Sprod = prove_goal Sprod0.thy 
nipkow@243
   368
	"z = Ispair(Isfst(z))(Issnd(z))"
nipkow@243
   369
(fn prems =>
nipkow@243
   370
	[
nipkow@243
   371
	(res_inst_tac [("z1","z")] (Exh_Sprod RS disjE) 1),
nipkow@243
   372
	(asm_simp_tac Sprod_ss 1),
nipkow@243
   373
	(etac exE 1),
nipkow@243
   374
	(etac exE 1),
nipkow@243
   375
	(asm_simp_tac Sprod_ss 1)
nipkow@243
   376
	]);
nipkow@243
   377
nipkow@243
   378
nipkow@243
   379
nipkow@243
   380
nipkow@243
   381
nipkow@243
   382
nipkow@243
   383
nipkow@243
   384
nipkow@243
   385
nipkow@243
   386
nipkow@243
   387
nipkow@243
   388
nipkow@243
   389