2.3 Logical operators

Two Boolean values can be combined by a logical operator. There are three commonly use logical operators:

2.3.1 Negation

The logical negation operator is not, and it serves the same purpose as in English. For example, (not (12 < 35)) is false because (12 < 35) is true, the negation of true is false.

The logical negation operator is called a unary operator because it only requires a value on the right hand side to operator on. This is similar to the numeric negation operator. The logical negation operator requires the value to its right to be a Boolean value.

This means that (not (x > y)) is fine, but (not 25) does not make any sense.

The definition of logical negation is as follows:

2.3.2 Conjunction

“Conjunction” is a fancy name for and. This logical operator works the same way as it does in English. The expressions ((x < y) and (y < z)) evaluates to true if and only if both sides of and individually evaluate to true. In this case, the expression evaluates to true if and only if x is less than y, and y is less than z.

The definition of conjunction is as follows:

2.3.3 Disjunction

“Disjunction” is a fancy name for or. This logical operator also works the same way as it does in English. However, it does not mean either or. The expression ((x = 2) or (y < 0)) evaluates to true if and only if at least one side of the word or is true. In this specific case, the expression is true when x has a value of 2, y is negative’, or both.

The definition of disjunction is as follows: