Congruence semimodular varieties I: Locally finite varieties