Image copyright AFP/Getty Images Image caption Mr Kim needs reining in - but will China take the lead internationally on the issue?

"The definition of insanity is doing the same thing over and over again, but expecting different results."

The quotation is attributed to Albert Einstein but after a torrid few days on the Korean peninsula, it's one for Chinese leaders to ponder.

China is simply in the wrong place on North Korea. It is allowing Kim Jong-un's nuclear ambitions to undermine Chinese national interest.

There are complex reasons for this including history, habit and political culture. But among Chinese foreign policy experts and even on social media, unease is beginning to spread.

North Korea's nuclear programme has already driven South Korea to agree to the deployment of an American anti-missile system, locking Seoul deeper into a defensive triangle with Japan and the United States.

Relations between Beijing and Seoul are at their worst in a quarter of a century and many South Koreans have been alienated by unofficial Chinese sanctions against the whole spectrum of South Korean interests from supermarkets to boy bands.

This is good for North Korea but for no-one else. It is nonsensical for China to punish South Korea for trying to defend itself against a nuclear threat which even Beijing describes as real and urgent.

And if North Korea continues its drive for nuclear weapons, there may be a worse arms race to come. A nuclear-armed Japan would hardly be in China's national interest.

But despite this catalogue of warning signals and failures, China seems trapped in an unfinished history marked by binary choice: a nuclear-armed North Korea or a reunified Korea with American troops on China's border. Between these choices, it finds a nuclear-armed North Korea preferable.

But if it thinks hard enough, perhaps there is an alternative.

Image copyright Reuters Image caption US President Donald Trump has offered China an incentive if it helps resolve the North Korean crisis

In fact, this is a moment of decision for China. President Xi has talked of an Asia led by Asians. Showing flexibility and resolve on fixing Korea in the interests of the region and the world would demonstrate a readiness to lead.

Almost everyone, even China's most suspicious neighbours, would be grateful. President Trump has already promised that American gratitude would take material form in a favourable trade deal.

So China could use the current crisis on the Korean peninsula to engage its neighbours and cement a key area of partnership with the US. Or it could duck the challenge and let the US lead. A choice put starkly in a tweet from President Trump: "I have great confidence that China will properly deal with North Korea. If they are unable to do so, the US, with its allies, will."

Of course, China's view on what constitutes "dealing with North Korea" does not coincide with Mr Trump's. But there will be no dealing with North Korea worth the name that does not require a fundamental shift in how Beijing sees the region and its relationships within it.

China is after all an ideologically insecure one-party state. A profound aversion to liberal internationalism has tied it to a rigid position on non-interference in the internal affairs of another state. A position which now constrains it in managing the North Korean leader Kim Jong-un.

What's more, in Beijing's worldview, the United States is its long-term rival in Asia and the US system of alliances is a barely concealed strategy of containment.

For decades, China's security planners have war-gamed scenarios of brinkmanship and conflict with the US as enemy in a zero-sum game. There are no established scenarios in which the US presents as a partner in managing a rogue state masquerading as a Chinese ally.

Image copyright AFP Image caption China shares a land border with North Korea and fears the regime's collapse

Outdated stance?

China and North Korea signed a mutual aid treaty in 1961. The treaty says if either ally comes under armed attack, the other should provide immediate assistance, including military support. But it also says both should safeguard peace and security.

Some Chinese experts now argue that Beijing is not obliged to defend North Korea on the grounds that its nuclear weapons breach the mutual defence pact. But in general, China's security policy for the Korean peninsula seems frozen in time.

Despite establishing diplomatic relations with Seoul 25 years ago, and despite the burgeoning economic relationship with South Korea which followed, the security logic has not changed.

And now that China's only formal ally is threatening a nuclear war which would bring incalculable horror to the entire region including China's own citizens, Beijing's position looks a quarter century out of date.

If it wants to claim leadership in Asia, it could say loudly that Pyongyang's threats are completely intolerable and must not stand. After all, what loyalty does it owe a regime which shows only contempt for Chinese diplomacy and Chinese national interest?

Rather than dragging its feet on economic sanctions and turning a half-blind eye to Chinese companies which supply high-tech components to North Korea's arms programme, Beijing could choose to lead the sanctions charge.

Rather than repeating tired rhetoric urging all parties to refrain from provoking and threatening each other, it could suspend oil exports and foreign currency dealings.

Rather than staging an unnecessary set piece forum on President Xi's "one belt, one road" slogan next month, it could host an emergency conference for Asia on dealing with North Korea.

That Beijing will not lead on North Korea is China's tragedy and Asia's tragedy.