src/HOL/List.thy
changeset 15305 0bd9eedaa301
parent 15304 3514ca74ac54
child 15307 10dd989282fd
equal deleted inserted replaced
15304:3514ca74ac54 15305:0bd9eedaa301
   647 
   647 
   648 subsection {* @{text filter} *}
   648 subsection {* @{text filter} *}
   649 
   649 
   650 lemma filter_append [simp]: "filter P (xs @ ys) = filter P xs @ filter P ys"
   650 lemma filter_append [simp]: "filter P (xs @ ys) = filter P xs @ filter P ys"
   651 by (induct xs) auto
   651 by (induct xs) auto
       
   652 
       
   653 lemma rev_filter: "rev (filter P xs) = filter P (rev xs)"
       
   654 by (induct xs) simp_all
   652 
   655 
   653 lemma filter_filter [simp]: "filter P (filter Q xs) = filter (\<lambda>x. Q x \<and> P x) xs"
   656 lemma filter_filter [simp]: "filter P (filter Q xs) = filter (\<lambda>x. Q x \<and> P x) xs"
   654 by (induct xs) auto
   657 by (induct xs) auto
   655 
   658 
   656 lemma filter_True [simp]: "\<forall>x \<in> set xs. P x ==> filter P xs = xs"
   659 lemma filter_True [simp]: "\<forall>x \<in> set xs. P x ==> filter P xs = xs"
  1450 
  1453 
  1451 lemma distinct_append [simp]:
  1454 lemma distinct_append [simp]:
  1452 "distinct (xs @ ys) = (distinct xs \<and> distinct ys \<and> set xs \<inter> set ys = {})"
  1455 "distinct (xs @ ys) = (distinct xs \<and> distinct ys \<and> set xs \<inter> set ys = {})"
  1453 by (induct xs) auto
  1456 by (induct xs) auto
  1454 
  1457 
       
  1458 lemma distinct_rev[simp]: "distinct(rev xs) = distinct xs"
       
  1459 by(induct xs) auto
       
  1460 
  1455 lemma set_remdups [simp]: "set (remdups xs) = set xs"
  1461 lemma set_remdups [simp]: "set (remdups xs) = set xs"
  1456 by (induct xs) (auto simp add: insert_absorb)
  1462 by (induct xs) (auto simp add: insert_absorb)
  1457 
  1463 
  1458 lemma distinct_remdups [iff]: "distinct (remdups xs)"
  1464 lemma distinct_remdups [iff]: "distinct (remdups xs)"
  1459 by (induct xs) auto
  1465 by (induct xs) auto