src/HOL/ex/Bit_Operations.thy
changeset 71420 572ab9e64e18
parent 71419 1d8e914e04d6
child 71424 e83fe2c31088
--- a/src/HOL/ex/Bit_Operations.thy	Wed Feb 05 20:16:59 2020 +0000
+++ b/src/HOL/ex/Bit_Operations.thy	Wed Feb 05 20:17:00 2020 +0000
@@ -248,176 +248,92 @@
 subsubsection \<open>Instance \<^typ>\<open>nat\<close>\<close>
 
 locale zip_nat = single: abel_semigroup f
-    for f :: "bool \<Rightarrow> bool \<Rightarrow> bool"  (infixl "\<^bold>*" 70) +
-  assumes end_of_bits: "\<not> False \<^bold>* False"
+    for f :: "bool \<Rightarrow> bool \<Rightarrow> bool"  (infixl \<open>\<^bold>*\<close> 70) +
+  assumes end_of_bits: \<open>\<not> False \<^bold>* False\<close>
 begin
 
-lemma False_P_imp:
-  "False \<^bold>* True \<and> P" if "False \<^bold>* P"
-  using that end_of_bits by (cases P) simp_all
-
-function F :: "nat \<Rightarrow> nat \<Rightarrow> nat"  (infixl "\<^bold>\<times>" 70)
-  where "m \<^bold>\<times> n = (if m = 0 \<and> n = 0 then 0
-    else of_bool (odd m \<^bold>* odd n) + (m div 2) \<^bold>\<times> (n div 2) * 2)"
+function F :: \<open>nat \<Rightarrow> nat \<Rightarrow> nat\<close>  (infixl \<open>\<^bold>\<times>\<close> 70)
+  where \<open>m \<^bold>\<times> n = (if m = 0 \<and> n = 0 then 0
+    else of_bool (odd m \<^bold>* odd n) + 2 * ((m div 2) \<^bold>\<times> (n div 2)))\<close>
   by auto
 
 termination
   by (relation "measure (case_prod (+))") auto
 
-lemma zero_left_eq:
-  "0 \<^bold>\<times> n = of_bool (False \<^bold>* True) * n"
-  by (induction n rule: nat_bit_induct) (simp_all add: end_of_bits)
-
-lemma zero_right_eq:
-  "m \<^bold>\<times> 0 = of_bool (True \<^bold>* False) * m"
-  by (induction m rule: nat_bit_induct) (simp_all add: end_of_bits)
-
-lemma simps [simp]:
-  "0 \<^bold>\<times> 0 = 0"
-  "0 \<^bold>\<times> n = of_bool (False \<^bold>* True) * n"
-  "m \<^bold>\<times> 0 = of_bool (True \<^bold>* False) * m"
-  "m > 0 \<Longrightarrow> n > 0 \<Longrightarrow> m \<^bold>\<times> n = of_bool (odd m \<^bold>* odd n) + (m div 2) \<^bold>\<times> (n div 2) * 2"
-  by (simp_all only: zero_left_eq zero_right_eq) simp
+declare F.simps [simp del]
 
 lemma rec:
   "m \<^bold>\<times> n = of_bool (odd m \<^bold>* odd n) + (m div 2) \<^bold>\<times> (n div 2) * 2"
-  by (cases "m = 0 \<and> n = 0") (auto simp add: end_of_bits)
+proof (cases \<open>m = 0 \<and> n = 0\<close>)
+  case True
+  then have \<open>m \<^bold>\<times> n = 0\<close>
+    using True by (simp add: F.simps [of 0 0])
+  moreover have \<open>(m div 2) \<^bold>\<times> (n div 2) = m \<^bold>\<times> n\<close>
+    using True by simp
+  ultimately show ?thesis
+    using True by (simp add: end_of_bits)
+next
+  case False
+  then show ?thesis
+    by (auto simp add: ac_simps F.simps [of m n])
+qed
 
