learn › Counting & Discrete Math

Logic & sets

lesson · about 3 minutes

Overlapping groups, subsets, truth tables, and “if … then”.

Pen and paper is fine · no calculator needed why?

Opens at level 32. You're level 1. You can read and practice here now.

the idea

Two overlapping groups share members, so adding them counts the shared ones twice. Take the overlap off once.

A set of n things has 2 to the power n subsets, because each thing is either in or out.

"If P, then Q" means the same as its contrapositive, "if not Q, then not P". The converse, "if Q, then P", can be false while the original is true. A truth table lists every true/false mix of the letters: 4 rows for two letters, 8 for three.

techniques

Add, then take off the overlap

Two groups that overlap: either, neither, or only one.

  1. Either group: add the two counts and subtract the overlap once.
  2. Neither: the total minus that.
  3. Only the first: its count minus the overlap.
worked example

Example: Of 50 people surveyed, 30 drink tea, 25 drink coffee, and 12 drink both. How many drink neither?

  1. Tea or coffee: 30 + 25 − 12 = 43.
  2. Neither: 50 − 43 = 7.

Answer: 7

In or out: powers of 2

Counting the subsets of a set.

  1. All subsets, the empty one included: 2 multiplied by itself n times.
  2. Non-empty subsets: subtract 1.
  3. Subsets of exactly k elements: C(n, k).
worked example

Example: How many non-empty subsets does a set with 5 elements have?

  1. 2 × 2 × 2 × 2 × 2 = 32 subsets.
  2. Leave out the empty one: 32 − 1 = 31.

Answer: 31

Count the true rows

How many rows of a truth table make a formula true.

  1. ∧ (and) needs both sides true; ∨ (or) needs at least one; ¬ (not) flips true and false.
  2. → (if … then) is false only when the left is true and the right false.
  3. Count the true rows, or count the false ones and subtract from the total.
worked example

Example: How many of the 8 rows of the truth table make p → (q ∧ r) true? Key: ∧ means and, → means if … then.

  1. False only when p is true and q ∧ r is false.
  2. p true: 4 rows, and q ∧ r is false in 3 of them.
  3. 8 − 3 = 5.

Answer: 5

watch out for

practice

Sign in to try one

Overlapping groups

worked example

Of 47 gym members, 12 swim, 23 run, and 2 do both. How many swim or run (or both)?

Answer: 33

  1. Adding 12 and 23 counts the 2 who do both twice, so take them off once:
  2. 12 + 23 − 2 = 33.

Counting subsets

worked example

How many non-empty subsets does a set with 4 elements have?

Answer: 15

  1. Each element is in or out: 2⁴ = 16 subsets.
  2. Leave out the empty one: 16 − 1 = 15.

“If … then”

worked example

Which statement means the same as “If a number is divisible by 4, it is even”?

  1. If a number is even, it is divisible by 4
  2. A number is divisible by 4 and it is even
  3. If a number is not even, it is not divisible by 4
  4. If a number is not divisible by 4, it is not even

Answer: If a number is not even, it is not divisible by 4

  1. Swapping the two parts and negating both (the contrapositive) keeps the meaning: “If a number is not even, it is not divisible by 4”.
  2. The converse and the inverse can be false while the original is true: 6 is even but not divisible by 4.

Truth-table rows

worked example

How many of the 8 rows of the truth table make (¬p ∨ q) → r true? Key: ∨ = or, ¬ = not, → = if … then.

Answer: 5

  1. Check all 8 rows, written as (p, q, r) with T for true and F for false.
  2. False only in TTF, FTF and FFF.
  3. So 5 of the 8 rows make it true.

Sign in to start