src/HOL/List.ML
author clasohm
Fri, 03 Mar 1995 12:02:25 +0100
changeset 923 ff1574a81019
child 962 136308504cd9
permissions -rw-r--r--
new version of HOL with curried function application
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,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    39
   filter_Nil, filter_Cons];
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    40
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
(** @ - append **)
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)@zs = xs@(ys@zs)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    45
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    46
by(ALLGOALS(asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    47
qed "append_assoc";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    48
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    49
goal List.thy "xs @ [] = xs";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    50
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    51
by(ALLGOALS(asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    52
qed "append_Nil2";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    53
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    54
goal List.thy "(xs@ys = []) = (xs=[] & ys=[])";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    55
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    56
by(ALLGOALS(asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    57
qed "append_is_Nil";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    58
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    59
goal List.thy "(xs @ ys = xs @ zs) = (ys=zs)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    60
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    61
by(ALLGOALS(asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    62
qed "same_append_eq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    63
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
(** mem **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    66
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    67
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
    68
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    69
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
    70
qed "mem_append";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    71
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    72
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
    73
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    74
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
    75
qed "mem_filter";
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
(** list_all **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    78
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    79
goal List.thy "(Alls x:xs.True) = True";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    80
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    81
by(ALLGOALS(asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    82
qed "list_all_True";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    83
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    84
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
    85
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    86
by(ALLGOALS(asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    87
qed "list_all_conj";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    88
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    89
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
    90
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    91
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
    92
by(fast_tac HOL_cs 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    93
qed "list_all_mem_conv";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    94
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
(** list_case **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    97
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    98
goal List.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    99
 "P(list_case a f xs) = ((xs=[] --> P(a)) & \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   100
\                         (!y ys. xs=y#ys --> P(f y ys)))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   101
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   102
by(ALLGOALS(asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   103
by(fast_tac HOL_cs 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   104
qed "expand_list_case";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   105
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   106
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
   107
by(list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   108
by(fast_tac HOL_cs 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
bind_thm("list_eq_cases",
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   111
  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
   112
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   113
(** flat **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   114
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   115
goal List.thy  "flat(xs@ys) = flat(xs)@flat(ys)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   116
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   117
by(ALLGOALS(asm_simp_tac (list_ss addsimps [append_assoc])));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   118
qed"flat_append";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   119
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   120
(** nth **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   121
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   122
val [nth_0,nth_Suc] = nat_recs nth_def; 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   123
store_thm("nth_0",nth_0);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   124
store_thm("nth_Suc",nth_Suc);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   125
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   126
(** Additional mapping lemmas **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   127
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   128
goal List.thy "map (%x.x) xs = xs";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   129
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   130
by (ALLGOALS (asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   131
qed "map_ident";
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 "map f (xs@ys) = map f xs @ map f ys";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   134
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   135
by (ALLGOALS (asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   136
qed "map_append";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   137
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   138
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
   139
by (list.induct_tac "xs" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   140
by (ALLGOALS (asm_simp_tac list_ss));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   141
qed "map_compose";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   142
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   143
val list_ss = list_ss addsimps
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   144
  [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
   145
   mem_append, mem_filter,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   146
   map_ident, map_append, map_compose,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   147
   flat_append, list_all_True, list_all_conj, nth_0, nth_Suc];
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   148