src/HOL/List.thy
changeset 70183 3ea80c950023
parent 69850 5f993636ac07
child 70226 accbd801fefa
equal deleted inserted replaced
70182:ca9dfa7ee3bd 70183:3ea80c950023
  1993   "\<exists>ss xs' ys'. xs = xs' @ ss \<and> ys = ys' @ ss
  1993   "\<exists>ss xs' ys'. xs = xs' @ ss \<and> ys = ys' @ ss
  1994        \<and> (xs' = [] \<or> ys' = [] \<or> last xs' \<noteq> last ys')"
  1994        \<and> (xs' = [] \<or> ys' = [] \<or> last xs' \<noteq> last ys')"
  1995   using longest_common_prefix[of "rev xs" "rev ys"]
  1995   using longest_common_prefix[of "rev xs" "rev ys"]
  1996   unfolding rev_swap rev_append by (metis last_rev rev_is_Nil_conv)
  1996   unfolding rev_swap rev_append by (metis last_rev rev_is_Nil_conv)
  1997 
  1997 
       
  1998 lemma butlast_rev [simp]: "butlast (rev xs) = rev (tl xs)"
       
  1999   by (cases xs) simp_all
       
  2000 
  1998 
  2001 
  1999 subsubsection \<open>\<^const>\<open>take\<close> and \<^const>\<open>drop\<close>\<close>
  2002 subsubsection \<open>\<^const>\<open>take\<close> and \<^const>\<open>drop\<close>\<close>
  2000 
  2003 
  2001 lemma take_0: "take 0 xs = []"
  2004 lemma take_0: "take 0 xs = []"
  2002   by (induct xs) auto
  2005   by (induct xs) auto
  3148   by (induct j) (auto simp add: less_Suc_eq nth_append split: nat_diff_split)
  3151   by (induct j) (auto simp add: less_Suc_eq nth_append split: nat_diff_split)
  3149 
  3152 
  3150 lemma hd_upt[simp]: "i < j \<Longrightarrow> hd[i..<j] = i"
  3153 lemma hd_upt[simp]: "i < j \<Longrightarrow> hd[i..<j] = i"
  3151   by(simp add:upt_conv_Cons)
  3154   by(simp add:upt_conv_Cons)
  3152 
  3155 
  3153 lemma tl_upt: "tl [m..<n] = [Suc m..<n]"
  3156 lemma tl_upt [simp]: "tl [m..<n] = [Suc m..<n]"
  3154   by (simp add: upt_rec)
  3157   by (simp add: upt_rec)
  3155 
  3158 
  3156 lemma last_upt[simp]: "i < j \<Longrightarrow> last[i..<j] = j - 1"
  3159 lemma last_upt[simp]: "i < j \<Longrightarrow> last[i..<j] = j - 1"
  3157   by(cases j)(auto simp: upt_Suc_append)
  3160   by(cases j)(auto simp: upt_Suc_append)
  3158 
  3161