Another way to say "sleeping at night is for dreaming" is "Dreaming is a function of nightly sleep."