We can't prove what is real but we can get a very high level of confidence the same way we get to know there is a reality, through inter-subjectivity, it is to say confronting our perceptions with that of others and agreeing on what is perceived in common.
Is there a stone in the middle of my backyard? Maybe I am just dreaming the stone, but I can ask my neighbours. If they can see it, touch it, and confirm my own perception of it, we can agree on the idea that there is something independent of each of our mindminds we can call reality, and this stone is part of it. At the very least, since we all agree on the existence of the stone's reality, we can organise our lifelives around it.
Of course, there are a couple of assumptions here:
- I am not dreaming my neighbours altogether. This idea is called solipsism and is a well known dead end of philosophical inquiry, because once one trusts nothing they can see, one can't inquire anymore. What is more, people who advocate for solipsism usually live their lives as if the people around them wereare real, not putting their money werewhere their mouth is for obvious survival reasons.
- We are not collectively making a mistake. Maybe the whole neighborhood is wrong and the stone is a turtle after all, or maybe I induced a collective hallucination by suggesting the stone is there in the first place. This case happens very often, as what was once consensus appears to be wrong as research progresses. This problem has no solution but the reasoned openness to contrary evidence and to challenges to the consensus.
Inter-subjectivity has been a cornerstone of the scientific method, as Inin order to get some traction a researcher needs to get their results validated by their peers. Experiments are accepted if they can be reproduced even by sceptics, in the same way my stone was accepted after all the neighborhood got a chance to touch it.
In the end, most of what we know is based on inductive reasoning and therefore subject to revision after the discovery of a "black swan". It requires some degree of trust, but since it appears to work so far it looks like a safe bet.