src/HOL/Library/Boolean_Algebra.thy
```     1.1 --- a/src/HOL/Library/Boolean_Algebra.thy	Wed Jan 27 14:03:08 2010 +0100
1.2 +++ b/src/HOL/Library/Boolean_Algebra.thy	Thu Jan 28 11:48:43 2010 +0100
1.3 @@ -24,15 +24,22 @@
1.4    assumes disj_zero_right [simp]: "x \<squnion> \<zero> = x"
1.5    assumes conj_cancel_right [simp]: "x \<sqinter> \<sim> x = \<zero>"
1.6    assumes disj_cancel_right [simp]: "x \<squnion> \<sim> x = \<one>"
1.7 +
1.8 +sublocale boolean < conj!: abel_semigroup conj proof
1.9 +qed (fact conj_assoc conj_commute)+
1.10 +
1.11 +sublocale boolean < disj!: abel_semigroup disj proof
1.12 +qed (fact disj_assoc disj_commute)+
1.13 +
1.14 +context boolean
1.15  begin
1.16
1.17 -lemmas disj_ac =
1.18 -  disj_assoc disj_commute
1.19 -  mk_left_commute [where 'a = 'a, of "disj", OF disj_assoc disj_commute]
1.20 +lemmas conj_left_commute = conj.left_commute
1.21
1.22 -lemmas conj_ac =
1.23 -  conj_assoc conj_commute
1.24 -  mk_left_commute [where 'a = 'a, of "conj", OF conj_assoc conj_commute]
1.25 +lemmas disj_left_commute = disj.left_commute
1.26 +
1.27 +lemmas conj_ac = conj.assoc conj.commute conj.left_commute
1.28 +lemmas disj_ac = disj.assoc disj.commute disj.left_commute
1.29
1.30  lemma dual: "boolean disj conj compl one zero"
1.31  apply (rule boolean.intro)
1.32 @@ -178,18 +185,9 @@
1.33  locale boolean_xor = boolean +
1.34    fixes xor :: "'a => 'a => 'a"  (infixr "\<oplus>" 65)
1.35    assumes xor_def: "x \<oplus> y = (x \<sqinter> \<sim> y) \<squnion> (\<sim> x \<sqinter> y)"
1.36 -begin
1.37
1.38 -lemma xor_def2:
1.39 -  "x \<oplus> y = (x \<squnion> y) \<sqinter> (\<sim> x \<squnion> \<sim> y)"
1.40 -by (simp only: xor_def conj_disj_distribs
1.41 -               disj_ac conj_ac conj_cancel_right disj_zero_left)
1.42 -
1.43 -lemma xor_commute: "x \<oplus> y = y \<oplus> x"
1.44 -by (simp only: xor_def conj_commute disj_commute)
1.45 -
1.46 -lemma xor_assoc: "(x \<oplus> y) \<oplus> z = x \<oplus> (y \<oplus> z)"
1.47 -proof -
1.48 +sublocale boolean_xor < xor!: abel_semigroup xor proof
1.49 +  fix x y z :: 'a
1.50    let ?t = "(x \<sqinter> y \<sqinter> z) \<squnion> (x \<sqinter> \<sim> y \<sqinter> \<sim> z) \<squnion>
1.51              (\<sim> x \<sqinter> y \<sqinter> \<sim> z) \<squnion> (\<sim> x \<sqinter> \<sim> y \<sqinter> z)"
1.52    have "?t \<squnion> (z \<sqinter> x \<sqinter> \<sim> x) \<squnion> (z \<sqinter> y \<sqinter> \<sim> y) =
1.53 @@ -199,11 +197,23 @@
1.54      apply (simp only: xor_def de_Morgan_disj de_Morgan_conj double_compl)
1.55      apply (simp only: conj_disj_distribs conj_ac disj_ac)
1.56      done
1.57 +  show "x \<oplus> y = y \<oplus> x"
1.58 +    by (simp only: xor_def conj_commute disj_commute)
1.59  qed
1.60
1.61 -lemmas xor_ac =
1.62 -  xor_assoc xor_commute
1.63 -  mk_left_commute [where 'a = 'a, of "xor", OF xor_assoc xor_commute]
1.64 +context boolean_xor
1.65 +begin
1.66 +
1.67 +lemmas xor_assoc = xor.assoc
1.68 +lemmas xor_commute = xor.commute
1.69 +lemmas xor_left_commute = xor.left_commute
1.70 +
1.71 +lemmas xor_ac = xor.assoc xor.commute xor.left_commute
1.72 +
1.73 +lemma xor_def2:
1.74 +  "x \<oplus> y = (x \<squnion> y) \<sqinter> (\<sim> x \<squnion> \<sim> y)"
1.75 +by (simp only: xor_def conj_disj_distribs
1.76 +               disj_ac conj_ac conj_cancel_right disj_zero_left)
1.77
1.78  lemma xor_zero_right [simp]: "x \<oplus> \<zero> = x"
1.79  by (simp only: xor_def compl_zero conj_one_right conj_zero_right disj_zero_right)
```