The premise of this thread is a contradiction in terms, at least here in the UK, and i suspect in most jurisdictions. A mentally ill person who was shown to have committed a crime, and it can be shown they are mentally ill at the time has is not per se a criminal, the reason is, is that for all crimes there are two elements, the criminal act and the criminal mind ( the actus reus and mens rea); therefore as this person whilst undoubtedly committing the act, they lack the second element, the criminal mind.
What Baba says is spot on too, there are people in the UK who will never return to society because their mind is so disturbed that they will always pose a real danger to society.
Why do we want to punish mentally ill people anyway, is it not better to treat them? If they do not respond to treatment, they should remain in a secure hospital.
Regards David