Source: https://www.cl.cam.ac.uk/teaching/1617/DiscMath/FormalLanguages.pdf