Skip to content

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.

Level: beginner12 min11 claims in this lesson were confirmed by the exact checker at build time

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
AND binds before OR
#ABCf
0FALSEFALSEFALSEFALSE
1FALSEFALSETRUEFALSE
2FALSETRUEFALSEFALSE
3FALSETRUETRUETRUE
4TRUEFALSEFALSETRUE
5TRUEFALSETRUETRUE
6TRUETRUEFALSETRUE
7TRUETRUETRUETRUE

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
Two groupings, two different rules
#ABCreading1reading2
0FALSEFALSEFALSEFALSEFALSE
1FALSEFALSETRUEFALSEFALSE
2FALSETRUEFALSEFALSEFALSE
3FALSETRUETRUETRUETRUE
4TRUEFALSEFALSETRUEFALSE
5TRUEFALSETRUETRUETRUE
6TRUETRUEFALSETRUEFALSE
7TRUETRUETRUETRUETRUE

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
NOT binds tightly
#ABtightwide
0FALSEFALSEFALSETRUE
1FALSETRUETRUETRUE
2TRUEFALSEFALSETRUE
3TRUETRUEFALSEFALSE

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;

Parentheses carry meaning
#memberinvitedbannedintendedunbracketed
0FALSEFALSEFALSEFALSEFALSE
1FALSEFALSETRUEFALSEFALSE
2FALSETRUEFALSETRUETRUE
3FALSETRUETRUEFALSEFALSE
4TRUEFALSEFALSETRUETRUE
5TRUEFALSETRUEFALSETRUE
6TRUETRUEFALSETRUETRUE
7TRUETRUETRUEFALSETRUE

Set member=TRUE, invited=FALSE, banned=TRUE and compare intended with unbracketed.

not-equivalent intended / unbracketed · holds

Exercises

  1. How does the parser group A OR B AND C? (choose-grouping)
  2. Which reading matches NOT A AND B OR C? (choose-grouping)
  3. Find an assignment on which reading1 and reading2 give 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

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.