The decay of a proton to neutron is possible only inside the nucleus because the mass of proton is less than the mass of neutron. This mass difference is compensated with the binding energy of nucleus. This decay is not possible outside the nucleus because particle cannot be decayed into the greater mass.