src/HOLCF/ssum1.ML
author wenzelm
Thu Aug 27 20:46:36 1998 +0200 (1998-08-27)
changeset 5400 645f46a24c72
parent 243 c22b85994e17
permissions -rw-r--r--
made tutorial first;
nipkow@243
     1
(*  Title: 	HOLCF/ssum1.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 theory ssum1.thy
nipkow@243
     7
*)
nipkow@243
     8
nipkow@243
     9
open Ssum1;
nipkow@243
    10
nipkow@243
    11
local 
nipkow@243
    12
nipkow@243
    13
fun eq_left s1 s2 = 
nipkow@243
    14
	(
nipkow@243
    15
	(res_inst_tac [("s",s1),("t",s2)] (inject_Isinl RS subst) 1)
nipkow@243
    16
	THEN 	(rtac trans 1)
nipkow@243
    17
	THEN 	(atac 2)
nipkow@243
    18
	THEN 	(etac sym 1));
nipkow@243
    19
nipkow@243
    20
fun eq_right s1 s2 = 
nipkow@243
    21
	(
nipkow@243
    22
	(res_inst_tac [("s",s1),("t",s2)] (inject_Isinr RS subst) 1)
nipkow@243
    23
	THEN 	(rtac trans 1)
nipkow@243
    24
	THEN 	(atac 2)
nipkow@243
    25
	THEN 	(etac sym 1));
nipkow@243
    26
nipkow@243
    27
fun UU_left s1 = 
nipkow@243
    28
	(
nipkow@243
    29
	(res_inst_tac [("t",s1)](noteq_IsinlIsinr RS conjunct1 RS ssubst)1)
nipkow@243
    30
	THEN (rtac trans 1)
nipkow@243
    31
	THEN (atac 2)
nipkow@243
    32
	THEN (etac sym 1));
nipkow@243
    33
nipkow@243
    34
fun UU_right s1 = 
nipkow@243
    35
	(
nipkow@243
    36
	(res_inst_tac [("t",s1)](noteq_IsinlIsinr RS conjunct2 RS ssubst)1)
nipkow@243
    37
	THEN (rtac trans 1)
nipkow@243
    38
	THEN (atac 2)
nipkow@243
    39
	THEN (etac sym 1))
nipkow@243
    40
nipkow@243
    41
in
nipkow@243
    42
nipkow@243
    43
val less_ssum1a = prove_goalw Ssum1.thy [less_ssum_def]
nipkow@243
    44
"[|s1=Isinl(x); s2=Isinl(y)|] ==> less_ssum(s1,s2) = (x << y)"
nipkow@243
    45
 (fn prems =>
nipkow@243
    46
	[
nipkow@243
    47
	(cut_facts_tac prems 1),
nipkow@243
    48
	(rtac  select_equality 1),
nipkow@243
    49
	(dtac conjunct1 2),
nipkow@243
    50
	(dtac spec 2),
nipkow@243
    51
	(dtac spec 2),
nipkow@243
    52
	(etac mp 2),
nipkow@243
    53
	(fast_tac HOL_cs 2),
nipkow@243
    54
	(rtac conjI 1),
nipkow@243
    55
	(strip_tac 1),
nipkow@243
    56
	(etac conjE 1),
nipkow@243
    57
	(eq_left "x" "u"),
nipkow@243
    58
	(eq_left "y" "xa"),
nipkow@243
    59
	(rtac refl 1),
nipkow@243
    60
	(rtac conjI 1),
nipkow@243
    61
	(strip_tac 1),
nipkow@243
    62
	(etac conjE 1),
nipkow@243
    63
	(UU_left "x"),
nipkow@243
    64
	(UU_right "v"),
nipkow@243
    65
	(simp_tac Cfun_ss 1),
nipkow@243
    66
	(rtac conjI 1),
nipkow@243
    67
	(strip_tac 1),
nipkow@243
    68
	(etac conjE 1),
nipkow@243
    69
	(eq_left "x" "u"),
nipkow@243
    70
	(UU_left "y"),
nipkow@243
    71
	(rtac iffI 1),
nipkow@243
    72
	(etac UU_I 1),
nipkow@243
    73
	(res_inst_tac [("s","x"),("t","UU")] subst 1),
nipkow@243
    74
	(atac 1),
nipkow@243
    75
	(rtac refl_less 1),
nipkow@243
    76
	(strip_tac 1),
nipkow@243
    77
	(etac conjE 1),
nipkow@243
    78
	(UU_left "x"),
nipkow@243
    79
	(UU_right "v"),
nipkow@243
    80
	(simp_tac Cfun_ss 1)
nipkow@243
    81
	]);
