Thanks for posting this! I think the logic can get a little complicated. It seems all the rules of first order logic apply:
As an example of De Morgan’s law applied to a tag query:
-#1 or -#2 == -(#1 and #2)