I suppose if a person wanted to blame their crime on sleepwalking then they should be allowed to do so. However, I do not think that changes their involvement in the crime. Asleep or awake, people should be punished for the crimes they committed. It sounds like a bad defense and I see it as such.
I think Sleepwalking can be used as a legal defense in certain circumstances. Sleepwalking needs to be verified by a certified medical authority. There must be documentation or a history of sleepwalking with that person or family. Just getting sleepwalking all of a sudden, especially when a crime is involved it not acceptable.
I have read on multiple occasions of people who did stuff while sleep walking. The phenomena is real, it usually has to do with sleep medications or some kind of sleep disorder. I don't think it is a wide spread thing though. People do sleep walk, but they usually don't go on a crime spree during their sleep walking.
I assume this question is in regard to the USA? I personally believe that individuals who sleep walk and then perform a crime should have this as their defence. They are unaware of what they are doing, they do not have the "guilty mind" or intention to commit the acts that they do.
This can actually be used as a defence elsewhere. In Britain, should you even commit murder in your sleepwalk, you are entitled to the defence of "insanity" as it covers sleepwalking. Insanity here does not require the defendant to be medically insane but merely to be unaware of their actions/not know what they are doing is wrong at the time of the offence due to a "disease of the mind" (this disease being a legal term not a medical term also).
But to conclude, it is wrong to punish people who have no intention or awareness of their crime. They may need serious medical help, but punishment is not the answer so yes, if should be a legal defence.
I do not think that it should be allowed as a legal defense, but I do think that it should be taken into consideration during the trail. Sleep walking is real and some do execute activities that they may or may not remember. Although, I do not think that it should be the complete legal defense of a person in any way.