2015-01-22 02:12:29 +00:00
|
|
|
import data.nat.basic
|
|
|
|
open nat
|
2015-12-06 07:52:16 +00:00
|
|
|
namespace foo
|
2015-01-22 02:12:29 +00:00
|
|
|
definition associative {A : Type} (op : A → A → A) := ∀a b c, op (op a b) c = op a (op b c)
|
|
|
|
|
|
|
|
structure semigroup [class] (A : Type) :=
|
|
|
|
mk {} :: (mul: A → A → A) (mul_assoc : associative mul)
|
|
|
|
|
|
|
|
definition nat_semigroup [instance] : semigroup nat :=
|
2015-10-14 19:27:09 +00:00
|
|
|
semigroup.mk nat.mul nat.mul_assoc
|
2015-01-22 02:12:29 +00:00
|
|
|
|
|
|
|
example (a b c : nat) : (a * b) * c = a * (b * c) :=
|
|
|
|
semigroup.mul_assoc a b c
|
|
|
|
|
|
|
|
structure semigroup2 (A : Type) :=
|
|
|
|
mk () :: (mul: A → A → A) (mul_assoc : associative mul)
|
|
|
|
|
2015-10-14 19:27:09 +00:00
|
|
|
definition s := semigroup2.mk nat nat.mul nat.mul_assoc
|
2015-01-22 02:12:29 +00:00
|
|
|
|
|
|
|
example (a b c : nat) : (a * b) * c = a * (b * c) :=
|
|
|
|
semigroup2.mul_assoc nat s a b c
|
2015-12-06 07:52:16 +00:00
|
|
|
end foo
|