src/HOL/List.ML
author nipkow
Wed Jun 24 13:59:45 1998 +0200 (1998-06-24)
changeset 5077 71043526295f
parent 5043 3fdc881e8ff9
child 5122 229190f9f303
permissions -rw-r--r--
* HOL/List: new function list_update written xs[i:=v] that updates the i-th
list position. May also be iterated as in xs[i:=a,j:=b,...].
clasohm@1465
     1
(*  Title:      HOL/List
clasohm@923
     2
    ID:         $Id$
clasohm@1465
     3
    Author:     Tobias Nipkow
clasohm@923
     4
    Copyright   1994 TU Muenchen
clasohm@923
     5
clasohm@923
     6
List lemmas
clasohm@923
     7
*)
clasohm@923
     8
nipkow@4935
     9
Goal "!x. xs ~= x#xs";
nipkow@3040
    10
by (induct_tac "xs" 1);
clasohm@1264
    11
by (ALLGOALS Asm_simp_tac);
nipkow@2608
    12
qed_spec_mp "not_Cons_self";
nipkow@3574
    13
bind_thm("not_Cons_self2",not_Cons_self RS not_sym);
nipkow@3574
    14
Addsimps [not_Cons_self,not_Cons_self2];
clasohm@923
    15
nipkow@4935
    16
Goal "(xs ~= []) = (? y ys. xs = y#ys)";
nipkow@3040
    17
by (induct_tac "xs" 1);
clasohm@1264
    18
by (Simp_tac 1);
clasohm@1264
    19
by (Asm_simp_tac 1);
clasohm@923
    20
qed "neq_Nil_conv";
clasohm@923
    21
nipkow@4830
    22
(* Induction over the length of a list: *)
nipkow@4935
    23
val [prem] = Goal
nipkow@4911
    24
  "(!!xs. (!ys. length ys < length xs --> P ys) ==> P xs) ==> P(xs)";
nipkow@4911
    25
by(rtac measure_induct 1 THEN etac prem 1);
nipkow@4911
    26
qed "length_induct";
nipkow@4911
    27
clasohm@923
    28
paulson@3468
    29
(** "lists": the list-forming operator over sets **)
paulson@3342
    30
nipkow@5043
    31
Goalw lists.defs "A<=B ==> lists A <= lists B";
paulson@3342
    32
by (rtac lfp_mono 1);
paulson@3342
    33
by (REPEAT (ares_tac basic_monos 1));
paulson@3342
    34
qed "lists_mono";
paulson@3196
    35
paulson@3468
    36
val listsE = lists.mk_cases list.simps  "x#l : lists A";
paulson@3468
    37
AddSEs [listsE];
paulson@3468
    38
AddSIs lists.intrs;
paulson@3468
    39
nipkow@5043
    40
Goal "l: lists A ==> l: lists B --> l: lists (A Int B)";
paulson@3468
    41
by (etac lists.induct 1);
paulson@3468
    42
by (ALLGOALS Blast_tac);
paulson@3468
    43
qed_spec_mp "lists_IntI";
paulson@3468
    44
nipkow@4935
    45
Goal "lists (A Int B) = lists A Int lists B";
wenzelm@4423
    46
by (rtac (mono_Int RS equalityI) 1);
wenzelm@4089
    47
by (simp_tac (simpset() addsimps [mono_def, lists_mono]) 1);
wenzelm@4089
    48
by (blast_tac (claset() addSIs [lists_IntI]) 1);
paulson@3468
    49
qed "lists_Int_eq";
paulson@3468
    50
Addsimps [lists_Int_eq];
paulson@3468
    51
paulson@3196
    52
nipkow@4643
    53
(**  Case analysis **)
nipkow@4643
    54
section "Case analysis";
nipkow@2608
    55
nipkow@4935
    56
val prems = Goal "[| P([]); !!x xs. P(x#xs) |] ==> P(xs)";
paulson@3457
    57
by (induct_tac "xs" 1);
paulson@3457
    58
by (REPEAT(resolve_tac prems 1));
nipkow@2608
    59
qed "list_cases";
nipkow@2608
    60
nipkow@4935
    61
Goal "(xs=[] --> P([])) & (!y ys. xs=y#ys --> P(y#ys)) --> P(xs)";
nipkow@3040
    62
by (induct_tac "xs" 1);
paulson@2891
    63
by (Blast_tac 1);
paulson@2891
    64
by (Blast_tac 1);
nipkow@2608
    65
bind_thm("list_eq_cases",
nipkow@2608
    66
  impI RSN (2,allI RSN (2,allI RSN (2,impI RS (conjI RS (result() RS mp))))));
nipkow@2608
    67
nipkow@3860
    68
(** length **)
nipkow@3860
    69
(* needs to come before "@" because of thm append_eq_append_conv *)
nipkow@3860
    70
nipkow@3860
    71
section "length";
nipkow@3860
    72
nipkow@4935
    73
Goal "length(xs@ys) = length(xs)+length(ys)";
nipkow@3860
    74
by (induct_tac "xs" 1);
nipkow@3860
    75
by (ALLGOALS Asm_simp_tac);
nipkow@3860
    76
qed"length_append";
nipkow@3860
    77
Addsimps [length_append];
nipkow@3860
    78
nipkow@4935
    79
Goal "length (map f l) = length l";
nipkow@3860
    80
by (induct_tac "l" 1);
nipkow@3860
    81
by (ALLGOALS Simp_tac);
nipkow@3860
    82
qed "length_map";
nipkow@3860
    83
Addsimps [length_map];
nipkow@3860
    84
nipkow@4935
    85
Goal "length(rev xs) = length(xs)";
nipkow@3860
    86
by (induct_tac "xs" 1);
nipkow@3860
    87
by (ALLGOALS Asm_simp_tac);
nipkow@3860
    88
qed "length_rev";
nipkow@3860
    89
Addsimps [length_rev];
nipkow@3860
    90
nipkow@5043
    91
Goal "xs ~= [] ==> length(tl xs) = (length xs) - 1";
wenzelm@4423
    92
by (exhaust_tac "xs" 1);
wenzelm@4423
    93
by (ALLGOALS Asm_full_simp_tac);
nipkow@3896
    94
qed "length_tl";
nipkow@3896
    95
Addsimps [length_tl];
nipkow@3896
    96
nipkow@4935
    97
Goal "(length xs = 0) = (xs = [])";
nipkow@3860
    98
by (induct_tac "xs" 1);
nipkow@3860
    99
