This works somewhat well in practice, but there are many cases where the inference is incorrect. As a particularly egregious example, :not(#foo) targets all elements except one, yet enjoys the same high specificity as #foo.
Explanation: #foo
which ideally targets one element, is more specific that :not(#foo)
because it targets every element except one. Didn't hit me the first time, thought might be beneficial for someone reading in a daze.