“Empires age and decay in the course of three generations,” Ibn Khaldun warned. And while his theory referred to early-modern desert dynasties, it could easily apply to Walmart. (This wouldn’t be the first time Ibn Khaldun was pressed into service for understanding the American economy: Ronald Reagan, a fan, cited him in support of supply-side policies, somewhat to the chagrin of scholars.)

In the first generation, Ibn Khaldun wrote, an empire is founded by rough-hewn bedouins, thirsty for power, closely tied together, and always wary: “Their swords are kept sharp, their attack is feared, and their neighbors vanquished.” In the second generation, things are still good: “Possessing dominion and affluence, they turn from nomadic to settled life, and from hardship to ease and plenty.” Yet the close bonds of kinship and family that made the empire so resilient start to erode. The dynasts begin to hire outside managers and mercenaries to maintain their empire. They rely ever more heavily on bureaucracy. This generation oversees the peak of the empire’s glory, but things tend to stagnate a bit, and while what they bequeath to their heirs looks powerful on the outside, it is hollowing out underneath.

In the third generation, the empire tends to fall apart. The second generation was raised in splendor, but its members were reared by the same rough and ready desert natives who had founded the empire. The third generation, however, has known nothing but the palace. Its members don’t have the same enterprising spirit, and they fall short of their ancestors’ models. “Their national spirit is wholly extinguished; they have no stomach for resistance, defense, or attack,” Ibn Khaldun wrote. “Nevertheless they impose on the people by their bearing and uniform, their horsemanship, and the address with which they maneuver.”

This lines up uncannily with the Walmart story. Take Sam Walton, patriarch of the dynasty. What is America’s equivalent of the desert in early-modern Arabia? One good candidate is Bentonville, Arkansas, a rural Ozarks town of fewer than 3,000 people when Sam Walton opened his first store there. But Walton was wily, wise, and energetic, and he converted that store into a huge chain, overwhelming more established competitors like Kmart—companies that had themselves grown complacent over time. By the time Walton died in 1992, Walmart was the largest retailer in the United States.

Under the Walton family’s second generation, Walmart reached its peak—with an incredible $486 billion in revenues on last count. The family has done well, too; four living members of the second generation are all worth at least $30 billion (though heirs lost $11 billion in Wednesday’s slide of Walmart stock). But the family has come to rely on mercenaries, as Ibn Khaldun predicted—or as we call them in modern parlance, business executives. The hired guns have made the company lots of money, but they have also sometimes led in unwise directions. Walmart has pled guilty to environmental crimes and paid out tens of millions in settlements. An inquiry into whether the company paid bribes overseas has cost it almost $500 million. Several high-level executives were forced out following that investigation, members of the family have become interested in pursuits outside Walmart, including philanthropy and art.