by (ALLGOALS Asm_simp_tac);
nipkow@3860
   100
qed "length_0_conv";
nipkow@3860
   101
AddIffs [length_0_conv];
nipkow@3860
   102
nipkow@4935
   103
Goal "(0 = length xs) = (xs = [])";
nipkow@3860
   104
by (induct_tac "xs" 1);
nipkow@3860
   105
by (ALLGOALS Asm_simp_tac);
nipkow@3860
   106
qed "zero_length_conv";
nipkow@3860
   107
AddIffs [zero_length_conv];
nipkow@3860
   108
nipkow@4935
   109
Goal "(0 < length xs) = (xs ~= [])";
nipkow@3860
   110
by (induct_tac "xs" 1);
nipkow@3860
   111
by (ALLGOALS Asm_simp_tac);
nipkow@3860
   112
qed "length_greater_0_conv";
nipkow@3860
   113
AddIffs [length_greater_0_conv];
nipkow@3860
   114
clasohm@923
   115
(** @ - append **)
clasohm@923
   116
nipkow@3467
   117
section "@ - append";
nipkow@3467
   118
nipkow@4935
   119
Goal "(xs@ys)@zs = xs@(ys@zs)";
nipkow@3040
   120
by (induct_tac "xs" 1);
clasohm@1264
   121
by (ALLGOALS Asm_simp_tac);
clasohm@923
   122
qed "append_assoc";
nipkow@2512
   123
Addsimps [append_assoc];
clasohm@923
   124
nipkow@4935
   125
Goal "xs @ [] = xs";
nipkow@3040
   126
by (induct_tac "xs" 1);
clasohm@1264
   127
by (ALLGOALS Asm_simp_tac);
clasohm@923
   128
qed "append_Nil2";
nipkow@2512
   129
Addsimps [append_Nil2];
clasohm@923
   130
nipkow@4935
   131
Goal "(xs@ys = []) = (xs=[] & ys=[])";
nipkow@3040
   132
by (induct_tac "xs" 1);
clasohm@1264
   133
by (ALLGOALS Asm_simp_tac);
nipkow@2608
   134
qed "append_is_Nil_conv";
nipkow@2608
   135
AddIffs [append_is_Nil_conv];
nipkow@2608
   136
nipkow@4935
   137
Goal "([] = xs@ys) = (xs=[] & ys=[])";
nipkow@3040
   138
by (induct_tac "xs" 1);
nipkow@2608
   139
by (ALLGOALS Asm_simp_tac);
paulson@3457
   140
by (Blast_tac 1);
nipkow@2608
   141
qed "Nil_is_append_conv";
nipkow@2608
   142
AddIffs [Nil_is_append_conv];
clasohm@923
   143
nipkow@4935
   144
Goal "(xs @ ys = xs) = (ys=[])";
nipkow@3574
   145
by (induct_tac "xs" 1);
nipkow@3574
   146
by (ALLGOALS Asm_simp_tac);
nipkow@3574
   147
qed "append_self_conv";
nipkow@3574
   148
nipkow@4935
   149
Goal "(xs = xs @ ys) = (ys=[])";
nipkow@3574
   150
by (induct_tac "xs" 1);
nipkow@3574
   151
by (ALLGOALS Asm_simp_tac);
nipkow@3574
   152
by (Blast_tac 1);
nipkow@3574
   153
qed "self_append_conv";
nipkow@3574
   154
AddIffs [append_self_conv,self_append_conv];
nipkow@3574
   155
nipkow@4935
   156
Goal "!ys. length xs = length ys | length us = length vs \
nipkow@3860
   157
\              --> (xs@us = ys@vs) = (xs=ys & us=vs)";
wenzelm@4423
   158
by (induct_tac "xs" 1);
wenzelm@4423
   159
 by (rtac allI 1);
wenzelm@4423
   160
 by (exhaust_tac "ys" 1);
wenzelm@4423
   161
  by (Asm_simp_tac 1);
wenzelm@4423
   162
 by (fast_tac (claset() addIs [less_add_Suc2] addss simpset()
nipkow@3860
   163
                      addEs [less_not_refl2 RSN (2,rev_notE)]) 1);
wenzelm@4423
   164
by (rtac allI 1);
wenzelm@4423
   165
by (exhaust_tac "ys" 1);
wenzelm@4423
   166
 by (fast_tac (claset() addIs [less_add_Suc2] addss simpset()
nipkow@3860
   167
                      addEs [(less_not_refl2 RS not_sym) RSN (2,rev_notE)]) 1);
wenzelm@4423
   168
by (Asm_simp_tac 1);
nipkow@3860
   169
qed_spec_mp "append_eq_append_conv";
nipkow@3860
   170
Addsimps [append_eq_append_conv];
nipkow@3860
   171
nipkow@4935
   172
Goal "(xs @ ys = xs @ zs) = (ys=zs)";
nipkow@3896
   173
by (Simp_tac 1);
nipkow@3896
   174
qed "same_append_eq";
nipkow@3860
   175
nipkow@4935
   176
Goal "(xs @ [x] = ys @ [y]) = (xs = ys & x = y)"; 
nipkow@3896
   177
by (Simp_tac 1);
nipkow@3896
   178
qed "append1_eq_conv";
nipkow@2608
   179
nipkow@4935
   180
Goal "(ys @ xs = zs @ xs) = (ys=zs)";
nipkow@3896
   181
by (Simp_tac 1);
nipkow@3896
   182
qed "append_same_eq";
nipkow@2608
   183
nipkow@3896
   184
AddSIs
nipkow@3896
   185
 [same_append_eq RS iffD2, append1_eq_conv RS iffD2, append_same_eq RS iffD2];
nipkow@3896
   186
AddSDs
nipkow@3896
   187
 [same_append_eq RS iffD1, append1_eq_conv RS iffD1, append_same_eq RS iffD1];
nipkow@3571
   188
nipkow@4935
   189
Goal "(xs @ ys = ys) = (xs=[])";
nipkow@4647
   190
by(cut_inst_tac [("zs","[]")] append_same_eq 1);
nipkow@4647
   191
by(Asm_full_simp_tac 1);
nipkow@4647
   192
qed "append_self_conv2";
nipkow@4647
   193
nipkow@4935
   194
Goal "(ys = xs @ ys) = (xs=[])";
nipkow@4647
   195
by(simp_tac (simpset() addsimps
nipkow@4647
   196
     [simplify (simpset()) (read_instantiate[("ys","[]")]append_same_eq)]) 1);
