Source: https://www.iro.umontreal.ca/~lapalme/intro-prolog.pdf