If we do computational work with algebras (for example in noncommutative geometry) we need a good way to represent our algebras on the computer. Generators and relations allow us to do this.

Before going further, I should say what an algebra is. Fix a base field k. A k-algebra is just a ring that has k as a subring If R and S are k-algebras we say that a function f:R-->S is a k-algebra homomorphism if it is a ring homomorphism and also f(a)=a for all a in k. For example the polynomial ring in two variables k[x,y] is a k-algebra.

Now we define generators. A subset S of an algebra R is a generating set for R if every element of R can be written as a finite sum of terms of the form

as1...sn with a in k and s1, ..., sn in S.
For example, {x,y} is a generating set for k[x,y]. Now we know that the polynomial ring is commutative so as well as these two generators we also have a relation
xy - yx = 0

Everything we know about the multiplication in the polynomial ring can be reconstructed from these generators and the relation. For example, we know that every element of the polynomial ring is a finite sum of terms of the form

axiyj
We can see this by first using the generating set {x,y} to write an arbitrary element as a sum of terms each of which is a product of various xs and ys in some order. Then we can use the relation to shuffle all the xs to the left. For example
6 + 3xyxy + 7yx = 6 + 3xxyy + 7xy = 6 + 3x2y2 + 7xy
Furthermore to mutiply to polynomials together we only need to understand how to mutiply two monomials
axiyj.bxmyn
But using the relation again we can shuffle the xs to the left to get the result (abxi+myj+n).

In other words we have discovered that mutiplying in the polynomial ring is completely understood once we have the generators and relations. We would like to formalise this and generalise it to. For this we need the idea of the free algebra. Roughly speaking this is what you get if you just have generators but no relations.

Suppose we are given a set X. A word in X is a formal expression of the form

x1...xn : each xi in X
We write k<X> for the vector space with basis consisting of all words in X. By convention we write 1 for the empty word. If we have two words w and w' then we can form a product by w.w'=ww'. i.e. just put one word after the other. Since an arbitrary element of k<X> is a linear combination of such words we can extend this product to all of k<X> in a natural way. It is easy to see that this makes k<X> into a k-algebra. This algebra is called the free algebra on X. Let i:X-->k<X> be the natural inclusion that maps x in X to itself.

Lets think about a couple of examples. First of all, to simplify notation, if X={x1,...,xn} is finite we write k<x1,...,xn> = k<X>. On with the examples. If we just have a single generator for the free algebra then k<x>=k[x]. For, by definition, the elements of k<x> are linear combinations of the words

1, x, xx=x2, xxx=x3, ...
But when we have two variables the free algebra is a much more exotic beast. This time k<x,y> has a basis consisting of all the words in x,y. That is
1, x, y, x2, xy, yx, y2, ...
So we can see that this is definitely different from the polynomial ring in two variables. Because yx is not the same as xy, this ring is noncommutative. Notice however that there is a very natural surjective k-algebra homomorphism f:k<x,y>-->k[x,y]. This is part of a much more general result.

Theorem Start with a set X and let i:X-->k<X> be the natural inclusion. If h:X-->R is function and R is a k-algebra then there is a unique k-algebra homomorphism f:k<X>-->R with fi=h.

Proof Although this is not needed for the proof, note that this is an example of a universal property. So that i is uniquely determined up to unique isomorphism by this property. The proof itself is fairly obvious. A typical element e of k<X> has the form

e = a1w1 + ... + anwn : ai in k and wi are words in X.
Lets's say that
wi=xi,1...xi,mi : xp,q is in X.
Define
f(e) = a1h(x1,1)...h(x1,m1) + ... + anh(xn,1)...h(xn,mn)
It's clear that f is a k-algebra homomorphism and has the required property.

So now we can say what we mean by generators and relations. Given a set X let S be a subset of k<X>. Then the algebra with generators X and relations S is the quotient ring k<X>/I, where I is the ideal of the free algebra generated by S. For example, it's not too hard to show that the polynomial ring in two variables is isomorphic to the algebra given by generators x,y and one relation xy - yx. Another example, is the Weyl algebra which is given by two generators x,y and one relation xy - yx - 1. For some other examples that arise in mathematical physics see noncommutative geometry.

We can similarly think about free objects, and generators and relations in other categories. For example, see generators and relations for groups.