structure
, with five fields. Note that We can also separate property from data and implement first the type of pointed magmas, whose terms are triples
structure PtdMagma where
carrier : Type
op : carrier → carrier → carrier
neut_elt : carrier
In this approach, we could implement the properties of pointed magmas using type classes, so that we can instantiate them on concrete types. We probably will not need to implement monoids in this way.
inv
is a proof of the proposition Due to the previous remark, a group is often implemented in the following way.
structure Group where
M : Monoid
ι : M.carrier → M.carrier
inv : ∀ x : M.carrier, μ x (ι x) = M.elt ∧ μ (ι x) x = M.neut_elt
Note that this implementation does not include an existential quantifier, but carries more data (namely, the map ι : M.carrier → M.carrier
).
Recall that we can write a monoid
structure InvElts (M : Monoid) where
elt : X
inv : X
isInv : μ(elt, inv) = e ∧ μ(inv, elt) = e
Then we can implement the map
def invMap {M : Monoid} InvElts M → InvElts M :=
fun ⟨x, y, p⟩ ↦ ⟨y, x, q⟩
where