The logic of time in the universe