Theory of pion-nucleus scattering lengths