Wiles did not prove fermats last theorem

That’s not what ad hoc means. If I set out to solve a problem, and I succeed, my solution isn’t ad hoc simply because it was designed to solve a problem. “In philosophy and science, ad hoc often means the addition of corollary hypotheses or adjustment to a philosophical or scientific theory to save the theory from being falsified by compensating for anomalies not anticipated by the theory in its unmodified form.” (Wiki) That’s not what’s going on here.