Well, presumably, the prosecutor would have some reasoning for the intent to kill the person. At which point, it would fall on the defense to counter with the proof that the defendant was sleepwalking.
Point is, for the prosecution to have to prove in each and every case that the defendant was not sleepwalking while allegedly committing the crime would be ridiculous, and the burden of proof would fall on the defense.
Yes; I was just explaining how/why someone who killed someone while sleepwalking would correctly plead "not guilty" to whatever charges were brought even if they did know they had done it.
And legally, the sleepwalker wouldn't have a burden of
proof, per se, the defense would only have the "burden" of casting reasonable doubt over the prosecution's charges (although practically, with something like this, such testimony in favor of sleepwalking
would need to be pretty damn convincing).