Why do you say that? Having WMDs is no guarantee of not being attacked; just ask Iraq since they had WMDs before the Gulf War and we know that because Saddam gassed the Kurds. While it's true that the U.S. has never attacked a nuclear state, that's either because they're allied (UK, France, somewhat more tentatively India and Israel, and nominally Pakistan), a competitor where we use proxies to fight instead (Russia, China), or or due to unacceptable risks of conventional warfare (North Korea, where we're afraid they'll barrage Seoul with artillery if we attack regardless of whether they had or would use nukes). If Libya had one or two nukes but no long-range delivery system that could threaten Europe or other key targets, I don't see why that would completely deter the U.S. from attacking them given sufficient cause.