The Matrix defense is the term applied to several legal cases of a defense based on the Matrix films where reality is a computer generation—simulism—and that the real world is quite different from what reality is perceived to be.
In using this defense, the defendant claims that they committed a crime because they believed they were in the Matrix, and not in the real world. This is a version of the insanity defense and considered a descendant of the Taxi Driver defense of John Hinckley, one of the first defenses based on blurring reality with films.
Regardless of whether the defendant believes that they were living inside the Matrix, this defense has been used successfully to put users inside of mental-care facilities instead of prisons:
References
The Matrix defense Wikipedia(Text) CC BY-SA