nipkow@4647
   197
by(Blast_tac 1);
nipkow@4647
   198
qed "self_append_conv2";
nipkow@4647
   199
AddIffs [append_self_conv2,self_append_conv2];
nipkow@4647
   200
nipkow@4935
   201
Goal "xs ~= [] --> hd xs # tl xs = xs";
paulson@3457
   202
by (induct_tac "xs" 1);
paulson@3457
   203
by (ALLGOALS Asm_simp_tac);
nipkow@2608
   204
qed_spec_mp "hd_Cons_tl";
nipkow@2608
   205
Addsimps [hd_Cons_tl];
clasohm@923
   206
nipkow@4935
   207
Goal "hd(xs@ys) = (if xs=[] then hd ys else hd xs)";
nipkow@3040
   208
by (induct_tac "xs" 1);
nipkow@1327
   209
by (ALLGOALS Asm_simp_tac);
nipkow@1327
   210
qed "hd_append";
clasohm@923
   211
nipkow@5043
   212
Goal "xs ~= [] ==> hd(xs @ ys) = hd xs";
wenzelm@4089
   213
by (asm_simp_tac (simpset() addsimps [hd_append]
nipkow@4069
   214
                           addsplits [split_list_case]) 1);
nipkow@3571
   215
qed "hd_append2";
nipkow@3571
   216
Addsimps [hd_append2];
nipkow@3571
   217
nipkow@4935
   218
Goal "tl(xs@ys) = (case xs of [] => tl(ys) | z#zs => zs@ys)";
wenzelm@4089
   219
by (simp_tac (simpset() addsplits [split_list_case]) 1);
nipkow@2608
   220
qed "tl_append";
nipkow@2608
   221
nipkow@5043
   222
Goal "xs ~= [] ==> tl(xs @ ys) = (tl xs) @ ys";
wenzelm@4089
   223
by (asm_simp_tac (simpset() addsimps [tl_append]
nipkow@4069
   224
                           addsplits [split_list_case]) 1);
nipkow@3571
   225
qed "tl_append2";
nipkow@3571
   226
Addsimps [tl_append2];
nipkow@3571
   227
nipkow@4830
   228
nipkow@2608
   229
(** map **)
nipkow@2608
   230
nipkow@3467
   231
section "map";
nipkow@3467
   232
nipkow@4935
   233
Goal
nipkow@3465
   234
  "(!x. x : set xs --> f x = g x) --> map f xs = map g xs";
paulson@3457
   235
by (induct_tac "xs" 1);
paulson@3457
   236
by (ALLGOALS Asm_simp_tac);
nipkow@2608
   237
bind_thm("map_ext", impI RS (allI RS (result() RS mp)));
nipkow@2608
   238
nipkow@4935
   239
Goal "map (%x. x) = (%xs. xs)";
nipkow@2608
   240
by (rtac ext 1);
nipkow@3040
   241
by (induct_tac "xs" 1);
nipkow@2608
   242
by (ALLGOALS Asm_simp_tac);
nipkow@2608
   243
qed "map_ident";
nipkow@2608
   244
Addsimps[map_ident];
nipkow@2608
   245
nipkow@4935
   246
Goal "map f (xs@ys) = map f xs @ map f ys";
nipkow@3040
   247
by (induct_tac "xs" 1);
nipkow@2608
   248
by (ALLGOALS Asm_simp_tac);
nipkow@2608
   249
qed "map_append";
nipkow@2608
   250
Addsimps[map_append];
nipkow@2608
   251
nipkow@4935
   252
Goalw [o_def] "map (f o g) xs = map f (map g xs)";
nipkow@3040
   253
by (induct_tac "xs" 1);
nipkow@2608
   254
by (ALLGOALS Asm_simp_tac);
nipkow@2608
   255
qed "map_compose";
nipkow@2608
   256
Addsimps[map_compose];
nipkow@2608
   257
nipkow@4935
   258
Goal "rev(map f xs) = map f (rev xs)";
nipkow@3040
   259
by (induct_tac "xs" 1);
nipkow@2608
   260
by (ALLGOALS Asm_simp_tac);
nipkow@2608
   261
qed "rev_map";
nipkow@2608
   262
nipkow@3589
   263
(* a congruence rule for map: *)
nipkow@4935
   264
Goal
nipkow@3589
   265
 "(xs=ys) --> (!x. x : set ys --> f x = g x) --> map f xs = map g ys";
wenzelm@4423
   266
by (rtac impI 1);
wenzelm@4423
   267
by (hyp_subst_tac 1);
wenzelm@4423
   268
by (induct_tac "ys" 1);
wenzelm@4423
   269
by (ALLGOALS Asm_simp_tac);
nipkow@3589
   270
val lemma = result();
nipkow@3589
   271
bind_thm("map_cong",impI RSN (2,allI RSN (2,lemma RS mp RS mp)));
nipkow@3589
   272
nipkow@4935
   273
Goal "(map f xs = []) = (xs = [])";
wenzelm@4423
   274
by (induct_tac "xs" 1);
wenzelm@4423
   275
by (ALLGOALS Asm_simp_tac);
nipkow@3860
   276
qed "map_is_Nil_conv";
nipkow@3860
   277
AddIffs [map_is_Nil_conv];
nipkow@3860
   278
nipkow@4935
   279
Goal "([] = map f xs) = (xs = [])";
wenzelm@4423
   280
by (induct_tac "xs" 1);
wenzelm@4423
   281
by (ALLGOALS Asm_simp_tac);
nipkow@3860
   282
qed "Nil_is_map_conv";
nipkow@3860
   283
AddIffs [Nil_is_map_conv];
nipkow@3860
   284
nipkow@3860
   285
lcp@1169
   286
(** rev **)
lcp@1169
   287
nipkow@3467
   288
section "rev";
nipkow@3467
   289
nipkow@4935
   290
Goal "rev(xs@ys) = rev(ys) @ rev(xs)";
nipkow@3040
   291
by (induct_tac "xs" 1);
nipkow@2512
   292
by (ALLGOALS Asm_simp_tac);
lcp@1169
   293
qed "rev_append";
nipkow@2512
   294
Addsimps[rev_append];
lcp@1169
   295
nipkow@4935
   296
Goal "rev(rev l) = l";
nipkow@3040
   297
by (induct_tac "l" 1);
nipkow@2512
   298
by (ALLGOALS Asm_simp_tac);
lcp@1169
   299
