Chris Collins

Tools · math

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

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 (any modN), empty or all, or as arrows 1>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

expr

Venn: the set expression (| or + union, & intersection, - difference, ^ symmetric difference, ' complement)

expr=(A-B)|C'

cmp

Venn: a second expression to compare with

cmp=A'∩B'

sets

Venn: 2 or 3 sets

sets=3

counts

Venn: inclusion–exclusion counts — |A|,|B|,|A∩B|[,|U|] or |A|,|B|,|C|,|A∩B|,|A∩C|,|B∩C|,|A∩B∩C|[,|U|]

counts=18,15,7,30

names

Venn: what A, B, C stand for

names=coffee,tea

set

Relations: the elements (at most 8)

set=1,2,3,4,6,12

rel

Relations: a rule (divides, lt, le, eq, ne, subset, mod3, empty, all) or arrows a>b,…

rel=divides

div

Relations: shorthand for the divisors of n under “divides”

div=12

q

Quantifiers: the prefix, AxEy (∀x ∃y), EyAx (∃y ∀x), …

q=AxEy

p

Quantifiers: the predicate (next, gt, ge, eq, ne, sum0, divides, inverse, le1, grid)

p=next

size

Quantifiers: the domain {0, …, size − 1}

size=5

grid

Quantifiers: your own P(x, y), rows of 0/1 separated by dots (with p=grid)

grid=01.10

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

ch21-venn-lab

venn

the lab’s example (A ∖ B) ∪ C′

ch21-de-morgan

venn

De Morgan: (A ∪ B)′ = A′ ∩ B′

ch21-distributive

venn

the distributive law, both sides

ch21-ie-2fa

venn

120 + 85 − 40 = 165 users

ch21-ie-coffee-tea

venn

30 people, 18 coffee, 15 tea, 7 both: 4 want neither

ch24-ie-2-3-5

venn

multiples of 2, 3 or 5 up to 1000: 734 (266 none)

ch21-mod3

relations

same remainder mod 3: three classes

ch21-divides-12

relations

divides on the divisors of 12, and its Hasse diagram

ch21-divides-1-6

relations

divides on 1–6

ch21-less-than

relations

less than: a strict order, not reflexive

ch21-friends

relations

friends: symmetric, not transitive

ch21-power-set-ab

relations

exercise: P({a, b}) under ⊆ is a diamond

ch21-forall-exists

quantifiers

∀x ∃y (y ≡ x + 1): true — y may depend on x

ch21-exists-forall

quantifiers

∃y ∀x (y ≡ x + 1): false — one y for every x

ch21-bigger-finite

quantifiers

∀x ∃y (y > x) fails on a finite domain: x = 4

Runs entirely in your browser; nothing you type leaves this page.