-declare F.simps [simp del]
+lemma bit_eq_iff:
+  \<open>bit (m \<^bold>\<times> n) q \<longleftrightarrow> bit m q \<^bold>* bit n q\<close>
+proof (induction q arbitrary: m n)
+  case 0
+  then show ?case
+    by (simp add: rec [of m n])
+next
+  case (Suc n)
+  then show ?case
+    by (simp add: rec [of m n])
+qed
 
 sublocale abel_semigroup F
-proof
-  show "m \<^bold>\<times> n \<^bold>\<times> q = m \<^bold>\<times> (n \<^bold>\<times> q)" for m n q :: nat
-  proof (induction m arbitrary: n q rule: nat_bit_induct)
-    case zero
-    show ?case
-      by simp
-  next
-    case (even m)
-    with rec [of "2 * m"] rec [of _ q] show ?case
-      by (cases "even n") (auto simp add: ac_simps dest: False_P_imp)
-  next
-    case (odd m)
-    with rec [of "Suc (2 * m)"] rec [of _ q] show ?case
-      by (cases "even n"; cases "even q")
-        (auto dest: False_P_imp simp add: ac_simps)
-  qed
-  show "m \<^bold>\<times> n = n \<^bold>\<times> m" for m n :: nat
-  proof (induction m arbitrary: n rule: nat_bit_induct)
-    case zero
-    show ?case
-      by (simp add: ac_simps)
-  next
-    case (even m)
-    with rec [of "2 * m" n] rec [of n "2 * m"] show ?case
-      by (simp add: ac_simps)
-  next
-    case (odd m)
-    with rec [of "Suc (2 * m)" n] rec [of n "Suc (2 * m)"] show ?case
-      by (simp add: ac_simps)
-  qed
-qed
-
-lemma self [simp]:
-  "n \<^bold>\<times> n = of_bool (True \<^bold>* True) * n"
-  by (induction n rule: nat_bit_induct) (simp_all add: end_of_bits)
-
-lemma even_iff [simp]:
-  "even (m \<^bold>\<times> n) \<longleftrightarrow> \<not> (odd m \<^bold>* odd n)"
-proof (induction m arbitrary: n rule: nat_bit_induct)
-  case zero
-  show ?case
-    by (cases "even n") (simp_all add: end_of_bits)
-next
-  case (even m)
-  then show ?case
-    by (simp add: rec [of "2 * m"])
-next
-  case (odd m)
-  then show ?case
-    by (simp add: rec [of "Suc (2 * m)"])
-qed
+  by standard (simp_all add: Parity.bit_eq_iff bit_eq_iff ac_simps)
 
 end
 
 instantiation nat :: semiring_bit_operations
 begin
 
-global_interpretation and_nat: zip_nat "(\<and>)"
+global_interpretation and_nat: zip_nat \<open>(\<and>)\<close>
   defines and_nat = and_nat.F
   by standard auto
 
-global_interpretation and_nat: semilattice "(AND) :: nat \<Rightarrow> nat \<Rightarrow> nat"
+global_interpretation and_nat: semilattice \<open>(AND) :: nat \<Rightarrow> nat \<Rightarrow> nat\<close>
 proof (rule semilattice.intro, fact and_nat.abel_semigroup_axioms, standard)
-  show "n AND n = n" for n :: nat
-    by (simp add: and_nat.self)
+  show \<open>n AND n = n\<close> for n :: nat
+    by (simp add: bit_eq_iff and_nat.bit_eq_iff)
 qed
 
-declare and_nat.simps [simp] \<comment> \<open>inconsistent declaration handling by
-  \<open>global_interpretation\<close> in \<open>instantiation\<close>\<close>
-
-global_interpretation or_nat: zip_nat "(\<or>)"
+global_interpretation or_nat: zip_nat \<open>(\<or>)\<close>
   defines or_nat = or_nat.F
   by standard auto
 
