Mathematical foundations of statistical mechanics