Skip to content
AriadneTechnology

The Outer Ring · Chamber 3 of 9

Logic: For All and There Exists

∀, ∃, ⇒ and ⇔: the logical glue of every definition and theorem, and your first real proofs.

35 min 50 XP + 12 questions + 1 challengeNotationVideoPapersProofsCodeLab

In this chamber you will

  • Read and negate statements with ∀ and ∃
  • Use ⇒, ⇔, ¬, ∧ and ∨ precisely
  • Recognise direct proof, contrapositive, contradiction and counterexample
  • Read the universal approximation theorem as a logical sentence
DiscoverLearnRead beyondPapers & lecturesYour turn

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

G(x)=∑j=1Nαj σ(yjTx+θj)G(x) = \sum_{j=1}^{N} \alpha_j\, \sigma(y_j^{T} x + \theta_j)∣G(x)−f(x)∣<εfor all x∈In|G(x) - f(x)| < \varepsilon \quad \text{for all } x \in I_n
Cybenko (1989), “Approximation by superpositions of a sigmoidal function”, Theorem 2

The first line is a neural network with one hidden layer. It has NN hidden units, each applying a sigmoid σ\sigma to a weighted input, and their outputs are weighted by the αj\alpha_j and added up. The second line says the network's output is within ε\varepsilon (epsilon, Chamber 1's tiny number) of a target function ff everywhere on the unit cube InI_n. The words that join them are the important part. The theorem says: “given any ff … and ε>0\varepsilon > 0, there is a sum, G(x)G(x), of the above form, for which” the inequality holds “for all xx”.

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.

Quick check +20 XP

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 A\text{A}, K\text{K}, 44 and 77. Which cards must you turn over to find out whether the rule is broken?

DiscoverLearnRead beyondPapers & lecturesYour turn

Learn: propositions and connectives

A proposition is a statement that is either true or false. “2+2=42 + 2 = 4” is a true proposition and “77 is even” is a false one. “x>3x > 3” is not a proposition yet, because its truth depends on xx. A statement with a free variable like that is called a predicate, written P(x)P(x). It becomes a proposition once you fix xx 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:

PPQQ¬P\neg PP∧QP \land QP∨QP \lor Q
TTFTT
TFFFT
FTTFT
FFTFF

¬P\neg P is “not P”, P∧QP \land Q is “P and Q” (true only when both are), and P∨QP \lor Q 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. x∈A∩Bx \in A \cap B means (x∈A)∧(x∈B)(x \in A) \land (x \in B), union is ∨\lor and complement is ¬\neg. So De Morgan's laws hold for logic too:

¬(P∧Q)≡¬P∨¬Q,¬(P∨Q)≡¬P∧¬Q.\neg(P \land Q) \equiv \neg P \lor \neg Q, \qquad \neg(P \lor Q) \equiv \neg P \land \neg Q.

The symbol ≡\equiv, “is logically equivalent to”, says the two sides have identical truth tables.

Learn: if, then

The connective that carries most of mathematics is implication, P⇒QP \Rightarrow Q, 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.

PPQQP⇒QP \Rightarrow Q
TTT
TFF
FTT
FFT

The last two rows surprise people. When PP is false the implication is vacuously true. That's why Chamber 2 could say ∅⊆A\varnothing \subseteq A for every set AA: “if x∈∅x \in \varnothing then x∈Ax \in A” can never be broken, because nothing is in ∅\varnothing.

English has many ways to say P⇒QP \Rightarrow Q, and papers use all of them:

PhrasingExample with PP = “nn is divisible by 4”, QQ = “nn is even”
if PP, then QQif nn is divisible by 4, then nn is even
QQ whenever PPnn is even whenever it's divisible by 4
PP only if QQnn is divisible by 4 only if it's even
PP is sufficient for QQdivisibility by 4 is sufficient for being even
QQ is necessary for PPbeing even is necessary for divisibility by 4

