consistent-histories algorithm