Logical Operators

Logical Operators

This page will give you a brief summary of all the logical operator blocks that are available in the “Logic” drawer of the Toolbox.


The and operator returns true if both of its internal parts return true, and returns false otherwise. It looks like this:

However, you will usually never need to use the “and” operator when using Blawx unless you want to be visibly explicit about something. This is because as a short-hand, the vertical connectors on Blawx work as an “and” connector. So the following piece of code:

… has exactly the same meaning if you remove the and block like this:

Because the vertical connection between the two blocks, shown here:

also means “and”.


The Or operator takes two statements, and returns true if either of the statements returns true. Unlike “and”, if you want to use “or”, you need to use it specifically. If you want to return true if one of three values is true, for example, you need to use nested “or” blocks, like this:


The negation operators, not, and naf not, look like this:

Basically, each will return true if their contents is false, but they have slightly different rules for what counts as false. For details, check out this reference page on Negation.


The implication block in Blawx looks like this:

The implication operator is intended to be used in the conditions of a rule. It is used to ask whether it is true that whenever the first query is true, the second one is true.

While the implication operator can be useful in some circumstances, it can also be very confusing, and is not entirely necessary. Everything that can be done with the implication operator can also be done using a combination of “or” and “negation” blocks.

There are four different symbols that can be used for the type of implication. They vary in two ways: directionality, and the semantic meaning of the implication.

Implication Directionality

Directionality is shown by the arrow heads at the end of the line. Either there is an arrow head only on the right, or there is an arrow head on both sides. If there is an arrowhead on the right, the implication is only from the top condition to the bottom condition. If there is an arrowhead on both sides, the implication is in both directions.

For example, conssider the query “Is it true that whenever A is True, B is 42?” That statement is made using only one arrowhead, like this:

If you used the line with two arrow heads, you are asking whether both implications are true. So this query, using the line with two arrow heads…

… means the exact same thing as this query, which uses two mirrored implications with only one arrow head:

So the line with two arrow heads is a short-hand for asking whether an implication is true in both directions.

Implication Semantics

The type of lines used in the implication indicate the semantics of the implication. To understand this, it is easier to look at the version of the implication created from negation and or blocks.

Let’s imagine we want to ask, “Is it true that whenever A is true, B is 42?”

Using an implication block, it would look like this:

If we wanted to do the same thing using “or” and “negation” blocks, it would be this:

This could be read as “is it true that either A is true, or, it cannot be shown that B is 42?” So if there is no proof that the value of B includes 42 (remember that B could be a list of more than one value), then n.a.f. not will return true, and the or will return true.

But if you use the double-line version of the implication arrow, like this:

Then the equivalent “or” and “negation” version would look like this:

So you can see that the only difference here is in the type of negation used. For more details on how the two types of negation differ, see this post on negation in Blawx.

But for now, this statement can be read as “is it true that either A is true, or you can prove that B cannot be 42.”

In most cases you are going to want to use the squiggly-line, n.a.f. version of implication.

Universal and Existential Quantification

Universal and existential quantification are both dealt with with the same quantification block, which can be modified to use either the word “any” or the word “all.” The quantification block looks like this:

The quantification block expects you to provide a variable, and then to provide a set of conditions that use that variable.

The software will consider all of the values that can be found for the variable provided, and for each possible value, will check to see if the condition is met when the variable has that value.

For an existential quantifier, it will return “true” if at least one value returns true in the condition. For a universal quantifier, it will return “true” if the condition returns true for every possible value of the variable.

Note that queries in Blawx are existential by nature. If you want to know are there any dogs, you can use the existential quantifier like this:

However, this is the same as asking whether there are any dogs like this:

So the existential qualifier is usually not required. If you want to ask whether all of the known Mammals are Dogs, you could ask that using the universal quantifier, like this:

Because A has already been limited to Mammals outside the universal quantifier, all Mammals, as opposed to all objects, will be checked to see if they are all dogs. And only if all Mammals are dogs will the query return “Yes.”


The comparison operator has 7 different comparisons it can make between two values, or objects.

Less Than, Greater Than

The inequality operators of “<“, “<=”, “>”, “>=” work much as you would expect as long as the values provided to the operator are numbers.

Numerical Equality and Inequality

The equality operator “=” asks whether the two objects or values or variables provided have the same value. For example, you could use the equality operator to ask whether two inventory objects have the same price.

The inequality operator “!=” works exactly the same as wrapping a “=” comparison in a “not” operator, reversing the truth value returned.

Identity and Non-Identity

The identity comparison, “==”, asks whether two objects or variables or values are the same object.

The non-identity operator asks whether two objects are not the same object.

This can be very useful when you are trying to compare two objects of the same category to one another. For example, you may want to check to see if someone is the winner of a game, by checking to see if there are any other players with a higher score. To do this, you need to check against all the players who are not the player you are interested in (otherwise, the player will always have the same score as one other object, themselves).

This query, without the non-identity comparison, would always return true, because Bob would be one of the other players against whom the score was tested.

No Comments

Add your comment