-global_interpretation or_nat: semilattice "(OR) :: nat \<Rightarrow> nat \<Rightarrow> nat"
+global_interpretation or_nat: semilattice \<open>(OR) :: nat \<Rightarrow> nat \<Rightarrow> nat\<close>
 proof (rule semilattice.intro, fact or_nat.abel_semigroup_axioms, standard)
-  show "n OR n = n" for n :: nat
-    by (simp add: or_nat.self)
+  show \<open>n OR n = n\<close> for n :: nat
+    by (simp add: bit_eq_iff or_nat.bit_eq_iff)
 qed
 
-declare or_nat.simps [simp] \<comment> \<open>inconsistent declaration handling by
-  \<open>global_interpretation\<close> in \<open>instantiation\<close>\<close>
-
-global_interpretation xor_nat: zip_nat "(\<noteq>)"
+global_interpretation xor_nat: zip_nat \<open>(\<noteq>)\<close>
   defines xor_nat = xor_nat.F
   by standard auto
 
-declare xor_nat.simps [simp] \<comment> \<open>inconsistent declaration handling by
-  \<open>global_interpretation\<close> in \<open>instantiation\<close>\<close>
-
 instance proof
   fix m n q :: nat
   show \<open>bit (m AND n) q \<longleftrightarrow> bit m q \<and> bit n q\<close>
-  proof (rule sym, induction q arbitrary: m n)
-    case 0
-    then show ?case
-      by (simp add: and_nat.even_iff)
-  next
-    case (Suc q)
-    with and_nat.rec [of m n] show ?case
-      by simp
-  qed
+    by (fact and_nat.bit_eq_iff)
   show \<open>bit (m OR n) q \<longleftrightarrow> bit m q \<or> bit n q\<close>
-  proof (rule sym, induction q arbitrary: m n)
-    case 0
-    then show ?case
-      by (simp add: or_nat.even_iff)
-  next
-    case (Suc q)
-    with or_nat.rec [of m n] show ?case
-      by simp
-  qed
+    by (fact or_nat.bit_eq_iff)
   show \<open>bit (m XOR n) q \<longleftrightarrow> bit m q \<noteq> bit n q\<close>
-  proof (rule sym, induction q arbitrary: m n)
-    case 0
-    then show ?case
-      by (simp add: xor_nat.even_iff)
-  next
-    case (Suc q)
-    with xor_nat.rec [of m n] show ?case
-      by simp
-  qed
+    by (fact xor_nat.bit_eq_iff)
 qed
 
 end
 
-global_interpretation or_nat: semilattice_neutr "(OR)" "0 :: nat"
-  by standard simp
-
-global_interpretation xor_nat: comm_monoid "(XOR)" "0 :: nat"
-  by standard simp
-
 lemma Suc_0_and_eq [simp]:
   \<open>Suc 0 AND n = of_bool (odd n)\<close>
   using one_and_eq [of n] by simp
@@ -445,314 +361,112 @@
 
 subsubsection \<open>Instance \<^typ>\<open>int\<close>\<close>
 
-abbreviation (input) complement :: "int \<Rightarrow> int"
-  where "complement k \<equiv> - k - 1"
-
-lemma complement_half:
-  "complement (k * 2) div 2 = complement k"
-  by simp
-
-lemma complement_div_2:
-  "complement (k div 2) = complement k div 2"
-  by linarith
-
 locale zip_int = single: abel_semigroup f
-  for f :: "bool \<Rightarrow> bool \<Rightarrow> bool"  (infixl "\<^bold>*" 70)
+  for f :: \<open>bool \<Rightarrow> bool \<Rightarrow> bool\<close>  (infixl \<open>\<^bold>*\<close> 70)
 begin
- 
-lemma False_False_imp_True_True:
-  "True \<^bold>* True" if "False \<^bold>* False"
-proof (rule ccontr)
-  assume "\<not> True \<^bold>* True"
-  with that show False
-    using single.assoc [of False True True]
-    by (cases "False \<^bold>* True") simp_all
-qed
 
