2014-07-25 00:46:41 +00: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-08-28 01:39:55 +00:00
|
|
|
import logic.core.eq
|
2014-09-03 23:00:38 +00:00
|
|
|
open eq_ops
|
2014-07-25 00:46:41 +00:00
|
|
|
|
|
|
|
namespace binary
|
2014-09-06 18:05:07 +00:00
|
|
|
context
|
|
|
|
parameter {A : Type}
|
|
|
|
parameter f : A → A → A
|
|
|
|
infixl `*`:75 := f
|
|
|
|
abbreviation commutative := ∀{a b}, a*b = b*a
|
|
|
|
abbreviation associative := ∀{a b c}, (a*b)*c = a*(b*c)
|
|
|
|
end
|
2014-07-25 00:46:41 +00:00
|
|
|
|
2014-09-06 18:05:07 +00:00
|
|
|
context
|
|
|
|
parameter {A : Type}
|
|
|
|
parameter {f : A → A → A}
|
|
|
|
hypothesis H_comm : commutative f
|
|
|
|
hypothesis H_assoc : associative f
|
|
|
|
infixl `*`:75 := f
|
|
|
|
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-25 00:46:41 +00:00
|
|
|
|
2014-09-06 18:05:07 +00: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-08-07 23:59:08 +00:00
|
|
|
end binary
|