Republican primary voters hate illegal immigration and love Israel. So Donald Trump has combined these two passions into one. “If you think walls don’t work,” he says again and again on the campaign trail, “all you have to do is ask Israel.”

Let’s do that. On the surface, Israel’s “wall” (aka fence/security barrier/separation barrier, I’ll go with the latter) has indeed worked. In 2002, the year its construction began, Palestinian terrorists took the lives of 457 Israelis, according to statistics compiled by the Jewish Virtual Library. After that, the number declined every year. In 2005, it was down to 53. By 2006, it was only 29.

Correlation, however, is not causation. Yes, by 2006, Israeli deaths from terrorism had declined to 29. But in 1999, when the barrier did not yet exist, only eight Israelis died. What occurred in between was the second intifada.

Did the separation barrier end the second intifada? Not really. For one thing, roughly one-fifth of the barrier was never built. Hagai Matar, author of an excellent 2012 series on the barrier, notes that to this day a large section remains unconstructed near the settlements of Gush Etzion. That’s because the Gush settlers will not accept being outside the barrier while international pressure prevents Israel from including them. An even larger section remains unbuilt in the far south of the West Bank, where environmental activists have warned that construction would damage the ecology of the Judean desert.

And even where the barrier is built, Palestinians climb over and break through it. Last year an Israeli defense official estimated that 6,000 Palestinians illegally enter Israel every month, mostly seeking work. “There’s no problem crossing the gaps in the fence and tens of thousands of illegal workers cross it back and forth every day, and there should be no problem getting suicide bombers through with them,” notes Ilan Tsion, who chairs an organization that supports the barrier.

So why did terrorism decline? In part, because Israel crushed the second intifada by force. In 2002, it sent 20,000 troops into the cities and towns of the West Bank to destroy the networks that were producing Palestinian terrorism. These offensive measures, argued Bar-Ilan University political scientist Hillel Frisch in a 2007 study, played a substantially larger role in reducing terrorism than did the barrier.

Even more importantly, Mahmoud Abbas, who became head of the Palestinian Authority following Yasser Arafat’s death in 2004, made a strategic decision to cooperate against terrorism and thus try to prove that a Palestinian state would not threaten Israel. In early 2005, the United States began training a new Palestinian security force, which over the last decade has won repeated praise from Israeli security officials. In 2006, Haaretz’s defense correspondent, Amos Harel reported that the Shin Bet, Israel’s internal security service, saw this “Palestinian truce” as the “main cause for reduced terror.” Among Shin Bet officials, Harel noted, “the security fence is no longer mentioned as the major factor in preventing suicide bombings, mainly because the terrorists have found ways to bypass it.”

But today, Palestinian terrorism is rising again, in large measure because Palestinians believe Abbas’ strategy has failed. For the Palestinians who supported it, security cooperation was never an end in itself. It was a means of moving toward statehood. But after close to a decade of such cooperation, Palestinian statehood is further away than ever.

Benjamin Netanyahu denies that this has anything to do with the increase in Palestinian violence. Israeli security officials, however, insist it does. Last month, Haaretz reported that Maj. General Herzl Halevi, the IDF’s head of military intelligence, had said that “Palestinian Despair, Frustration Are Among Reasons for Terror Wave.”

The separation barrier isn’t stopping this new terror wave. It may limit attacks by West Bank Palestinians inside the Green Line. But many of the initial attacks occurred in Jerusalem, where most Palestinians live within the security barrier. Now many are occurring in the West Bank, where many Jewish settlers live beyond it. What’s more, the barrier contributes to the rage and despair that leads some Palestinians to commit terrorism in the first place. Because the wall has shut off their access to Jerusalem, notes Sarit Michaeli of the Israeli human rights group B’tselem, Palestinians neighborhoods like “Dir Naballah, Abu-Dis, A-Ram, northern Bethlehem and Beit Jala…have simply died out as area of commerce and transportation.” This is what former Shin Bet head Avraham Shalom foresaw when he warned, in 2003, that the separation barrier “creates hatred.”

What does all this mean for the wall Trump wants to build along America’s southern border? First, America’s wall, like Israel’s, won’t be as effective in stopping intruders as Trump thinks. In 2006, after George W. Bush signed the Secure Fence Act, the US built a fence along 670 miles of its 2000-mile border with Mexico. But according to a 2009 investigation by the Wall Street Journal, “drug smugglers and illegal immigrants continue to breach the fencing.” According to a Congressional Research Service investigation, other border crossers have simply found new routes.

Building a less permeable wall across the entire 2000-mile border might prevent that, but Trump’s wall, like Israel’s, will almost certainly have gaps. When the Bush administration started building its fence in environmentally sensitive areas, it encountered the same resistance from environmental activists that Israel did. Some property owners have also protested the fence’s construction on their land. Building a 2000-mile wall might require the government to seize substantial chunks of territory under eminent domain, something conservatives generally oppose.

Because of the nature of the terrain, the two-thirds of the border that remains unfenced also poses far greater logistical challenges than the one-third that has been fenced so far. As a result, Marc Rosenblum, deputy director of the U.S. Immigration Policy Program at the Migration Policy Institute, has estimated that completing a 2000-mile wall could cost $15-$25 billion, which is substantially more than the Customs and Border Protection Agency’s annual budget. Which helps explain why Congressman Michael McCaul, chairman of the House Committee on Homeland Security and a conservative Republican from Texas, admitted early this year that, “it would be an inefficient use of taxpayer money to complete the fence.”

To be fair, Trump’s barrier wouldn’t be exactly like Israel’s. Much of Israel’s separation barrier sits inside the West Bank. Trump’s would presumably all be on the U.S. side of the border. But Trump’s plans would still damage cooperation both with Mexico’s government and with Mexican-Americans in the United States, both of whom are crucial to border security. Trump’s anti-Mexican demagoguery has already led Latinos in the United States to begin boycotting his businesses. Mexico’s ambassador in Washington has demanded that Trump apologize to his people. As even the conservative Heritage Foundation has noted, “Tighter border security requires Mexico’s cooperation.” Donald Trump’s wall would destroy it.

Trump is peddling a fantasy of isolation, a fantasy that the United States can build a wall high enough to keep the world’s threatening forces away. Such fantasies exist in Israel too, where politicians sometimes promise separation from the Palestinians—as if millions of Israel’s own citizens weren’t Palestinian themselves, and as if a Palestinian state wouldn’t require economic integration with Israel to survive.

Cooperation is harder than isolation because it requires coming to terms with the people on the other side of the line. It requires recognizing that their security and prosperity are intertwined with your own. If Donald Trump wants to see the consequences of not recognizing that, all he needs to do it look at Israel.