nipkow@243
    82
nipkow@243
    83
nipkow@243
    84
val less_ssum1b = prove_goalw Ssum1.thy [less_ssum_def]
nipkow@243
    85
"[|s1=Isinr(x); s2=Isinr(y)|] ==> less_ssum(s1,s2) = (x << y)"
nipkow@243
    86
 (fn prems =>
nipkow@243
    87
	[
nipkow@243
    88
	(cut_facts_tac prems 1),
nipkow@243
    89
	(rtac  select_equality 1),
nipkow@243
    90
	(dtac conjunct2 2),
nipkow@243
    91
	(dtac conjunct1 2),
nipkow@243
    92
	(dtac spec 2),
nipkow@243
    93
	(dtac spec 2),
nipkow@243
    94
	(etac mp 2),
nipkow@243
    95
	(fast_tac HOL_cs 2),
nipkow@243
    96
	(rtac conjI 1),
nipkow@243
    97
	(strip_tac 1),
nipkow@243
    98
	(etac conjE 1),
nipkow@243
    99
	(UU_right "x"),
nipkow@243
   100
	(UU_left "u"),
nipkow@243
   101
	(simp_tac Cfun_ss 1),
nipkow@243
   102
	(rtac conjI 1),
nipkow@243
   103
	(strip_tac 1),
nipkow@243
   104
	(etac conjE 1),
nipkow@243
   105
	(eq_right "x" "v"),
nipkow@243
   106
	(eq_right "y" "ya"),
nipkow@243
   107
	(rtac refl 1),
nipkow@243
   108
	(rtac conjI 1),
nipkow@243
   109
	(strip_tac 1),
nipkow@243
   110
	(etac conjE 1),
nipkow@243
   111
	(UU_right "x"),
nipkow@243
   112
	(UU_left "u"),
nipkow@243
   113
	(simp_tac Cfun_ss 1),
nipkow@243
   114
	(strip_tac 1),
nipkow@243
   115
	(etac conjE 1),
nipkow@243
   116
	(eq_right "x" "v"),
nipkow@243
   117
	(UU_right "y"),
nipkow@243
   118
	(rtac iffI 1),
nipkow@243
   119
	(etac UU_I 1),
nipkow@243
   120
	(res_inst_tac [("s","UU"),("t","x")] subst 1),
nipkow@243
   121
	(etac sym 1),
nipkow@243
   122
	(rtac refl_less 1)
nipkow@243
   123
	]);
nipkow@243
   124
nipkow@243
   125
nipkow@243
   126
val less_ssum1c = prove_goalw Ssum1.thy [less_ssum_def]
nipkow@243
   127
"[|s1=Isinl(x); s2=Isinr(y)|] ==> less_ssum(s1,s2) = (x = UU)"
nipkow@243
   128
 (fn prems =>
nipkow@243
   129
	[
nipkow@243
   130
	(cut_facts_tac prems 1),
nipkow@243
   131
	(rtac  select_equality 1),
nipkow@243
   132
	(rtac conjI 1),
nipkow@243
   133
	(strip_tac 1),
nipkow@243
   134
	(etac conjE 1),
nipkow@243
   135
	(eq_left  "x" "u"),
nipkow@243
   136
	(UU_left "xa"),
nipkow@243
   137
	(rtac iffI 1),
nipkow@243
   138
	(res_inst_tac [("s","x"),("t","UU")] subst 1),
nipkow@243
   139
	(atac 1),
nipkow@243
   140
	(rtac refl_less 1),
nipkow@243
   141
	(etac UU_I 1),
nipkow@243
   142
	(rtac conjI 1),
nipkow@243
   143
	(strip_tac 1),
nipkow@243
   144
	(etac conjE 1),
nipkow@243
   145
	(UU_left "x"),
nipkow@243
   146
	(UU_right "v"),
nipkow@243
   147
	(simp_tac Cfun_ss 1),
nipkow@243
   148
	(rtac conjI 1),
nipkow@243
   149
	(strip_tac 1),
nipkow@243
   150
	(etac conjE 1),
nipkow@243
   151
	(eq_left  "x" "u"),
nipkow@243
   152
	(rtac refl 1),
nipkow@243
   153
	(strip_tac 1),
nipkow@243
   154
	(etac conjE 1),
nipkow@243
   155
	(UU_left "x"),
nipkow@243
   156
	(UU_right "v"),
nipkow@243
   157
	(simp_tac Cfun_ss 1),
nipkow@243
   158
	(dtac conjunct2 1),
nipkow@243
   159
	(dtac conjunct2 1),
nipkow@243
   160
	(dtac conjunct1 1),
nipkow@243
   161
	(dtac spec 1),
nipkow@243
   162
	(dtac spec 1),
nipkow@243
   163
	(etac mp 1),
nipkow@243
   164
	(fast_tac HOL_cs 1)
nipkow@243
   165
	]);
