Sets, relations and quantifiers
Paint a three-set Venn diagram from an expression (or find the expression from a painting), linked to its truth table, with inclusion–exclusion counts; explore relations on up to eight dots — reflexive, symmetric, antisymmetric and transitive with witnesses, closures, equivalence classes and Hasse diagrams; and play the ∀∃ against ∃∀ game over a finite domain.
Added
Works with
- Boolean logic Mathematicsopens the Venn region’s logic as a truth table
How to use it
Three tabs, each a picture of an idea from the logic chapter.
-
Venn painter — type a set expression such as
(A-B)|C'and the matching regions of a two- or three-set Venn diagram are shaded. Click regions (or rows of the truth table beside it) to paint a shape yourself, and the shortest expression the tool knows for it replaces yours. Each region is one row of the truth table for x ∈ A, x ∈ B, x ∈ C, and hovering over either highlights the other. Type a second expression under compare with to check an identity such as De Morgan’s law: the tool says whether the two shade the same regions, and if not, which regions differ. Fill in the counts |A|, |B|, |A∩B|, … and |U| to see inclusion–exclusion at work: the count in every region, the size of the union and of “none of them”, the size of the shaded set, and a warning when counts are impossible. -
Relations — up to eight elements on a circle. Click one dot and then another to toggle the arrow between them; click a dot twice for its loop. The tool checks reflexive, symmetric, antisymmetric and transitive, and for each one that fails it names and draws a witness in red: the missing loop, the unreturned arrow, the two-way pair, or the two-step path with no shortcut. The buttons add the reflexive, symmetric or transitive closure. An equivalence relation colours the dots by class and lists the partition; a partial order is redrawn as a Hasse diagram with its incomparable pairs. Relations can also be typed as rules:
divides,lt(<),le(≤),eq,ne,subset(⊆ on labels such as∅,a,b,ab),mod3(anymodN),emptyorall, or as arrows1>2,2>3. -
∀∃ game — a statement with two quantifiers over {0, …, n − 1}, such as ∀x ∃y (y ≡ x + 1), and the table of P(x, y). You play ∃ (or ∀) against the computer, which plays its side perfectly. The table shows why the statement is true or false: for ∀x ∃y every row needs a T; for ∃y ∀x one column must be T all the way down. Winning strategy spells out the winning moves. Click cells to make your own predicate.
Expressions use ∪ or | or + for union, ∩ or & for intersection, ∖ or - for
difference, △ or ^ for symmetric difference, and ' (or ′, or a leading ~) for
complement; U is everything and ∅ (or 0) nothing. Complement binds tightest, then ∩, then
∖, then △, then ∪, but brackets are clearer and the tool always writes them. Write an operator
between sets: AB is an error, not an intersection.
Limits
Two or three sets in the Venn painter; at most eight elements in a relation; domains of at most eight values in the game. The “shortest expression” is the shortest in a search over expressions built from A, B, C, U, ∅ and the five operations; for every one of the 256 three-set shapes it finds one with at most a dozen or so symbols.
Related: Boolean logic (the same truth tables as logic, with Karnaugh maps and gate diagrams), Probability (inclusion–exclusion for probabilities), Number theory step by step (congruence mod m, divisibility).
Companion to chapter 21 of Mathematics, Reconnected, Logic, sets and relations (sections on quantifiers, sets and relations), with the inclusion–exclusion of chapter 24 (the book).
Linking to an example
Share link (under the title) copies a link to the tool as you have it. You can also write one by
hand, for example
?expr=(A|B)'&cmp=A'%26B'&sets=2#venn
or ?div=12#relations. The tabs are venn,
relations and quantifiers. In a link, & separates parameters, so write intersection as %26
(or ∩); a + arrives as a space, which the Venn painter reads as union. A link replaces your
saved settings for this tool (Restore my settings undoes it).
| Parameter | Meaning | Example |
|---|---|---|
|
Venn: the set expression (| or + union, & intersection, - difference, ^ symmetric difference, ' complement) |
|
|
Venn: a second expression to compare with |
|
|
Venn: 2 or 3 sets |
|
|
Venn: inclusion–exclusion counts — |A|,|B|,|A∩B|[,|U|] or |A|,|B|,|C|,|A∩B|,|A∩C|,|B∩C|,|A∩B∩C|[,|U|] |
|
|
Venn: what A, B, C stand for |
|
|
Relations: the elements (at most 8) |
|
|
Relations: a rule (divides, lt, le, eq, ne, subset, mod3, empty, all) or arrows a>b,… |
|
|
Relations: shorthand for the divisors of n under “divides” |
|
|
Quantifiers: the prefix, AxEy (∀x ∃y), EyAx (∃y ∀x), … |
|
|
Quantifiers: the predicate (next, gt, ge, eq, ne, sum0, divides, inverse, le1, grid) |
|
|
Quantifiers: the domain {0, …, size − 1} |
|
|
Quantifiers: your own P(x, y), rows of 0/1 separated by dots (with p=grid) |
|
example= opens one of the book’s examples and picks its tab when the link has no #; other parameters in the same link override it.
example= |
Tab | What it shows |
|---|---|---|
venn |
the lab’s example (A ∖ B) ∪ C′ |
|
venn |
De Morgan: (A ∪ B)′ = A′ ∩ B′ |
|
venn |
the distributive law, both sides |
|
venn |
120 + 85 − 40 = 165 users |
|
venn |
30 people, 18 coffee, 15 tea, 7 both: 4 want neither |
|
venn |
multiples of 2, 3 or 5 up to 1000: 734 (266 none) |
|
relations |
same remainder mod 3: three classes |
|
relations |
divides on the divisors of 12, and its Hasse diagram |
|
relations |
divides on 1–6 |
|
relations |
less than: a strict order, not reflexive |
|
relations |
friends: symmetric, not transitive |
|
relations |
exercise: P({a, b}) under ⊆ is a diamond |
|
quantifiers |
∀x ∃y (y ≡ x + 1): true — y may depend on x |
|
quantifiers |
∃y ∀x (y ≡ x + 1): false — one y for every x |
|
quantifiers |
∀x ∃y (y > x) fails on a finite domain: x = 4 |
Feedback is a gift. Something to improve, a feature to add, or a bug? Tell me.
Runs entirely in your browser; nothing you type leaves this page.