Ergodic theory and statistical mechanics