We think of mathematics as having little to do with the real world. If it is a “science,” it is the science of abstract entities like numbers or sets. Proper sciences look at some portion of reality and seek to understand it, ultimately using experiment to distinguish between possible theories. A branch of mathematics may theorize about some (not-real) object, but it can’t run experiments to compare an idea with the external object itself — there is no external object. Then what does it do instead?
Mathematicians use proof. A mathematical proof is a sequence of steps following agreed upon rules for validity that demonstrates the truth of its theorem. A proof is effectively a computer program, but most proofs are not written formally or checked automatically (yet). Instead, the thing that checks if a proof works is the community of mathematicians examining it. What rules of inference are valid depends on the standards and goals of that community — but it is not as arbitrary as that might sound. Just as a group of scientists cannot decide on a whim that their experiments should be held to a lower standard, mathematicians are bound to higher rules of validity. You cannot decide that “It’s true because I said so.” (Proof by intimidation?) is valid — or, if you do, don’t expect your results to be accepted by the wider mathematical community. The highest standards that proofs are held to have changed — improved! — over time and will continue to do so.
Despite how it can sometimes feel, this process of proof-checking is not some metaphysical access of a Platonic realm. Rather, it is an experiment taking place in what happens to be a brain.
A scientific experiment is an arrangement of physical matter along with a theory that this arrangement will produce an outcome associated with one model of reality or another, to falsify the models that fail the test.
Once the mathematician’s brain has been sufficiently arranged with theories and prior knowledge, we can test a proof on them. If the outcome is satisfaction that every step of the proof is valid, then we falsify our model-of-the-world that the proof is faulty. (As with any experiment, you should run it independently multiple times for greater certainty.) It feels like verification, but when you exhibit a successful proof, you are really falsifying the hypothesis that there is no successful proof.
In this way, knowledge is accumulated. The “external” medium that mathematics checks itself on is still internal to the mathematician’s mind. Everything that exists does so here in the physical universe — including the brains of mathematicians. There is still a line to be drawn between the sciences and the myriad branches of mathematics, but it is not as sharp as it looks. They are all fields of knowledge using ultimately-similar methods. Science examining everything that can be examined out in the universe. Mathematics, everything else.