Three relatives of P⇒QP \Rightarrow Q are worth naming. The converse is Q⇒PQ \Rightarrow P: “if nn is even, then nn is divisible by 4”, which is false (take n=6n = 6). The contrapositive is ¬Q⇒¬P\neg Q \Rightarrow \neg P: “if nn is odd, then nn is not divisible by 4”, which is true. And the biconditional P⇔QP \Leftrightarrow Q, “P if and only if Q”, claims both directions at once, P⇒QP \Rightarrow Q and Q⇒PQ \Rightarrow P.

The contrapositive always has the same truth value as the original. Here is why, as a derivation in full. First, reading the table above, P⇒QP \Rightarrow Q is false in exactly one row, where PP is true and QQ is false. The formula ¬P∨Q\neg P \lor Q is also false in exactly that row, so

P⇒Q  ≡  ¬P∨Q.P \Rightarrow Q \;\equiv\; \neg P \lor Q.

Now apply that rule to the contrapositive, with ¬Q\neg Q in the role of PP and ¬P\neg P in the role of QQ:

¬Q⇒¬P≡¬(¬Q)∨¬Pthe rule above≡Q∨¬Ptwo negations cancel≡¬P∨Q“or” doesn’t care about order≡P⇒Qthe rule above, read backwards.\begin{aligned} \neg Q \Rightarrow \neg P &\equiv \neg(\neg Q) \lor \neg P && \text{the rule above} \\ &\equiv Q \lor \neg P && \text{two negations cancel} \\ &\equiv \neg P \lor Q && \text{“or” doesn't care about order} \\ &\equiv P \Rightarrow Q && \text{the rule above, read backwards.} \end{aligned}

Back to Wason's cards. The rule is vowel ⇒\Rightarrow even. Its contrapositive is odd ⇒\Rightarrow not a vowel, and it's the same rule. That's why the 77 must be turned: it's the contrapositive's test case. The 44 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

Each row fixes a truth value for P and Q. Click a cell to cycle it between T and F, fill in all four columns, then press Check. Remember the only way to break a promise “if P then Q”: P happens and Q doesn't.
PPQQImpl.P⇒QP \Rightarrow QConv.Q⇒PQ \Rightarrow PContra.¬Q⇒¬P\neg Q \Rightarrow \neg PEquiv.P⇔QP \Leftrightarrow Q
TT
TF
FT
FF

Mistakes

–

Blank

16

Bonus round: quantifiers over D={1,2,3,4,5,6}D = \{1, 2, 3, 4, 5, 6\}

On a finite set, ∀ is a long “and” and ∃ is a long “or”. Check every case.

  • ∀x∈D,  x>1\forall x \in D,\; x > 1
  • ∃x∈D,  x>5\exists x \in D,\; x > 5
  • ∀x∈D,  ∃y∈D,  y>x\forall x \in D,\; \exists y \in D,\; y > x
  • ∃y∈D,  ∀x∈D,  x≤y\exists y \in D,\; \forall x \in D,\; x \le y
  • ∀x∈D,  (x even⇒x>1)\forall x \in D,\; (x \text{ even} \Rightarrow x > 1)
  • ∃! x∈D,  x2>20\exists!\, x \in D,\; x^2 > 20
  • ¬ (∀x∈D,  x<6)\neg\,(\forall x \in D,\; x < 6)
Challenge: Truth be toldFill in every row of the truth tables for implication and equivalence.+40 XP
Connectives
  • ¬\neg“not”
    Negation: ¬P\neg P is true exactly when PP is false. Some authors write ∼P\sim P.
    ¬(x>0)\neg (x > 0)
  • ∧\land“and”
    Conjunction: P∧QP \land Q is true only when both PP and QQ are true.
    x>0∧x<1x > 0 \land x < 1
  • ∨\lor“or”
    Disjunction: P∨QP \lor Q is true when at least one of them is. Mathematical “or” is inclusive: both is fine.
    x<0∨x>1x < 0 \lor x > 1
  • ⇒\Rightarrow“implies”
    P⇒QP \Rightarrow Q, “if PP then QQ”: false only when PP is true and QQ is false. Also written   ⟹  \implies or →\to.
    x>2⇒x2>4x > 2 \Rightarrow x^2 > 4
  • ⇐\Leftarrow“is implied by”
    P⇐QP \Leftarrow Q means Q⇒PQ \Rightarrow P. Proofs of an “if and only if” often label their two halves (⇒)(\Rightarrow) and (⇐)(\Leftarrow).
    x2>4⇐x>2x^2 > 4 \Leftarrow x > 2
  • ⇔\Leftrightarrow“if and only if”
    P⇔QP \Leftrightarrow Q: each implies the other, so they are always true or false together. Also written   ⟺  \iff.
    n even⇔n2 evenn \text{ even} \Leftrightarrow n^2 \text{ even}
  • ≡\equiv“is logically equivalent to”
    Two statements with identical truth tables, like an implication and its contrapositive. (Chamber 1 met ≡\equiv as “is identical to”: the same idea, for logic.)
    ¬¬P≡P\neg\neg P \equiv P
Quick check +20 XP

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:

  • ∀x∈S, P(x)\forall x \in S,\ P(x), “for all xx in SS, PP of xx”: every element passes.
  • ∃x∈S, P(x)\exists x \in S,\ P(x), “there exists an xx in SS such that PP of xx”: at least one does.

A few sentences you could meet in a paper:

∀x∈R, max⁡(0,x)≥0∀z∈R, σ(z)∈(0,1)∃θ such that L(θ)=0\forall x \in \mathbb{R},\ \max(0, x) \ge 0 \qquad \forall z \in \mathbb{R},\ \sigma(z) \in (0, 1) \qquad \exists \theta \text{ such that } \mathcal{L}(\theta) = 0

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 ∀\forall you must handle an arbitrary element, as in Chamber 2's element chasing. To prove an ∃\exists one witness is enough.

On a finite set, ∀\forall is a long “and” and ∃\exists a long “or”. With S={1,2,3}S = \{1, 2, 3\}, the statement ∀x∈S, P(x)\forall x \in S,\ P(x) means P(1)∧P(2)∧P(3)P(1) \land P(2) \land P(3). That's why Python calls them all and any.

Order matters. Compare two sentences about the real numbers:

∀x∈R, ∃y∈R, y>xversus∃y∈R, ∀x∈R, y>x.\forall x \in \mathbb{R},\ \exists y \in \mathbb{R},\ y > x \qquad \text{versus} \qquad \exists y \in \mathbb{R},\ \forall x \in \mathbb{R},\ y > x.

The first says every number has a bigger one, which is true: given xx, take y=x+1y = x + 1. The second says one single yy is bigger than every number, including itself, which is false. In the first, yy is chosen after xx and may depend on it. In the second, yy 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:

¬(∀x, P(x))≡∃x, ¬P(x),¬(∃x, P(x))≡∀x, ¬P(x).\neg\big(\forall x,\ P(x)\big) \equiv \exists x,\ \neg P(x), \qquad \neg\big(\exists x,\ P(x)\big) \equiv \forall x,\ \neg P(x).

“Not every weight is positive” means “some weight is not positive”, ∃i, wi≤0\exists i,\ w_i \le 0. It does not mean “every weight is negative”. With several quantifiers, push the ¬\neg 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 ε>0\varepsilon > 0 in ∀ε>0\forall \varepsilon > 0, stays as it is.

Quantifiers
  • ∀\forall“for all”
    The universal quantifier: what follows holds for every element. Also read “for every” or “for each”.
    ∀x∈R,  x2≥0\forall x \in \mathbb{R},\; x^2 \ge 0
  • ∃\exists“there exists”
    The existential quantifier: at least one element makes what follows true. One witness is enough.
    ∃x∈R,  x2=2\exists x \in \mathbb{R},\; x^2 = 2
  • ∃!\exists!“there exists exactly one”
    Existence and uniqueness: one element works, and no second one does.
    ∃! x∈R,  2x=6\exists!\, x \in \mathbb{R},\; 2x = 6
  • ∄\nexists“there does not exist”
    No element works: the same as ¬∃\neg\exists, or “for all, not”.
    ∄x∈R,  x2<0\nexists x \in \mathbb{R},\; x^2 < 0
  • s.t.\text{s.t.}“such that”
    Introduces the condition after a quantifier. Papers also use a colon, a vertical bar or just a comma.
    ∃θ s.t. L(θ)=0\exists \theta \text{ s.t. } \mathcal{L}(\theta) = 0
Quick check +20 XP

Which statement is the negation of ∀x∈S, ∃y∈S, y>x\forall x \in S,\ \exists y \in S,\ y > x?

Learn: definitions, lemmas and theorems

Papers label their statements, and the labels tell you how to read them.

LabelWhat it is
DefinitionGives a name to something. Not true or false, just agreed.
TheoremAn important result, proved.
LemmaA smaller result, proved mainly to help prove a theorem.
PropositionA result of middling importance. (Logicians also use the word for any true-or-false statement.)
CorollaryA result that follows quickly from a theorem just proved.
ConjectureA statement believed true but not yet proved.
AssumptionA 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 ⇒\Rightarrow 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:

The words of proofs
  • iff\text{iff}“if and only if”
    The written-out form of ⇔\Leftrightarrow, said exactly the same way. Two statements are claimed, one in each direction.
    n even iff n2 evenn \text{ even iff } n^2 \text{ even}
  • WLOG\text{WLOG}“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.
    WLOG, a≤b\text{WLOG, } a \le b
  • i.e.\text{i.e.}“that is”
    Latin id est: a restatement of what was just said, in other words.
    x∈R≥0, i.e. x≥0x \in \mathbb{R}_{\ge 0}, \text{ i.e. } x \ge 0
  • e.g.\text{e.g.}“for example”
    Latin exempli gratia: one example among several, not a restatement.
    e.g. ReLU\text{e.g. ReLU}
  • ∴\therefore“therefore”
    Marks a conclusion. Rare in papers, common on whiteboards.
    ∴  x=3\therefore\; x = 3
  • ⇒ ⁣⇐\Rightarrow\!\Leftarrow“contradiction”
    Marks the moment a proof by contradiction reaches something impossible. Also drawn as ⊥\bot or a lightning bolt.
    p=2k=2m+1  ⇒ ⁣⇐p = 2k = 2m + 1 \;\Rightarrow\!\Leftarrow

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 nn is an even integer, then n2n^2 is even.

Proof. Let nn be even, so n=2kn = 2k for some integer kk. Then n2=4k2=2(2k2)n^2 = 4k^2 = 2(2k^2), which is two times an integer, so n2n^2 is even. ■\blacksquare

Going the other way directly is awkward. Knowing n2=2mn^2 = 2m tells you little about nn itself. So use the contrapositive: prove ¬Q⇒¬P\neg Q \Rightarrow \neg P, which you now know is the same statement.

Lemma B. If n2n^2 is even, then nn is even.

Proof. We prove the contrapositive: if nn is odd, then n2n^2 is odd. But n2=n⋅nn^2 = n \cdot n, and Chamber 1's prove-it exercise showed that the product of two odd integers is odd. So n2n^2 is odd. ■\blacksquare

Together, Lemmas A and B prove a biconditional: nn is even if and only if n2n^2 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. 2\sqrt{2} is irrational.

Proof. Suppose, for contradiction, that 2\sqrt{2} is rational. Then 2=p/q\sqrt{2} = p/q for some integers pp and qq with q≠0q \ne 0. Any fraction can be reduced to lowest terms, so we may assume that pp and qq have no common factor greater than 1. Squaring both sides gives 2=p2/q22 = p^2/q^2, so

p2=2q2.p^2 = 2q^2.

So p2p^2 is even, and by Lemma B, pp is even. Write p=2kp = 2k. Substituting, 4k2=2q24k^2 = 2q^2, so q2=2k2q^2 = 2k^2. Now q2q^2 is even, and by Lemma B again, qq is even. So pp and qq are both even, and they share the factor 2. That contradicts our choice of p/qp/q in lowest terms. The assumption must be false, so 2\sqrt{2} is irrational. ■\blacksquare

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 ∀x, P(x)\forall x,\ P(x), you need its negation, ∃x, ¬P(x)\exists x,\ \neg P(x), and one example proves that: a counterexample. Euler noticed that n2+n+41n^2 + n + 41 is prime for n=0,1,2,…,39n = 0, 1, 2, \ldots, 39. Forty primes in a row look like a law of nature. Then

402+40+41=1681=412,40^2 + 40 + 41 = 1681 = 41^2,

and the “law” is dead. No number of confirming cases proves a ∀\forall over an infinite set, but a single counterexample always refutes one. Problem 1 hunts for one in a disguised version of this polynomial.

Quick check +20 XP

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. In=[0,1]nI_n = [0, 1]^n is the unit cube. C(In)C(I_n) is the set of continuous functions on it. σ\sigma is any continuous sigmoidal function, which the paper defines as one with σ(t)→1\sigma(t) \to 1 as t→+∞t \to +\infty and σ(t)→0\sigma(t) \to 0 as t→−∞t \to -\infty. With those fixed, the theorem is one logical sentence:

∀f∈C(In)    ∀ε>0    ∃N∈N, αj,θj∈R, yj∈Rn    ∀x∈In:  ∣G(x)−f(x)∣<ε.\forall f \in C(I_n)\;\; \forall \varepsilon > 0\;\; \exists N \in \mathbb{N},\ \alpha_j, \theta_j \in \mathbb{R},\ y_j \in \mathbb{R}^n\;\; \forall x \in I_n : \; |G(x) - f(x)| < \varepsilon.

Read it aloud: “for every continuous function ff on the cube, and every positive tolerance ε\varepsilon, there exist a number of units NN and weights such that, for every input xx in the cube, the network is within ε\varepsilon of ff.” Everything this chamber taught is in that line, and each piece tells you something:

  1. It's an existence theorem. ∃\exists promises that suitable weights exist. It says nothing about finding them, and in particular nothing about whether gradient descent will.
  2. The order is ∀f ∀ε ∃N\forall f\ \forall \varepsilon\ \exists N. So NN is allowed to depend on ff and on ε\varepsilon: a wigglier function or a tighter tolerance may need more units, and the theorem gives no bound. Swapping to ∃N ∀f\exists N\ \forall f would claim something far stronger, that one network size serves every function, and the theorem says no such thing. In Problem 3, halving ε\varepsilon doubles the NN you need.
  3. The hypotheses matter. ff must be continuous and the inputs must lie in the bounded cube InI_n. Outside those conditions this theorem is silent.
  4. The last quantifier is ∀x\forall x. 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: ∃f ∃ε>0 ∀N,αj,θj,yj ∃x∈In\exists f\ \exists \varepsilon > 0\ \forall N, \alpha_j, \theta_j, y_j\ \exists x \in I_n with ∣G(x)−f(x)∣≥ε|G(x) - f(x)| \ge \varepsilon. In words, you would need one continuous function and one tolerance that every network misses somewhere. Cybenko's proof shows no such pair exists.

DiscoverLearnRead beyondPapers & lecturesYour turn

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 Proof

Richard 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 Science

Eric 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: 2\sqrt{2} is irrational. Chapter 3 goes further into logical formulas if you want more.

Book · free online · ~40 min

Neural Networks and Deep Learning

Michael 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 ∃N\exists N being constructed before your eyes.

Article · free online · ~10 min

Wason selection task

Wikipedia

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.

DiscoverLearnRead beyondPapers & lecturesYour turn

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, 1989

The 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 function

George Cybenko · Mathematics of Control, Signals and Systems, 1989

+30 XP
G(x)=∑j=1Nαj σ(yjTx+θj),∣G(x)−f(x)∣<εfor all x∈InG(x) = \sum_{j=1}^{N} \alpha_j\, \sigma(y_j^{T} x + \theta_j), \qquad |G(x) - f(x)| < \varepsilon \quad \text{for all } x \in I_n

Cybenko's Theorem 2, the result behind the phrase “neural networks are universal approximators”. It says finite sums of the form G(x)G(x) are dense in C(In)C(I_n), and then spells that out: “given any f∈C(In)f \in C(I_n) and ε>0\varepsilon > 0, there is a sum, G(x)G(x), of the above form, for which” the inequality holds for all x∈Inx \in I_n. Here In=[0,1]nI_n = [0, 1]^n is the unit cube and C(In)C(I_n) the set of continuous functions on it. Match each symbol to its meaning.

σ\sigma
NN
yjy_j
θj\theta_j
αj\alpha_j
ε\varepsilon
for all x∈In\text{for all } x \in I_n

Options

Watch

Lec 1 | MIT 6.042J Mathematics for Computer Science, Fall 2010MIT OpenCourseWare · 44 min

Tom Leighton's first lecture covers this chamber from a computer scientist's angle. Watch for his ∀n∈N\forall n \in \mathbb{N} claim about n2+n+41n^2 + n + 41, 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.

Negating Universal and Existential QuantifiersDr. Trefor Bazett · 8 min

A short, clear walk through the negation rules, with examples. Pause before each answer and negate the statement yourself first.

DiscoverLearnRead beyondPapers & lecturesYour turn

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

+25 XP

Match each piece of logic to the way a mathematician would read it aloud.

¬P\neg P
P∧QP \land Q
P∨QP \lor Q
P⇒QP \Rightarrow Q
P⇔QP \Leftrightarrow Q
∀x∈S\forall x \in S
∃! x\exists!\, x

Options

Match · Logic ↔ Python

From logic to Python

+25 XP

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.

∀x∈S:P(x)\forall x \in S : P(x)
∃x∈S:P(x)\exists x \in S : P(x)
∄x∈S:P(x)\nexists x \in S : P(x)
P⇒QP \Rightarrow Q
P⇔QP \Leftrightarrow Q
¬(P∧Q)\neg(P \land Q)

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 2\sqrt{2}.

Proof puzzle

Prove it backwards

+25 XP

Claim

For every integer nn: if 3n+23n + 2 is odd, then nn 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

  1. Pick the first line below.

Available lines

Prove it yourself

Rational plus irrational

+40 XP

Claim

If rr is rational and xx is irrational, then r+xr + x is irrational. (A real number is rational if it equals p/qp/q for some integers pp and qq with q≠0q \ne 0, and irrational otherwise.) For instance, it follows that 1+21 + \sqrt{2} is irrational.

Preview

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 ∃N\exists N.

Problem 7·Warm-up

Eighty primes, then a counterexample

+20 XP

Here is a claim, written the way this chamber taught you to read:

∀n∈N0:  n2−79n+1601 is prime.\forall n \in \mathbb{N}_0 : \; n^2 - 79n + 1601 \text{ is prime}.

Here N0={0,1,2,…}\mathbb{N}_0 = \{0, 1, 2, \ldots\}, and a prime is an integer greater than 1 whose only positive divisors are 1 and itself. The first few values, 1601,1523,1447,1373,…1601, 1523, 1447, 1373, \ldots, are all prime, and the claim starts to look convincing. But one counterexample is enough to refute a “for all”.

What is the smallest n∈N0n \in \mathbb{N}_0 for which n2−79n+1601n^2 - 79n + 1601 is not prime?

An exact integer (or a fraction like 7/12)

Problem 8·Standard

For all pairs, never a sum

+35 XP

Quantifiers over a finite range turn straight into code: ∀\forall becomes Python's all(...) and ∃\exists becomes any(...). For a positive integer nn, consider the statement

Q(n):∀a,b∈N0:  a2+b2≠n,Q(n): \quad \forall a, b \in \mathbb{N}_0 : \; a^2 + b^2 \ne n,

where N0={0,1,2,…}\mathbb{N}_0 = \{0, 1, 2, \ldots\}. In words, nn is not a sum of two squares. For example, Q(3)Q(3) is true because no two squares add up to 3, but Q(5)Q(5) is false because 12+22=51^2 + 2^2 = 5, and Q(4)Q(4) is false because 22+02=42^2 + 0^2 = 4.

For how many n∈{1,2,…,1000}n \in \{1, 2, \ldots, 1000\} is Q(n)Q(n) true?

An exact integer (or a fraction like 7/12)

Problem 9·Challenge

How many units does the theorem need?

+50 XP

Cybenko's Theorem 2 promises that for every continuous ff on [0,1][0, 1] and every ε>0\varepsilon > 0, there exist NN and weights such that

G(x)=∑j=1Nαj σ(yjx+θj)G(x) = \sum_{j=1}^{N} \alpha_j\, \sigma(y_j x + \theta_j)

satisfies ∣G(x)−f(x)∣<ε|G(x) - f(x)| < \varepsilon for all x∈[0,1]x \in [0, 1]. (The Σ\Sigma means “add up the NN terms for j=1,…,Nj = 1, \ldots, N”; Chamber 5 covers it properly.) The theorem doesn't say how big NN must be, so let's find out for one concrete recipe.

Take f(x)=x2f(x) = x^2 and the logistic sigmoid σ(t)=1/(1+e−t)\sigma(t) = 1/(1 + e^{-t}). For each N≥1N \ge 1, build GNG_N from NN smoothed steps, one centred at each midpoint (j−12)/N(j - \tfrac{1}{2})/N:

αj=f ⁣(jN)−f ⁣(j−1N),yj=10N,θj=−10(j−12),j=1,…,N.\alpha_j = f\!\left(\tfrac{j}{N}\right) - f\!\left(\tfrac{j-1}{N}\right), \qquad y_j = 10N, \qquad \theta_j = -10\left(j - \tfrac{1}{2}\right), \qquad j = 1, \ldots, N.

Replace “for all x∈[0,1]x \in [0, 1]” by a check at the 1001 grid points x=k/1000x = k/1000 for k=0,1,…,1000k = 0, 1, \ldots, 1000. What is the smallest NN for which ∣GN(x)−f(x)∣<0.025|G_N(x) - f(x)| < 0.025 at every grid point?

An exact integer (or a fraction like 7/12)

Key takeaways

  • P⇒QP \Rightarrow Q is false only when PP is true and QQ is false. When PP is false it's vacuously true.
  • The contrapositive ¬Q⇒¬P\neg Q \Rightarrow \neg P is the same statement as P⇒QP \Rightarrow Q; the converse Q⇒PQ \Rightarrow P is not. P⇔QP \Leftrightarrow Q claims both directions.
  • ∀\forall needs every case, ∃\exists needs one witness, and their order matters: ∀x ∃y\forall x\, \exists y lets yy depend on xx.
  • Negation flips every quantifier and negates the condition: ¬∀x P(x)≡∃x ¬P(x)\neg \forall x\, P(x) \equiv \exists x\, \neg P(x). That's why one counterexample refutes a “for all”.
  • Four techniques: direct, contrapositive, contradiction (2\sqrt{2} is irrational) and counterexample.
  • Cybenko's theorem is ∀f ∀ε ∃N ∀x\forall f\ \forall \varepsilon\ \exists N\ \forall x: 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.

0/8
Question 1 of 8 +20 XP

When is P⇒QP \Rightarrow Q false?

Question 2 of 8 +20 XP

A textbook proves: if a function is differentiable, then it is continuous. Which of these follows?

Question 3 of 8 +20 XP

Over the real numbers, which of these are true?

(i) ∀x∈R, ∃y∈R, y>x\forall x \in \mathbb{R},\ \exists y \in \mathbb{R},\ y > x

(ii) ∃y∈R, ∀x∈R, y>x\exists y \in \mathbb{R},\ \forall x \in \mathbb{R},\ y > x

Question 4 of 8 +20 XP

Negate this statement: *for every ε>0\varepsilon > 0 there is an NN such that ∣an∣<ε|a_n| < \varepsilon for all n≥Nn \ge N.*

Question 5 of 8 +20 XP

The truth table of (P∨Q)⇒R(P \lor Q) \Rightarrow R has 8 rows. In how many of them is the whole statement true?

Question 6 of 8 +20 XP

A paper states: *nn is even if and only if n2n^2 is even.* What must a proof establish?

Question 7 of 8 +20 XP

Cybenko's theorem says: for every continuous ff on the unit cube InI_n and every ε>0\varepsilon > 0, there is a finite sum GG of sigmoids with ∣G(x)−f(x)∣<ε|G(x) - f(x)| < \varepsilon for all x∈Inx \in I_n. What does it guarantee?

Question 8 of 8 +20 XP

A proof by contradiction that 2\sqrt{2} is irrational begins by assuming what?

End of the chamber

Clear this chamber

+50 XPFor All and There ExistsImplicationProof TechniquesCounterexample