Hamiltonian formalism