If you have advanced Alzheimer's or some other state of severe mental impairment, you basically are a living corpse. Sorry, but when you can no longer reason or communicate with others, you have ceased being human and started simply being a hunk of flesh that happens to be able to convert oxygen into carbon dioxide. The person you were before - the person your spouse married - is gone.
That seems like overkill. You "have ceased being human"? Is there really a bright line between being a competent adult and being a vegetable, or is there a continuum along that line? Who decides when you've crossed it, and what criteria do they use?
Also, how is this handled in cases where people are mentally handicapped from birth? Are they deemed not fit to consent to sex in their entire lives, and on what criteria is this judgment made?