>This is another story by Philip K. Dick that served as a basis for movie. The movie was called “Total Recall”. The story basically matches the first part of the movie. It starts with the main character, Douglas Quail, dreaming of a trip to Mars. Since he cannot afford it, he decides to get a false memory of such a trip implanted in his head.
To make the memory more exciting he asks that he remember the trip to Mars as a secret agent. Unfortunately during the memory implantation process he discovers that he in fact did go to Mars as a secret agent, and the life he is currently living is based on an implanted memory.
At this point the story diverges from the movie. There is no trip to Mars and big shootouts with the bad guys. Instead once the police (called the Interplan) discover that he remembered his trip they attempt to kill him.
However, he eludes them and negotiates a settlement, which is to have his most deepest desire implanted as a memory instead of the real memory of the trip to Mars.
You’d have to read the story to check the clever twist that this second attempt at memory insertions leads into..