The Gift

A young American computer engineer (Shane West as Max) acquires a mobile phone that receives strange text messages. First they encourage him to miss his flight which crashes soon after takeoff. Then the messages direct him to buy a certain stock, which increases by 313%. Next, the messages direct him to a hotel/casino in Prague to gamble. He first wins one-hundred thousand Euro on a slot machine and bets the entire amount on a hand of blackjack, which he wins. Max then has an altercation with a beautiful woman (Tamara Feldman) and her jealous boyfriend in the hotel corridor, where he is knocked-out, and his mysterious phone is apparently scanned. Max wakes up with the smiling woman, Kamila, and asks her out for a drink.
To further his new-found career in gambling, Max enlists the aid of a Russian cabbie/apparent e-gadget enthusiast, Yuri (Sergey Gubanov), who outfits him with a text-to-voice earpiece to wirelessly receive his anonymous and lucrative text messages. He then hits the 3 million Euro jackpot on a slot machine but runs away when casino security led by John Reed (Edward Burns) attempts to detain him. FBI Agent Dave Grant (Ving Rhames) interrupts the chase and handcuffs Max to interrogate him about the phone. Frightened, Max is unable to provide any information.
At this point, Agent Grant contacts Raymond Burke (Martin Sheen) of the NSA, apparently monitoring Max because of messages from an omniscient communication surveillance computer system known as Echelon. These messages have been responsible for the deaths of several Americans, most recently a Pentagon IT specialist. Burke recently lost a battle to pass a bill in Congress to allow Echelon to be upgraded by being uploaded into personal computers worldwide. Burke eventually decides that Max knows too much and must be eliminated; however, Reed and the beautiful woman from the hotel â now revealed as Reed's associate â come to Max's aid and spirit him away to Moscow. There, Max reconnects with the techie Yuri to get his help to discovering who is sending the messages. Yuri believes that the messages are coming directly from the computer itself, and that the system has somehow become self-aware and autonomous. Max and Reed don't agree but flee when more armed men arrive at Yuri's apartment. A car chase through Moscow ensues.
The chase ends with Reed outmaneuvering and blowing-up the pursuing cars led by Agent Grant, escaping injury; nevertheless, Max inflicts some payback for their previous encounter. Grant, who now receives threatening texts, asks Max to help to stop Echelon. Max receives another text, instructing him to return to Omaha, Nebraska, where he first worked as a computer security engineer. Max, Grant, and Reed all fly home on a military aircraft.
After arrival, the group finds a sealed-up bunker-like structure with a cache of servers and a high-end computer system that Max helped install years earlier and is revealed to belong to another victim of Echelon's messages - the same person whose credit card was used to send Max the phone. Max starts up the bunker's computer and is instructed via text to fire up the servers to connect them to the network for Echelon to download itself into the bunker's computers and to begin a countdown to replicate itself across the world wide network. Agent Grant calls Burke at the NSA to inform him; nonetheless, Burke wants the Echelon in the global network in the interests of US national security. Meanwhile, Max fails to stop Echelon's replication countdown, until he takes the idea of using the computer self-learning ability (also in 1968 Star Trek episode The Ultimate Computer and in 1983 WarGames). Max asks the computer about its primary purpose, and it replies that it aims to defend the US as defined by the Constitution. Max asks the computer to search for threats to the US Constitution. A lot of articles appear concerned about the recent attempts to secure Congressional approval to upgrade Echelon, underlined as a grave threat to personal freedoms. When the download is complete, Echelon shuts itself down, "learning" that it itself is the threat.
In the end, Agent Grant and Reed send Max and Kamila to Paris while Burke is subpoenaed to appear before the Senate intelligence committee. In the final scene, back in Moscow, the techie Yuri is unveiled as a Captain in the Russian Security Service. He is commended for his actions and says they will soon start it again, but they have helped the Americans to make the right decision for the time being; "I want to believe so." he cryptically adds, turning off his mobile phone.

Question: The computer's primary purpose is to defend what?
Answer: Constitution