The decay of a proton to a neutron outside the nucleus is not possible because a particle can not decay to a state of greater mass. Inside a nucleus however, the situation is different, as the binding energy of a nucleus provides the necessary energy to compensate for the neutron-proton mass difference.