equal
deleted
inserted
replaced
3387 "drop (numeral v) (x # xs) = drop (numeral v - 1) xs" |
3387 "drop (numeral v) (x # xs) = drop (numeral v - 1) xs" |
3388 by (simp add: drop_Cons') |
3388 by (simp add: drop_Cons') |
3389 |
3389 |
3390 lemma nth_Cons_numeral [simp]: |
3390 lemma nth_Cons_numeral [simp]: |
3391 "(x # xs) ! numeral v = xs ! (numeral v - 1)" |
3391 "(x # xs) ! numeral v = xs ! (numeral v - 1)" |
3392 by (simp add: nth_Cons') |
3392 by (simp add: nth_Cons') |
|
3393 |
|
3394 lemma map_upt_eqI: |
|
3395 \<open>map f [m..<n] = xs\<close> if \<open>length xs = n - m\<close> |
|
3396 \<open>\<And>i. i < length xs \<Longrightarrow> xs ! i = f (m + i)\<close> |
|
3397 proof (rule nth_equalityI) |
|
3398 from \<open>length xs = n - m\<close> show \<open>length (map f [m..<n]) = length xs\<close> |
|
3399 by simp |
|
3400 next |
|
3401 fix i |
|
3402 assume \<open>i < length (map f [m..<n])\<close> |
|
3403 then have \<open>i < n - m\<close> |
|
3404 by simp |
|
3405 with that have \<open>xs ! i = f (m + i)\<close> |
|
3406 by simp |
|
3407 with \<open>i < n - m\<close> show \<open>map f [m..<n] ! i = xs ! i\<close> |
|
3408 by simp |
|
3409 qed |
3393 |
3410 |
3394 |
3411 |
3395 subsubsection \<open>\<open>upto\<close>: interval-list on \<^typ>\<open>int\<close>\<close> |
3412 subsubsection \<open>\<open>upto\<close>: interval-list on \<^typ>\<open>int\<close>\<close> |
3396 |
3413 |
3397 function upto :: "int \<Rightarrow> int \<Rightarrow> int list" ("(1[_../_])") where |
3414 function upto :: "int \<Rightarrow> int \<Rightarrow> int list" ("(1[_../_])") where |