diff -r effe7f8b2b1b -r 2424301cc73d src/HOL/Set_Interval.thy --- a/src/HOL/Set_Interval.thy Tue Oct 23 10:50:48 2018 +0200 +++ b/src/HOL/Set_Interval.thy Thu Oct 25 09:48:02 2018 +0000 @@ -2271,42 +2271,28 @@ qed lemma Sum_Icc_nat: - "\{m..n} = (n * (n + 1) - m * (m - 1)) div 2" - if "m \ n" for m n :: nat -proof - - have *: "m * (m - 1) \ n * (n + 1)" - using that by (meson diff_le_self order_trans le_add1 mult_le_mono) + "\{m..n} = (n * (n + 1) - m * (m - 1)) div 2" for m n :: nat +proof (cases "m \ n") + case True + then have *: "m * (m - 1) \ n * (n + 1)" + by (meson diff_le_self order_trans le_add1 mult_le_mono) have "int (\{m..n}) = (\{int m..int n})" by (simp add: sum.atLeast_int_atMost_int_shift) also have "\ = (int n * (int n + 1) - int m * (int m - 1)) div 2" - using that by (simp add: Sum_Icc_int) + using \m \ n\ by (simp add: Sum_Icc_int) also have "\ = int ((n * (n + 1) - m * (m - 1)) div 2)" using le_square * by (simp add: algebra_simps of_nat_div of_nat_diff) finally show ?thesis by (simp only: of_nat_eq_iff) +next + case False + then show ?thesis + by (auto dest: less_imp_Suc_add simp add: not_le algebra_simps) qed lemma Sum_Ico_nat: - "\{m.. n" for m n :: nat -proof - - from that consider "m < n" | "m = n" - by (auto simp add: less_le) - then show ?thesis proof cases - case 1 - then have "{m..{m..{m..n - 1}" - by simp - also have "\ = (n * (n - 1) - m * (m - 1)) div 2" - using \m < n\ by (simp add: Sum_Icc_nat mult.commute) - finally show ?thesis . - next - case 2 - then show ?thesis - by simp - qed -qed + "\{m..Division remainder\