2014-07-24 17:46:41 -07:00
|
|
|
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
-- Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
-- Author: Leonardo de Moura
|
2014-10-05 10:50:13 -07:00
|
|
|
import logic.eq
|
2014-10-01 17:51:17 -07:00
|
|
|
open eq.ops
|
2014-07-24 17:46:41 -07:00
|
|
|
|
|
|
|
namespace binary
|
2014-09-06 11:05:07 -07:00
|
|
|
context
|
2014-10-09 07:13:06 -07:00
|
|
|
variable {A : Type}
|
|
|
|
variable f : A → A → A
|
2014-10-21 15:27:45 -07:00
|
|
|
infixl `*` := f
|
2014-09-17 14:39:05 -07:00
|
|
|
definition commutative := ∀{a b}, a*b = b*a
|
|
|
|
definition associative := ∀{a b c}, (a*b)*c = a*(b*c)
|
2014-09-06 11:05:07 -07:00
|
|
|
end
|
2014-07-24 17:46:41 -07:00
|
|
|
|
2014-09-06 11:05:07 -07:00
|
|
|
context
|
2014-10-09 07:13:06 -07:00
|
|
|
variable {A : Type}
|
|
|
|
variable {f : A → A → A}
|
|
|
|
variable H_comm : commutative f
|
|
|
|
variable H_assoc : associative f
|
2014-10-21 15:27:45 -07:00
|
|
|
infixl `*` := f
|
2014-09-06 11:05:07 -07:00
|
|
|
theorem left_comm : ∀a b c, a*(b*c) = b*(a*c) :=
|
|
|
|
take a b c, calc
|
|
|
|
a*(b*c) = (a*b)*c : H_assoc⁻¹
|
|
|
|
... = (b*a)*c : {H_comm}
|
|
|
|
... = b*(a*c) : H_assoc
|
2014-07-24 17:46:41 -07:00
|
|
|
|
2014-09-06 11:05:07 -07:00
|
|
|
theorem right_comm : ∀a b c, (a*b)*c = (a*c)*b :=
|
|
|
|
take a b c, calc
|
|
|
|
(a*b)*c = a*(b*c) : H_assoc
|
|
|
|
... = a*(c*b) : {H_comm}
|
|
|
|
... = (a*c)*b : H_assoc⁻¹
|
|
|
|
end
|
2014-10-08 21:45:44 -04:00
|
|
|
|
|
|
|
context
|
2014-10-09 07:13:06 -07:00
|
|
|
variable {A : Type}
|
|
|
|
variable {f : A → A → A}
|
|
|
|
variable H_assoc : associative f
|
2014-10-21 15:27:45 -07:00
|
|
|
infixl `*` := f
|
2014-10-08 21:45:44 -04:00
|
|
|
theorem assoc4helper (a b c d) : (a*b)*(c*d) = a*((b*c)*d) :=
|
|
|
|
calc
|
|
|
|
(a*b)*(c*d) = a*(b*(c*d)) : H_assoc
|
|
|
|
... = a*((b*c)*d) : {H_assoc⁻¹}
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-08-07 16:59:08 -07:00
|
|
|
end binary
|