Library UniMath.Algebra.Universal.Examples.Monoid

Example on monoids.

Gianluca Amato, Marco Maggesi, Cosimo Perini Brogi 2019-2021
This file contains the definition of the signature of monoids and the way to turn a monoid (as defined in UniMath.Algebra.Monoids) into an algebra.

Require Import UniMath.MoreFoundations.Notations.
Require Import UniMath.Combinatorics.StandardFiniteSets.
Require Import UniMath.Algebra.Monoids.

Require Import UniMath.Algebra.Universal.EqAlgebras.

Local Open Scope stn.
Local Open Scope eq.

Signature.
Algebra of monoids without equations.
Free algebra of open terms.
Every monoid is a monoid eqalgebra.

Section Make_Monoid_Eqalgebra.

Variable M : monoid.

Lemma holds_monoid_mul_lid : holds (monoid_algebra M) monoid_mul_lid.
Show proof.
  intro. cbn in α.
  change (fromterm (ops (monoid_algebra M)) α tt (mul id x) = α 0).
  change (op (unel M) (α 0) = α 0).
  apply lunax.

Lemma holds_monoid_mul_rid : holds (monoid_algebra M) monoid_mul_rid.
Show proof.
  intro.
  change (op (α 0) (unel M) = α 0).
  apply runax.

Lemma holds_monoid_mul_assoc : holds (monoid_algebra M) monoid_mul_assoc.
Show proof.
  intro.
  change (op (op (α 0) (α 1)) (α 2) = op (α 0) (op (α 1) (α 2))).
  apply assocax.

Definition is_eqalgebra_monoid :
  is_eqalgebra (σ := monoid_eqspec) (monoid_algebra M).
Show proof.
  red. simpl.
  apply three_rec_dep; cbn.
  - exact holds_monoid_mul_assoc.
  - exact holds_monoid_mul_lid.
  - exact holds_monoid_mul_rid.

Definition make_monoid_eqalgebra : monoid_eqalgebra.
  use make_eqalgebra.
  - exact (monoid_algebra M).
  - exact is_eqalgebra_monoid.
Defined.

End Make_Monoid_Eqalgebra.

End Eqspec.