Memoization is the process of noting down the results of complicated
computations or inferences that might be needed again later, so that
it is not necessary to re-compute them if they are needed. In Prolog
this can be done by asserting the fact that has been computed. It is
often the case that it is necessary to use
asserta in order
to ensure that the asserted result is accessed before the
rule that would be used if the asserted result were not available.