-function F :: "int \<Rightarrow> int \<Rightarrow> int"  (infixl "\<^bold>\<times>" 70)
-  where "k \<^bold>\<times> l = (if k \<in> {0, - 1} \<and> l \<in> {0, - 1}
+function F :: \<open>int \<Rightarrow> int \<Rightarrow> int\<close>  (infixl \<open>\<^bold>\<times>\<close> 70)
+  where \<open>k \<^bold>\<times> l = (if k \<in> {0, - 1} \<and> l \<in> {0, - 1}
     then - of_bool (odd k \<^bold>* odd l)
-    else of_bool (odd k \<^bold>* odd l) + (k div 2) \<^bold>\<times> (l div 2) * 2)"
+    else of_bool (odd k \<^bold>* odd l) + 2 * ((k div 2) \<^bold>\<times> (l div 2)))\<close>
   by auto
 
 termination
   by (relation "measure (\<lambda>(k, l). nat (\<bar>k\<bar> + \<bar>l\<bar>))") auto
 
-lemma zero_left_eq:
-  "0 \<^bold>\<times> l = (case (False \<^bold>* False, False \<^bold>* True)
-    of (False, False) \<Rightarrow> 0
-     | (False, True) \<Rightarrow> l
-     | (True, False) \<Rightarrow> complement l
-     | (True, True) \<Rightarrow> - 1)"
-  by (induction l rule: int_bit_induct)
-   (simp_all split: bool.split) 
-
-lemma minus_left_eq:
-  "- 1 \<^bold>\<times> l = (case (True \<^bold>* False, True \<^bold>* True)
-    of (False, False) \<Rightarrow> 0
-     | (False, True) \<Rightarrow> l
-     | (True, False) \<Rightarrow> complement l
-     | (True, True) \<Rightarrow> - 1)"
-  by (induction l rule: int_bit_induct)
-   (simp_all split: bool.split) 
-
-lemma zero_right_eq:
-  "k \<^bold>\<times> 0 = (case (False \<^bold>* False, False \<^bold>* True)
-    of (False, False) \<Rightarrow> 0
-     | (False, True) \<Rightarrow> k
-     | (True, False) \<Rightarrow> complement k
-     | (True, True) \<Rightarrow> - 1)"
-  by (induction k rule: int_bit_induct)
-    (simp_all add: ac_simps split: bool.split)
-
-lemma minus_right_eq:
-  "k \<^bold>\<times> - 1 = (case (True \<^bold>* False, True \<^bold>* True)
-    of (False, False) \<Rightarrow> 0
-     | (False, True) \<Rightarrow> k
-     | (True, False) \<Rightarrow> complement k
-     | (True, True) \<Rightarrow> - 1)"
-  by (induction k rule: int_bit_induct)
-    (simp_all add: ac_simps split: bool.split)
-
-lemma simps [simp]:
-  "0 \<^bold>\<times> 0 = - of_bool (False \<^bold>* False)"
-  "- 1 \<^bold>\<times> 0 = - of_bool (True \<^bold>* False)"
-  "0 \<^bold>\<times> - 1 = - of_bool (False \<^bold>* True)"
-  "- 1 \<^bold>\<times> - 1 = - of_bool (True \<^bold>* True)"
-  "0 \<^bold>\<times> l = (case (False \<^bold>* False, False \<^bold>* True)
-    of (False, False) \<Rightarrow> 0
-     | (False, True) \<Rightarrow> l
-     | (True, False) \<Rightarrow> complement l
-     | (True, True) \<Rightarrow> - 1)"
-  "- 1 \<^bold>\<times> l = (case (True \<^bold>* False, True \<^bold>* True)
-    of (False, False) \<Rightarrow> 0
-     | (False, True) \<Rightarrow> l
-     | (True, False) \<Rightarrow> complement l
-     | (True, True) \<Rightarrow> - 1)"
-  "k \<^bold>\<times> 0 = (case (False \<^bold>* False, False \<^bold>* True)
-    of (False, False) \<Rightarrow> 0
-     | (False, True) \<Rightarrow> k
-     | (True, False) \<Rightarrow> complement k
-     | (True, True) \<Rightarrow> - 1)"
-  "k \<^bold>\<times> - 1 = (case (True \<^bold>* False, True \<^bold>* True)
-    of (False, False) \<Rightarrow> 0
-     | (False, True) \<Rightarrow> k
-     | (True, False) \<Rightarrow> complement k
-     | (True, True) \<Rightarrow> - 1)"
-  "k \<noteq> 0 \<Longrightarrow> k \<noteq> - 1 \<Longrightarrow> l \<noteq> 0 \<Longrightarrow> l \<noteq> - 1
-    \<Longrightarrow> k \<^bold>\<times> l = of_bool (odd k \<^bold>* odd l) + (k div 2) \<^bold>\<times> (l div 2) * 2"
-  by simp_all[4] (simp_all only: zero_left_eq minus_left_eq zero_right_eq minus_right_eq, simp)
-
 declare F.simps [simp del]
 
 lemma rec:
