src/HOL/List.ML
author nipkow
Fri, 17 Jan 1997 10:09:46 +0100
changeset 2512 0231e4f467f2
parent 1985 84cf16192e03
child 2608 450c9b682a92
permissions -rw-r--r--
Got rid of Alls in List. Added Ball_insert and Ball_Un in equalities.ML.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1419
diff changeset
     1
(*  Title:      HOL/List
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1419
diff changeset
     3
    Author:     Tobias Nipkow
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1994 TU Muenchen
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     5
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     6
List lemmas
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     7
*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     8
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     9
open List;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    10
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1936
diff changeset
    11
AddIffs list.distinct;
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1936
diff changeset
    12
AddIffs list.inject;
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    13
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    14
bind_thm("Cons_inject", (hd list.inject) RS iffD1 RS conjE);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    15
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    16
goal List.thy "!x. xs ~= x#xs";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    17
by (list.induct_tac "xs" 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1202
diff changeset
    18
by (ALLGOALS Asm_simp_tac);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    19
qed "not_Cons_self";
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
    20
Addsimps [not_Cons_self];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    21
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    22
goal List.thy "(xs ~= []) = (? y ys. xs = y#ys)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    23
by (list.induct_tac "xs" 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1202
diff changeset
    24
by (Simp_tac 1);
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1202
diff changeset
    25
by (Asm_simp_tac 1);
1169
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
    26
by (REPEAT(resolve_tac [exI,refl,conjI] 1));
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    27
qed "neq_Nil_conv";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    28
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    29
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    30
(** @ - append **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    31
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    32
goal List.thy "(xs@ys)@zs = xs@(ys@zs)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    33
by (list.induct_tac "xs" 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1202
diff changeset
    34
by (ALLGOALS Asm_simp_tac);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    35
qed "append_assoc";
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
    36
Addsimps [append_assoc];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    37
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    38
goal List.thy "xs @ [] = xs";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    39
by (list.induct_tac "xs" 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1202
diff changeset
    40
by (ALLGOALS Asm_simp_tac);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    41
qed "append_Nil2";
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
    42
Addsimps [append_Nil2];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    43
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    44
goal List.thy "(xs@ys = []) = (xs=[] & ys=[])";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    45
by (list.induct_tac "xs" 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1202
diff changeset
    46
by (ALLGOALS Asm_simp_tac);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    47
qed "append_is_Nil";
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
    48
Addsimps [append_is_Nil];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    49
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    50
goal List.thy "(xs @ ys = xs @ zs) = (ys=zs)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    51
by (list.induct_tac "xs" 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1202
diff changeset
    52
by (ALLGOALS Asm_simp_tac);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    53
qed "same_append_eq";
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
    54
Addsimps [same_append_eq];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    55
1327
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
    56
goal List.thy "hd(xs@ys) = (if xs=[] then hd ys else hd xs)";
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
    57
by (list.induct_tac "xs" 1);
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
    58
by (ALLGOALS Asm_simp_tac);
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
    59
qed "hd_append";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    60
1169
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
    61
(** rev **)
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
    62
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
    63
goal List.thy "rev(xs@ys) = rev(ys) @ rev(xs)";
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
    64
by (list.induct_tac "xs" 1);
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
    65
by (ALLGOALS Asm_simp_tac);
1169
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
    66
qed "rev_append";
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
    67
Addsimps[rev_append];
1169
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
    68
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
    69
goal List.thy "rev(rev l) = l";
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
    70
by (list.induct_tac "l" 1);
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
    71
by (ALLGOALS Asm_simp_tac);
1169
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
    72
qed "rev_rev_ident";
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
    73
Addsimps[rev_rev_ident];
1169
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
    74
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    75
(** mem **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    76
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    77
goal List.thy "x mem (xs@ys) = (x mem xs | x mem ys)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    78
by (list.induct_tac "xs" 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1202
diff changeset
    79
by (ALLGOALS (asm_simp_tac (!simpset setloop (split_tac [expand_if]))));
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    80
qed "mem_append";
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
    81
Addsimps[mem_append];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    82
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    83
goal List.thy "x mem [x:xs.P(x)] = (x mem xs & P(x))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    84
by (list.induct_tac "xs" 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1202
diff changeset
    85
by (ALLGOALS (asm_simp_tac (!simpset setloop (split_tac [expand_if]))));
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    86
qed "mem_filter";
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
    87
Addsimps[mem_filter];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    88
1908
55d8e38262a8 Renamed setOfList to set_of_list
paulson
parents: 1812
diff changeset
    89
(** set_of_list **)
1812
debfc40b7756 Addition of setOfList
paulson
parents: 1760
diff changeset
    90
1908
55d8e38262a8 Renamed setOfList to set_of_list
paulson
parents: 1812
diff changeset
    91
goal thy "set_of_list (xs@ys) = (set_of_list xs Un set_of_list ys)";
1812
debfc40b7756 Addition of setOfList
paulson
parents: 1760
diff changeset
    92
by (list.induct_tac "xs" 1);
debfc40b7756 Addition of setOfList
paulson
parents: 1760
diff changeset
    93
by (ALLGOALS Asm_simp_tac);
debfc40b7756 Addition of setOfList
paulson
parents: 1760
diff changeset
    94
by (Fast_tac 1);
1908
55d8e38262a8 Renamed setOfList to set_of_list
paulson
parents: 1812
diff changeset
    95
qed "set_of_list_append";
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
    96
Addsimps[set_of_list_append];
1812
debfc40b7756 Addition of setOfList
paulson
parents: 1760
diff changeset
    97
1908
55d8e38262a8 Renamed setOfList to set_of_list
paulson
parents: 1812
diff changeset
    98
goal thy "(x mem xs) = (x: set_of_list xs)";
1812
debfc40b7756 Addition of setOfList
paulson
parents: 1760
diff changeset
    99
by (list.induct_tac "xs" 1);
debfc40b7756 Addition of setOfList
paulson
parents: 1760
diff changeset
   100
by (ALLGOALS (asm_simp_tac (!simpset setloop (split_tac [expand_if]))));
debfc40b7756 Addition of setOfList
paulson
parents: 1760
diff changeset
   101
by (Fast_tac 1);
1908
55d8e38262a8 Renamed setOfList to set_of_list
paulson
parents: 1812
diff changeset
   102
qed "set_of_list_mem_eq";
1812
debfc40b7756 Addition of setOfList
paulson
parents: 1760
diff changeset
   103
1936
979e8b4f5fa5 Proved set_of_list_subset_Cons
paulson
parents: 1908
diff changeset
   104
goal List.thy "set_of_list l <= set_of_list (x#l)";
979e8b4f5fa5 Proved set_of_list_subset_Cons
paulson
parents: 1908
diff changeset
   105
by (Simp_tac 1);
979e8b4f5fa5 Proved set_of_list_subset_Cons
paulson
parents: 1908
diff changeset
   106
by (Fast_tac 1);
979e8b4f5fa5 Proved set_of_list_subset_Cons
paulson
parents: 1908
diff changeset
   107
qed "set_of_list_subset_Cons";
979e8b4f5fa5 Proved set_of_list_subset_Cons
paulson
parents: 1908
diff changeset
   108
1812
debfc40b7756 Addition of setOfList
paulson
parents: 1760
diff changeset
   109
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   110
(** list_all **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   111
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
   112
goal List.thy "list_all (%x.True) xs = True";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   113
by (list.induct_tac "xs" 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1202
diff changeset
   114
by (ALLGOALS Asm_simp_tac);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   115
qed "list_all_True";
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
   116
Addsimps [list_all_True];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   117
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   118
goal List.thy "list_all p (xs@ys) = (list_all p xs & list_all p ys)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   119
by (list.induct_tac "xs" 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1202
diff changeset
   120
by (ALLGOALS Asm_simp_tac);
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
   121
qed "list_all_append";
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
   122
Addsimps [list_all_append];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   123
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
   124
goal List.thy "list_all P xs = (!x. x mem xs --> P(x))";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   125
by (list.induct_tac "xs" 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1202
diff changeset
   126
by (ALLGOALS (asm_simp_tac (!simpset setloop (split_tac [expand_if]))));
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1552
diff changeset
   127
by (Fast_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   128
qed "list_all_mem_conv";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   129
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   130
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   131
(** list_case **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   132
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   133
goal List.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   134
 "P(list_case a f xs) = ((xs=[] --> P(a)) & \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   135
\                         (!y ys. xs=y#ys --> P(f y ys)))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   136
by (list.induct_tac "xs" 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1202
diff changeset
   137
by (ALLGOALS Asm_simp_tac);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1552
diff changeset
   138
by (Fast_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   139
qed "expand_list_case";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   140
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
   141
val prems = goal List.thy "[| P([]); !!x xs. P(x#xs) |] ==> P(xs)";
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
   142
by(list.induct_tac "xs" 1);
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
   143
by(REPEAT(resolve_tac prems 1));
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
   144
qed "list_cases";
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
   145
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   146
goal List.thy  "(xs=[] --> P([])) & (!y ys. xs=y#ys --> P(y#ys)) --> P(xs)";
1169
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
   147
by (list.induct_tac "xs" 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1552
diff changeset
   148
by (Fast_tac 1);
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1552
diff changeset
   149
by (Fast_tac 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   150
bind_thm("list_eq_cases",
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   151
  impI RSN (2,allI RSN (2,allI RSN (2,impI RS (conjI RS (result() RS mp))))));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   152
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   153
(** flat **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   154
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   155
goal List.thy  "flat(xs@ys) = flat(xs)@flat(ys)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   156
by (list.induct_tac "xs" 1);
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
   157
by (ALLGOALS Asm_simp_tac);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   158
qed"flat_append";
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
   159
Addsimps [flat_append];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   160
962
136308504cd9 Added a few thms to nat_ss and list_ss
nipkow
parents: 923
diff changeset
   161
(** length **)
136308504cd9 Added a few thms to nat_ss and list_ss
nipkow
parents: 923
diff changeset
   162
136308504cd9 Added a few thms to nat_ss and list_ss
nipkow
parents: 923
diff changeset
   163
goal List.thy "length(xs@ys) = length(xs)+length(ys)";
136308504cd9 Added a few thms to nat_ss and list_ss
nipkow
parents: 923
diff changeset
   164
by (list.induct_tac "xs" 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1202
diff changeset
   165
by (ALLGOALS Asm_simp_tac);
962
136308504cd9 Added a few thms to nat_ss and list_ss
nipkow
parents: 923
diff changeset
   166
qed"length_append";
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   167
Addsimps [length_append];
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   168
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   169
goal List.thy "length (map f l) = length l";
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   170
by (list.induct_tac "l" 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   171
by (ALLGOALS Simp_tac);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   172
qed "length_map";
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   173
Addsimps [length_map];
962
136308504cd9 Added a few thms to nat_ss and list_ss
nipkow
parents: 923
diff changeset
   174
1169
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
   175
goal List.thy "length(rev xs) = length(xs)";
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
   176
by (list.induct_tac "xs" 1);
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   177
by (ALLGOALS Asm_simp_tac);
1169
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
   178
qed "length_rev";
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   179
Addsimps [length_rev];
1169
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
   180
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   181
(** nth **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   182
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   183
val [nth_0,nth_Suc] = nat_recs nth_def; 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   184
store_thm("nth_0",nth_0);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   185
store_thm("nth_Suc",nth_Suc);
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   186
Addsimps [nth_0,nth_Suc];
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   187
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   188
goal List.thy "!n. n < length xs --> nth n (map f xs) = f (nth n xs)";
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   189
by (list.induct_tac "xs" 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   190
(* case [] *)
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   191
by (Asm_full_simp_tac 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   192
(* case x#xl *)
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   193
by (rtac allI 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   194
by (nat_ind_tac "n" 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   195
by (ALLGOALS Asm_full_simp_tac);
1485
240cc98b94a7 Added qed_spec_mp to avoid renaming of bound vars in 'th RS spec'
nipkow
parents: 1465
diff changeset
   196
qed_spec_mp "nth_map";
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   197
Addsimps [nth_map];
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   198
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   199
goal List.thy "!n. n < length xs --> list_all P xs --> P(nth n xs)";
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   200
by (list.induct_tac "xs" 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   201
(* case [] *)
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   202
by (Simp_tac 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   203
(* case x#xl *)
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   204
by (rtac allI 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   205
by (nat_ind_tac "n" 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   206
by (ALLGOALS Asm_full_simp_tac);
1485
240cc98b94a7 Added qed_spec_mp to avoid renaming of bound vars in 'th RS spec'
nipkow
parents: 1465
diff changeset
   207
qed_spec_mp "list_all_nth";
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   208
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   209
goal List.thy "!n. n < length xs --> (nth n xs) mem xs";
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   210
by (list.induct_tac "xs" 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   211
(* case [] *)
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   212
by (Simp_tac 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   213
(* case x#xl *)
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   214
by (rtac allI 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   215
by (nat_ind_tac "n" 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   216
(* case 0 *)
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   217
by (Asm_full_simp_tac 1);
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   218
(* case Suc x *)
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   219
by (asm_full_simp_tac (!simpset setloop (split_tac [expand_if])) 1);
1485
240cc98b94a7 Added qed_spec_mp to avoid renaming of bound vars in 'th RS spec'
nipkow
parents: 1465
diff changeset
   220
qed_spec_mp "nth_mem";
1301
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   221
Addsimps [nth_mem];
42782316d510 Added various thms and tactics.
nipkow
parents: 1264
diff changeset
   222
1327
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
   223
(** drop **)
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
   224
1419
a6a034a47a71 defined take/drop by induction over list rather than nat.
nipkow
parents: 1327
diff changeset
   225
goal thy "drop 0 xs = xs";
a6a034a47a71 defined take/drop by induction over list rather than nat.
nipkow
parents: 1327
diff changeset
   226
by (list.induct_tac "xs" 1);
a6a034a47a71 defined take/drop by induction over list rather than nat.
nipkow
parents: 1327
diff changeset
   227
by (ALLGOALS Asm_simp_tac);
1327
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
   228
qed "drop_0";
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
   229
1419
a6a034a47a71 defined take/drop by induction over list rather than nat.
nipkow
parents: 1327
diff changeset
   230
goal thy "drop (Suc n) (x#xs) = drop n xs";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1485
diff changeset
   231
by (Simp_tac 1);
1419
a6a034a47a71 defined take/drop by induction over list rather than nat.
nipkow
parents: 1327
diff changeset
   232
qed "drop_Suc_Cons";
1327
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
   233
1419
a6a034a47a71 defined take/drop by induction over list rather than nat.
nipkow
parents: 1327
diff changeset
   234
Delsimps [drop_Cons];
a6a034a47a71 defined take/drop by induction over list rather than nat.
nipkow
parents: 1327
diff changeset
   235
Addsimps [drop_0,drop_Suc_Cons];
1327
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
   236
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
   237
(** take **)
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
   238
1419
a6a034a47a71 defined take/drop by induction over list rather than nat.
nipkow
parents: 1327
diff changeset
   239
goal thy "take 0 xs = []";
a6a034a47a71 defined take/drop by induction over list rather than nat.
nipkow
parents: 1327
diff changeset
   240
by (list.induct_tac "xs" 1);
a6a034a47a71 defined take/drop by induction over list rather than nat.
nipkow
parents: 1327
diff changeset
   241
by (ALLGOALS Asm_simp_tac);
1327
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
   242
qed "take_0";
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
   243
1419
a6a034a47a71 defined take/drop by induction over list rather than nat.
nipkow
parents: 1327
diff changeset
   244
goal thy "take (Suc n) (x#xs) = x # take n xs";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1485
diff changeset
   245
by (Simp_tac 1);
1419
a6a034a47a71 defined take/drop by induction over list rather than nat.
nipkow
parents: 1327
diff changeset
   246
qed "take_Suc_Cons";
1327
6c29cfab679c added new arithmetic lemmas and the functions take and drop.
nipkow
parents: 1301
diff changeset
   247
1419
a6a034a47a71 defined take/drop by induction over list rather than nat.
nipkow
parents: 1327
diff changeset
   248
Delsimps [take_Cons];
a6a034a47a71 defined take/drop by induction over list rather than nat.
nipkow
parents: 1327
diff changeset
   249
Addsimps [take_0,take_Suc_Cons];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   250
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   251
(** Additional mapping lemmas **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   252
995
95c148a7b9c4 generalized map (%x.x) xs = xs to map (%x.x) = (%xs.xs)
nipkow
parents: 974
diff changeset
   253
goal List.thy "map (%x.x) = (%xs.xs)";
95c148a7b9c4 generalized map (%x.x) xs = xs to map (%x.x) = (%xs.xs)
nipkow
parents: 974
diff changeset
   254
by (rtac ext 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   255
by (list.induct_tac "xs" 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1202
diff changeset
   256
by (ALLGOALS Asm_simp_tac);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   257
qed "map_ident";
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
   258
Addsimps[map_ident];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   259
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   260
goal List.thy "map f (xs@ys) = map f xs @ map f ys";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   261
by (list.induct_tac "xs" 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1202
diff changeset
   262
by (ALLGOALS Asm_simp_tac);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   263
qed "map_append";
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
   264
Addsimps[map_append];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   265
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   266
goalw List.thy [o_def] "map (f o g) xs = map f (map g xs)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   267
by (list.induct_tac "xs" 1);
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1202
diff changeset
   268
by (ALLGOALS Asm_simp_tac);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   269
qed "map_compose";
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
   270
Addsimps[map_compose];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   271
1169
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
   272
goal List.thy "rev(map f l) = map f (rev l)";
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
   273
by (list.induct_tac "l" 1);
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
   274
by (ALLGOALS Asm_simp_tac);
1169
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
   275
qed "rev_map_distrib";
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
   276
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
   277
goal List.thy "rev(flat ls) = flat (map rev (rev ls))";
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
   278
by (list.induct_tac "ls" 1);
2512
0231e4f467f2 Got rid of Alls in List.
nipkow
parents: 1985
diff changeset
   279
by (ALLGOALS Asm_simp_tac);
1169
5873833cf37f Added function rev and its properties length_rev, etc.
lcp
parents: 995
diff changeset
   280
qed "rev_flat";