Negation in Blawx
Blawx provides you with two different types of negation blawx, both of which are available under the Logic section of the Toolbox.
The first type of negation is a logical “not.” A logical “not” looks like this:
The Not block will return “true” if its contents return “false”, and will return “false” if its contents return “true”.
The second type of negation is a “n.a.f. not.” It looks like this:
NAF is short for “negation as failure.” An easy way to understand the n.a.f. not block is that it will return true if it can prove that its contents are true. If it’s contents are false, or if it can’t prove the contents are true, it will return false.
So NOT asks “can I prove this value is false”, whereas n.a.f not asks “can I not prove that this value is true.”
NAF Not is useful when you are checking to see whether or not an object exists in the data. For example, let’s say that you have a category “Dog”, and you will be sad if there are no objects in that category. You could code that like this:
But this code will not work as expected. A logical “not” only returns “true” if its contents return “false.” But “X is in the Category Dog” will not return “false.” If it did, that would mean “it is impossible for an object to be a dog.”
Instead “X is in the Category Dog” will return something that means “I can’t prove that’s true, and provide examples.” It is a failed search. If you want failure to count as falsehood, you need to use naf not.
That version of the rule will work.
It can be difficult to understand, but generally, you only want to use logical not for values that you know exist, and that will be true or false. You want to use naf not whenever the answer the the search included could be “I couldn’t find any”, and you want failure to count as falsehood.