Exact formalism for the quench dynamics of integrable models