How to deal with a student who most likely has a mental condition, and keeps arguing with me in class?
I have responsibility for students with alternate needs within a Computer Science department and thus have professional experience of the situation you describe. It is not uncommon in our subject.
Our experience is that computing attracts a higher proportion of students on the Autistic Spectrum than do other disciplines. We are operating with about (my personal guess) 2-3% (of total cohort) diagnosed and perhaps double that number undiagnosed.
Some of these students are often not aware of the rest of the class being present and treat teaching as a personal one-to-one dialogue with the teacher. They act as they would sitting with you across a desk. Sometimes it is more extreme and the social norms and boundaries of even working one-to-one are not clear to them. Although, as a spectrum condition, each person may be different, it is common that they wish to understand every point of minutiae before they can build the big picture understanding; becoming detailed obsessed is often a common trait. This leads to question after question as a form of quest.
You should seek advice from a more experienced professional in your institution. It is likely that the student's condition is known, but details are often considered confidential and perhaps not shared with you, because that is what the student may wish. The student may be receiving support elsewhere, perhaps in the form of mentoring. If that is the case then the mentor may be able to assist in explaining the social situation to the student and also give you guidance on how to reply.
Sometimes such students are not diagnosed with any specific condition and are not receiving support as it has never been needed. They are likely to have achieved high grades in earlier studies and the good results have propelled them through to your class.
For a student who is unaware that their behaviour is different from others in their class it is more difficult to handle. I ask such a student to speak to me in a one-to-one appointment in my office. I do not assume that they have any named condition, as this is not really relevant. I just talk to them to explain how lectures work, clarify my role and how I can answer questions. I often have to explain, sometimes in great detail, what makes a good verbal question in class, what makes a good verbal question, what makes a good written question for email, what makes a good question for the class VLE, what makes a good question for StackExchange and so on. It is often the case that no one has ever explained how information is obtained. It does take a degree of tact and experience to do this, which is why I suggested seeking more experienced advice.
Remember, some of the achievements in our subject have been made by people who others found difficult to work with. Look at the movie "The Imitation Game" and you can clearly see (in a fictionalised portrayal) Alan Turing is shown displaying tendencies similar to those you describe. I'm sure if you had a current student with similar attributes you would have been pleased to have had the opportunity to have someone so similarly gifted in your class.
As a fellow TA, I would definitely recommend that you discuss this issue with the professor in charge of the course as taking matters into your own hands without his knowledge (especially with special cases like these) could cause problems. When discussing the issue with the professor, I would refrain from using the phrase "mental condition".
Note: This started out as a comment to vonbrand's answer, but grew a bit too long, so I turned it into a separate answer of its own.
While asking students to defer any distracting (irrelevant, too advanced, based on a quirky misunderstanding, etc.) questions until after class can indeed be a good way to deal with such interruptions in general, it may not work very well for some students with autistic spectrum traits or other behavioral patterns like those described by the OP.
Not only can such strongly detail-oriented students get fixated on the apparent error, and become unable to process further material until it has been resolved, but if they also have poor social awareness, they may not even find it easy to realize that others in the class don't necessarily share their inability to get past the (apparent) error. From their viewpoint, they may actually feel that they're doing the whole class a favor by insisting that you resolve the issue now, so that it won't undermine the validity of everything else that you're about to teach.
(It should be noted that, in some cases, this could actually be a valid reason to interrupt your presentation. If you were presenting a deductive argument, following a novel line of reasoning that had not already been independently verified many times, and if there really was an error in one of your early steps, leaving it uncorrected could indeed cause everything built upon the erroneous step to be meaningless. This is, of course, not a very typical scenario in undergrad teaching, but it may seem that way to the student who is new to the subject, and having a hard time accepting your presentation of it.)
What might help, if your problem student seems unwilling to defer their questions until a more suitable time, is speaking with the student one-on-one and suggesting that, if they spot what they think is an error, they should write down a note of it (to let them switch their attention to other things), briefly mention it to you, and then try to set it temporarily aside and concentrate on other things until you both have time to look into the matter more closely (which might be e.g. after class). Do reassure them that, while you don't have unlimited time especially during class, you will at some point (it may be helpful to be specific here, e.g. reserving up to 15 minutes after class for such things) at least take a look at any potential mistakes they've noted down.
You might want to also suggest that, if the student still thinks there's a mistake even after you've looked into it and found none, they should go over it using their textbook at home, carefully prepare a written analysis of where the error is and what the correct answer should be (with test cases, for a programming class) and submit it to you and/or your professor. (Obviously, get your professor's OK before involving them here!)
On one hand, this will help reassure the student that the issue they noticed will not get forgotten or swept under the carpet. Also, the odds are that, if they do carry out that analysis, they'll eventually find their own mistake without you having to spend excessive time and effort chasing it down with them, quite likely producing less stress for both of you.
Finally, if the student does find and document an actual mistake, do remember to thank them, note the mistake during the following class, and briefly present a corrected version of whatever material the mistake was in. In the (perhaps unlikely) case that this does actually happen, it will help raise the student's confidence that you're not trying to hide or brush off any actual errors in your presentation.