A logical account of PSPACE