code theorems for nth, list_update
authorhaftmann
Sat, 07 Feb 2009 08:37:43 +0100
changeset 29827 c82b3e8a4daf
parent 29826 5132da6ebca3
child 29828 2bc09b164f2b
code theorems for nth, list_update
src/HOL/List.thy
--- a/src/HOL/List.thy	Sat Feb 07 08:37:42 2009 +0100
+++ b/src/HOL/List.thy	Sat Feb 07 08:37:43 2009 +0100
@@ -1215,10 +1215,10 @@
 
 subsubsection {* @{text nth} *}
 
-lemma nth_Cons_0 [simp]: "(x # xs)!0 = x"
+lemma nth_Cons_0 [simp, code]: "(x # xs)!0 = x"
 by auto
 
-lemma nth_Cons_Suc [simp]: "(x # xs)!(Suc n) = xs!n"
+lemma nth_Cons_Suc [simp, code]: "(x # xs)!(Suc n) = xs!n"
 by auto
 
 declare nth.simps [simp del]
@@ -1375,6 +1375,12 @@
 apply auto
 done
 
+lemma list_update_code [code]:
+  "[][i := y] = []"
+  "(x # xs)[0 := y] = y # xs"
+  "(x # xs)[Suc i := y] = x # xs[i := y]"
+  by simp_all
+
 
 subsubsection {* @{text last} and @{text butlast} *}