Exactly. Out ideas can be wrong. We can be mistaken. What we think may not be correct. In fact, it is possible to have full confidence in one's ideas and to still be factually mistaken.This all started with you saying "the ideas in the mind don’t necessarily code for reality."
The question then becomes how we avoid such error. And, the best way we have found is to test our ideas: we *try to prove them wrong* and see which ideas survive such attempts. Only those that survive many repeated attempts to disprove them can be said to have some facet of knowledge (justified true belief).
It is because we can be wrong, even in our most cherished beliefs, that we need to be skeptical and avoid taking *anything* on faith alone.
..but math is not an invention of mankind .. it is discovered .. it existed in the same way 1000 years ago as it does today.
Once again, there is a place for discovery. Once the rules have been *invented* (to adapt to our intuitions), we *discover* the consequences of those rules. Just like in the game of chess: we invent the rules and discover their effects.