equal
deleted
inserted
replaced
4982 by(auto simp: sorted_wrt_iff_nth_less) |
4982 by(auto simp: sorted_wrt_iff_nth_less) |
4983 |
4983 |
4984 lemma sorted_wrt_upt[simp]: "sorted_wrt (<) [m..<n]" |
4984 lemma sorted_wrt_upt[simp]: "sorted_wrt (<) [m..<n]" |
4985 by(induction n) (auto simp: sorted_wrt_append) |
4985 by(induction n) (auto simp: sorted_wrt_append) |
4986 |
4986 |
4987 lemma sorted_wrt_upto[simp]: "sorted_wrt (<) [m..n]" |
4987 lemma sorted_wrt_upto[simp]: "sorted_wrt (<) [i..j]" |
4988 proof cases |
4988 apply(induction i j rule: upto.induct) |
4989 assume "n < m" thus ?thesis by simp |
4989 apply(subst upto.simps) |
4990 next |
4990 apply(simp) |
4991 assume "\<not> n < m" |
4991 done |
4992 hence "m \<le> n" by simp |
|
4993 thus ?thesis |
|
4994 by(induction m rule:int_le_induct)(auto simp: upto_rec1) |
|
4995 qed |
|
4996 |
4992 |
4997 text \<open>Each element is greater or equal to its index:\<close> |
4993 text \<open>Each element is greater or equal to its index:\<close> |
4998 |
4994 |
4999 lemma sorted_wrt_less_idx: |
4995 lemma sorted_wrt_less_idx: |
5000 "sorted_wrt (<) ns \<Longrightarrow> i < length ns \<Longrightarrow> i \<le> ns!i" |
4996 "sorted_wrt (<) ns \<Longrightarrow> i < length ns \<Longrightarrow> i \<le> ns!i" |
5379 "remove1 x (insort x xs) = xs" |
5375 "remove1 x (insort x xs) = xs" |
5380 by (induct xs) simp_all |
5376 by (induct xs) simp_all |
5381 |
5377 |
5382 end |
5378 end |
5383 |
5379 |
5384 lemma sorted_upt[simp]: "sorted[i..<j]" |
5380 lemma sort_upt [simp]: "sort [m..<n] = [m..<n]" |
5385 by (induct j) (simp_all add:sorted_append) |
5381 by (rule sorted_sort_id) simp |
5386 |
5382 |
5387 lemma sort_upt [simp]: |
5383 lemma sort_upto [simp]: "sort [i..j] = [i..j]" |
5388 "sort [m..<n] = [m..<n]" |
5384 by (rule sorted_sort_id) simp |
5389 by (rule sorted_sort_id) simp |
|
5390 |
|
5391 lemma sorted_upto[simp]: "sorted[i..j]" |
|
5392 apply(induct i j rule:upto.induct) |
|
5393 apply(subst upto.simps) |
|
5394 apply(simp) |
|
5395 done |
|
5396 |
5385 |
5397 lemma sorted_find_Min: |
5386 lemma sorted_find_Min: |
5398 "sorted xs \<Longrightarrow> \<exists>x \<in> set xs. P x \<Longrightarrow> List.find P xs = Some (Min {x\<in>set xs. P x})" |
5387 "sorted xs \<Longrightarrow> \<exists>x \<in> set xs. P x \<Longrightarrow> List.find P xs = Some (Min {x\<in>set xs. P x})" |
5399 proof (induct xs) |
5388 proof (induct xs) |
5400 case Nil then show ?case by simp |
5389 case Nil then show ?case by simp |