src/HOL/List.thy
changeset 17762 478869f444ca
parent 17724 e969fc0a4925
child 17765 e3cd31bc2e40
equal deleted inserted replaced
17761:2c42d0a94f58 17762:478869f444ca
   993 
   993 
   994 lemma last_appendR[simp]: "ys \<noteq> [] \<Longrightarrow> last(xs @ ys) = last ys"
   994 lemma last_appendR[simp]: "ys \<noteq> [] \<Longrightarrow> last(xs @ ys) = last ys"
   995 by(simp add:last_append)
   995 by(simp add:last_append)
   996 
   996 
   997 
   997 
       
   998 lemma hd_rev: "xs \<noteq> [] \<Longrightarrow> hd(rev xs) = last xs"
       
   999 by(rule rev_exhaust[of xs]) simp_all
       
  1000 
       
  1001 lemma last_rev: "xs \<noteq> [] \<Longrightarrow> last(rev xs) = hd xs"
       
  1002 by(cases xs) simp_all
       
  1003 
       
  1004 
   998 lemma length_butlast [simp]: "length (butlast xs) = length xs - 1"
  1005 lemma length_butlast [simp]: "length (butlast xs) = length xs - 1"
   999 by (induct xs rule: rev_induct) auto
  1006 by (induct xs rule: rev_induct) auto
  1000 
  1007 
  1001 lemma butlast_append:
  1008 lemma butlast_append:
  1002 "!!ys. butlast (xs @ ys) = (if ys = [] then butlast xs else xs @ butlast ys)"
  1009 "!!ys. butlast (xs @ ys) = (if ys = [] then butlast xs else xs @ butlast ys)"