nipkow@243
   166
nipkow@243
   167
nipkow@243
   168
val less_ssum1d = prove_goalw Ssum1.thy [less_ssum_def]
nipkow@243
   169
"[|s1=Isinr(x); s2=Isinl(y)|] ==> less_ssum(s1,s2) = (x = UU)"
nipkow@243
   170
 (fn prems =>
nipkow@243
   171
	[
nipkow@243
   172
	(cut_facts_tac prems 1),
nipkow@243
   173
	(rtac  select_equality 1),
nipkow@243
   174
	(dtac conjunct2 2),
nipkow@243
   175
	(dtac conjunct2 2),
nipkow@243
   176
	(dtac conjunct2 2),
nipkow@243
   177
	(dtac spec 2),
nipkow@243
   178
	(dtac spec 2),
nipkow@243
   179
	(etac mp 2),
nipkow@243
   180
	(fast_tac HOL_cs 2),
nipkow@243
   181
	(rtac conjI 1),
nipkow@243
   182
	(strip_tac 1),
nipkow@243
   183
	(etac conjE 1),
nipkow@243
   184
	(UU_right "x"),
nipkow@243
   185
	(UU_left "u"),
nipkow@243
   186
	(simp_tac Cfun_ss 1),
nipkow@243
   187
	(rtac conjI 1),
nipkow@243
   188
	(strip_tac 1),
nipkow@243
   189
	(etac conjE 1),
nipkow@243
   190
	(UU_right "ya"),
nipkow@243
   191
	(eq_right "x" "v"),
nipkow@243
   192
	(rtac iffI 1),
nipkow@243
   193
	(etac UU_I 2),
nipkow@243
   194
	(res_inst_tac [("s","UU"),("t","x")] subst 1),
nipkow@243
   195
	(etac sym 1),
nipkow@243
   196
	(rtac refl_less 1),
nipkow@243
   197
	(rtac conjI 1),
nipkow@243
   198
	(strip_tac 1),
nipkow@243
   199
	(etac conjE 1),
nipkow@243
   200
	(UU_right "x"),
nipkow@243
   201
	(UU_left "u"),
nipkow@243
   202
	(simp_tac HOL_ss 1),
nipkow@243
   203
	(strip_tac 1),
nipkow@243
   204
	(etac conjE 1),
nipkow@243
   205
	(eq_right "x" "v"),
nipkow@243
   206
	(rtac refl 1)
nipkow@243
   207
	])
nipkow@243
   208
end;
nipkow@243
   209
nipkow@243
   210
nipkow@243
   211
(* ------------------------------------------------------------------------ *)
nipkow@243
   212
(* optimize lemmas about less_ssum                                          *)
nipkow@243
   213
(* ------------------------------------------------------------------------ *)
nipkow@243
   214
nipkow@243
   215
val less_ssum2a = prove_goal Ssum1.thy 
nipkow@243
   216
	"less_ssum(Isinl(x),Isinl(y)) = (x << y)"
nipkow@243
   217
 (fn prems =>
nipkow@243
   218
	[
nipkow@243
   219
	(rtac less_ssum1a 1),
nipkow@243
   220
	(rtac refl 1),
nipkow@243
   221
	(rtac refl 1)
nipkow@243
   222
	]);
nipkow@243
   223
nipkow@243
   224
val less_ssum2b = prove_goal Ssum1.thy 
nipkow@243
   225
	"less_ssum(Isinr(x),Isinr(y)) = (x << y)"
