A common AI technique is to use * productions* or * rewrite rules*
to restructure symbolic expressions. The rules we
need are some basic identities from algebra:

x + 0 => x 0 + x => x 2 + 3 => 5 (fold constants) x * 0 => 0 0 * x => 0 x * 1 => x 1 * x => x 3 * 4 => 12 (fold constants)We can implement these transformations directly as programs.