diff -r 96d126844adc -r 65ffe9e910d4 src/HOL/Euclidean_Division.thy --- a/src/HOL/Euclidean_Division.thy Sat Feb 01 19:10:37 2020 +0100 +++ b/src/HOL/Euclidean_Division.thy Sat Feb 01 19:10:40 2020 +0100 @@ -327,6 +327,26 @@ using div_plus_div_distrib_dvd_left [of c b a] by (simp add: ac_simps) +lemma sum_div_partition: + \(\a\A. f a) div b = (\a\A \ {a. b dvd f a}. f a div b) + (\a\A \ {a. \ b dvd f a}. f a) div b\ + if \finite A\ +proof - + have \A = A \ {a. b dvd f a} \ A \ {a. \ b dvd f a}\ + by auto + then have \(\a\A. f a) = (\a\A \ {a. b dvd f a} \ A \ {a. \ b dvd f a}. f a)\ + by simp + also have \\ = (\a\A \ {a. b dvd f a}. f a) + (\a\A \ {a. \ b dvd f a}. f a)\ + using \finite A\ by (auto intro: sum.union_inter_neutral) + finally have *: \sum f A = sum f (A \ {a. b dvd f a}) + sum f (A \ {a. \ b dvd f a})\ . + define B where B: \B = A \ {a. b dvd f a}\ + with \finite A\ have \finite B\ and \a \ B \ b dvd f a\ for a + by simp_all + then have \(\a\B. f a) div b = (\a\B. f a div b)\ and \b dvd (\a\B. f a)\ + by induction (simp_all add: div_plus_div_distrib_dvd_left) + then show ?thesis using * + by (simp add: B div_plus_div_distrib_dvd_left) +qed + named_theorems mod_simps text \Addition respects modular equivalence.\ @@ -442,6 +462,26 @@ by (simp add: mod_mult_left_eq mod_mult_right_eq) qed +lemma power_diff_power_eq: + \a ^ m div a ^ n = (if n \ m then a ^ (m - n) else 1 div a ^ (n - m))\ + if \a \ 0\ +proof (cases \n \ m\) + case True + with that power_diff [symmetric, of a n m] show ?thesis by simp +next + case False + then obtain q where n: \n = m + Suc q\ + by (auto simp add: not_le dest: less_imp_Suc_add) + then have \a ^ m div a ^ n = (a ^ m * 1) div (a ^ m * a ^ Suc q)\ + by (simp add: power_add ac_simps) + moreover from that have \a ^ m \ 0\ + by simp + ultimately have \a ^ m div a ^ n = 1 div a ^ Suc q\ + by (subst (asm) div_mult_mult1) simp + with False n show ?thesis + by simp +qed + end