I am an early mathematics researcher. Last year I was approached by a contemporary for collaboration. We started discussing the problem with possible approaches, I read all literature related to the problem. I had some failed attempts. But it was him who eventually solved the problem. And the level of creativity from his side, never came from mine. I wanted to ask if I should back out and ask him to publish it alone?
I believe that if you contribute ideas towards the solution and also take an active part in writing the paper, you should be a co-author.
In your case, you believe that your discussions didn't contribute to the solution. However, often false-leads are crucial steps in solving the problem- and hence your contribution was perhaps not as trivial as you think.
I would suggest you to volunteer to type up the paper. That way, you shall understand the proof better, and also have a nontrivial contribution towards the final form of the paper. While typing, try to think if the proof can be "polished". Or maybe, you can get some nice corollaries of the main theorem. Or, some examples where your theorem applies. Often times, the main theorem is just the "start" of the paper- you can still get more results by applying the main theorem to various examples. This part, in my opinion, elevates a paper.
Finally, don't be too harsh on yourself regarding your "contribution" as yet. You still have time to contribute more to this project. Good luck!
Let me suggest a slightly different approach. Tell him that you understand all the work is his and that you don't expect co-authorship and will understand completely if he wants to do that. You could also say that you would appreciate any acknowledgement in the paper for any contributions you might have made.
In other words, make a statement about your understanding, not a question.
It would be good if you can keep the lines of communication open for the future. Some future collaboration might be more fruitful.
Edited to add, based on a comment stream.
This is valid, I hope, in the case in which you made no real contribution to finding the answer amongst yourselves, but not otherwise. Other answers here explore some of the subtle issues of math insight and should certainly be considered.
There is a lot more to a mathematical paper than just the new ideas. There's also the work that goes into exploring the avenues that never lead anywhere, surveying the literature, checking that the argument is correct, writing the argument down, etc. A rule of thumb that I've heard repeated multiple times is that each author should contribute at least 10% of the work done in the paper (although, in the long run, it should even out). It's perfectly possible to have this level of contribution without being the one who came up with the new ideas, so - assuming your collaborator is willing - there is nothing wrong in publishing jointly. If they do prefer to publish alone, though, you shouldn't insist.
It is very difficult to say, when working on a mathematical problem, how much each person contributed. It is only through failed attempts that one reaches a solution to any problem which isn't completely trivial.
In the comments, @CaptainEmacs asked you a good question: "Did your failures contribute to your partner better understanding the problem? Or were they just abortive without real contribution?" You answer was that both things are true. But, so long as your failed attempts contributed to your partner's understanding of the problem, you certainly deserve to be a co-author.
Observe that this is very much an issue of culture. These things are different between different fields. In mathematics, what you describe is usually considered enough to be a co-author. But it might also be different in different subfields of mathematics, and in different places in the world. I would suggest consulting with your PhD advisor (if you are still on good terms with them), or some other older researcher that you feel comfortable asking such questions. And then I would discuss this with your partner.
I also agree with @DarthVader that it's a good idea to put it more work on the writing of the paper, to feel less "guilty" about this. But it's just the way it is; the work in joint papers is very often not divided 'equally'.
To summarize: It seems to me like you very much deserve to be a co-author. I would discuss this with someone with more experience than you (perhaps your PhD advisor), and then discuss this directly with your partner.