Discover: the theorem everyone quotes
Ask why neural networks work at all and someone will say that they “can approximate any function”. That slogan comes from a 1989 theorem by George Cybenko. Here is its heart, exactly as the paper prints it:
Spotted in the wild
The first line is a neural network with one hidden layer. It has hidden units, each applying a sigmoid to a weighted input, and their outputs are weighted by the and added up. The second line says the network's output is within (epsilon, Chamber 1's tiny number) of a target function everywhere on the unit cube . The words that join them are the important part. The theorem says: “given any … and , there is a sum, , of the above form, for which” the inequality holds “for all ”.
Given any. There is. For all. Those little words are logic, and the order they come in is the whole theorem. Get the order wrong and you'll believe something the theorem never said. By the end of this chamber you'll write it as a single line of symbols and know exactly what it promises.
First, a warm-up with the smallest word of all: if. Here is a version of a puzzle the psychologist Peter Wason devised in 1966.
Every card has a letter on one side and a number on the other. The rule: if a card has a vowel on one side, then it has an even number on the other side. Four cards lie on the table showing , , and . Which cards must you turn over to find out whether the rule is broken?
Learn: propositions and connectives
A proposition is a statement that is either true or false. “” is a true proposition and “ is even” is a false one. “” is not a proposition yet, because its truth depends on . A statement with a free variable like that is called a predicate, written . It becomes a proposition once you fix or quantify it, which is the job of the second half of this chamber.
Propositions combine with connectives. Each one is defined by what it does to truth values:
| T | T | F | T | T |
| T | F | F | F | T |
| F | T | T | F | T |
| F | F | T | F | F |
is “not P”, is “P and Q” (true only when both are), and is “P or Q”, true when at least one is. Mathematical “or” is inclusive: “you may have tea or coffee” in mathematics allows both.
These are the set operations of Chamber 2 in another costume. means , union is and complement is . So De Morgan's laws hold for logic too:
The symbol , “is logically equivalent to”, says the two sides have identical truth tables.
Learn: if, then
The connective that carries most of mathematics is implication, , read “P implies Q” or “if P, then Q”. Think of it as a promise: if it rains, I'll bring an umbrella. There's only one way to break that promise. It rains and you don't bring the umbrella. On a dry day the promise isn't tested, so it isn't broken, whatever you carry.
| T | T | T |
| T | F | F |
| F | T | T |
| F | F | T |
The last two rows surprise people. When is false the implication is vacuously true. That's why Chamber 2 could say for every set : “if then ” can never be broken, because nothing is in .
English has many ways to say , and papers use all of them:
| Phrasing | Example with = “ is divisible by 4”, = “ is even” |
|---|---|
| if , then | if is divisible by 4, then is even |
| whenever | is even whenever it's divisible by 4 |
| only if | is divisible by 4 only if it's even |
| is sufficient for | divisibility by 4 is sufficient for being even |
| is necessary for | being even is necessary for divisibility by 4 |
Three relatives of are worth naming. The converse is : “if is even, then is divisible by 4”, which is false (take ). The contrapositive is : “if is odd, then is not divisible by 4”, which is true. And the biconditional , “P if and only if Q”, claims both directions at once, and .
The contrapositive always has the same truth value as the original. Here is why, as a derivation in full. First, reading the table above, is false in exactly one row, where is true and is false. The formula is also false in exactly that row, so
Now apply that rule to the contrapositive, with in the role of and in the role of :
Back to Wason's cards. The rule is vowel even. Its contrapositive is odd not a vowel, and it's the same rule. That's why the must be turned: it's the contrapositive's test case. The only tests the converse, which the rule never claimed.
Now fill in the tables yourself. The lab checks your columns and then shows you the contrapositive and the converse side by side. There's a bonus round on quantifiers underneath, which the next section explains.
Interactive lab
Truth-table lab
| ImplicationImpl. | ConverseConv. | ContrapositiveContra. | EquivalenceEquiv. | ||
|---|---|---|---|---|---|
| T | T | ||||
| T | F | ||||
| F | T | ||||
| F | F |
Mistakes
–
Blank
16
Bonus round: quantifiers over
On a finite set, ∀ is a long “and” and ∃ is a long “or”. Check every case.
- “not”Negation: is true exactly when is false. Some authors write .
- “and”Conjunction: is true only when both and are true.
- “or”Disjunction: is true when at least one of them is. Mathematical “or” is inclusive: both is fine.
- “implies”, “if then ”: false only when is true and is false. Also written or .
- “is implied by”means . Proofs of an “if and only if” often label their two halves and .
- “if and only if”: each implies the other, so they are always true or false together. Also written .
- “is logically equivalent to”Two statements with identical truth tables, like an implication and its contrapositive. (Chamber 1 met as “is identical to”: the same idea, for logic.)
| Symbol | Say it | Meaning | LaTeX |
|---|---|---|---|
| “not” | Negation: is true exactly when is false. Some authors write . | ||
| “and” | Conjunction: is true only when both and are true. | ||
| “or” | Disjunction: is true when at least one of them is. Mathematical “or” is inclusive: both is fine. | ||
| “implies” | , “if then ”: false only when is true and is false. Also written or . | ||
| “is implied by” | means . Proofs of an “if and only if” often label their two halves and . | ||
| “if and only if” | : each implies the other, so they are always true or false together. Also written . | ||
| “is logically equivalent to” | Two statements with identical truth tables, like an implication and its contrapositive. (Chamber 1 met as “is identical to”: the same idea, for logic.) |
What is the contrapositive of “if a model overfits, then its validation loss rises”?
Learn: for all and there exists
Most statements in machine learning are about every input, or claim that some parameter setting exists. Two symbols, the quantifiers, turn predicates into propositions:
- , “for all in , of ”: every element passes.
- , “there exists an in such that of ”: at least one does.
A few sentences you could meet in a paper:
The first says ReLU never outputs a negative number. The second says the sigmoid's output always lies strictly between 0 and 1. The third says some parameter setting fits the training data perfectly. To prove a you must handle an arbitrary element, as in Chamber 2's element chasing. To prove an one witness is enough.
On a finite set, is a long “and” and a long “or”. With , the statement means . That's why Python calls them all and any.
Order matters. Compare two sentences about the real numbers:
The first says every number has a bigger one, which is true: given , take . The second says one single is bigger than every number, including itself, which is false. In the first, is chosen after and may depend on it. In the second, must be chosen first, once and for all. It's the difference between “everyone has someone they trust” and “there's someone everyone trusts”.
Negating a quantified statement follows two rules:
“Not every weight is positive” means “some weight is not positive”, . It does not mean “every weight is negative”. With several quantifiers, push the inwards one symbol at a time: each quantifier flips, and the condition at the end is negated. The set a quantifier ranges over, like the in , stays as it is.
- “for all”The universal quantifier: what follows holds for every element. Also read “for every” or “for each”.
- “there exists”The existential quantifier: at least one element makes what follows true. One witness is enough.
- “there exists exactly one”Existence and uniqueness: one element works, and no second one does.
- “there does not exist”No element works: the same as , or “for all, not”.
- “such that”Introduces the condition after a quantifier. Papers also use a colon, a vertical bar or just a comma.
| Symbol | Say it | Meaning | LaTeX |
|---|---|---|---|
| “for all” | The universal quantifier: what follows holds for every element. Also read “for every” or “for each”. | ||
| “there exists” | The existential quantifier: at least one element makes what follows true. One witness is enough. | ||
| “there exists exactly one” | Existence and uniqueness: one element works, and no second one does. | ||
| “there does not exist” | No element works: the same as , or “for all, not”. | ||
| “such that” | Introduces the condition after a quantifier. Papers also use a colon, a vertical bar or just a comma. |
Which statement is the negation of ?
Learn: definitions, lemmas and theorems
Papers label their statements, and the labels tell you how to read them.
| Label | What it is |
|---|---|
| Definition | Gives a name to something. Not true or false, just agreed. |
| Theorem | An important result, proved. |
| Lemma | A smaller result, proved mainly to help prove a theorem. |
| Proposition | A result of middling importance. (Logicians also use the word for any true-or-false statement.) |
| Corollary | A result that follows quickly from a theorem just proved. |
| Conjecture | A statement believed true but not yet proved. |
| Assumption | A condition the paper's results depend on, common in ML theory. Check it before you rely on the result. |
Nearly every theorem has the shape “for all objects of some kind, hypotheses conclusion”. Reading one means finding three things: what it ranges over, what it assumes, and what it concludes. Proofs also use a small vocabulary of shorthand:
- “if and only if”The written-out form of , said exactly the same way. Two statements are claimed, one in each direction.
- “without loss of generality”“The other cases work the same way, so we only treat this one.” Honest only when the cases really are symmetric.
- “that is”Latin id est: a restatement of what was just said, in other words.
- “for example”Latin exempli gratia: one example among several, not a restatement.
- “therefore”Marks a conclusion. Rare in papers, common on whiteboards.
- “contradiction”Marks the moment a proof by contradiction reaches something impossible. Also drawn as or a lightning bolt.
| Symbol | Say it | Meaning | LaTeX |
|---|---|---|---|
| “if and only if” | The written-out form of , said exactly the same way. Two statements are claimed, one in each direction. | ||
| “without loss of generality” | “The other cases work the same way, so we only treat this one.” Honest only when the cases really are symmetric. | ||
| “that is” | Latin id est: a restatement of what was just said, in other words. | ||
| “for example” | Latin exempli gratia: one example among several, not a restatement. | ||
| “therefore” | Marks a conclusion. Rare in papers, common on whiteboards. | ||
| “contradiction” | Marks the moment a proof by contradiction reaches something impossible. Also drawn as or a lightning bolt. |
Learn: four ways to prove it
You met a direct proof in Chamber 1: assume the hypothesis and walk forwards to the conclusion. Here's another, the first half of a statement we'll need shortly.
Lemma A. If is an even integer, then is even.
Proof. Let be even, so for some integer . Then , which is two times an integer, so is even.
Going the other way directly is awkward. Knowing tells you little about itself. So use the contrapositive: prove , which you now know is the same statement.
Lemma B. If is even, then is even.
Proof. We prove the contrapositive: if is odd, then is odd. But , and Chamber 1's prove-it exercise showed that the product of two odd integers is odd. So is odd.
Together, Lemmas A and B prove a biconditional: is even if and only if is even. Now the most famous proof by contradiction, where you assume the claim is false and follow the assumption until something impossible happens.
Theorem. is irrational.
Proof. Suppose, for contradiction, that is rational. Then for some integers and with . Any fraction can be reduced to lowest terms, so we may assume that and have no common factor greater than 1. Squaring both sides gives , so
So is even, and by Lemma B, is even. Write . Substituting, , so . Now is even, and by Lemma B again, is even. So and are both even, and they share the factor 2. That contradicts our choice of in lowest terms. The assumption must be false, so is irrational.
Look at how the pieces fit. The proof never touches a decimal expansion; it lives entirely on definitions (rational, even, lowest terms). Lemma B does the real work, twice. And the contradiction lands on the one assumption we made for free, lowest terms. That's the architecture of mathematics in miniature: definitions, then lemmas, then a theorem assembled from them.
The fourth technique only ever disproves. To refute a claim of the form , you need its negation, , and one example proves that: a counterexample. Euler noticed that is prime for . Forty primes in a row look like a law of nature. Then
and the “law” is dead. No number of confirming cases proves a over an infinite set, but a single counterexample always refutes one. Problem 1 hunts for one in a disguised version of this polynomial.
What is enough to disprove “every prime number is odd”?
Learn: the universal approximation theorem, as a sentence
Now back to Cybenko's theorem. Here are its hypotheses, straight from the paper. is the unit cube. is the set of continuous functions on it. is any continuous sigmoidal function, which the paper defines as one with as and as . With those fixed, the theorem is one logical sentence:
Read it aloud: “for every continuous function on the cube, and every positive tolerance , there exist a number of units and weights such that, for every input in the cube, the network is within of .” Everything this chamber taught is in that line, and each piece tells you something:
- It's an existence theorem. promises that suitable weights exist. It says nothing about finding them, and in particular nothing about whether gradient descent will.
- The order is . So is allowed to depend on and on : a wigglier function or a tighter tolerance may need more units, and the theorem gives no bound. Swapping to would claim something far stronger, that one network size serves every function, and the theorem says no such thing. In Problem 3, halving doubles the you need.
- The hypotheses matter. must be continuous and the inputs must lie in the bounded cube . Outside those conditions this theorem is silent.
- The last quantifier is . The error bound holds at every input simultaneously, not just on average or at the training points.
Finally, what would it take to refute the theorem? Negate it, flipping every quantifier: with . In words, you would need one continuous function and one tolerance that every network misses somewhere. Cybenko's proof shows no such pair exists.
Read beyond the course
Logic is the most reusable thing in this course: every later chamber, and every theory paper, leans on it. These are free and worth your time now.
Book · free online · ~90 min
Book of ProofRichard Hammack · Chapter 2: Logic (§2.1–2.10), then Chapters 4–6
Chapter 2 covers truth tables, conditionals, quantifiers and negation at a gentle pace with many exercises. Chapters 4, 5 and 6 are devoted to direct proof, contrapositive proof and proof by contradiction, one technique each. If you do one reading from this chamber, make it this.
Lecture notes · free online · ~45 min
Mathematics for Computer ScienceEric Lehman, F. Thomson Leighton & Albert R. Meyer · Chapter 1: What is a Proof? (§1.1–1.8)
A later edition of the textbook used with the MIT lecture below. Chapter 1 moves from propositions to proving implications, “if and only if” statements and proof by contradiction, including Theorem 1.8.1: is irrational. Chapter 3 goes further into logical formulas if you want more.
Book · free online · ~40 min
Neural Networks and Deep LearningMichael Nielsen · Chapter 4: A visual proof that neural nets can compute any function
An interactive, picture-driven argument for the universal approximation theorem, built from steep sigmoids stacked into steps, just like Problem 3. Read it after this chamber's last Learn section and you'll see the being constructed before your eyes.
Article · free online · ~10 min
Wason selection taskWikipedia
The card puzzle from this chamber's opening, its variants, and the surprising finding that people solve the same logic far more easily when it's phrased as a social rule. A reminder that careful reasoning about “if” doesn't come naturally to anyone.
Papers and lectures
Cybenko's paper is twelve pages of functional analysis, but you can read the parts that matter today if you take them in the right order. Start with the abstract and the first page of the Introduction. Equation (1) there is the one-hidden-layer network, and the definition of “sigmoidal” sits right below it. Then skip Section 2. Its proof uses the Hahn–Banach and Riesz representation theorems and measures, which is graduate analysis. Jump to the start of Section 3 for Theorem 2. Its proof is a single line: “Combine Theorem 1 and Lemma 1”. That's the definition–lemma–theorem architecture of this chamber in action. The heavy lifting happens earlier, and the headline result is assembled from parts. The rest of Section 3, on classification and decision regions, can wait until you've met measures.
Approximation by superpositions of a sigmoidal functionGeorge Cybenko · Mathematics of Control, Signals and Systems 2, 303–314, 1989The classic universal approximation theorem for one hidden layer of sigmoids. It's quoted in countless papers, and often read with the quantifiers in the wrong order.
Decode the paper · Theorem 2, Section 3
Approximation by superpositions of a sigmoidal functionGeorge Cybenko · Mathematics of Control, Signals and Systems, 1989
Cybenko's Theorem 2, the result behind the phrase “neural networks are universal approximators”. It says finite sums of the form are dense in , and then spells that out: “given any and , there is a sum, , of the above form, for which” the inequality holds for all . Here is the unit cube and the set of continuous functions on it. Match each symbol to its meaning.
Options
Watch
Tom Leighton's first lecture covers this chamber from a computer scientist's angle. Watch for his claim about , then a conjecture of Euler's about fourth powers that stood for more than two centuries before a counterexample turned up, and his truth table for “implies”, including why “if pigs fly, then I'm king” is true.
A short, clear walk through the negation rules, with examples. Pause before each answer and negate the statement yourself first.
Your turn
You've filled in the truth tables. Now translate logic into words and into Python, prove one statement by contrapositive and another by contradiction, and finish with three problems that turn quantifiers into code.
Match · Symbols ↔ Read aloud as
Say it aloud
Match each piece of logic to the way a mathematician would read it aloud.
Options
Match · Logic ↔ Python
From logic to Python
Python has and, or and not, plus all and any for quantifiers over a finite collection. It has no implication operator, so you build one. Match each statement to the Python that computes it. One of them has been rewritten with a De Morgan law.
Options
Proofs
The puzzle is a proof by contrapositive. Watch which statement it starts from, because two of the lines on offer start from the wrong place. The proof you write yourself is a proof by contradiction, in the style of the one for .
Proof puzzle
Prove it backwards
Claim
For every integer : if is odd, then is odd.
Tap lines in the order they should appear. Not every line belongs. Tap a line in your proof to send it back.
Your proof
- Pick the first line below.
Available lines
Prove it yourself
Rational plus irrational
Claim
If is rational and is irrational, then is irrational. (A real number is rational if it equals for some integers and with , and irrational otherwise.) For instance, it follows that is irrational.
Your typeset proof appears here.
Code it up
Each problem is a quantified statement. The first needs a counterexample, the second a negated quantifier over infinitely many pairs, and the third a witness for Cybenko's .
Problem 7·Warm-up
Eighty primes, then a counterexample
Here is a claim, written the way this chamber taught you to read:
Here , and a prime is an integer greater than 1 whose only positive divisors are 1 and itself. The first few values, , are all prime, and the claim starts to look convincing. But one counterexample is enough to refute a “for all”.
What is the smallest for which is not prime?
Problem 8·Standard
For all pairs, never a sum
Quantifiers over a finite range turn straight into code: becomes Python's all(...) and becomes any(...). For a positive integer , consider the statement
where . In words, is not a sum of two squares. For example, is true because no two squares add up to 3, but is false because , and is false because .
For how many is true?
Problem 9·Challenge
How many units does the theorem need?
Cybenko's Theorem 2 promises that for every continuous on and every , there exist and weights such that
satisfies for all . (The means “add up the terms for ”; Chamber 5 covers it properly.) The theorem doesn't say how big must be, so let's find out for one concrete recipe.
Take and the logistic sigmoid . For each , build from smoothed steps, one centred at each midpoint :
Replace “for all ” by a check at the 1001 grid points for . What is the smallest for which at every grid point?
Key takeaways
- is false only when is true and is false. When is false it's vacuously true.
- The contrapositive is the same statement as ; the converse is not. claims both directions.
- needs every case, needs one witness, and their order matters: lets depend on .
- Negation flips every quantifier and negates the condition: . That's why one counterexample refutes a “for all”.
- Four techniques: direct, contrapositive, contradiction ( is irrational) and counterexample.
- Cybenko's theorem is : a network exists for each function and tolerance, with no bound on its size and no promise that training finds it.
Checkpoint
Prove it to the labyrinth
Answer every question to clear this chamber. First-try answers earn the most XP.
When is false?
A textbook proves: if a function is differentiable, then it is continuous. Which of these follows?
Over the real numbers, which of these are true?
(i)
(ii)
Negate this statement: *for every there is an such that for all .*
The truth table of has 8 rows. In how many of them is the whole statement true?
A paper states: * is even if and only if is even.* What must a proof establish?
Cybenko's theorem says: for every continuous on the unit cube and every , there is a finite sum of sigmoids with for all . What does it guarantee?
A proof by contradiction that is irrational begins by assuming what?
End of the chamber
Clear this chamber
- Questions in this chamber (0/12 solved)Next unsolved
- Bonus: Truth be told (+40 XP)
- Bonus: Problem 7: Eighty primes, then a counterexample (+20 XP)
- Bonus: Problem 8: For all pairs, never a sum (+35 XP)
- Bonus: Problem 9: How many units does the theorem need? (+50 XP)
- Bonus: Proof: Prove it backwards (+25 XP)
- Bonus: Proof: Rational plus irrational (+40 XP)
- Bonus: Decode the paper (+30 XP)
- Bonus: Match: Say it aloud (+25 XP)
- Bonus: Match: From logic to Python (+25 XP)