-  "k \<^bold>\<times> l = of_bool (odd k \<^bold>* odd l) + (k div 2) \<^bold>\<times> (l div 2) * 2"
-  by (cases "k \<in> {0, - 1} \<and> l \<in> {0, - 1}") (auto simp add: ac_simps F.simps [of k l] split: bool.split)
+  \<open>k \<^bold>\<times> l = of_bool (odd k \<^bold>* odd l) + 2 * ((k div 2) \<^bold>\<times> (l div 2))\<close>
+proof (cases \<open>k \<in> {0, - 1} \<and> l \<in> {0, - 1}\<close>)
+  case True
+  then have \<open>(k div 2) \<^bold>\<times> (l div 2) = k \<^bold>\<times> l\<close>
+    by auto
+  moreover have \<open>of_bool (odd k \<^bold>* odd l) = - (k \<^bold>\<times> l)\<close>
+    using True by (simp add: F.simps [of k l])
+  ultimately show ?thesis by simp
+next
+  case False
+  then show ?thesis
+    by (auto simp add: ac_simps F.simps [of k l])
+qed
+
+lemma bit_eq_iff:
+  \<open>bit (k \<^bold>\<times> l) n \<longleftrightarrow> bit k n \<^bold>* bit l n\<close>
+proof (induction n arbitrary: k l)
+  case 0
+  then show ?case
+    by (simp add: rec [of k l])
+next
+  case (Suc n)
+  then show ?case
+    by (simp add: rec [of k l])
+qed
 
 sublocale abel_semigroup F
