The Doctor is very observant. Back in page 12 he learned how the device was powered. He learned that Luna and Celestia had the power to raise the moon and sun from Derpy a few pages before that. From there he deduced that Luna is obviously more powerful than a regular unicorn. Of course he didn't know for sure in this case, but that never stops the Doctor from doing crazy things as long as they have a chance of helping the cause.