nipkow@243
   226
 (fn prems =>
nipkow@243
   227
	[
nipkow@243
   228
	(rtac less_ssum1b 1),
nipkow@243
   229
	(rtac refl 1),
nipkow@243
   230
	(rtac refl 1)
nipkow@243
   231
	]);
nipkow@243
   232
nipkow@243
   233
val less_ssum2c = prove_goal Ssum1.thy 
nipkow@243
   234
	"less_ssum(Isinl(x),Isinr(y)) = (x = UU)"
nipkow@243
   235
 (fn prems =>
nipkow@243
   236
	[
nipkow@243
   237
	(rtac less_ssum1c 1),
nipkow@243
   238
	(rtac refl 1),
nipkow@243
   239
	(rtac refl 1)
nipkow@243
   240
	]);
nipkow@243
   241
nipkow@243
   242
val less_ssum2d = prove_goal Ssum1.thy 
nipkow@243
   243
	"less_ssum(Isinr(x),Isinl(y)) = (x = UU)"
nipkow@243
   244
 (fn prems =>
nipkow@243
   245
	[
nipkow@243
   246
	(rtac less_ssum1d 1),
nipkow@243
   247
	(rtac refl 1),
nipkow@243
   248
	(rtac refl 1)
nipkow@243
   249
	]);
nipkow@243
   250
nipkow@243
   251
nipkow@243
   252
(* ------------------------------------------------------------------------ *)
nipkow@243
   253
(* less_ssum is a partial order on ++                                     *)
nipkow@243
   254
(* ------------------------------------------------------------------------ *)
nipkow@243
   255
nipkow@243
   256
val refl_less_ssum = prove_goal Ssum1.thy "less_ssum(p,p)"
nipkow@243
   257
 (fn prems =>
nipkow@243
   258
	[
nipkow@243
   259
	(res_inst_tac [("p","p")] IssumE2 1),
nipkow@243
   260
	(hyp_subst_tac 1),
nipkow@243
   261
	(rtac (less_ssum2a RS iffD2) 1),
nipkow@243
   262
	(rtac refl_less 1),
nipkow@243
   263
	(hyp_subst_tac 1),
nipkow@243
   264
	(rtac (less_ssum2b RS iffD2) 1),
nipkow@243
   265
	(rtac refl_less 1)
nipkow@243
   266
	]);
nipkow@243
   267
nipkow@243
   268
val antisym_less_ssum = prove_goal Ssum1.thy 
nipkow@243
   269
 "[|less_ssum(p1,p2);less_ssum(p2,p1)|] ==> p1=p2"
nipkow@243
   270
 (fn prems =>
nipkow@243
   271
	[
nipkow@243
   272
	(cut_facts_tac prems 1),
nipkow@243
   273
	(res_inst_tac [("p","p1")] IssumE2 1),
nipkow@243
   274
	(hyp_subst_tac 1),
nipkow@243
   275
	(res_inst_tac [("p","p2")] IssumE2 1),
nipkow@243
   276
	(hyp_subst_tac 1),
nipkow@243
   277
	(res_inst_tac [("f","Isinl")] arg_cong 1),
nipkow@243
   278
	(rtac antisym_less 1),
nipkow@243
   279
	(etac (less_ssum2a RS iffD1) 1),
nipkow@243
   280
	(etac (less_ssum2a RS iffD1) 1),
nipkow@243
   281
	(hyp_subst_tac 1),
nipkow@243
   282
	(etac (less_ssum2d RS iffD1 RS ssubst) 1),
nipkow@243
   283
	(etac (less_ssum2c RS iffD1 RS ssubst) 1),
nipkow@243
   284
	(rtac strict_IsinlIsinr 1),
nipkow@243
   285
	(hyp_subst_tac 1),
nipkow@243
   286
	(res_inst_tac [("p","p2")] IssumE2 1),
nipkow@243
   287
	(hyp_subst_tac 1),
nipkow@243
   288
	(etac (less_ssum2c RS iffD1 RS ssubst) 1),
nipkow@243
   289
	(etac (less_ssum2d RS iffD1 RS ssubst) 1),
nipkow@243
   290
	(rtac (strict_IsinlIsinr RS sym) 1),
nipkow@243
   291
	(hyp_subst_tac 1),
nipkow@243
   292
	(res_inst_tac [("f","Isinr")] arg_cong 1),
nipkow@243
   293
	(rtac antisym_less 1),
nipkow@243
   294
	(etac (less_ssum2b RS iffD1) 1),
nipkow@243
   295
	(etac (less_ssum2b RS iffD1) 1)
nipkow@243
   296
	]);