qed "rev_rev_ident";
nipkow@2512
   300
Addsimps[rev_rev_ident];
lcp@1169
   301
nipkow@4935
   302
Goal "(rev xs = []) = (xs = [])";
wenzelm@4423
   303
by (induct_tac "xs" 1);
wenzelm@4423
   304
by (ALLGOALS Asm_simp_tac);
nipkow@3860
   305
qed "rev_is_Nil_conv";
nipkow@3860
   306
AddIffs [rev_is_Nil_conv];
nipkow@3860
   307
nipkow@4935
   308
Goal "([] = rev xs) = (xs = [])";
wenzelm@4423
   309
by (induct_tac "xs" 1);
wenzelm@4423
   310
by (ALLGOALS Asm_simp_tac);
nipkow@3860
   311
qed "Nil_is_rev_conv";
nipkow@3860
   312
AddIffs [Nil_is_rev_conv];
nipkow@3860
   313
nipkow@4935
   314
val prems = Goal "[| P []; !!x xs. P xs ==> P(xs@[x]) |] ==> P xs";
nipkow@4935
   315
by(stac (rev_rev_ident RS sym) 1);
nipkow@4935
   316
br(read_instantiate [("P","%xs. ?P(rev xs)")]list.induct)1;
nipkow@4935
   317
by(ALLGOALS Simp_tac);
nipkow@4935
   318
brs prems 1;
nipkow@4935
   319
bes prems 1;
nipkow@4935
   320
qed "rev_induct";
nipkow@4935
   321
nipkow@4935
   322
Goal  "(xs = [] --> P) -->  (!ys y. xs = ys@[y] --> P) --> P";
nipkow@4935
   323
by(res_inst_tac [("xs","xs")] rev_induct 1);
nipkow@4935
   324
by(ALLGOALS Asm_simp_tac);
nipkow@4935
   325
bind_thm ("rev_exhaust",
nipkow@4935
   326
  impI RSN (2,allI RSN (2,allI RSN (2,impI RS (result() RS mp RS mp)))));
nipkow@4935
   327
nipkow@2608
   328
clasohm@923
   329
(** mem **)
clasohm@923
   330
nipkow@3467
   331
section "mem";
nipkow@3467
   332
nipkow@4935
   333
Goal "x mem (xs@ys) = (x mem xs | x mem ys)";
nipkow@3040
   334
by (induct_tac "xs" 1);
nipkow@4686
   335
by (ALLGOALS Asm_simp_tac);
clasohm@923
   336
qed "mem_append";
nipkow@2512
   337
Addsimps[mem_append];
clasohm@923
   338
nipkow@4935
   339
Goal "x mem [x:xs. P(x)] = (x mem xs & P(x))";
nipkow@3040
   340
by (induct_tac "xs" 1);
nipkow@4686
   341
by (ALLGOALS Asm_simp_tac);
clasohm@923
   342
qed "mem_filter";
nipkow@2512
   343
Addsimps[mem_filter];
clasohm@923
   344
nipkow@3465
   345
(** set **)
paulson@1812
   346
nipkow@3467
   347
section "set";
nipkow@3467
   348
nipkow@4935
   349
Goal "set (xs@ys) = (set xs Un set ys)";
nipkow@3040
   350
by (induct_tac "xs" 1);
paulson@1812
   351
by (ALLGOALS Asm_simp_tac);
paulson@3647
   352
qed "set_append";
paulson@3647
   353
Addsimps[set_append];
paulson@1812
   354
nipkow@4935
   355
Goal "(x mem xs) = (x: set xs)";
nipkow@3040
   356
by (induct_tac "xs" 1);
nipkow@4686
   357
by (ALLGOALS Asm_simp_tac);
paulson@2891
   358
by (Blast_tac 1);
paulson@3647
   359
qed "set_mem_eq";
paulson@1812
   360
nipkow@4935
   361
Goal "set l <= set (x#l)";
paulson@1936
   362
by (Simp_tac 1);
paulson@2891
   363
by (Blast_tac 1);
paulson@3647
   364
qed "set_subset_Cons";
paulson@1936
   365
nipkow@4935
   366
Goal "(set xs = {}) = (xs = [])";
paulson@3457
   367
by (induct_tac "xs" 1);
paulson@3457
   368
by (ALLGOALS Asm_simp_tac);
paulson@3647
   369
qed "set_empty";
paulson@3647
   370
Addsimps [set_empty];
nipkow@2608
   371
nipkow@4935
   372
Goal "set(rev xs) = set(xs)";
paulson@3457
   373
by (induct_tac "xs" 1);
paulson@3457
   374
by (ALLGOALS Asm_simp_tac);
paulson@3647
   375
qed "set_rev";
paulson@3647
   376
Addsimps [set_rev];
nipkow@2608
   377
nipkow@4935
   378
Goal "set(map f xs) = f``(set xs)";
paulson@3457
   379
by (induct_tac "xs" 1);
paulson@3457
   380
by (ALLGOALS Asm_simp_tac);
paulson@3647
   381
qed "set_map";
paulson@3647
   382
Addsimps [set_map];
nipkow@2608
   383
nipkow@4935
   384
Goal "set(map f xs) = f``(set xs)";
nipkow@4605
   385
by (induct_tac "xs" 1);
nipkow@4605
   386
by (ALLGOALS Asm_simp_tac);
nipkow@4605
   387
qed "set_map";
nipkow@4605
   388
Addsimps [set_map];
nipkow@4605
   389
nipkow@4935
   390
Goal "(x : set(filter P xs)) = (x : set xs & P x)";
nipkow@4605
   391
by (induct_tac "xs" 1);
nipkow@4686
   392
by (ALLGOALS Asm_simp_tac);
nipkow@4605
   393
by(Blast_tac 1);
nipkow@4605
   394
qed "in_set_filter";
nipkow@4605
   395
Addsimps [in_set_filter];
nipkow@4605
   396
paulson@1812
   397
clasohm@923
   398
(** list_all **)
clasohm@923
   399
nipkow@3467
   400
section "list_all";
nipkow@3467
   401
nipkow@4935
   402
Goal "list_all (%x. True) xs = True";
nipkow@3040
   403
by (induct_tac "xs" 1);
clasohm@1264
   404
by (ALLGOALS Asm_simp_tac);
clasohm@923
   405
qed "list_all_True";
nipkow@2512
   406
Addsimps [list_all_True];
clasohm@923
   407
