Variational approach to solids and the hard sphere melting law