Skip to content
LearnMathora

Discrete mathematics · 01 · The algebra of yes and no · 8 min

Logic & truth

Strip reasoning down to its skeleton and two values remain: true and false. Logic is the discovery that these two values have an algebra — exact laws for combining them — and that algebra turns out to be the blueprint of every computer.

Build the intuition

Three gates build everything

AND (both must hold), OR (at least one holds), NOT (flip it). Every condition you've ever typed — “premium user AND NOT expired” — composes these three. Remarkably, every possible logical function, however baroque, can be built from them; processors are billions of these gates etched in silicon.

The laws: algebra without numbers

Logic has identities as exact as arithmetic's. The stars are De Morgan's laws: NOT(A AND B) = (NOT A) OR (NOT B) — the negation of “both” is “at least one fails.” Programmers use this daily to untangle conditions; lawyers and logicians, to untangle clauses.

¬(AB)=¬A¬B\neg(A \land B) = \neg A \lor \neg B

Implication: the trickiest connective

“If it rains, the ground gets wet” is only broken by rain + dry ground. Wet ground without rain? Consistent (sprinklers exist). Confusing “if A then B” with “if B then A” is the converse error — the most common reasoning bug in humans, and one truth tables vaccinate against.

See it move

InteractiveLogic, the algebra of true and false
  • A AND Btrue only when both areF
  • A OR Btrue when at least one isT
  • NOT Aflips AF
  • A XOR Btrue when they disagreeT
Every if-statement, search filter, and processor circuit is built from exactly these moves. Two values, a handful of laws — and they compose into everything a computer does.

Two switches, four gates, no exceptions. Flip A and B through all four worlds and the laws verify themselves before your eyes.

A worked example

Untangle a real filter

  1. A store needs: NOT (in-stock AND cheap) — flag items failing the “good deal” test.

  2. De Morgan translates:

    ¬(stockcheap)=¬stock¬cheap\neg(\text{stock} \land \text{cheap}) = \neg\text{stock} \lor \neg\text{cheap}
  3. Flag items that are out of stock OR expensive. Same logic, readable code — this exact rewrite passes code review daily, worldwide.

Out in the world

Your searches are logic expressions

“laptop AND (16GB OR 32GB) NOT refurbished” — search engines, email filters, and database queries evaluate boolean algebra over millions of records per keystroke. Fluency in three little words is fluency in querying the modern world.

Common confusion, cleared

OR means one or the other, not both.

Logical OR includes both (soup or salad? yes). The exclusive version is a separate gate, XOR — true only when the two disagree.

If A implies B, then B implies A.

Rain wets ground; wet ground doesn't prove rain. The converse needs its own evidence — assuming it free of charge is history's favorite fallacy.

Recap

  • AND, OR, NOT compose every condition — and every circuit.
  • De Morgan's laws let you rewrite negations cleanly.
  • Implication is one-directional; the converse is a separate claim.