Magmas, Monoids & Groups
A magma <G,*> is a pair consisting of a set G and an operation * from G×G→G. A group is a magma with the following three additional properties:
 G1. If f, g, h are three elements of G then (f*g)*h = f*(g*h).
 G2. There is an element of G, called the identity element, and which we shall denote by e, such that for all g in G e*g=g*e=g.
 G3. For each element g∈G there is an element, denoted g^{1}, or (in plaintext g^1), and called the inverse of g such that g*g^{1}=g^{1}*g=e.
If a magma <G,*> has property G1 and G2 without having property G3 it is called a monoid. In any monoid <M,*> there is at least one element, namely e, with an inverse (since e*e=e e^{1}=e). Any element of M with an inverse is said to be invertible. Note that if g is invertible with inverse g^{1} then g^{1} is also invertible with inverse g. In any group or monoid, an invertible element g such that g = g^{1} and g ≠ e is called an involution.
If <G,*> only has property G1 it is called a semigroup. The theory of monoids and of semigroups is very similar since if <G,*> is a semigroup without an element satisfying property G2 we can convert the semigroup <G,*> into the monoid <G',*'> where G'=G∪{e} and *' G'*G'→G' is the operation defined by g*'h=g*h if both g,h ∈G and by e *' g = g' * e = g for all g ∈ G' otherwise.
When the operation * is understood it is common to suppress the notation <G,*> and to refer to the magma simply as G, and to denote the product of two elements g, h by gh rather than g*h. However, it is important to remember that a set G can be a magma for more than one operation, as for example in the case of ordinary integers: <Z,+> is a group, while <Z,×> is a monoid, but not a group.
Uniqueness of Identity Element and Inverse
It is easy to show that in any monoid the identity element is unique, i.e. that e is the only element such that e*g=g*e for all g∈G. Similarly for groups it is easy to show that for any g in G that f*g=e implies that f=g^{1}:

Suppose f*g=g for all g. Then
f = f*e (by G2) = e (by assumption).
 Suppose f*g = e. Then f = f * e = f * (g * g^{1}) = (f *g) * g^{1} = e * g^{1} = g^{1}. Here we have used property G3. In a monoid it is possible that there might be pairs of distinct elements f, g such that f*g = e without either f or g being invertible. However the proof above shows that if g is invertible then f=g^{1}, and a similar proof shows that if f is invertible then g = f^{1}. Again a very similar proof shows that if we can find f and h such that f*g = g * h = e then g is invertible and f = h = g^{1}.
In any group, not only is e the only element such that e*g=e for all g, for all g∈G it is the only element such that x*g = g. For:
x = x * e = x * (g * g^{1}) = (x*g)*g^{1} = g * g^{1} = e.
However, in a monoid there may be pairs of elements x,g such that x*g=g or g*x=g but where x is not e. Given such a pair of elements an the proof above can be used as a proof by contradiction to show that g is not invertible. On the other hand it can happen that for an invertible x there is some noninvertible g such that x*g = g.
Although we are here using e to denote the identity element, given some particular G we may well wish to denote the identiy element some other way. For example in the group <Z,+< 0 is the identity element, while in the monoid <Z,×> 1 is the identity element. By analogy 0 or 1 is often used to denote the identity element in other groups using + or × as the symbol for the operation.
Abelian Monoids and Groups
In any monoid we have that e*g=g*e for all g∈G. However, in general g*h ≠ h*g.
If the operation * has the following additional property:
G4 For all g,h∈G g*h = h*g
Then <G,*> is said to be abelian. In this case the operation * is usually named +, and the inverse of an element g is denoted by −g. If for two distinct elments g,h of a group or monoid we have g*h = h*g then the elements are said to commute.
Submonoids and subgroups
Suppose <G,*> is a monoid or a group and H is a subset of G containing e such that for all g,h in H g*h∈H. Then using the same symbol * to denote the restriction of the function * to H×H <H,*> is also a monoid, and is called a submonoid of G. The caveat that H should contain e is important if <G,*> is a monoid since otherwise it would be possible for <H,*> to be a monoid with a different identity element from G. In the case where G is a group the caveat is unnecessary because the identity element for G is the only possible candidate for an identity element.
If in addition <H,*> satisfies property G3, then it is called a subgroup of G. Any monoid has at least one subgroup  the single element set {e} is a subgroup. In any monoid the set of all invertible elements also forms a subgroup, since if f and g are both invertible then so is f*g and g^{1}*f^{1} is the inverse.
Just as a monoid that is not a group can contain a subgroup, a group can contain a submonoid that is not a group. For example <Z,*> is a proper submonoid of <Q{0},*>
An important subgroup of any group G is the set Z_{G} for which for all g∈G;,z∈Z_{G} z*g=g*z. This subgroup is called the centre of G.