--- a/src/HOL/Bit_Operations.thy Tue Jan 30 22:43:10 2024 +0100
+++ b/src/HOL/Bit_Operations.thy Mon Jan 29 20:37:03 2024 +0000
@@ -14,8 +14,7 @@
\<open>(\<And>a. a div 2 = a \<Longrightarrow> P a)
\<Longrightarrow> (\<And>a b. P a \<Longrightarrow> (of_bool b + 2 * a) div 2 = a \<Longrightarrow> P (of_bool b + 2 * a))
\<Longrightarrow> P a\<close>
- assumes even_half_succ_eq [simp]: \<open>even a \<Longrightarrow> (1 + a) div 2 = a div 2\<close>
- and half_div_exp_eq: \<open>a div 2 div 2 ^ n = a div 2 ^ Suc n\<close>
+ assumes half_div_exp_eq: \<open>a div 2 div 2 ^ n = a div 2 ^ Suc n\<close>
and even_double_div_exp_iff: \<open>2 ^ Suc n \<noteq> 0 \<Longrightarrow> even (2 * a div 2 ^ Suc n) \<longleftrightarrow> even (a div 2 ^ n)\<close>
and even_decr_exp_div_exp_iff: \<open>2 ^ n \<noteq> 0 \<Longrightarrow> even ((2 ^ m - 1) div 2 ^ n) \<longleftrightarrow> m \<le> n\<close>
and even_mod_exp_diff_exp_iff: \<open>even (a mod 2 ^ m div 2 ^ n) \<longleftrightarrow> m \<le> n \<or> even (a div 2 ^ n)\<close>
--- a/src/HOL/Library/Word.thy Tue Jan 30 22:43:10 2024 +0100
+++ b/src/HOL/Library/Word.thy Mon Jan 29 20:37:03 2024 +0000
@@ -668,7 +668,8 @@
end
instance word :: (len) semiring_parity
- by (standard; transfer) (simp_all add: mod_2_eq_odd)
+ by (standard; transfer)
+ (auto simp add: mod_2_eq_odd take_bit_Suc elim: evenE dest: le_Suc_ex)
lemma word_bit_induct [case_names zero even odd]:
\<open>P a\<close> if word_zero: \<open>P 0\<close>
@@ -837,11 +838,6 @@
show \<open>0 div a = 0\<close>
for a :: \<open>'a word\<close>
by transfer simp
- show \<open>(1 + a) div 2 = a div 2\<close>
- if \<open>even a\<close>
- for a :: \<open>'a word\<close>
- using that by transfer
- (auto dest: le_Suc_ex simp add: take_bit_Suc elim!: evenE)
show \<open>a div 2 div 2 ^ n = a div 2 ^ Suc n\<close>
for a :: \<open>'a word\<close> and m n :: nat
apply transfer
--- a/src/HOL/Parity.thy Tue Jan 30 22:43:10 2024 +0100
+++ b/src/HOL/Parity.thy Mon Jan 29 20:37:03 2024 +0000
@@ -14,6 +14,7 @@
class semiring_parity = comm_semiring_1 + semiring_modulo +
assumes mod_2_eq_odd: \<open>a mod 2 = of_bool (\<not> 2 dvd a)\<close>
and odd_one [simp]: \<open>\<not> 2 dvd 1\<close>
+ and even_half_succ_eq [simp]: \<open>2 dvd a \<Longrightarrow> (1 + a) div 2 = a div 2\<close>
begin
abbreviation even :: "'a \<Rightarrow> bool"
@@ -32,7 +33,7 @@
end
instance nat :: semiring_parity
- by standard (simp_all add: dvd_eq_mod_eq_0)
+ by standard (auto simp add: dvd_eq_mod_eq_0)
instance int :: ring_parity
by standard (auto simp add: dvd_eq_mod_eq_0)
@@ -855,6 +856,8 @@
then show False
by simp
qed
+ show \<open>(1 + a) div 2 = a div 2\<close> if \<open>2 dvd a\<close> for a
+ using that by auto
qed
lemma even_succ_div_two [simp]: