author | nipkow |
Fri, 02 Dec 1994 16:13:34 +0100 | |
changeset 196 | 61620d959717 |
parent 171 | 16c4ea954511 |
child 199 | ad45e477926c |
permissions | -rw-r--r-- |
113 | 1 |
(* Title: HOL/List |
0 | 2 |
ID: $Id$ |
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
3 |
Author: Tobias Nipkow |
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
4 |
Copyright 1994 TU Muenchen |
0 | 5 |
|
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
6 |
List lemmas |
0 | 7 |
*) |
8 |
||
9 |
open List; |
|
10 |
||
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
11 |
val [Nil_not_Cons,Cons_not_Nil] = list.distinct; |
0 | 12 |
|
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
13 |
val Cons_neq_Nil = store_thm("Cons_neq_Nil", standard (Cons_not_Nil RS notE)); |
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
14 |
val Nil_neq_Cons = store_thm("Nil_neq_Cons", sym RS Cons_neq_Nil); |
0 | 15 |
|
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
16 |
val Cons_inject = |
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
17 |
store_thm("Cons_inject", standard ((hd list.inject) RS iffD1 RS conjE)); |
0 | 18 |
|
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
19 |
val list_ss = HOL_ss addsimps list.simps; |
0 | 20 |
|
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
21 |
goal List.thy "!x. xs ~= x#xs"; |
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
22 |
by (list.induct_tac "xs" 1); |
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
23 |
by (ALLGOALS (asm_simp_tac list_ss)); |
171 | 24 |
qed "not_Cons_self"; |
0 | 25 |
|
48
21291189b51e
changed "." to "$" and Cons to infix "#" to eliminate ambiguity
clasohm
parents:
44
diff
changeset
|
26 |
goal List.thy "(xs ~= []) = (? y ys. xs = y#ys)"; |
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
27 |
by (list.induct_tac "xs" 1); |
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
28 |
by(simp_tac list_ss 1); |
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
29 |
by(asm_simp_tac list_ss 1); |
40 | 30 |
by(REPEAT(resolve_tac [exI,refl,conjI] 1)); |
171 | 31 |
qed "neq_Nil_conv"; |
40 | 32 |
|
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
33 |
val list_ss = arith_ss addsimps list.simps @ |
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
34 |
[null_Nil, null_Cons, hd_Cons, tl_Cons, ttl_Nil, ttl_Cons, |
34 | 35 |
mem_Nil, mem_Cons, |
36 |
append_Nil, append_Cons, |
|
37 |
map_Nil, map_Cons, |
|
38 |
list_all_Nil, list_all_Cons, |
|
39 |
filter_Nil, filter_Cons]; |
|
40 |
||
0 | 41 |
|
13 | 42 |
(** @ - append **) |
43 |
||
44 |
goal List.thy "(xs@ys)@zs = xs@(ys@zs)"; |
|
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
45 |
by (list.induct_tac "xs" 1); |
34 | 46 |
by(ALLGOALS(asm_simp_tac list_ss)); |
171 | 47 |
qed "append_assoc"; |
0 | 48 |
|
40 | 49 |
goal List.thy "xs @ [] = xs"; |
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
50 |
by (list.induct_tac "xs" 1); |
40 | 51 |
by(ALLGOALS(asm_simp_tac list_ss)); |
171 | 52 |
qed "append_Nil2"; |
40 | 53 |
|
34 | 54 |
(** mem **) |
55 |
||
56 |
goal List.thy "x mem (xs@ys) = (x mem xs | x mem ys)"; |
|
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
57 |
by (list.induct_tac "xs" 1); |
34 | 58 |
by(ALLGOALS(asm_simp_tac (list_ss setloop (split_tac [expand_if])))); |
171 | 59 |
qed "mem_append"; |
34 | 60 |
|
61 |
goal List.thy "x mem [x:xs.P(x)] = (x mem xs & P(x))"; |
|
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
62 |
by (list.induct_tac "xs" 1); |
34 | 63 |
by(ALLGOALS(asm_simp_tac (list_ss setloop (split_tac [expand_if])))); |
171 | 64 |
qed "mem_filter"; |
34 | 65 |
|
66 |
(** list_all **) |
|
0 | 67 |
|
34 | 68 |
goal List.thy "(Alls x:xs.True) = True"; |
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
69 |
by (list.induct_tac "xs" 1); |
34 | 70 |
by(ALLGOALS(asm_simp_tac list_ss)); |
171 | 71 |
qed "list_all_True"; |
0 | 72 |
|
34 | 73 |
goal List.thy "list_all(p,xs@ys) = (list_all(p,xs) & list_all(p,ys))"; |
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
74 |
by (list.induct_tac "xs" 1); |
34 | 75 |
by(ALLGOALS(asm_simp_tac list_ss)); |
171 | 76 |
qed "list_all_conj"; |
34 | 77 |
|
78 |
goal List.thy "(Alls x:xs.P(x)) = (!x. x mem xs --> P(x))"; |
|
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
79 |
by (list.induct_tac "xs" 1); |
34 | 80 |
by(ALLGOALS(asm_simp_tac (list_ss setloop (split_tac [expand_if])))); |
81 |
by(fast_tac HOL_cs 1); |
|
171 | 82 |
qed "list_all_mem_conv"; |
34 | 83 |
|
84 |
||
40 | 85 |
(** list_case **) |
86 |
||
87 |
goal List.thy |
|
113 | 88 |
"P(list_case(a,f,xs)) = ((xs=[] --> P(a)) & \ |
48
21291189b51e
changed "." to "$" and Cons to infix "#" to eliminate ambiguity
clasohm
parents:
44
diff
changeset
|
89 |
\ (!y ys. xs=y#ys --> P(f(y,ys))))"; |
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
90 |
by (list.induct_tac "xs" 1); |
44 | 91 |
by(ALLGOALS(asm_simp_tac list_ss)); |
40 | 92 |
by(fast_tac HOL_cs 1); |
171 | 93 |
qed "expand_list_case"; |
40 | 94 |
|
0 | 95 |
|
96 |
(** Additional mapping lemmas **) |
|
97 |
||
98 |
goal List.thy "map(%x.x, xs) = xs"; |
|
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
99 |
by (list.induct_tac "xs" 1); |
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
100 |
by (ALLGOALS (asm_simp_tac list_ss)); |
171 | 101 |
qed "map_ident"; |
0 | 102 |
|
83 | 103 |
goal List.thy "map(f, xs@ys) = map(f,xs) @ map(f,ys)"; |
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
104 |
by (list.induct_tac "xs" 1); |
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
105 |
by (ALLGOALS (asm_simp_tac list_ss)); |
171 | 106 |
qed "map_append"; |
83 | 107 |
|
108 |
goalw List.thy [o_def] "map(f o g, xs) = map(f, map(g, xs))"; |
|
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
109 |
by (list.induct_tac "xs" 1); |
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
110 |
by (ALLGOALS (asm_simp_tac list_ss)); |
171 | 111 |
qed "map_compose"; |
83 | 112 |
|
34 | 113 |
val list_ss = list_ss addsimps |
196
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
114 |
[not_Cons_self, append_assoc, append_Nil2, mem_append, mem_filter, |
61620d959717
Moved the old List to ex and replaced it by one defined via
nipkow
parents:
171
diff
changeset
|
115 |
map_ident, map_append, map_compose, |
34 | 116 |
list_all_True, list_all_conj]; |
40 | 117 |