Was there a time in mathematics when a counterexample was wrong? I am doing an essay on the knowledge of Mathematics and how we know what we know to be true. I was just wondering if there was an example in mathematics of some theorem that was disproven by a counterexample, but then the counterexample was wrong and the theorem stayed true after all?
Thanks for your time. :)
 A: A very famous and important example of a counterexample that was found to be defective occurred in set theory.  As Georg Cantor developed the theory of infinite sets, he proved that some infinite sets are larger than others, by showing that there was not a one-to-one function between them.  Most famously, he showed that the real numbers $a\leq x\leq b$ are more numerous (have greater "cardinality") than the natural numbers $\{1,2,\ldots\}$.
However, he also proved a more general statement, Cantor's Theorem—that if $X$ is a set (any set, finite or infinite), and ${\cal P}(X)$ is the set of all subsets of $X$ [we call ${\cal P}(X)$ the "power set" of $X$], then ${\cal P}(X)$ has a greater cardinality than $X$.  Crudely put, this says that any set has more subsets than it has elements.  That is certainly true for finite sets; a set with $n$ elements has $2^{n}$ subsets, and $2^{n}>n$ for all integers $n\geq0$.  However, Cantor showed it was true for arbitrary sets, even infinite ones.
There were many objections to Cantor's theory of infinite sets, and one important objection was to the theorem that ${\cal P}(X)$ has a greater cardinality than $X$.  This seems to be impossible, because it cannot be true of the set of all sets (usually denoted by ${\bf U}$, for the "universe" all sets).  For, if ${\bf U}$ contains all sets, then it necessarily contains all elements of its own power set ${\cal P}({\bf U})$, meaning ${\cal P}({\bf U})$ cannot be more numerous than ${\bf U}$.
The resolution of this apparent paradox is that the supposed universal set ${\bf U}$ cannot exist, at least not as a set.  (The universe ${\bf U}$ does exist as a more general kind of object, a proper class.)  This was not evident in Cantor's approach, since he did not provide a axiomatic basis for his set theory.  (His approach is sometimes therefore known as "naive set theory.")  However, with the development of a rigorous foundation for set theory, based on axioms (such the Zermelo-Fraenkel axioms), it became clear that the object ${\bf U}$ is simply not definable as a set in the theory.  While this might seem to be a problem, since it means that a rather natural-seeming object cannot exist, it is actually extremely advantageous, since it means that the counterexample to Cantor's Theorem does not actually exist, leaving the theory (so far as we can tell) consistent.