-proof
-  show "k \<^bold>\<times> l \<^bold>\<times> r = k \<^bold>\<times> (l \<^bold>\<times> r)" for k l r :: int
-  proof (induction k arbitrary: l r rule: int_bit_induct)
-    case zero
-    have "complement l \<^bold>\<times> r = complement (l \<^bold>\<times> r)" if "False \<^bold>* False" "\<not> False \<^bold>* True"
-    proof (induction l arbitrary: r rule: int_bit_induct)
-      case zero
-      from that show ?case
-        by (auto simp add: ac_simps False_False_imp_True_True split: bool.splits)
-    next
-      case minus
-      from that show ?case
-        by (auto simp add: ac_simps False_False_imp_True_True split: bool.splits)
-    next
-      case (even l)
-      with that rec [of _ r] show ?case
-        by (cases "even r")
-          (auto simp add: complement_half ac_simps False_False_imp_True_True split: bool.splits)
-    next
-      case (odd l)
-      moreover have "- l - 1 = - 1 - l"
-        by simp
-      ultimately show ?case
-        using that rec [of _ r]
-        by (cases "even r")
-          (auto simp add: ac_simps False_False_imp_True_True split: bool.splits)
-    qed
-    then show ?case
-      by (auto simp add: ac_simps False_False_imp_True_True split: bool.splits)
-  next
-    case minus
-    have "complement l \<^bold>\<times> r = complement (l \<^bold>\<times> r)" if "\<not> True \<^bold>* True" "False \<^bold>* True"
-    proof (induction l arbitrary: r rule: int_bit_induct)
-      case zero
-      from that show ?case
-        by (auto simp add: ac_simps False_False_imp_True_True split: bool.splits)
-    next
-      case minus
-      from that show ?case
-        by (auto simp add: ac_simps False_False_imp_True_True split: bool.splits)
-    next
-      case (even l)
-      with that rec [of _ r] show ?case
-        by (cases "even r")
-          (auto simp add: complement_half ac_simps False_False_imp_True_True split: bool.splits)
-    next
-      case (odd l)
-      moreover have "- l - 1 = - 1 - l"
-        by simp
-      ultimately show ?case
-        using that rec [of _ r]
-        by (cases "even r")
-          (auto simp add: ac_simps False_False_imp_True_True split: bool.splits)
-    qed
-    then show ?case
-      by (auto simp add: ac_simps False_False_imp_True_True split: bool.splits)
-  next
-    case (even k)
-    with rec [of "k * 2"] rec [of _ r] show ?case
-      by (cases "even r"; cases "even l") (auto simp add: ac_simps False_False_imp_True_True)
-  next
-    case (odd k)
-    with rec [of "1 + k * 2"] rec [of _ r] show ?case
-      by (cases "even r"; cases "even l") (auto simp add: ac_simps False_False_imp_True_True)
-  qed
-  show "k \<^bold>\<times> l = l \<^bold>\<times> k" for k l :: int
-  proof (induction k arbitrary: l rule: int_bit_induct)
-    case zero
-    show ?case
-      by simp
-  next
-    case minus
-    show ?case
-      by simp
-  next
-    case (even k)
-    with rec [of "k * 2" l] rec [of l "k * 2"] show ?case
-      by (simp add: ac_simps)
-  next
-    case (odd k)
-    with rec [of "k * 2 + 1" l] rec [of l "k * 2 + 1"] show ?case
-      by (simp add: ac_simps)
-  qed
-qed
-
-lemma self [simp]:
-  "k \<^bold>\<times> k = (case (False \<^bold>* False, True \<^bold>* True)
-    of (False, False) \<Rightarrow> 0
-     | (False, True) \<Rightarrow> k
-     | (True, True) \<Rightarrow> - 1)"
-  by (induction k rule: int_bit_induct) (auto simp add: False_False_imp_True_True split: bool.split)
-
-lemma even_iff [simp]:
-  "even (k \<^bold>\<times> l) \<longleftrightarrow> \<not> (odd k \<^bold>* odd l)"
-proof (induction k arbitrary: l rule: int_bit_induct)
-  case zero
-  show ?case
-    by (cases "even l") (simp_all split: bool.splits)
-next
-  case minus
-  show ?case
-    by (cases "even l") (simp_all split: bool.splits)
-next
-  case (even k)
-  then show ?case
-    by (simp add: rec [of "k * 2"])
-next
-  case (odd k)
-  then show ?case
-    by (simp add: rec [of "1 + k * 2"])
-qed
+  by standard (simp_all add: Parity.bit_eq_iff bit_eq_iff ac_simps)
 
 end
 
 instantiation int :: ring_bit_operations
 begin
 
-definition not_int :: "int \<Rightarrow> int"
-  where "not_int = complement"
-
 global_interpretation and_int: zip_int "(\<and>)"
   defines and_int = and_int.F
   by standard
 
-declare and_int.simps [simp] \<comment> \<open>inconsistent declaration handling by
-  \<open>global_interpretation\<close> in \<open>instantiation\<close>\<close>
-
 global_interpretation and_int: semilattice "(AND) :: int \<Rightarrow> int \<Rightarrow> int"
 proof (rule semilattice.intro, fact and_int.abel_semigroup_axioms, standard)
   show "k AND k = k" for k :: int
-    by (simp add: and_int.self)
+    by (simp add: bit_eq_iff and_int.bit_eq_iff)
 qed
 
 global_interpretation or_int: zip_int "(\<or>)"
   defines or_int = or_int.F
   by standard
 
