Lesson 3: Grouping and precedence (beginner, 12 min)
Which operator applies first when there are no brackets, how the parser reads A OR B AND C, and why dropping the brackets from the entry rule lets a banned member in. Four steps, beginner level, about twelve minutes.
Learn which operator binds first, read `A OR B AND C` the way the parser does, and use parentheses to say what you mean.
The order is fixed: parentheses and the postfix complement first, then NOT, AND, XOR, OR, -> and <->. The first step states it and reads A OR B AND C as A OR (B AND C). The second step puts the two readings, A OR (B AND C) and (A OR B) AND C, on one table and finds an assignment that tells them apart. The third does the same for NOT A AND B against NOT (A AND B), and the fourth removes the brackets from (member OR invited) AND NOT banned to show that member OR invited AND NOT banned admits a banned member.
Three of the four steps carry a verified claim that the paired formulas differ, and the exercises are two multiple-choice questions about how the parser groups an expression and one hunt for a distinguishing assignment. The precedence page in the operators section prints the fully bracketed form of anything you type, which is the habit the lesson is trying to build.
The lesson is short because the rule is short; the difficulty is entirely in sentences, where “A or B and C” has no precedence, and the lesson's advice is to bracket every mixed group rather than remember the order.
Do this lesson interactively in the app
Steps
1. AND binds before OR
Without parentheses, operators apply in a fixed order, highest first: parentheses (and the postfix complement A'), NOT, AND, XOR, OR, ->, <->.
So A OR B AND C means A OR (B AND C), just as 1 + 2 × 3 means 1 + (2 × 3). Tangibool can always show this fully grouped reading, and it adds a hint when AND and OR are mixed without parentheses.
f := A OR B AND C · output | # | A | B | C | f |
|---|---|---|---|---|
| 0 | FALSE | FALSE | FALSE | FALSE |
| 1 | FALSE | FALSE | TRUE | FALSE |
| 2 | FALSE | TRUE | FALSE | FALSE |
| 3 | FALSE | TRUE | TRUE | TRUE |
| 4 | TRUE | FALSE | FALSE | TRUE |
| 5 | TRUE | FALSE | TRUE | TRUE |
| 6 | TRUE | TRUE | FALSE | TRUE |
| 7 | TRUE | TRUE | TRUE | TRUE |
Open the fully grouped reading of f and compare it with the text you typed.
2. Two groupings, two different rules
reading1 := A OR (B AND C) and reading2 := (A OR B) AND C use the same inputs and operators, yet they are different rules.
One assignment is enough to tell them apart: with A=TRUE, B=FALSE, C=FALSE, reading1 is TRUE and reading2 is FALSE. Such a distinguishing assignment settles any debate about which grouping was meant.
reading1 := A OR (B AND C) · outputreading2 := (A OR B) AND C · output | # | A | B | C | reading1 | reading2 |
|---|---|---|---|---|---|
| 0 | FALSE | FALSE | FALSE | FALSE | FALSE |
| 1 | FALSE | FALSE | TRUE | FALSE | FALSE |
| 2 | FALSE | TRUE | FALSE | FALSE | FALSE |
| 3 | FALSE | TRUE | TRUE | TRUE | TRUE |
| 4 | TRUE | FALSE | FALSE | TRUE | FALSE |
| 5 | TRUE | FALSE | TRUE | TRUE | TRUE |
| 6 | TRUE | TRUE | FALSE | TRUE | FALSE |
| 7 | TRUE | TRUE | TRUE | TRUE | TRUE |
Compare reading1 with reading2 and replay the counterexample the checker finds.
not-equivalent reading1 / reading2 · holds
3. NOT binds tightly
NOT A AND B means (NOT A) AND B: the NOT applies only to A. To negate the whole conjunction, write NOT (A AND B).
The two differ, for example, when both inputs are FALSE.
tight := NOT A AND B · outputwide := NOT (A AND B) · output | # | A | B | tight | wide |
|---|---|---|---|---|
| 0 | FALSE | FALSE | FALSE | TRUE |
| 1 | FALSE | TRUE | TRUE | TRUE |
| 2 | TRUE | FALSE | FALSE | TRUE |
| 3 | TRUE | TRUE | FALSE | FALSE |
Set both inputs to FALSE and compare tight with wide.
not-equivalent tight / wide · holds
4. Parentheses carry meaning
Drop the parentheses from the entry rule and its meaning changes: member OR invited AND NOT banned reads as member OR (invited AND NOT banned), so a banned member gets in.
When a rule mixes AND and OR, write the parentheses you mean, even where precedence would give the same result.
intended := (member OR invited) AND NOT banned · outputunbracketed := member OR invited AND NOT banned · output member: the person is a member; invited: the person has an invitation; banned: the person is banned;
| # | member | invited | banned | intended | unbracketed |
|---|---|---|---|---|---|
| 0 | FALSE | FALSE | FALSE | FALSE | FALSE |
| 1 | FALSE | FALSE | TRUE | FALSE | FALSE |
| 2 | FALSE | TRUE | FALSE | TRUE | TRUE |
| 3 | FALSE | TRUE | TRUE | FALSE | FALSE |
| 4 | TRUE | FALSE | FALSE | TRUE | TRUE |
| 5 | TRUE | FALSE | TRUE | FALSE | TRUE |
| 6 | TRUE | TRUE | FALSE | TRUE | TRUE |
| 7 | TRUE | TRUE | TRUE | FALSE | TRUE |
Set member=TRUE, invited=FALSE, banned=TRUE and compare intended with unbracketed.
not-equivalent intended / unbracketed · holds
Exercises
- How does the parser group
A OR B AND C? (choose-grouping) - Which reading matches
NOT A AND B OR C? (choose-grouping) - Find an assignment on which
reading1andreading2give different results. (find-assignment)
Do this lesson interactively in the app
Questions
Does the engine ever change my grouping?
No. It keeps the brackets you write and applies the fixed order where you write none; the fully bracketed form on every page shows what it read.
Where do -> and <-> fit?
Below OR: A OR B -> C is (A OR B) -> C, and <-> is lowest of all. Chains of -> associate to the right, and chains of <-> must be bracketed.
Related
Laws
Tools
See also
- Operator precedence in Boolean logic: NOT, then AND, then XOR, then OR
- “A or B and C”: the grouping ambiguity and how to resolve it
- Associative law: (A AND B) AND C = A AND (B AND C)
- Entry rule slip: member OR (invited AND NOT banned) and the case that differs
- Lesson 1: NOT, AND, OR: the basic operators (beginner, 10 min)
- Lesson 9: Counterexamples (intermediate, 12 min)
Lessons
Generated from the Tangibool engine, semantics tangibool-semantics/1, engine 1.0.0, build . Every table, map, simplification and verdict on these pages was computed by the Tangibool engine when the site was built, and every claim was re-checked by the same exact checker the app uses. Limits are stated where they apply. © 2026 Foreranger LTD.