src/HOL/List.ML
author nipkow
Fri, 17 Mar 1995 15:49:37 +0100
changeset 962 136308504cd9
parent 923 ff1574a81019
child 974 68d58134fad6
permissions -rw-r--r--
Added a few thms to nat_ss and list_ss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     1
(*  Title: 	HOL/List
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     3
    Author: 	Tobias Nipkow
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
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    11
val [Nil_not_Cons,Cons_not_Nil] = list.distinct;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    12
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    13
bind_thm("Cons_neq_Nil", Cons_not_Nil RS notE);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    14
bind_thm("Nil_neq_Cons", sym RS Cons_neq_Nil);
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
bind_thm("Cons_inject", (hd list.inject) RS iffD1 RS conjE);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    17
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    18
val list_ss = HOL_ss addsimps list.simps;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    19
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    20
goal List.thy "!x. xs ~= x#xs";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    21
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    22
by (ALLGOALS (asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    23
qed "not_Cons_self";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    24
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    25
goal List.thy "(xs ~= []) = (? y ys. xs = y#ys)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    26
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    27
by(simp_tac list_ss 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    28
by(asm_simp_tac list_ss 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    29
by(REPEAT(resolve_tac [exI,refl,conjI] 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    30
qed "neq_Nil_conv";
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
val list_ss = arith_ss addsimps list.simps @
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    33
  [null_Nil, null_Cons, hd_Cons, tl_Cons, ttl_Nil, ttl_Cons,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    34
   mem_Nil, mem_Cons,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    35
   append_Nil, append_Cons,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    36
   map_Nil, map_Cons,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    37
   flat_Nil, flat_Cons,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    38
   list_all_Nil, list_all_Cons,
962
136308504cd9 Added a few thms to nat_ss and list_ss
nipkow
parents: 923
diff changeset
    39
   filter_Nil, filter_Cons,
136308504cd9 Added a few thms to nat_ss and list_ss
nipkow
parents: 923
diff changeset
    40
   length_Nil, length_Cons];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    41
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    42
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    43
(** @ - append **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    44
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    45
goal List.thy "(xs@ys)@zs = xs@(ys@zs)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    46
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    47
by(ALLGOALS(asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    48
qed "append_assoc";
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 @ [] = xs";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    51
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    52
by(ALLGOALS(asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    53
qed "append_Nil2";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    54
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    55
goal List.thy "(xs@ys = []) = (xs=[] & ys=[])";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    56
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    57
by(ALLGOALS(asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    58
qed "append_is_Nil";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    59
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    60
goal List.thy "(xs @ ys = xs @ zs) = (ys=zs)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    61
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    62
by(ALLGOALS(asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    63
qed "same_append_eq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    64
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    65
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    66
(** mem **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    67
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    68
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
    69
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    70
by(ALLGOALS(asm_simp_tac (list_ss setloop (split_tac [expand_if]))));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    71
qed "mem_append";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    72
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    73
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
    74
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    75
by(ALLGOALS(asm_simp_tac (list_ss setloop (split_tac [expand_if]))));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    76
qed "mem_filter";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    77
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    78
(** list_all **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    79
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    80
goal List.thy "(Alls x:xs.True) = True";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    81
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    82
by(ALLGOALS(asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    83
qed "list_all_True";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    84
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    85
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
    86
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    87
by(ALLGOALS(asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    88
qed "list_all_conj";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    89
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    90
goal List.thy "(Alls x:xs.P(x)) = (!x. x mem xs --> P(x))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    91
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    92
by(ALLGOALS(asm_simp_tac (list_ss setloop (split_tac [expand_if]))));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    93
by(fast_tac HOL_cs 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    94
qed "list_all_mem_conv";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    95
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    96
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    97
(** list_case **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    98
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    99
goal List.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   100
 "P(list_case a f xs) = ((xs=[] --> P(a)) & \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   101
\                         (!y ys. xs=y#ys --> P(f y ys)))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   102
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   103
by(ALLGOALS(asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   104
by(fast_tac HOL_cs 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   105
qed "expand_list_case";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   106
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   107
goal List.thy  "(xs=[] --> P([])) & (!y ys. xs=y#ys --> P(y#ys)) --> P(xs)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   108
by(list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   109
by(fast_tac HOL_cs 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   110
by(fast_tac HOL_cs 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   111
bind_thm("list_eq_cases",
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   112
  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
   113
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   114
(** flat **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   115
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   116
goal List.thy  "flat(xs@ys) = flat(xs)@flat(ys)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   117
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   118
by(ALLGOALS(asm_simp_tac (list_ss addsimps [append_assoc])));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   119
qed"flat_append";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   120
962
136308504cd9 Added a few thms to nat_ss and list_ss
nipkow
parents: 923
diff changeset
   121
(** length **)
136308504cd9 Added a few thms to nat_ss and list_ss
nipkow
parents: 923
diff changeset
   122
136308504cd9 Added a few thms to nat_ss and list_ss
nipkow
parents: 923
diff changeset
   123
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
   124
by (list.induct_tac "xs" 1);
136308504cd9 Added a few thms to nat_ss and list_ss
nipkow
parents: 923
diff changeset
   125
by(ALLGOALS(asm_simp_tac list_ss));
136308504cd9 Added a few thms to nat_ss and list_ss
nipkow
parents: 923
diff changeset
   126
qed"length_append";
136308504cd9 Added a few thms to nat_ss and list_ss
nipkow
parents: 923
diff changeset
   127
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   128
(** nth **)
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
val [nth_0,nth_Suc] = nat_recs nth_def; 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   131
store_thm("nth_0",nth_0);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   132
store_thm("nth_Suc",nth_Suc);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   133
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   134
(** Additional mapping lemmas **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   135
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   136
goal List.thy "map (%x.x) xs = xs";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   137
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   138
by (ALLGOALS (asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   139
qed "map_ident";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   140
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   141
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
   142
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   143
by (ALLGOALS (asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   144
qed "map_append";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   145
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   146
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
   147
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   148
by (ALLGOALS (asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   149
qed "map_compose";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   150
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   151
val list_ss = list_ss addsimps
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   152
  [not_Cons_self, append_assoc, append_Nil2, append_is_Nil, same_append_eq,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   153
   mem_append, mem_filter,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   154
   map_ident, map_append, map_compose,
962
136308504cd9 Added a few thms to nat_ss and list_ss
nipkow
parents: 923
diff changeset
   155
   flat_append, length_append, list_all_True, list_all_conj, nth_0, nth_Suc];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   156