Calculate patches between two Prolog terms