JOVANA
Explore Library Glossary Getting Started Three Levels Fields How it works Mission
Join the mission
All guides

Logic, Quantifiers, and Negation

Logic is the grammar of every proof you will write in this subject. Learn to read for-all and there-exists, to chain them precisely, and — the load-bearing skill — to negate a quantified statement cleanly. This single move is what turns the pumping lemma into a non-regularity proof.

From hand-waving to airtight claims

In the previous guide you pinned down sets, relations, and functions — the nouns of this subject. Logic supplies its verbs: the precise way to say what is true and to combine claims without leaving cracks for ambiguity. A proposition is simply a statement that is definitely true or definitely false, with no middle ground: '3 is odd' (true), 'the empty string has length 1' (false). Every theorem you meet from here on is really a proposition we intend to settle one way or the other, and every proof is a chain of smaller propositions joined by airtight reasoning.

We build big propositions from small ones with four connectives. AND requires both parts to hold; OR requires at least one; NOT flips true and false; and implication 'if P then Q' (written P -> Q) says P forces Q. Two everyday traps live here. First, logic's OR is inclusive: 'P or Q' is true when either side is true, or when both are — unlike the menu's 'soup or salad'. Second, the implication P -> Q is false in exactly one situation, when P is true but Q is false; in every other case it is true, including the slightly eerie case where P is false, where we call it 'vacuously true'. ('If the moon is cheese, then 2+2=5' is a true implication, because its premise never fires.)

For-all and there-exists: the two quantifiers

Connectives glue together a few named propositions, but the theorems of this subject talk about infinitely many objects at once — every string, every state, every machine. For that we need quantifiers. 'For all' (the universal quantifier, written with an upside-down A, the symbol forall) claims something holds for every object in a collection: 'for all strings w over Sigma, the length of w is at least 0'. 'There exists' (the existential quantifier, written with a backwards E, the symbol exists) claims at least one object works: 'there exists a string of length 5'. The collection being ranged over — all strings, all natural numbers — is the quantifier's domain, and stating it clearly is half the battle.

The real subtlety arrives when quantifiers alternate. The statement 'for all x there exists a y such that y > x' (every number is beaten by a bigger one) is true over the integers — but swap the order to 'there exists a y such that for all x, y > x' (one single number beats everything) and it becomes flatly false. The order is not decoration: it controls whether y is allowed to depend on x. Reading these statements left to right, deciding for each quantifier whether the choice may look at the variables already fixed, is a skill you will lean on in every limit argument, every closure proof, and — crucially — in the pumping lemma, whose statement is a four-deep nest of alternating quantifiers.

Quantifier order matters:

  forall x. exists y.  y > x     ->  TRUE   (y may depend on x; pick y = x+1)
  exists y. forall x.  y > x     ->  FALSE  (one y must beat every x at once)

Reading rule: a later quantifier's choice may use
every variable fixed to its LEFT, never one to its right.
Swapping for-all and there-exists can flip a true statement to false; inner choices may depend only on outer (left) variables.

Negation: the one move you must get right

Here is the single most important manoeuvre in the whole toolkit. To disprove a universal claim you do not argue with all of it — you produce one counterexample. To deny 'all swans are white', show one black swan. Symbolically, the negation of 'for all x, P(x)' is 'there exists an x such that not P(x)'. And the mirror image: the negation of 'there exists x with P(x)' is 'for all x, not P(x)'. Pushing a NOT inward across a quantifier flips it — for-all becomes there-exists, there-exists becomes for-all — and the NOT keeps travelling inward onto whatever the quantifier was guarding.

When several quantifiers are stacked, you flip them one at a time, from the outside in, like turning a glove inside out finger by finger. The rule never changes: each forall becomes exists, each exists becomes forall, and the innermost proposition gets negated last. Connectives flip too as the NOT passes through them — by De Morgan's laws, the negation of 'P and Q' is 'not P or not Q', and the negation of 'P or Q' is 'not P and not Q'. (Negating an implication P -> Q is a favourite trick question: it becomes 'P and not Q', the single case that made it false.) Do this mechanically and you will never lose your place.

  1. Start with the statement, written with every quantifier and connective explicit — no abbreviations hiding a hidden 'for all'.
  2. Put a NOT in front of the whole thing and push it rightward across the outermost quantifier, flipping that quantifier (forall <-> exists).
  3. Keep pushing the NOT inward, flipping each quantifier it passes in turn, until it reaches the innermost proposition.
  4. Apply De Morgan to any AND/OR there, and rewrite 'not (P -> Q)' as 'P and not Q'. Now read the result aloud — it should describe exactly the situation that breaks the original.

Why this is the pumping lemma in disguise

All of this pays off in one of the first big proofs ahead. The pumping lemma says, roughly: for every regular language L, there exists a number p (the pumping length) such that for all strings s in L of length at least p, there exists a way to split s into three pieces x, y, z (with y non-empty and short) such that for all i >= 0, the pumped string x y^i z is still in L. Count the quantifiers: forall, exists, forall, exists, forall — five levels, alternating. The statement is about regular languages; on its own it does no work.

To use it as a weapon you negate it, and the negation is exactly the glove-flipping you just practised. 'L is not regular' is overkill; what the lemma gives you is: if L were regular, the pumping condition would hold. So you assume L is regular (a proof by contradiction), then negate the inner condition to drive a wedge. Flip every quantifier in turn and the proof obligation becomes: for all p, there exists a bad string s in L of length at least p, such that for all splits x, y, z, there exists an i >= 0 with x y^i z not in L. That negated sentence is your battle plan — and reading it correctly is the whole reason this guide exists.

Concretely, take the classic non-regular language a^n b^n (equal numbers of a's then b's). Whatever pumping length p the lemma hands you, you pick the bad string s = a^p b^p. Any short prefix-piece y must sit entirely inside the run of a's, so pumping it up to x y^2 z creates more a's than b's — a string outside the language. That single counterexample, found by following the negated quantifier nest, is enough to prove non-regularity. Notice the shape underneath: a long string is forced through a finite machine, so some state must repeat — that is the pigeonhole principle wearing a quantifier costume, the subject of guide 4.

The contrapositive, and honest cautions

One more equivalence saves enormous effort. The contrapositive of 'if P then Q' is 'if not Q then not P', and the two are logically identical — true in exactly the same situations, always. So to prove an implication you may instead prove its contrapositive, whichever direction is easier to argue. This is not the converse (which we warned about earlier and which can be false); the contrapositive is a genuine restatement. Much of the pumping argument is really the contrapositive of a simpler fact: 'if no state of a DFA repeats while reading a string, that string is no longer than the state count.'

These few moves — quantifiers, their alternation, clean negation, the contrapositive — are not just exam tricks; they are the literal load-bearing beams of everything from closure proofs to undecidability. The very same outside-in negation, aimed at the halting problem, produces a machine forced to disagree with itself, the heartbeat of diagonalization in guide 5. Get fluent here and the hard theorems ahead stop feeling like magic and start feeling like bookkeeping.