The movie Total Recall 1990 was inspired by the book "We Can Remember It for You Wholesale" written by Philip K. Dick whose leading role was played by Arnold Schwarzenegger. The storyline is about a trip into a virtual world in order to fulfil an emotional need which is the need a man has to be a hero.
In this film the protagonist pays for an "ego trip" as a secret agent. This virtual world is created by AI machine whose result is sensory undistinguishable from real life (mind the blue sky on Mars) and as the story unfolds the main character is led to believe that he is not a real person but a just fabrication whose real identity has been erased. As technology to remove memories is available and new fake ones can be imprinted and the simulated virtual world is totally realistic the main character can never really know if his memories are real or whether he is a spy for "the agency" who volunteered to have his memories removed nor if he is just an ordinary construction worker experiencing a computer simulation. He cannot even be certain about the idea he has of himself (ego) because it could have been created by the AI machine.
Concepts such us the illusory nature of reality (Veil of Maya) and how ego, perception and mind blind you from who you really are(consciousness) has been debated in Hinduism and Buddhism for millennia. eg "Pususha or spirit in Samkhya". ref here
Some religions and new age sects talk about pre-birth soul contracts or even you having chosen your experiences and fate in your present life as a writer or god of your of own life for hidden spiritual purposes, then again if an entity (yourself, god, demon, archon, alien, AI, etc.) can create illusory realities and might remove your memories reincarnation after reincarnation just like in the movie you cannot really know because you have to trust what that entity or your forgotten ego says which could be deceitful too. If you could voluntarily and permanently ignore and a decision you made (eg. reincarnate as a serial killer) and memories and reality could be rigged how can you trust that you made that decision in the fist place? (paradox)
According to some Buddhist traditions when Buddha attained enlightenment he was able to remember his past lives and capable of knowing his own and other people's karma and its consequences in the present time, however it's not clear why he was so sure all those previous lives were real and so was karma because they could be potentially illusory, artificial and deceitful in nature as well.
Philip K. Dick was no amateur to these philosophies besides he was among the first few people to pose the simulation hypothesis (1977) as real ref here. He was not only interested in eastern philosophies but in shamanism, psychedelic drugs and experiences under hypnosis. He understood that if all perception can be rigged so can all systems of believes therefore all religions and ultimately all knowledge.
Was he inspired by any other religion or philosopher or it was just his imagination and personal experiences? Any references to this would be appreciated.
"You're nothing! You're nobody! You're a stupid dream." Cohaagen
"A man is defined by his actions, not his memories." Kuato