nipkow@243
   297
nipkow@243
   298
val trans_less_ssum = prove_goal Ssum1.thy 
nipkow@243
   299
 "[|less_ssum(p1,p2);less_ssum(p2,p3)|] ==> less_ssum(p1,p3)"
nipkow@243
   300
 (fn prems =>
nipkow@243
   301
	[
nipkow@243
   302
	(cut_facts_tac prems 1),
nipkow@243
   303
	(res_inst_tac [("p","p1")] IssumE2 1),
nipkow@243
   304
	(hyp_subst_tac 1),
nipkow@243
   305
	(res_inst_tac [("p","p3")] IssumE2 1),
nipkow@243
   306
	(hyp_subst_tac 1),
nipkow@243
   307
	(rtac (less_ssum2a RS iffD2) 1),
nipkow@243
   308
	(res_inst_tac [("p","p2")] IssumE2 1),
nipkow@243
   309
	(hyp_subst_tac 1),
nipkow@243
   310
	(rtac trans_less 1),
nipkow@243
   311
	(etac (less_ssum2a RS iffD1) 1),
nipkow@243
   312
	(etac (less_ssum2a RS iffD1) 1),
nipkow@243
   313
	(hyp_subst_tac 1),
nipkow@243
   314
	(etac (less_ssum2c RS iffD1 RS ssubst) 1),
nipkow@243
   315
	(rtac minimal 1),
nipkow@243
   316
	(hyp_subst_tac 1),
nipkow@243
   317
	(rtac (less_ssum2c RS iffD2) 1),
nipkow@243
   318
	(res_inst_tac [("p","p2")] IssumE2 1),
nipkow@243
   319
	(hyp_subst_tac 1),
nipkow@243
   320
	(rtac UU_I 1),
nipkow@243
   321
	(rtac trans_less 1),
nipkow@243
   322
	(etac (less_ssum2a RS iffD1) 1),
nipkow@243
   323
	(rtac (antisym_less_inverse RS conjunct1) 1),
nipkow@243
   324
	(etac (less_ssum2c RS iffD1) 1),
nipkow@243
   325
	(hyp_subst_tac 1),
nipkow@243
   326
	(etac (less_ssum2c RS iffD1) 1),
nipkow@243
   327
	(hyp_subst_tac 1),
nipkow@243
   328
	(res_inst_tac [("p","p3")] IssumE2 1),
nipkow@243
   329
	(hyp_subst_tac 1),
nipkow@243
   330
	(rtac (less_ssum2d RS iffD2) 1),
nipkow@243
   331
	(res_inst_tac [("p","p2")] IssumE2 1),
nipkow@243
   332
	(hyp_subst_tac 1),
nipkow@243
   333
	(etac (less_ssum2d RS iffD1) 1),
nipkow@243
   334
	(hyp_subst_tac 1),
nipkow@243
   335
	(rtac UU_I 1),
nipkow@243
   336
	(rtac trans_less 1),
nipkow@243
   337
	(etac (less_ssum2b RS iffD1) 1),
nipkow@243
   338
	(rtac (antisym_less_inverse RS conjunct1) 1),
nipkow@243
   339
	(etac (less_ssum2d RS iffD1) 1),
nipkow@243
   340
	(hyp_subst_tac 1),
nipkow@243
   341
	(rtac (less_ssum2b RS iffD2) 1),
nipkow@243
   342
	(res_inst_tac [("p","p2")] IssumE2 1),
nipkow@243
   343
	(hyp_subst_tac 1),
nipkow@243
   344
	(etac (less_ssum2d RS iffD1 RS ssubst) 1),
nipkow@243
   345
	(rtac minimal 1),
nipkow@243
   346
	(hyp_subst_tac 1),
nipkow@243
   347
	(rtac trans_less 1),
nipkow@243
   348
	(etac (less_ssum2b RS iffD1) 1),
nipkow@243
   349
	(etac (less_ssum2b RS iffD1) 1)
nipkow@243
   350
	]);
nipkow@243
   351
nipkow@243
   352
nipkow@243
   353