nipkow@4935
   408
Goal "list_all p (xs@ys) = (list_all p xs & list_all p ys)";
nipkow@3040
   409
by (induct_tac "xs" 1);
clasohm@1264
   410
by (ALLGOALS Asm_simp_tac);
nipkow@2512
   411
qed "list_all_append";
nipkow@2512
   412
Addsimps [list_all_append];
clasohm@923
   413
nipkow@4935
   414
Goal "list_all P xs = (!x. x mem xs --> P(x))";
nipkow@3040
   415
by (induct_tac "xs" 1);
nipkow@4686
   416
by (ALLGOALS Asm_simp_tac);
paulson@2891
   417
by (Blast_tac 1);
clasohm@923
   418
qed "list_all_mem_conv";
clasohm@923
   419
clasohm@923
   420
nipkow@2608
   421
(** filter **)
clasohm@923
   422
nipkow@3467
   423
section "filter";
nipkow@3467
   424
nipkow@4935
   425
Goal "filter P (xs@ys) = filter P xs @ filter P ys";
paulson@3457
   426
by (induct_tac "xs" 1);
nipkow@4686
   427
by (ALLGOALS Asm_simp_tac);
nipkow@2608
   428
qed "filter_append";
nipkow@2608
   429
Addsimps [filter_append];
nipkow@2608
   430
nipkow@4935
   431
Goal "filter (%x. True) xs = xs";
nipkow@4605
   432
by (induct_tac "xs" 1);
nipkow@4605
   433
by (ALLGOALS Asm_simp_tac);
nipkow@4605
   434
qed "filter_True";
nipkow@4605
   435
Addsimps [filter_True];
nipkow@4605
   436
nipkow@4935
   437
Goal "filter (%x. False) xs = []";
nipkow@4605
   438
by (induct_tac "xs" 1);
nipkow@4605
   439
by (ALLGOALS Asm_simp_tac);
nipkow@4605
   440
qed "filter_False";
nipkow@4605
   441
Addsimps [filter_False];
nipkow@4605
   442
nipkow@4935
   443
Goal "length (filter P xs) <= length xs";
paulson@3457
   444
by (induct_tac "xs" 1);
nipkow@4686
   445
by (ALLGOALS Asm_simp_tac);
nipkow@4605
   446
qed "length_filter";
paulson@3383
   447
nipkow@2608
   448
nipkow@2608
   449
(** concat **)
nipkow@2608
   450
nipkow@3467
   451
section "concat";
nipkow@3467
   452
nipkow@4935
   453
Goal  "concat(xs@ys) = concat(xs)@concat(ys)";
nipkow@3040
   454
by (induct_tac "xs" 1);
clasohm@1264
   455
by (ALLGOALS Asm_simp_tac);
nipkow@2608
   456
qed"concat_append";
nipkow@2608
   457
Addsimps [concat_append];
nipkow@2512
   458
nipkow@4935
   459
Goal "(concat xss = []) = (!xs:set xss. xs=[])";
wenzelm@4423
   460
by (induct_tac "xss" 1);
wenzelm@4423
   461
by (ALLGOALS Asm_simp_tac);
nipkow@3896
   462
qed "concat_eq_Nil_conv";
nipkow@3896
   463
AddIffs [concat_eq_Nil_conv];
nipkow@3896
   464
nipkow@4935
   465
Goal "([] = concat xss) = (!xs:set xss. xs=[])";
wenzelm@4423
   466
by (induct_tac "xss" 1);
wenzelm@4423
   467
by (ALLGOALS Asm_simp_tac);
nipkow@3896
   468
qed "Nil_eq_concat_conv";
nipkow@3896
   469
AddIffs [Nil_eq_concat_conv];
nipkow@3896
   470
nipkow@4935
   471
Goal  "set(concat xs) = Union(set `` set xs)";
nipkow@3467
   472
by (induct_tac "xs" 1);
nipkow@3467
   473
by (ALLGOALS Asm_simp_tac);
paulson@3647
   474
qed"set_concat";
paulson@3647
   475
Addsimps [set_concat];
nipkow@3467
   476
nipkow@4935
   477
Goal "map f (concat xs) = concat (map (map f) xs)"; 
nipkow@3467
   478
by (induct_tac "xs" 1);
nipkow@3467
   479
by (ALLGOALS Asm_simp_tac);
nipkow@3467
   480
qed "map_concat";
nipkow@3467
   481
nipkow@4935
   482
Goal "filter p (concat xs) = concat (map (filter p) xs)"; 
nipkow@3467
   483
by (induct_tac "xs" 1);
nipkow@3467
   484
by (ALLGOALS Asm_simp_tac);
nipkow@3467
   485
qed"filter_concat"; 
nipkow@3467
   486
nipkow@4935
   487
Goal "rev(concat xs) = concat (map rev (rev xs))";
nipkow@3467
   488
by (induct_tac "xs" 1);
nipkow@2512
   489
by (ALLGOALS Asm_simp_tac);
nipkow@2608
   490
qed "rev_concat";
clasohm@923
   491
clasohm@923
   492
(** nth **)
clasohm@923
   493
nipkow@3467
   494
section "nth";
nipkow@3467
   495
nipkow@4935
   496
Goal
nipkow@4502
   497
  "!xs. (xs@ys)!n = (if n < length xs then xs!n else ys!(n - length xs))";
paulson@3457
   498
by (nat_ind_tac "n" 1);
paulson@3457
   499
 by (Asm_simp_tac 1);
paulson@3457
   500
 by (rtac allI 1);
paulson@3457
   501
 by (exhaust_tac "xs" 1);
paulson@3457
   502
  by (ALLGOALS Asm_simp_tac);
nipkow@2608
   503
qed_spec_mp "nth_append";
nipkow@2608
   504
nipkow@4935
   505
Goal "!n. n < length xs --> (map f xs)!n = f(xs!n)";
nipkow@3040
   506
by (induct_tac "xs" 1);
nipkow@1301
   507
(* case [] *)
nipkow@1301
   508
by (Asm_full_simp_tac 1);
nipkow@1301
   509
