src/HOL/List.ML
changeset 8115 c802042066e8
parent 8064 357652a08ee0
child 8118 746c5cf09bde
equal deleted inserted replaced
8114:09a7a180cc99 8115:c802042066e8
   991  by (Auto_tac);
   991  by (Auto_tac);
   992 by (asm_full_simp_tac (simpset() addsimps [zip_append]) 1);
   992 by (asm_full_simp_tac (simpset() addsimps [zip_append]) 1);
   993 qed_spec_mp "zip_rev";
   993 qed_spec_mp "zip_rev";
   994 
   994 
   995 Goal
   995 Goal
       
   996  "!ys. set(zip xs ys) = {(xs!i,ys!i) |i. i < min (length xs) (length ys)}";
       
   997 by(induct_tac "xs" 1);
       
   998  by (Simp_tac 1);
       
   999 br allI 1;
       
  1000 by(exhaust_tac "ys" 1);
       
  1001  by(Asm_simp_tac 1);
       
  1002 by(auto_tac (claset(),
       
  1003            simpset() addsimps [nth_Cons,gr0_conv_Suc] addsplits [nat.split]));
       
  1004 qed_spec_mp "set_zip";
       
  1005 
       
  1006 Goal
   996 "!i xs. i < length xs --> i < length ys --> (zip xs ys)!i = (xs!i, ys!i)";
  1007 "!i xs. i < length xs --> i < length ys --> (zip xs ys)!i = (xs!i, ys!i)";
   997 by (induct_tac "ys" 1);
  1008 by (induct_tac "ys" 1);
   998  by (Simp_tac 1);
  1009  by (Simp_tac 1);
   999 by (Clarify_tac 1);
  1010 by (Clarify_tac 1);
  1000 by (exhaust_tac "xs" 1);
  1011 by (exhaust_tac "xs" 1);
  1015 by (exhaust_tac "j" 1);
  1026 by (exhaust_tac "j" 1);
  1016  by (Auto_tac);
  1027  by (Auto_tac);
  1017 qed "zip_replicate";
  1028 qed "zip_replicate";
  1018 Addsimps [zip_replicate];
  1029 Addsimps [zip_replicate];
  1019 
  1030 
       
  1031 (** list_all2 **)
       
  1032 section "list_all2";
       
  1033 
       
  1034 Goalw [list_all2_def] "list_all2 P xs ys ==> length xs = length ys";
       
  1035 by(Asm_simp_tac 1);
       
  1036 qed "list_all2_lengthD";
       
  1037 
       
  1038 Goalw [list_all2_def] "list_all2 P [] ys = (ys=[])";
       
  1039 by (Simp_tac 1);
       
  1040 qed "list_all2_Nil";
       
  1041 AddIffs [list_all2_Nil];
       
  1042 
       
  1043 Goalw [list_all2_def] "list_all2 P xs [] = (xs=[])";
       
  1044 by (Simp_tac 1);
       
  1045 qed "list_all2_Nil2";
       
  1046 AddIffs [list_all2_Nil2];
       
  1047 
       
  1048 Goalw [list_all2_def]
       
  1049  "list_all2 P (x#xs) (y#ys) = (P x y & list_all2 P xs ys)";
       
  1050 by (Auto_tac);
       
  1051 qed "list_all2_Cons";
       
  1052 AddIffs[list_all2_Cons];
       
  1053 
       
  1054 Goalw [list_all2_def]
       
  1055   "list_all2 P xs ys = \
       
  1056 \  (length xs = length ys & (!i<length xs. P (xs!i) (ys!i)))";
       
  1057 by(force_tac (claset(), simpset() addsimps [set_zip]) 1);
       
  1058 qed "list_all2_conv_all_nth";
  1020 
  1059 
  1021 (** foldl **)
  1060 (** foldl **)
  1022 section "foldl";
  1061 section "foldl";
  1023 
  1062 
  1024 Goal "!a. foldl f a (xs @ ys) = foldl f (foldl f a xs) ys";
  1063 Goal "!a. foldl f a (xs @ ys) = foldl f (foldl f a xs) ys";