A decade or so ago, in his book "Terror and Liberalism," social critic Paul Berman derided the West for repeatedly making the conceptual error of refusing to understand "that, from time to time, mass political movements do get drunk on the idea of slaughter." Our mistake, he wrote, is "expecting the world to act in sensible ways" — that is, "without mystery, self-contradiction, murk, or madness."

But terrorism isn't madness. That's the true lesson that the West keeps refusing to learn. The terrorist isn't irrational. Evil, yes; irrational, no. So although most of the world surely agrees with President Obama's condemnation of the fatal shooting at the offices of Charlie Hebdo as "senseless attacks against innocent civilians," it's useful to remember that to the terrorist, the attacks aren't senseless, and the civilians aren't innocent.

There is a logic to terrorism, a coldly calculated ends- means rationality. The armamentum of terror is chosen by radical groups not because they are madmen but because they consider it efficacious. In short words, they believe it will get them what they want.

Many news organizations, in reporting on the Paris attacks, have made the decision not to show the cartoons that evidently motivated the attackers. This choice is sensibly prudent — who wants to wind up on a hit list? — but from the point of view of the terrorist, it furnishes evidence for the rationality of the action itself. Killing can be a useful weapon if it gets the killer more of what he wants.

Terror seeks to raise the price of the policy to which terrorists object. In that sense it's like a tax on a particular activity. In general, more taxes mean less of the activity. If you don't want people to smoke, you make smoking more expensive. If you don't want people to mock the prophet Mohammed, you kill them for it. The logic is ugly and evil, but it's still logic.

To the terrorist, history is full of useful lessons: The U.S. withdrawal from Lebanon after the 1983 Marine bombing is a prominent example still discussed in terror circles. True, the counterlessons are often ignored, but perhaps that is because of their rarity. The Sept. 11 attacks brought the war in Afghanistan down on the heads of Al-Qaida and its Taliban protectors, but wars on terror in that traditional sense — boots on the ground, bleeding and dying to hold territory — are difficult to mobilize and impossible to sustain.

Thus, even after the fall of the Taliban, the terror lords counseled their warriors to patience. The West, they said, will grow weary. The West always grows weary. That, too, is a lesson drawn rationally from history. And, as the terrorist well knows, there will always be people in the West who will counsel yielding, often by dressing up the terror as an unfortunate response to a "legitimate" concern.

The United States nowadays fights terror largely electronically, through its surveillance, its drying up of the flow of funds and, of course, its drone wars. All of these the patient and rational terrorist learns to evade. The occasional spectacular killing of a major terror figure might be viewed by theorists (including me) as potentially reducing the demand side of the terror market, but the terror continues, and even expands. The U.S.-led coalition that is relying on air power to attack the Islamic State in Iraq and the Levant does not seriously imagine that its missiles and bombs will be able to roll back their territorial gains. For that, ground troops will be needed. Very soon the Iraqi security forces are supposed to move on Mosul, but they will be trying to drive out a well-armed, well-funded and well-entrenched enemy.

Boko Haram has learned some of the same lessons, which is why the group is doing a good deal more than kidnapping girls to be forced into marriage and boys to be forced to fight. It is taking and holding territory. On the very day that the world was focusing on the attacks in Paris, Boko Haram was renewing its assault on Baga, in northeastern Nigeria, leaving the streets littered with corpses. Over the course of the past week, the death toll from the raids is estimated in the thousands.

All of which leads to the second part of Obama's condemnation, that the terrorists are killing "innocent civilians." Few, I hope, would disagree. The entire Western understanding of the law of war is built upon the immunity of noncombatants. From this point of view, intentionally targeting civilians is a war crime precisely because civilians are innocent.

The terrorist disagrees. Terrorists, notes the philosopher Jeff McMahan, "are unlikely to think of themselves as killing innocent people." McMahan points to the writings of Osama bin Laden, who did not take the position that Americans could be killed because God said so. Rather, McMahan says, bin Laden believed "that it is permissible to kill Americans because of what they have done."

A generation ago, radicals raised to the writings of Frantz Fanon took a similar line. I'm old enough to remember campus coffeehouse conversations in the 1970s, when armchair revolutionaries argued with every appearance of seriousness that the child of the colonizers, living among the colonized, is not merely a legitimate military target, but actually morally blameworthy for living off the sweat of the native brow. Again, that this logic might be reprehensible doesn't mean it isn't logic.

This is a point we tend to forget. When we condemn terror as a sort of madness, we refuse to look with a clear eye at the way the enemy is thinking. The enemy is not making the same mistake. He studies us, working out our weaknesses and our fears. As the anthropologist Talal Asad notes in his work on suicide bombers, the terrorist's point is less to shock us by what he has done than it is to leave us frightened about what act of indiscriminate violence might come next.

The terrorist knows what scares us. He believes he also knows what will break us. Our short-run task is to prove rather than assert him wrong. In the long run, however, the only true means of deterrence is the creation of a new history, in which the terrorist is always tracked to his lair, and never gets what he wants.