(* case x#xl *)
nipkow@1301
   510
by (rtac allI 1);
nipkow@1301
   511
by (nat_ind_tac "n" 1);
nipkow@1301
   512
by (ALLGOALS Asm_full_simp_tac);
nipkow@1485
   513
qed_spec_mp "nth_map";
nipkow@1301
   514
Addsimps [nth_map];
nipkow@1301
   515
nipkow@4935
   516
Goal "!n. n < length xs --> list_all P xs --> P(xs!n)";
nipkow@3040
   517
by (induct_tac "xs" 1);
nipkow@1301
   518
(* case [] *)
nipkow@1301
   519
by (Simp_tac 1);
nipkow@1301
   520
(* case x#xl *)
nipkow@1301
   521
by (rtac allI 1);
nipkow@1301
   522
by (nat_ind_tac "n" 1);
nipkow@1301
   523
by (ALLGOALS Asm_full_simp_tac);
nipkow@1485
   524
qed_spec_mp "list_all_nth";
nipkow@1301
   525
nipkow@4935
   526
Goal "!n. n < length xs --> xs!n mem xs";
nipkow@3040
   527
by (induct_tac "xs" 1);
nipkow@1301
   528
(* case [] *)
nipkow@1301
   529
by (Simp_tac 1);
nipkow@1301
   530
(* case x#xl *)
nipkow@1301
   531
by (rtac allI 1);
nipkow@1301
   532
by (nat_ind_tac "n" 1);
nipkow@1301
   533
(* case 0 *)
nipkow@1301
   534
by (Asm_full_simp_tac 1);
nipkow@1301
   535
(* case Suc x *)
nipkow@4686
   536
by (Asm_full_simp_tac 1);
nipkow@1485
   537
qed_spec_mp "nth_mem";
nipkow@1301
   538
Addsimps [nth_mem];
nipkow@1301
   539
nipkow@5077
   540
(** list update **)
nipkow@5077
   541
nipkow@5077
   542
section "list update";
nipkow@5077
   543
nipkow@5077
   544
Goal "!i. length(xs[i:=x]) = length xs";
nipkow@5077
   545
by (induct_tac "xs" 1);
nipkow@5077
   546
by (Simp_tac 1);
nipkow@5077
   547
by (asm_full_simp_tac (simpset() addsplits [split_nat_case]) 1);
nipkow@5077
   548
qed_spec_mp "length_list_update";
nipkow@5077
   549
Addsimps [length_list_update];
nipkow@5077
   550
nipkow@5077
   551
nipkow@3896
   552
(** last & butlast **)
nipkow@1327
   553
nipkow@4935
   554
Goal "last(xs@[x]) = x";
wenzelm@4423
   555
by (induct_tac "xs" 1);
nipkow@4686
   556
by (ALLGOALS Asm_simp_tac);
nipkow@3896
   557
qed "last_snoc";
nipkow@3896
   558
Addsimps [last_snoc];
nipkow@3896
   559
nipkow@4935
   560
Goal "butlast(xs@[x]) = xs";
wenzelm@4423
   561
by (induct_tac "xs" 1);
nipkow@4686
   562
by (ALLGOALS Asm_simp_tac);
nipkow@3896
   563
qed "butlast_snoc";
nipkow@3896
   564
Addsimps [butlast_snoc];
nipkow@3896
   565
nipkow@4935
   566
Goal "length(butlast xs) = length xs - 1";
nipkow@4935
   567
by (res_inst_tac [("xs","xs")] rev_induct 1);
nipkow@4686
   568
by (ALLGOALS Asm_simp_tac);
nipkow@4643
   569
qed "length_butlast";
nipkow@4643
   570
Addsimps [length_butlast];
nipkow@4643
   571
nipkow@4935
   572
Goal
nipkow@3896
   573
  "!ys. butlast (xs@ys) = (if ys=[] then butlast xs else xs@butlast ys)";
wenzelm@4423
   574
by (induct_tac "xs" 1);
nipkow@4686
   575
by (ALLGOALS Asm_simp_tac);
nipkow@3896
   576
qed_spec_mp "butlast_append";
nipkow@3896
   577
nipkow@4935
   578
Goal "x:set(butlast xs) --> x:set xs";
wenzelm@4423
   579
by (induct_tac "xs" 1);
nipkow@4686
   580
by (ALLGOALS Asm_simp_tac);
nipkow@3896
   581
qed_spec_mp "in_set_butlastD";
nipkow@3896
   582
nipkow@5043
   583
Goal "x:set(butlast xs) ==> x:set(butlast(xs@ys))";
nipkow@4686
   584
by (asm_simp_tac (simpset() addsimps [butlast_append]) 1);
wenzelm@4423
   585
by (blast_tac (claset() addDs [in_set_butlastD]) 1);
nipkow@3896
   586
qed "in_set_butlast_appendI1";
nipkow@3896
   587
nipkow@5043
   588
Goal "x:set(butlast ys) ==> x:set(butlast(xs@ys))";
nipkow@4686
   589
by (asm_simp_tac (simpset() addsimps [butlast_append]) 1);
wenzelm@4423
   590
by (Clarify_tac 1);
wenzelm@4423
   591
by (Full_simp_tac 1);
nipkow@3896
   592
qed "in_set_butlast_appendI2";
nipkow@3902
   593
nipkow@2608
   594
(** take  & drop **)
nipkow@2608
   595
section "take & drop";
nipkow@1327
   596
nipkow@4935
   597
Goal "take 0 xs = []";
nipkow@3040
   598
by (induct_tac "xs" 1);
nipkow@1419
   599
by (ALLGOALS Asm_simp_tac);
nipkow@1327
   600
qed "take_0";
nipkow@1327
   601
nipkow@4935
   602
Goal "drop 0 xs = xs";
nipkow@3040
   603
by (induct_tac "xs" 1);
nipkow@2608
   604
by (ALLGOALS Asm_simp_tac);
nipkow@2608
   605
qed "drop_0";
nipkow@2608
   606
nipkow@4935
   607
Goal "take (Suc n) (x#xs) = x # take n xs";
paulson@1552
   608
by (Simp_tac 1);
nipkow@1419
   609
qed "take_Suc_Cons";
nipkow@1327
   610
nipkow@4935
   611
Goal "drop (Suc n) (x#xs) = drop n xs";
nipkow@2608
   612
by (Simp_tac 1);
nipkow@2608
   613
qed "drop_Suc_Cons";
nipkow@2608
   614
nipkow@2608
   615
Delsimps [take_Cons,drop_Cons];
nipkow@2608
   616
Addsimps [take_0,take_Suc_Cons,drop_0,drop_Suc_Cons];
nipkow@2608
   617
nipkow@4935
   618
Goal "!xs. length(take n xs) = min (length xs) n";
paulson@3457
   619
by (nat_ind_tac "n" 1);
paulson@3457
   620
 by (ALLGOALS Asm_simp_tac);
paulson@3457
   621
by (rtac allI 1);
paulson@3457
   622
by (exhaust_tac "xs" 1);
paulson@3457
   623
 by (ALLGOALS Asm_simp_tac);
nipkow@2608
   624
qed_spec_mp "length_take";
nipkow@2608
   625
Addsimps [length_take];
clasohm@923
   626
nipkow@4935
   627
Goal "!xs. length(drop n xs) = (length xs - n)";
paulson@3457
   628
by (nat_ind_tac "n" 1);
paulson@3457
   629
 by (ALLGOALS Asm_simp_tac);
paulson@3457
   630
by (rtac allI 1);
paulson@3457
   631
by (exhaust_tac "xs" 1);
paulson@3457
   632
 by (ALLGOALS Asm_simp_tac);
nipkow@2608
   633
qed_spec_mp "length_drop";
nipkow@2608
   634
Addsimps [length_drop];
nipkow@2608
   635
nipkow@4935
   636
Goal "!xs. length xs <= n --> take n xs = xs";
paulson@3457
   637
by (nat_ind_tac "n" 1);
paulson@3457
   638
 by (ALLGOALS Asm_simp_tac);
paulson@3457
   639
by (rtac allI 1);
paulson@3457
   640
by (exhaust_tac "xs" 1);
paulson@3457
   641
 by (ALLGOALS Asm_simp_tac);
nipkow@2608
   642
qed_spec_mp "take_all";
clasohm@923
   643
nipkow@4935
   644
Goal "!xs. length xs <= n --> drop n xs = []";
paulson@3457
   645
by (nat_ind_tac "n" 1);
paulson@3457
   646
 by (ALLGOALS Asm_simp_tac);
paulson@3457
   647
by (rtac allI 1);
paulson@3457
   648
by (exhaust_tac "xs" 1);
paulson@3457
   649
 by (ALLGOALS Asm_simp_tac);
nipkow@2608
   650
qed_spec_mp "drop_all";
nipkow@2608
   651
nipkow@4935
   652
Goal 
nipkow@2608
   653
  "!xs. take n (xs @ ys) = (take n xs @ take (n - length xs) ys)";
paulson@3457
   654
by (nat_ind_tac "n" 1);
paulson@3457
   655
 by (ALLGOALS Asm_simp_tac);
paulson@3457
   656
by (rtac allI 1);
paulson@3457
   657
by (exhaust_tac "xs" 1);
paulson@3457
   658
 by (ALLGOALS Asm_simp_tac);
nipkow@2608
   659
qed_spec_mp "take_append";
nipkow@2608
   660
Addsimps [take_append];
nipkow@2608
   661
nipkow@4935
   662
Goal "!xs. drop n (xs@ys) = drop n xs @ drop (n - length xs) ys"; 
paulson@3457
   663
by (nat_ind_tac "n" 1);
paulson@3457
   664
 by (ALLGOALS Asm_simp_tac);
paulson@3457
   665
by (rtac allI 1);
paulson@3457
   666
by (exhaust_tac "xs" 1);
paulson@3457
   667
 by (ALLGOALS Asm_simp_tac);
nipkow@2608
   668
qed_spec_mp "drop_append";
nipkow@2608
   669
Addsimps [drop_append];
nipkow@2608
   670
nipkow@4935
   671
Goal "!xs n. take n (take m xs) = take (min n m) xs"; 
paulson@3457
   672
by (nat_ind_tac "m" 1);
paulson@3457
   673
 by (ALLGOALS Asm_simp_tac);
paulson@3457
   674
by (rtac allI 1);
paulson@3457
   675
by (exhaust_tac "xs" 1);
paulson@3457
   676
 by (ALLGOALS Asm_simp_tac);
paulson@3457
   677
by (rtac allI 1);
paulson@3457
   678
by (exhaust_tac "n" 1);
paulson@3457
   679
 by (ALLGOALS Asm_simp_tac);
nipkow@2608
   680
qed_spec_mp "take_take";
nipkow@2608
   681
nipkow@4935
   682
Goal "!xs. drop n (drop m xs) = drop (n + m) xs"; 
paulson@3457
   683
by (nat_ind_tac "m" 1);
paulson@3457
   684
 by (ALLGOALS Asm_simp_tac);
paulson@3457
   685
by (rtac allI 1);
paulson@3457
   686
by (exhaust_tac "xs" 1);
paulson@3457
   687
 by (ALLGOALS Asm_simp_tac);
nipkow@2608
   688
qed_spec_mp "drop_drop";
clasohm@923
   689
nipkow@4935
   690
Goal "!xs n. take n (drop m xs) = drop m (take (n + m) xs)"; 
paulson@3457
   691
by (nat_ind_tac "m" 1);
paulson@3457
   692
 by (ALLGOALS Asm_simp_tac);
paulson@3457
   693
by (rtac allI 1);
paulson@3457
   694
by (exhaust_tac "xs" 1);
paulson@3457
   695
 by (ALLGOALS Asm_simp_tac);
nipkow@2608
   696
qed_spec_mp "take_drop";
nipkow@2608
   697
nipkow@4935
   698
Goal "!xs. take n (map f xs) = map f (take n xs)"; 
paulson@3457
   699
by (nat_ind_tac "n" 1);
paulson@3457
   700
by (ALLGOALS Asm_simp_tac);
paulson@3457
   701
by (rtac allI 1);
paulson@3457
   702
by (exhaust_tac "xs" 1);
paulson@3457
   703
by (ALLGOALS Asm_simp_tac);
nipkow@2608
   704
qed_spec_mp "take_map"; 
nipkow@2608
   705
nipkow@4935
   706
Goal "!xs. drop n (map f xs) = map f (drop n xs)"; 
paulson@3457
   707
by (nat_ind_tac "n" 1);
paulson@3457
   708
by (ALLGOALS Asm_simp_tac);
paulson@3457
   709
by (rtac allI 1);
paulson@3457
   710
by (exhaust_tac "xs" 1);
paulson@3457
   711
by (ALLGOALS Asm_simp_tac);
nipkow@2608
   712
qed_spec_mp "drop_map";
nipkow@2608
   713
nipkow@4935
   714
Goal "!n i. i < n --> (take n xs)!i = xs!i";
paulson@3457
   715
by (induct_tac "xs" 1);
paulson@3457
   716
 by (ALLGOALS Asm_simp_tac);
paulson@3708
   717
by (Clarify_tac 1);
paulson@3457
   718
by (exhaust_tac "n" 1);
paulson@3457
   719
 by (Blast_tac 1);
paulson@3457
   720
by (exhaust_tac "i" 1);
paulson@3457
   721
by (ALLGOALS Asm_full_simp_tac);
nipkow@2608
   722
qed_spec_mp "nth_take";
nipkow@2608
   723
Addsimps [nth_take];
clasohm@923
   724
nipkow@4935
   725
Goal  "!xs i. n + i <= length xs --> (drop n xs)!i = xs!(n+i)";
paulson@3457
   726
by (nat_ind_tac "n" 1);
paulson@3457
   727
 by (ALLGOALS Asm_simp_tac);
paulson@3457
   728
by (rtac allI 1);
paulson@3457
   729
by (exhaust_tac "xs" 1);
paulson@3457
   730
 by (ALLGOALS Asm_simp_tac);
nipkow@2608
   731
qed_spec_mp "nth_drop";
nipkow@2608
   732
Addsimps [nth_drop];
nipkow@2608
   733
nipkow@2608
   734
(** takeWhile & dropWhile **)
nipkow@2608
   735
nipkow@3467
   736
section "takeWhile & dropWhile";
nipkow@3467
   737
nipkow@4935
   738
Goal "takeWhile P xs @ dropWhile P xs = xs";
nipkow@3586
   739
by (induct_tac "xs" 1);
nipkow@4686
   740
by (ALLGOALS Asm_full_simp_tac);
nipkow@3586
   741
qed "takeWhile_dropWhile_id";
nipkow@3586
   742
Addsimps [takeWhile_dropWhile_id];
nipkow@3586
   743
nipkow@4935
   744
Goal  "x:set xs & ~P(x) --> takeWhile P (xs @ ys) = takeWhile P xs";
paulson@3457
   745
by (induct_tac "xs" 1);
nipkow@4686
   746
by (ALLGOALS Asm_full_simp_tac);
paulson@3457
   747
by (Blast_tac 1);
nipkow@2608
   748
bind_thm("takeWhile_append1", conjI RS (result() RS mp));
nipkow@2608
   749
Addsimps [takeWhile_append1];
clasohm@923
   750
nipkow@4935
   751
Goal "(!x:set xs. P(x)) --> takeWhile P (xs @ ys) = xs @ takeWhile P ys";
paulson@3457
   752
by (induct_tac "xs" 1);
nipkow@4686
   753
by (ALLGOALS Asm_full_simp_tac);
nipkow@2608
   754
bind_thm("takeWhile_append2", ballI RS (result() RS mp));
nipkow@2608
   755
Addsimps [takeWhile_append2];
lcp@1169
   756
nipkow@4935
   757
Goal "x:set xs & ~P(x) --> dropWhile P (xs @ ys) = (dropWhile P xs)@ys";
paulson@3457
   758
by (induct_tac "xs" 1);
nipkow@4686
   759
by (ALLGOALS Asm_full_simp_tac);
paulson@3457
   760
by (Blast_tac 1);
nipkow@2608
   761
bind_thm("dropWhile_append1", conjI RS (result() RS mp));
nipkow@2608
   762
Addsimps [dropWhile_append1];
nipkow@2608
   763
nipkow@4935
   764
Goal "(!x:set xs. P(x)) --> dropWhile P (xs @ ys) = dropWhile P ys";
paulson@3457
   765
by (induct_tac "xs" 1);
nipkow@4686
   766
by (ALLGOALS Asm_full_simp_tac);
nipkow@2608
   767
bind_thm("dropWhile_append2", ballI RS (result() RS mp));
nipkow@2608
   768
Addsimps [dropWhile_append2];
nipkow@2608
   769
nipkow@4935
   770
Goal "x:set(takeWhile P xs) --> x:set xs & P x";
paulson@3457
   771
by (induct_tac "xs" 1);
nipkow@4686
   772
by (ALLGOALS Asm_full_simp_tac);
paulson@3647
   773
qed_spec_mp"set_take_whileD";
nipkow@2608
   774
oheimb@4132
   775
qed_goal "zip_Nil_Nil"   thy "zip []     []     = []" (K [Simp_tac 1]);
oheimb@4132
   776
qed_goal "zip_Cons_Cons" thy "zip (x#xs) (y#ys) = (x,y)#zip xs ys" 
oheimb@4132
   777
						      (K [Simp_tac 1]);
nipkow@4605
   778
nipkow@4605
   779
(** nodups & remdups **)
nipkow@4605
   780
section "nodups & remdups";
nipkow@4605
   781
nipkow@4935
   782
Goal "set(remdups xs) = set xs";
nipkow@4605
   783
by (induct_tac "xs" 1);
nipkow@4605
   784
 by (Simp_tac 1);
nipkow@4686
   785
by (asm_full_simp_tac (simpset() addsimps [insert_absorb]) 1);
nipkow@4605
   786
qed "set_remdups";
nipkow@4605
   787
Addsimps [set_remdups];
nipkow@4605
   788
nipkow@4935
   789
Goal "nodups(remdups xs)";
nipkow@4605
   790
by (induct_tac "xs" 1);
nipkow@4686
   791
by (ALLGOALS Asm_full_simp_tac);
nipkow@4605
   792
qed "nodups_remdups";
nipkow@4605
   793
nipkow@4935
   794
Goal "nodups xs --> nodups (filter P xs)";
nipkow@4605
   795
by (induct_tac "xs" 1);
nipkow@4686
   796
by (ALLGOALS Asm_full_simp_tac);
nipkow@4605
   797
qed_spec_mp "nodups_filter";
nipkow@4605
   798
nipkow@3589
   799
(** replicate **)
nipkow@3589
   800
section "replicate";
nipkow@3589
   801
nipkow@4935
   802
Goal "set(replicate (Suc n) x) = {x}";
wenzelm@4423
   803
by (induct_tac "n" 1);
wenzelm@4423
   804
by (ALLGOALS Asm_full_simp_tac);
nipkow@3589
   805
val lemma = result();
nipkow@3589
   806
nipkow@5043
   807
Goal "n ~= 0 ==> set(replicate n x) = {x}";
wenzelm@4423
   808
by (fast_tac (claset() addSDs [not0_implies_Suc] addSIs [lemma]) 1);
nipkow@3589
   809
qed "set_replicate";
nipkow@3589
   810
Addsimps [set_replicate];