open import 1Lab.Prelude

open import Algebra.Magma.Unital
open import Algebra.Semigroup
open import Algebra.Monoid

module Algebra.Magma.Unital.EckmannHilton where

# The Eckmann-Hilton Argument🔗

The Eckmann-Hilton argument shows that two unital magmas on the same carrier type that satisfy a particular interchange law are not only equal to another, but are also commutative and associative.

More precisely, let $(A,e,\star)$ and $(A,e',\star')$ two unital magmas such that $(a \star b) \star' (c \star d) = (a \star' c) \star (b \star' d)$.

module _ { : _} {A : Type } {_⋆_ : A  A  A} {_⋆'_ : A  A  A} {e : A} {e' : A}
(unital-mgm : is-unital-magma e _⋆_) (unital-mgm' : is-unital-magma e' _⋆'_)
(interchange : (a b c d : A)  (a  b) ⋆' (c  d)  (a ⋆' c)  (b ⋆' d)) where

Then, one can first show that both operations share a unit, i.e. $e = e'$. Notably, this holds because the units can be expanded to products of themselves, which can then be transformed into another by making use of the interchange equation.

units-equal : e  e'
units-equal =
e
(e  e)
((e' ⋆'  e)  (e ⋆' e'))
((e'  e) ⋆' (e  e'))
(e' ⋆' e')
e'

From there on, we are able to derive that one operation is equal to the dual of the other, once again by using the interchange law as well as swapping units whenever needed.

⋆-reverse-⋆' : (x y : A)  x  y  y ⋆' x
⋆-reverse-⋆' x y =
x  y
(e' ⋆' x)  (y ⋆' e')
(e'  y) ⋆' (x  e')
(e  y) ⋆' (x  e)
y ⋆' x

By a similar method, we can show pointwise equality of the two operators.

operations-equal : (x y : A)  x  y  x ⋆' y
operations-equal x y =
x  y
(x ⋆' e')  (e' ⋆' y)
(x  e') ⋆' (e'  y)
(x  e) ⋆' (e  y)
x ⋆' y

These two properties make it rather straightforward to show that $\star$ is commutative - since we know that $a \star b = a \star' b$ as well as $a \star b = b \star' a$, the proof can be completed by simple path concatenation.

⋆-commutative : (x y : A)  x  y  y  x
⋆-commutative x y = ⋆-reverse-⋆' x y  sym (operations-equal y x)

Finally, associativity of the operation can be established by what can be informally described as rotating the elements of the product, using commutativity inside the factors of a products that can then be interchanged and reduced. Thus, associativity combined with the assumed unitality allows us to prove that the operation is a monoid.

⋆-associative : (x y z : A)  x  (y  z)  (x  y)  z
⋆-associative x y z = sym (
(x  y)  z
(x  y)  (z  e)
(y  x)  (z  e)
(y  x) ⋆' (z  e)
(y ⋆' z)  (x ⋆' e)
(x ⋆' e)  (y ⋆' z)
(x  e)  (y  z)
x  (y  z) )

⋆-is-monoid : is-monoid e _⋆_
⋆-is-monoid .has-is-semigroup .has-is-magma = unital-mgm .has-is-magma
⋆-is-monoid .has-is-semigroup .associative = ⋆-associative _ _ _
⋆-is-monoid .idl = unital-mgm .idl
⋆-is-monoid .idr = unital-mgm .idr