-declare or_int.simps [simp] \<comment> \<open>inconsistent declaration handling by
-  \<open>global_interpretation\<close> in \<open>instantiation\<close>\<close>
-
 global_interpretation or_int: semilattice "(OR) :: int \<Rightarrow> int \<Rightarrow> int"
 proof (rule semilattice.intro, fact or_int.abel_semigroup_axioms, standard)
   show "k OR k = k" for k :: int
-    by (simp add: or_int.self)
+    by (simp add: bit_eq_iff or_int.bit_eq_iff)
 qed
 
 global_interpretation xor_int: zip_int "(\<noteq>)"
   defines xor_int = xor_int.F
   by standard
 
-declare xor_int.simps [simp] \<comment> \<open>inconsistent declaration handling by
-  \<open>global_interpretation\<close> in \<open>instantiation\<close>\<close>
+definition not_int :: \<open>int \<Rightarrow> int\<close>
+  where \<open>not_int k = - k - 1\<close>
+
+lemma not_int_rec:
+  "NOT k = of_bool (even k) + 2 * NOT (k div 2)" for k :: int
+  by (auto simp add: not_int_def elim: oddE)
+
+lemma even_not_iff_int:
+  \<open>even (NOT k) \<longleftrightarrow> odd k\<close> for k :: int
+  by (simp add: not_int_def)
+
+lemma not_int_div_2:
+  \<open>NOT k div 2 = NOT (k div 2)\<close> for k :: int
+  by (simp add: not_int_def)
 
 lemma bit_not_iff_int:
   \<open>bit (NOT k) n \<longleftrightarrow> \<not> bit k n\<close>
     for k :: int
-    by (induction n arbitrary: k)
-      (simp_all add: not_int_def flip: complement_div_2)
+  by (induction n arbitrary: k) (simp_all add: not_int_div_2 even_not_iff_int)
 
 instance proof
   fix k l :: int and n :: nat
   show \<open>- k = NOT (k - 1)\<close>
     by (simp add: not_int_def)
   show \<open>bit (k AND l) n \<longleftrightarrow> bit k n \<and> bit l n\<close>
-  proof (rule sym, induction n arbitrary: k l)
-    case 0
-    then show ?case
-      by (simp add: and_int.even_iff)
-  next
-    case (Suc n)
-    with and_int.rec [of k l] show ?case
-      by simp
-  qed
+    by (fact and_int.bit_eq_iff)
   show \<open>bit (k OR l) n \<longleftrightarrow> bit k n \<or> bit l n\<close>
-  proof (rule sym, induction n arbitrary: k l)
-    case 0
-    then show ?case
-      by (simp add: or_int.even_iff)
-  next
-    case (Suc n)
-    with or_int.rec [of k l] show ?case
-      by simp
-  qed
+    by (fact or_int.bit_eq_iff)
   show \<open>bit (k XOR l) n \<longleftrightarrow> bit k n \<noteq> bit l n\<close>
-  proof (rule sym, induction n arbitrary: k l)
-    case 0
-    then show ?case
-      by (simp add: xor_int.even_iff)
-  next
-    case (Suc n)
-    with xor_int.rec [of k l] show ?case
-      by simp
-  qed
-qed (simp_all add: minus_1_div_exp_eq_int bit_not_iff_int)
+    by (fact xor_int.bit_eq_iff)
+qed (simp_all add: bit_not_iff_int)
 
 end
 
-lemma not_int_div_2:
-  "NOT k div 2 = NOT (k div 2)" for k :: int
-  by (simp add: complement_div_2 not_int_def)
-
-lemma not_int_rec [simp]:
-  "k \<noteq> 0 \<Longrightarrow> k \<noteq> - 1 \<Longrightarrow> NOT k = of_bool (even k) + 2 * NOT (k div 2)" for k :: int
-  by (auto simp add: not_int_def elim: oddE)
-
 end