Had Gaddafi developed a working nuclear bomb with the necessary delivery mechanism, would France/UK/US have launched a campaign that ultimately ended with his death? We will never know, only speculate, but North Korea is betting that the answer to this question is "no".
The reason for this is arguably because we could not. North Korea borders both China and what was at the time the Soviet Union. The cliff notes of the Korean War (at least after the point of division and active war) are that North Korea decided to invade South Korea. They had South Korea on the brink of destruction and then the UN/US intervened on behalf of South Korea.
The US/UN enforces then pushed the North Korean forces back north and to the brink of destruction. Then Chinese (and to a much lesser degree Soviet) forces intervened on behalf of North Korea and pushed US/UN forces back beginning a sort of see-saw that ended up with neither coalition able to make meaningful progress. After some time of a back and forth, an armistice was signed.
I think it's somewhat unclear how the balance of powers changed in the time after this.
Quite true. Though western countries didn't attack Gaddafi before he gave up nuke either.
The speculation I've heard (on radio, so I cannot paste a link) is that NK analysis is roughly: NK's regime is safe as long as China sees it as useful (probably using NK as some sort of buffer state against US), but sooner or later that support will end. Then only nuclear weapons will ensure NK's regime survival. It's rational, though again just speculation.
The contradiction, or maybe unintended side effect, is that the developing of nuclear weapons itself is causing China to rethink its support of NK regime...
Not saying the hypothesis you put forward is wrong but I've heard a very convincing complementary one:
Kim's goals are:
1. Survival of the Kim leadership
2. Reunification of Korea
To achieve the latter (and also the prior), he needs to remove the US from intervening in any conflict on the Korean peninsula. If he had a credible threat to any major US city, then the US would have to weight the freedom of S. Korea vs. the lives of hundreds of thousands of Americans.
Kim has a substantial problem in that premise, regarding China.
At this point we have to assume North Korea will soon have dozens of nuclear weapons (basically as many as they can manage to make), and in a few years that they'll have dozens capable of being placed on an ICBM that can hit most US cities. Their progress has accelerated dramatically, that will probably make such numbers very feasible.
Now, following the premise of keeping the US out of it by way of the risk that the US will lose several or more of its major cities. Here's the problem. If the US loses a dozen of its major cities, we'll destroy China in retaliation for making the North Korea situation possible to begin with. There's no scenario where the US just absorbs that kind of vast destruction, trades nukes with North Korea and says: oh well, woe is me. China will lose hundreds of millions of its people - Beijing, Shanghai, etc - if the US sees its biggest cities nuked. The American public will demand all enablers of North Korea be held accountable, it'll lead to the classic global nuclear war scenario, a billion people die.
If the US loses one city, that'll be an extreme tragedy that the US can absorb, while obliterating NK in response.
If the US loses its top dozen (or more) cities in a nuclear exchange with North Korea, there's no scenario under which the American public won't demand retribution against the enabling power/s that made that outcome possible. China would be guaranteed to get nuked as a consequence, given its responsibility for propping up and nurturing the Kim dynasty. If the US loses half of its civilization, it will respond exactly as one might expect.
You can't actually think the American public is going to sit on its collective hands and suffer its outcome quietly? That they'd be ok with trading NY, LA, SF, Seattle, Houston, Washington DC, et al. for Pyongyang and call it a day, while China goes on about its business, its civilization unscathed, like its actions over five decades didn't make the North Korean threat what it was. If it weren't for China, the US would have destroyed the Kim dynasty during the Korean War and unified Korea. They're responsible in every possible way for what North Korea is today, they propped them up and supported each regime with full understanding of what was going on in regards to the North's nuclear program across decades. Even if I don't agree with that premise, of holding China accountable in such a way, you can bet a just-been-nuked-40-times American public will, they'll ask a simple question: who has been North Korea's primary supporting ally?
Xi Jinping does not like Kim at all. I suspect if NK continues the current course and gets close to launching China will invade NK and remove the leadership. They primarily want a stable region not under US control. A NK modernized in the Chinese communi-capitalist manner would benefit everyone.
Ths US population lives down-wind of China. I’m guessing the demand for more nuclear fallout will be at an all-time low after dozens of US cities are nuked.
Also, I’ve seen MASH. The US’s pointless war was as responsible for North Korea as anything else.
Anyway, I really doubt there will ever be significant popular demand for nuclear war.
Indeed. It's the whole reason to never allow a nuclear conflict to erupt in the first place. And particularly to not get into a scenario where a weak third world type power can threaten the existence of a superpower (because it may topple the MAD premise in the after-consequences; MAD has a rarely discussed psychological requirement involving the people of a nation: acceptable parity exchange, aka great powers with a lot to lose choosing to not destroy each other; ie how does a superpower react to being destroyed by a country like NK? what's left of MAD afterward?).