> I mean bot boxes could be open, with the treasure being in green box at all but it could be all dream!
Have you studied Descartes? "I think, therefore I am" is the philosophical answer to thta problem. It's the only certainty that can not be invalidated by untrustworthy perceptions.
No, because dreaming of thinking is a way of thinking. I'd still be certain of having experienced those perceptions, even if I can't be sure whether it's a dream or not.