# 📖 Boolean Logic

A pattern device using boolean logic to combine items

Boolean logic is a puzzle device facet that uses boolean operations, mostly "and", "or" and "not", to combine items. It is commonly used in pattern sequences and constraint logic.

Live Example:

Boolean logic concerns itself with true or false values. However, this can be the answer to any arbitrary true or false question. For example, questions like "Is there a dog in the house?" or "Does this person like blue?" can be answered as yes or no, which map to true or false values. This gives a wide berth to a puzzle designer to make use of boolean logic.

#### Operators

There are three common operators for boolean logic: "and", "not", and "or", where operator means how two values are combined.

##### And

For example, at a high level, we ask "Is the statue hot and red?". We're asking two separate questions, and wondering if both of them are true: "Is the statue hot?" and "Is the statue red?".

In truth form, where ∧ is "and":

• True ∧ True = True
• True ∧ False = False
• False ∧ True = False
• False ∧ False = False

This maps to our logical understanding of "and". "Is the status hot and red?" can only be answered yes, if both the status is read (true) and the statue is hot (true).

##### Or

In truth form, where ∨ is "or":

• True ∨ True = True
• True ∨ False = True
• False ∨ True = True
• False ∨ False = False

We have to be careful that the English interpretation of "or" doesn't always work the same as the truth table. For example, the question "Is the status hot or red?" could be asking if either it is hot or red, or it could be asking it is either hot or red, but not both. This second interpretation is the "exclusive or" operator, shown later.

Some questions involving "or" aren't actually boolean operations. At a restaurant a waiter may ask "Would you like soup or salad?" They certainly aren't expecting a yes or no answer, but would like you to make a choice between the two. In puzzle design, if using language, it's important to understand the ambiguity between "or" meaning a choice, or the boolean operation.

##### Not

In truth form, where ¬ is "not":

• ¬True = False
• ¬False = True

The "not" operator takes the opposite of a value. For example, "Is the dog not in the house?" If the dog is in the house, then we answer "no", due to the "not". If the dog is not in the house, we answer "yes".

#### Donut Delivery

In the Donut Delivery puzzle I used boolean logic to create a pattern. At first it may not be obvious how boolean logic can apply to images of a donut, and that was kind of why I chose that abstraction.

The boolean logic applies to the sprinkles. If you look at all the sprinkles you'll see that they only appear in fixed positions. I added colours to the sprinkles only to make it easier to distinguish the locations of nearby sprinkles. But that colours, indeed eveyrthing but the location of the sprinkles, can be ignored.

If we break the donut down into all the places where sprinkles could occur we can see the boolean logic at work. Look at the top row of donuts, and pick a sprinkle location. Each of the donuts in that row either has or doesn't have a sprinkle at that location. Actually, you might notice a pattern, that either there are exactly two sprinkles or none for a given location.

This is the boolean operator "exclusive or", otherwise known as "xor". If either the first two donuts have a sprinkle at the location, but not both, then the third donut has a sprinkle.

In truth form, where ⊕ is "exclusive or":

• True ⊕ True = False
• True ⊕ False = True
• False ⊕ True = True
• False ⊕ False = False

#### Feedback on Working Draft

If you have any questions, need an example, or want clarification, then let me know. Ask on Discord or Twitter.

Assume everything in this reference is a working draft, there's prone to be some mistakes and inconsistencies. I figure it's best to publish and get feedback rather than write for years in secret. The terms will change, the structure will shift, and the bugs will be chased out. It'll take a while.