Is someone who solely contributes negative feedback to a paper considered an author?
To moderate Yemon Choi's comment:  yes.  Your first assertion is that A and B are collaborating, which means they should be co-authors, unless one actively backs out.  

For a mathematical project, it's easy to have lots of ideas but not enough time to pursue them all to see which (if any) work.  If someone can shoot down ideas and tell you they definitely (or with high likelihood) won't work, this can help put you on the right track.  So in your situation I would say B was instrumental in finding a correct solution.  

(In a somewhat different abstract scenario where B dismisses some approaches to a problem that A suggests, and B does not otherwise actively work on the project, it may depends on the situation and they should have a discussion about whether B is a co-author or not.  And some people will have different opinions about the same situation, e.g. RS versus A in the RSA example.)

In general in a mathematical collaboration, if there's one key idea it's unlikely that both collaborators arrive at it together.  Maybe through discussion they enhance each other's understanding of the problem, and then one will have the key idea and the other will encourage/validate it.  That doesn't mean was the other person was unnecessary, even if you can't
pinpoint parts of the final paper as being "their contribution."

(And if collaborations became competitive to the point of dropping co-authors just because the didn't see the final solution first, who would want to collaborate?)