src/HOL/List.thy
changeset 71593 71579bd59cd4
parent 71585 4b1021677f15
child 71766 1249b998e377
equal deleted inserted replaced
71592:0c6d29145881 71593:71579bd59cd4
  3548      \<And> ys. ys \<in> set xs \<Longrightarrow> distinct ys;
  3548      \<And> ys. ys \<in> set xs \<Longrightarrow> distinct ys;
  3549      \<And> ys zs. \<lbrakk> ys \<in> set xs ; zs \<in> set xs ; ys \<noteq> zs \<rbrakk> \<Longrightarrow> set ys \<inter> set zs = {}
  3549      \<And> ys zs. \<lbrakk> ys \<in> set xs ; zs \<in> set xs ; ys \<noteq> zs \<rbrakk> \<Longrightarrow> set ys \<inter> set zs = {}
  3550    \<rbrakk> \<Longrightarrow> distinct (concat xs)"
  3550    \<rbrakk> \<Longrightarrow> distinct (concat xs)"
  3551 by (induct xs) auto
  3551 by (induct xs) auto
  3552 
  3552 
  3553 text \<open>It is best to avoid this indexed version of distinct, but
  3553 text \<open>An iff-version of @{thm distinct_concat} is available further down as \<open>distinct_concat_iff\<close>.\<close>
  3554 sometimes it is useful.\<close>
  3554 
       
  3555 text \<open>It is best to avoid the following indexed version of distinct, but sometimes it is useful.\<close>
  3555 
  3556 
  3556 lemma distinct_conv_nth: "distinct xs = (\<forall>i < size xs. \<forall>j < size xs. i \<noteq> j \<longrightarrow> xs!i \<noteq> xs!j)"
  3557 lemma distinct_conv_nth: "distinct xs = (\<forall>i < size xs. \<forall>j < size xs. i \<noteq> j \<longrightarrow> xs!i \<noteq> xs!j)"
  3557 proof (induct xs)
  3558 proof (induct xs)
  3558   case (Cons x xs)
  3559   case (Cons x xs)
  3559   show ?case
  3560   show ?case
  4176   by (simp add: removeAll_filter_not_eq)
  4177   by (simp add: removeAll_filter_not_eq)
  4177 
  4178 
  4178 lemma length_removeAll_less [termination_simp]:
  4179 lemma length_removeAll_less [termination_simp]:
  4179   "x \<in> set xs \<Longrightarrow> length (removeAll x xs) < length xs"
  4180   "x \<in> set xs \<Longrightarrow> length (removeAll x xs) < length xs"
  4180   by (auto dest: length_filter_less simp add: removeAll_filter_not_eq)
  4181   by (auto dest: length_filter_less simp add: removeAll_filter_not_eq)
       
  4182 
       
  4183 lemma distinct_concat_iff: "distinct (concat xs) \<longleftrightarrow>
       
  4184   distinct (removeAll [] xs) \<and> 
       
  4185   (\<forall>ys. ys \<in> set xs \<longrightarrow> distinct ys) \<and>
       
  4186   (\<forall>ys zs. ys \<in> set xs \<and> zs \<in> set xs \<and> ys \<noteq> zs \<longrightarrow> set ys \<inter> set zs = {})"
       
  4187 apply (induct xs)
       
  4188  apply(simp_all, safe, auto)
       
  4189 by (metis Int_iff UN_I empty_iff equals0I set_empty)
  4181 
  4190 
  4182 
  4191 
  4183 subsubsection \<open>\<^const>\<open>replicate\<close>\<close>
  4192 subsubsection \<open>\<^const>\<open>replicate\<close>\<close>
  4184 
  4193 
  4185 lemma length_replicate [simp]: "length (replicate n x) = n"
  4194 lemma length_replicate [simp]: "length (replicate n x) = n"