Dealing with unwanted co-authorship requests
Well, of course the young mathematician should simply discuss the matter with the senior mathematician and perhaps the student until they can come to an agreeable arrangement. My advice is that they should all talk about it. Co-authorship is a matter upon which all authors must agree. What other answer could there be?
If it seemed that the professor or the student had little or no contribution, then the young mathematician should say so and inquire why the professor should be co-author, or why the student should be co-author. If there was not sufficient contribution, then the young mathematician should simply say so and there should be a discussion about it. Perhaps the senior mathematician will point out that the contribution was greater than realized, or that there were other aspects of the collaboration of which the young mathematician is not aware. Or perhaps not, and the senior mathematician will agree that the young mathematician should proceed solo.
But apart from the particular situation described in the post, let me now mention several further reactions that I have more generally to the issues about co-authorship that this question raises.
The first and most important thing to say is that collaborative research is one of the great joys of mathematical life, and I strongly recommend it. To discuss a mathematical idea with another mathematician, who can understand what you are saying and who has thought deeply about the very same topic, gives enormous satisfaction and meaning to one's life as a mathematician. Collaborative research is our mathematical social life. For my own part, I am thankful on today, Thanksgiving Day, for the opportunity that I have had to interact with all my collaborators; I have learned so much from them. (See the list of my collaborators.)
Therefore, my advice is that one should seek out collaborations wherever they are to be found. Often, after one has proved a theorem, then in joint work it becomes much better, strengthened or simplified, or a collaborator finds new applications or uses. If someone asks a question and you answer it, then perhaps the mathematics is not yet finished, but only begun. Aren't there further natural questions arising from the result or its proof? This could be the beginning of a collaboration rather than the end of one.
Another part of my view is that one should be relaxed about collaboration and co-authorship. Except in extraordinary cases, the stakes are low. A mathematician seems to get basically as much respect and credit for a result, whether or not there are co-authors on the paper, and so I question whether there really is any meaningful "dilution" as mentioned in the post. It is simply no big deal to have co-authors or not.
Therefore, why not be generous? If someone has made a contribution to your project, even when the contribution is light, then invite them as co-author. Few mathematical collaborations are perfectly balanced contributions, and in most collaborations one person has had a more important insight or made a larger contribution than the other. But so what? Perhaps the co-author invitation will be declined, and that is fine, or perhaps they will join and then proceed to make your result even better. I have had many collaborations where at first we had a result, which seemed fine and complete, but then in writing the joint paper we were able together to improve the result or give further applications, which wouldn't have happened without the joint interaction. I think you will often be surprised.
Another point, as I mentioned in the comments, is that asking a good question in my view is often sufficient for co-authorship. I have several joint papers that arose from someone asking me a question (in some cases on MathOverflow), which I answered, and then asked them to join as co-author. And I've had some the other way around as well. I find it more natural in such a case, however, for the theorem-prover to be suggesting the idea of co-authorship, rather than the question-asker, which is part of why the situation in the OP seems wrong to me.
Another point is that it sometimes happens that person A, perhaps a junior person, asks a question that person B, perhaps a senior person, answers, settling the question; but the situation is that person A simply cares more about it or has a stronger vision of what the result can become than person B, who is not as interested. In this case, the solution is that person A should do the work of writing the paper, with person B as co-author, even though the result may have been due to person B. The point is that person B would not bother to write this paper on their own, but the joint authorship brings the mathematical paper into existence. The result can be a great paper, and I know of many papers following this pattern.
In summary, pursue collaborations; be generous about co-authorship; be relaxed about co-authorship; enjoy joint mathematical interaction; make great mathematics.
If several people work collaboratively on a problem, they all get to be authors even if all the ideas that finally led to the solution came from only one of them. That is a perfectly ordinary situation.
The question then reduces to that of whether the situation described comes under the description of "collaborative work". I think that needs more detail to judge and there will always be a grey area.
If what actually happened was that the Alice said to Bobby "Charlotte and I are working on an interesting problem, namely ..." and then Bobby went away and solved it, I would call that a collaboration.
OTOH, if what happened was that Alice said to Bobby "here is a problem for you" without mentioning that Alice & Charlotte were working on it too, then Bobby has a good case for being sole author. Whether Bobby should insist on that right is another question.
In a practical situation I would recommend a somewhat greater degree of generosity towards a student than towards a seasoned researcher.
Unwelcome requests should be denied. Period.