Fixed how Prolog terms are built for substitutions.
Updated tests to expect new output syntax from effect inference.