A statement is a sentence that is either true or false, but not both. This is the fundamental unit of mathematical discourse.
Examples of Statements
eiπ+1=0
“17 is a prime number”
“There are infinitely many primes”
Non-examples
“This statement is false” (paradox)
“Is 7 prime?” (question, not a statement)
“Let x=5” (command, not a statement)
Predicates
A predicate is a statement whose truth depends on the value of one or more free variables.
Examples
P(n):≡ ”n is even”
Q(x,y):≡ "x2+y2=1"
“The function f is differentiable”
A predicate becomes a statement once we substitute specific values for its free variables.
The Hierarchy of Mathematical Results
Mathematicians distinguish different types of true statements:
Axiom
A statement assumed true without proof. Axioms form the foundation of a mathematical theory.
Example: The axioms of Zermelo-Fraenkel set theory (ZF).
Definition
A name given to a concept, establishing terminology.
Example: “A prime number is a natural number greater than 1 divisible only by 1 and itself.”
Theorem
A major proved result of significant importance.
Example: Fermat’s Last Theorem, the Fundamental Theorem of Arithmetic.
Proposition
A proved result of lesser importance than a theorem.
Lemma
A result proved chiefly to support the proof of another result. Lemmas are “helper theorems.”
Example: The “lifting the exponent lemma” used in number theory proofs.
Corollary
A statement that follows easily from a previously proved theorem or proposition.
Example: “There are infinitely many primes congruent to 3 mod 4” is a corollary of Dirichlet’s theorem.
Conjecture
A statement believed to be true but not yet proved.
Example: The Goldbach Conjecture (every even integer greater than 2 is the sum of two primes).
Why Precision Matters
Consider the statement: “The product of two odd integers is odd.”
This hides significant logical structure. More precisely:
For all integers m,n: if m and n are odd, then m⋅n is odd.
Even more formally:
∀m,n∈Z.(Odd(m)∧Odd(n))⇒Odd(m⋅n)
Tripos Credit
Marks are awarded for making such logical structure explicit, not just for getting the right answer. A solution that correctly proves the result but fails to exhibit awareness of the quantifiers and implication structure may lose marks.
Variables and Scope
Free Variables
A variable is free in a statement if the statement’s truth depends on its value.
In "x>5", the variable x is free.
Bound Variables
A variable is bound if it is quantified by ∀ or ∃.
In "∀x∈R.x2≥0", the variable x is bound by the universal quantifier.
Common Notation
Logical Symbols
Symbol
Meaning
∧
and (conjunction)
∨
or (disjunction)
¬
not (negation)
⇒
implies
⇔
if and only if
∀
for all
∃
there exists
Set Notation
Symbol
Meaning
∈
element of
⊆
subset
∪
union
∩
intersection
∖
set difference
N
natural numbers {0,1,2,…}
Z
integers {…,−1,0,1,…}
Q
rational numbers
R
real numbers
Number Notation
a∣b means ”a divides b”
a≡b(modn) means ”a is congruent to b modulo n”
gcd(a,b) means “greatest common divisor of a and b“
Summary
A statement is a sentence that is either true or false
A predicate is a statement with free variables
Mathematical results form a hierarchy: axiom, definition, theorem, proposition, lemma, corollary, conjecture
Precision in stating logical structure is essential for rigorous proof and earns Tripos credit
Abstract algebra studies mathematical structures by specifying the operations and properties they must satisfy. Each structure adds more requirements, making it more powerful but more restrictive.
Monoids
Definition
A monoid is a triple (S,∙,e) where:
S is a set
∙:S×S→S is a binary operation (closed)
e∈S is the identity element
satisfying:
Associativity: (x∙y)∙z=x∙(y∙z) for all x,y,z∈S
Identity: e∙x=x=x∙e for all x∈S
Examples
Monoid
Operation
Identity
(N,+,0)
Addition
0
(N,×,1)
Multiplication
1
(Σ∗,⋅,ε)
String concatenation
ε
(Rel(A,A),∘,idA)
Relational composition
idA
(P(A),∪,∅)
Union
∅
(P(A),∩,A)
Intersection
A
Commutative Monoid
A monoid is commutative (or abelian) if x∙y=y∙x for all x,y∈S.
Examples: (N,+,0), (P(A),∪,∅).
Non-example: (Σ∗,⋅,ε) is NOT commutative (ab=ba in general).
Examinable: Endo-Relations Form a Monoid
Theorem: For any set A, the endo-relations (Rel(A,A),∘,idA) form a monoid.
Proof:
Closure: Composition of relations R:A↛A and S:A↛A yields S∘R:A↛A.
Associativity: Already proved: (T∘S)∘R=T∘(S∘R).
Identity: idA∘R=R=R∘idA.
Groups
Definition
A group is a monoid (G,∙,e) where every element has an inverse.
For each x∈G, there exists x−1∈G such that:
x∙x−1=e=x−1∙x
Examples
Group
Operation
Identity
Inverse
(Z,+,0)
Addition
0
−x
(Q∖{0},×,1)
Multiplication
1
1/x
(Zn,+,0) mod n
Addition mod n
0
n−x
Symmetric group Sn
Permutation composition
Identity permutation
Inverse permutation
Abelian Group
A group is abelian if the operation is commutative.
Key Property
In a group, equations are always solvable: for any a,b∈G, there exists a unique x with a∙x=b (namely x=a−1∙b).
Non-examples
(N,+,0) is NOT a group (no additive inverses)
(Z,×,1) is NOT a group (most elements lack multiplicative inverses)
Semirings
Definition
A semiring is a structure (S,0,⊕,1,⊗) where:
(S,0,⊕) is a commutative monoid (addition)
(S,1,⊗) is a monoid (multiplication)
Distributivity: x⊗(y⊕z)=(x⊗y)⊕(x⊗z) and (x⊕y)⊗z=(x⊗z)⊕(y⊗z)
Annihilation: 0⊗x=0=x⊗0
Examples
Semiring
Addition ⊕
Multiply ⊗
Zero
One
(N,+,×)
+
×
0
1
Boolean semiring B
∨ (OR)
∧ (AND)
0
1
Min-plus (tropical)
min
+
∞
0
Max-plus
max
+
−∞
0
The Boolean Semiring
B=({0,1},0,∨,1,∧)
This is the foundation for:
Relational composition via matrix multiplication
Reachability in graphs
The Min-Plus Semiring (Tropical)
(R∪{∞},∞,min,0,+)
Applications:
Shortest path algorithms
Dynamic programming optimisation
Rings
Definition
A ring is a semiring where (S,0,⊕) is an abelian group.
Every element has an additive inverse.
Examples
(Z,+,×): integers (additive inverse is negation)
(Zn,+,×): integers mod n
Polynomials over Z
Non-example
(N,+,×) is NOT a ring (no additive inverses).
Fields
Definition
A field is a commutative ring where every non-zero element has a multiplicative inverse.
(F,0,+,1,×) satisfies:
(F,0,+) is an abelian group
(F∖{0},1,×) is an abelian group
Distributivity holds
Examples
Q: rational numbers
R: real numbers
C: complex numbers
Zp: integers mod p, where p is prime
Key Theorem
Theorem: Zp (integers mod p) is a field if and only if p is prime.
Proof:
If p is prime and a≡0(modp), then gcd(a,p)=1.
By Bézout’s identity, ∃x,y with ax+py=1.
Thus ax≡1(modp), so a has a multiplicative inverse.
If p is composite, say p=ab with 1<a,b<p, then a,b are zero divisors and cannot have inverses.
Why This Matters for Cryptography
Zp being a field is essential for:
Diffie-Hellman key exchange: relies on exponentiation in Zp∗
RSA: requires computing inverses mod φ(n)
Summary Table
Structure
Addition
Multiplication
Key Property
Monoid
Associative + Identity
—
Minimal structure
Group
Inverses exist
—
Equations solvable
Semiring
Commutative monoid
Monoid
Matrix multiplication works
Ring
Abelian group
Monoid
Can subtract
Field
Abelian group
Abelian group (except 0)
Can divide
Tripos Questions
2016 P2 Q6: Prove that the set of all strings over alphabet {a,b} under concatenation forms a monoid. Is it a group?
2020 P2 Q9: Show that Zp is a field when p is prime. Explain why ap−1≡1(modp) for a≡0(modp).
Summary
Monoid: set + operation + identity + associativity
Group: monoid + inverses
Semiring: two operations, distributivity, additive identity annihilates
Ring: semiring + additive inverses
Field: ring + multiplicative inverses (except zero)
Zp is a field iff p is prime (foundational for cryptography)
Sets, Relations, and Functions
Set theory, Venn diagrams, relations, path closures, and function classifications
A binary relationR from a set A to a set B is a subset R⊆A×B.
We write:
R:A↛B to indicate a relation from A to B
aRb or (a,b)∈R to indicate R relates a and b
Intuition
A relation describes how elements of A are connected to elements of B. Unlike a function, a single a∈A can be related to multiple b∈B, or to none at all.
Relational Extensionality
Two relations are equal iff they relate the same pairs:
R=S⟺∀a∈A.∀b∈B.(aRb⇔aSb)
Examples of Relations
The Empty Relation
For any sets A,B, the empty relation∅⊆A×B relates nothing.
a∅b is never true
The Full Relation
The full relationA×B⊆A×B relates everything.
a(A×B)b for all a∈A,b∈B
The Identity Relation
For a set A, the identity relationidA⊆A×A:
aidAa′⟺a=a′
Examples from Computer Science
Program specification: The relation sq:R≥0↛R given by xsqy⟺x=y2.
Operational semantics: A transition relation S:E↛E on machine states where eSe′ means “state e can transition to e′”.
Network connectivity: A relation C:N↛N on network nodes, where aCb means “node a is directly connected to node b”.
Database relations: A table relating Movies, Directors, Years, and People.
Special Relations on a Single Set
A relation R⊆A×A is called an endo-relation or relation on A.
Reflexivity
R is reflexive if ∀a∈A.aRa.
Equivalently: idA⊆R.
Symmetry
R is symmetric if ∀a,b∈A.(aRb⇒bRa).
Transitivity
R is transitive if ∀a,b,c∈A.(aRb∧bRc⇒aRc).
Antisymmetry
R is antisymmetric if ∀a,b∈A.(aRb∧bRa⇒a=b).
Examples
Relation
Reflexive
Symmetric
Transitive
Antisymmetric
a=b on any set
Yes
Yes
Yes
Yes
a≤b on R
Yes
No
Yes
Yes
a<b on R
No
No
Yes
Yes
a∣b on Z
Yes
No
Yes
No
”is a sibling of” on people
No
Yes
No
No
Visualising Relations
Internal Diagrams
Draw elements of A on the left, elements of B on the right. Draw arrows from a to b whenever aRb.
Matrix Representation
For finite sets A={a1,…,am} and B={b1,…,bn}, represent R as an m×n boolean matrix M:
Mij=1⟺aiRbj
Graph Representation (for endo-relations)
Draw elements of A as vertices. Draw a directed edge from a to b whenever aRb.
Let R be a set of rules on X. Let XR be the set of derivable elements.
To prove ∀x∈XR.P(x): show that for every rule
vu1⋯un
if P(ui) holds for all premises ui, then P(v) holds.
Intuition
If every rule “preserves” property P from premises to conclusion, and P holds for all axioms (rules with no premises), then P holds for all derivable elements.
Examinable Proof: Rule Induction is Valid
Theorem: If S={x∈X:P(x)} is closed under all rules in R, then XR⊆S.
Proof:
Method: Induction on the height of derivations.
Base case (height ≤0): No derivation has height 0 (a derivation must be a tree with at least a root). Alternatively: axioms have height 1, and S contains all axiom conclusions since S is closed under rules with no premises.
Inductive step: Suppose all derivations of height ≤n have conclusions in S. Consider a derivation of height n+1 with conclusion v.
The derivation uses some rule vu1⋯un where each ui is derived by a subtree of height ≤n.
By the induction hypothesis, each ui∈S.
Since S is closed under the rule, v∈S.
Conclusion: By induction, every derivable element is in S.
Equivalence of Characterisations
Two Characterisations of XR
XR={x:x has a derivation using R}
XR=⋂{S:S closed under R}
Proof of Equivalence
(1⊆2): Every S closed under R contains all derivable elements (shown by induction on derivation height).
(2⊆1): XR is itself closed under R (union of rule applications preserves membership), and contains exactly the derivable elements.
The Recipe for Rule Induction
To prove ∀x∈XR.P(x):
For each axiom a: verify P(a) holds
For each rule vu1⋯un: assume P(u1),…,P(un) and prove P(v)
This is the single most reusable proof template in this course.
Example: Balanced Parentheses
Rules
εu(v)uv
Define language LR with these rules.
Claim
Every w∈LR has balanced parentheses: #(’(’) = #(’)’) and every prefix has at least as many ’(’ as ’)’.
Proof by Rule Induction
Axiom: ε has 0 ’(’ and 0 ’)’. Trivially balanced.
Rule: Assume u and v are balanced. Consider u(v).
Count: adds 1 ’(’ and 1 ’)’ to total from u and v. Since u,v balanced, total balanced.
Prefix property: Any prefix is either:
A prefix of u (balanced by IH)
u itself (balanced by IH)
u( or u(v′ where v′ is a prefix of v (still satisfies prefix property)
Example: Natural Numbers
Rules
0S(n)n
Claim: Every derived n is either 0 or S(m) for some derived m
Proof:
Axiom: 0 is of the right form.
Rule: S(n) is of the right form (as successor of n).
When to Use Rule Induction
Use rule induction when:
The set is defined inductively by rules
The property P should be preserved by rule application
You need to prove something about all derivable elements
Common applications:
Properties of syntax trees
Type preservation in programming languages
Semantic equivalences
Language properties
Summary
Rule induction: if S closed under R, then XR⊆S
Recipe: handle axioms, then each rule preserves P from premises to conclusion
Proof: induction on derivation height
Fundamental proof technique for inductively defined sets
Rule induction in discrete maths and pattern matching in functional programming (OCaml, Haskell) are deeply connected. Both deal with inductively defined structures and recursive processing.
Recap: Inductive Definitions
A set defined inductively specifies:
Axioms: base elements
Rules: ways to construct new elements from existing ones
Example: Arithmetic Expressions
E::=Num(n)∣Add(E,E)∣Mul(E,E)
The set of expressions includes:
Num(5)
Add(Num(3),Num(7))
Mul(Add(Num(1),Num(2)),Num(3))
Abstract Syntax Trees
Concrete Syntax
The textual representation: 1 + 2 * 3
Abstract Syntax Tree (AST)
The tree structure:
Add / \ Num(1) Mul / \ Num(2) Num(3)
OCaml Data Type
The BNF grammar translates directly to an algebraic data type:
type expr = | Num of int | Add of expr * expr | Mul of expr * expr
Each constructor corresponds to a rule in the inductive definition.
Rule Induction Recap
The Principle
To prove a property P(e) holds for all expressions e:
Base case (axioms): Prove P(Num(n)) for all n
Inductive step (rules): Assuming P(e1) and P(e2), prove P(Add(e1,e2)) and P(Mul(e1,e2))
A match expression examines the structure of data and:
Identifies which constructor was used
Extracts (binds) the sub-components to variables
Evaluating Expressions
let rec eval (e : expr) : int = match e with | Num n -> n | Add (e1, e2) -> eval e1 + eval e2 | Mul (e1, e2) -> eval e1 * eval e2
Correspondence to Rule Induction
Pattern match branch
Rule induction step
`
Num n -> …`
`
Add (e1, e2) -> …`
`
Mul (e1, e2) -> …`
The recursive calls eval e1 and eval e2 apply the function to the sub-expressions, exactly as rule induction applies the hypothesis to premises.
Variable Binding
The Mechanism
When pattern matching encounters:
| Add (e1, e2) -> ...
and the input is Add (Num 3, Num 7):
The constructor Add matches
e1 is bound to Num 3
e2 is bound to Num 7
The right-hand side executes with these bindings
Exhaustiveness Checking
The Compiler’s Job
The OCaml compiler checks that a match covers ALL constructors.
let rec eval (e : expr) : int = match e with | Num n -> n | Add (e1, e2) -> eval e1 + eval e2(* Warning: this pattern-matching is not exhaustive. *)
The compiler warns that Mul is missing.
Why This Works
Because the data type was inductively defined with a fixed set of constructors, the compiler knows exactly what patterns are possible.
Mathematical Connection
Exhaustiveness checking is the compiler verifying that your proof covers all axioms and rules!
Structural Recursion
Definition
A function is structurally recursive if:
Each recursive call is on a proper sub-structure of the input
There is a base case for each axiom
This guarantees termination.
Example: Size Function
let rec size (e : expr) : int = match e with | Num _ -> 1 | Add (e1, e2) -> 1 + size e1 + size e2 | Mul (e1, e2) -> 1 + size e1 + size e2
The recursion follows the tree structure:
Base case: Num _ has size 1
Recursive calls on e1 and e2 are on smaller sub-trees
Termination
Since the AST has finite depth, structural recursion always terminates.
Example: Pretty Printing
Convert an AST back to a string:
let rec pretty (e : expr) : string = match e with | Num n -> string_of_int n | Add (e1, e2) -> "(" ^ pretty e1 ^ " + " ^ pretty e2 ^ ")" | Mul (e1, e2) -> "(" ^ pretty e1 ^ " * " ^ pretty e2 ^ ")"
Pattern: recurse on sub-expressions, combine results.
Example: Optimisation
Simplify expressions (constant folding):
let rec simplify (e : expr) : expr = match e with | Num n -> Num n | Add (e1, e2) -> (match simplify e1, simplify e2 with | Num 0, e -> e (* 0 + e = e *) | e, Num 0 -> e (* e + 0 = e *) | Num n1, Num n2 -> Num (n1 + n2) (* fold *) | e1', e2' -> Add (e1', e2')) | Mul (e1, e2) -> (match simplify e1, simplify e2 with | Num 0, _ -> Num 0 | _, Num 0 -> Num 0 | Num 1, e -> e | e, Num 1 -> e | Num n1, Num n2 -> Num (n1 * n2) | e1', e2' -> Mul (e1', e2'))
Lists: Another Inductive Structure
Definition
List(A)::=Nil∣Cons(A,List(A))
OCaml Type
type 'a list = | [] | (::) of 'a * 'a list
Pattern Matching
let rec length (lst : 'a list) : int = match lst with | [] -> 0 | _ :: xs -> 1 + length xs
Base case: empty list. Inductive step: head + tail.
Summary
Discrete Maths
Functional Programming
Inductive definition
Algebraic data type
Axiom
Constructor (e.g., Num)
Rule
Constructor with arguments (e.g., Add)
Rule induction proof
Recursive function
Base case
Base case pattern
Inductive hypothesis
Recursive call
Variable in rule
Pattern variable
Exhaustive cases?
Exhaustiveness check
Pattern matching is executable rule induction: the compiler verifies your proof structure, and the machine executes the computation.
Tripos Questions
2021 P1 Q4: Explain how pattern matching in functional programming relates to proof by rule induction.
Paper 1 FOCS: Implement a recursive function to compute the depth of an expression tree.
Automata Theory
NFAs, DFAs, subset construction, Kleene's theorem, Thompson's construction, and the pumping lemma
Convert an NFA (or NFA-ε) M to an equivalent DFA P(M) that recognises the same language.
The Construction
Input
NFA-εM=(Q,Σ,Δ,τ,s,F)
Output
DFA P(M)=(Q′,Σ,δ′,s′,F′)
States
Q′=P(Q)={S:S⊆Q}
Each DFA state is a set of NFA states.
Start State
s′=E(s)={q′:sε∗q′}
The ε-closure of the NFA’s start state.
Accepting States
F′={S⊆Q:S∩F=∅}
A DFA state is accepting if it contains at least one NFA accepting state.
Transition Function
For S⊆Q and a∈Σ:
δ′(S,a)=⋃q∈S{q′:qaq′′ε∗q′ for some q′′}
Equivalently: the set of all states reachable from S on symbol a, followed by any number of ε-transitions.
Algorithm Summary
Start with ε-closure of {s}
For each reachable set S and symbol a, compute δ′(S,a)
Add newly discovered states to worklist
Repeat until no new states
Example
NFA
M: Q={q0,q1,q2}, s=q0, F={q2}
Transitions:
q0aq0, q0aq1
q1bq2
DFA Construction
Start: s′=E(q0)={q0}
Compute transitions:
DFA State
a
b
{q0}
{q0,q1}
∅
{q0,q1}
{q0,q1}
{q2}
{q2}
∅
∅
∅
∅
∅
Accepting: F′={{q2}} (states containing q2)
Resulting DFA
Size
Worst Case
The DFA can have up to 2∣Q∣ states.
Typical Case
Many subsets may be unreachable, so the actual DFA is often smaller.
Exponential Blowup
Some NFAs require exponentially many DFA states. Example: language of strings where the n-th symbol from the end is a requires Ω(2n) DFA states but only n+1 NFA states.
Key Intuition
The DFA simulates “all possible computations” of the NFA simultaneously.
DFA state = set of NFA states that could be active
Transition = move all active states, take ε-closures
Accepting = any active state is an NFA accept state
Summary
Subset construction: NFA state ↦ DFA state = set of NFA states
We construct an NFA-ε for each regular expression by induction on the structure of the regex.
Each construction maintains the invariant that:
The NFA has exactly one start state (no incoming ε-transitions)
The NFA has exactly one accepting state (no outgoing ε-transitions)
This modular approach enables clean composition.
Base Cases
Epsilon: ε
NFA with one state that is both start and accepting.
q◯
L(Mε)={ε}
Empty: ∅
NFA with one state, start but not accepting.
q
L(M∅)=∅
Symbol: a
NFA with two states with a single a-labelled transition.
q0aq1◯
L(Ma)={a}
Union: R1∣R2
Construction
Create new start state qs
Create new accepting state qf
Add ε-transitions:
qsεstart(M1)
qsεstart(M2)
accept(M1)εqf
accept(M2)εqf
Properties
Number of states: ∣M1∣+∣M2∣+2
Linear in regex size
Concatenation: R1R2
Construction
Add ε-transition from accept(M1) to start(M2)
Start state: start(M1)
Accepting state: accept(M2)
Properties
Number of states: ∣M1∣+∣M2∣
No new states added
Kleene Star: R∗
Construction
Create new start/accepting state q0
Add ε-transition q0εstart(M)
Add ε-transition from accept(M) to start(M) (loop)
Add ε-transition from accept(M) to q0
q0 is the new accepting state
Alternative Construction
Some presentations use:
q0 is start, ε→start(M)
Accepting states include accept(M) and a new state
Loop back from accept(M) to start(M)
Properties
Number of states: ∣M∣+1
Accepts ε and any concatenation of strings from L(M)
Size Analysis
Number of States
For regex R of size n (number of symbols and operators):
∣MR∣=O(n)
The Thompson construction builds NFAs with at most 2n states.
Comparison to DFA
The equivalent DFA may have up to 2∣MR∣ states.
The exponential blowup is unavoidable in the worst case.
Correctness
Theorem
For any regex R, the construction produces NFA-εMR with L(MR)=L(R).
Proof
By structural induction on R.
Base cases: Direct verification for ε, ∅, and symbols.
Union: w∈L(MR1∣R2) iff there is a path through M1 or M2. This happens iff w∈L(M1) or w∈L(M2), iff w∈L(R1)∪L(R2)=L(R1∣R2).
Concatenation: w∈L(MR1R2) iff we can split w=uv with path through M1 on u then through M2 on v. This happens iff u∈L(R1) and v∈L(R2), iff w∈L(R1)⋅L(R2).
Star: Similar analysis using the fact that the construction accepts ε and any concatenation of strings from L(M).
Summary
Thompson’s construction: linear-size NFA for any regex
Union: new start with ε-edges to both branches
Concatenation: ε-edge from accept of first to start of second
Let L be a regular language. There exists p≥1 (the pumping length) such that for every w∈L with ∣w∣≥p:
w can be written as w=xyz where:
∣xy∣≤p
∣y∣≥1 (so y=ε)
xyiz∈L for all i≥0
Intuition
If a string is long enough and the language is regular, then some part of the string can be “pumped” (repeated) any number of times while staying in the language.
The pumped part corresponds to a loop in an accepting computation of the DFA.
Proof Idea
Let M=(Q,Σ,δ,s,F) be a DFA for L with ∣Q∣=n.
Set p=n.
For any w∈L with ∣w∣≥n: the computation visits n+1 states in sequence. By the pigeonhole principle, some state is visited twice.
The part of w that causes the loop can be pumped.
Formal Argument
Path through DFA: s=q0→q1→⋯→q∣w∣=qf.
Since ∣w∣≥n+1 states are visited, but there are only n states, some qi=qj for i<j.
Let x=w[0..i] (before the loop), y=w[i..j] (the loop), z=w[j..∣w∣] (after).
Condition 1: Loop occurs within first n states, so ∣xy∣≤n=p
Condition 2: i<j, so ∣y∣≥1
Condition 3: Repeating or omitting the loop keeps the computation in the accepting state
Using the Pumping Lemma
To Prove Non-regularity
AssumeL is regular with pumping length p
Choose a string w∈L with ∣w∣≥p
Show that for ALL possible decompositions w=xyz satisfying conditions 1 and 2:
There exists i such that xyiz∈/L
Conclude: contradiction, so L is not regular
Key Point
You must show that the pumping lemma fails for every possible choice of x,y,z satisfying the conditions.
Application: L={anbn:n≥0}
Proof
Assume L is regular with pumping length p.
Choose w=apbp (in L, length ≥p).
For any decomposition w=xyz with ∣xy∣≤p and ∣y∣≥1:
Since ∣xy∣≤p, the substring xy consists of only a‘s
Thus y=ak for some k≥1
Consider xy2z=ap+kbp:
Number of a‘s is p+k>p
Number of b‘s is p
Not equal, so xy2z∈/L
Contradiction. Thus L is not regular.
Application: L={ww:w∈{a,b}∗}
Proof
Assume L is regular with pumping length p.
Choose w=apbapb (in L, length 2p+2≥p).
For any decomposition w=xyz with ∣xy∣≤p and ∣y∣≥1:
∣xy∣≤p means xy lies within the first apb (actually, within first ap)
So y=ak for some k≥1
Consider xy2z=ap+kbapb:
This is not of the form ww (different lengths of prefix)
Alternatively: after pumping, the string is ap+kbapb, not a square
Contradiction.
Application: L={an2:n≥0}
Proof
Choose w=ap2.
The pumped string is ap2+k for some k with 1≤k≤p.
We need p2+k to be a perfect square.
But (p+1)2=p2+2p+1>p2+k for k≤p.
So ap2+k∈/L.
Limitations of the Pumping Lemma
The pumping lemma is a necessary condition for regularity, not sufficient.
Some non-regular languages satisfy the pumping lemma conditions.
For proving non-regularity, use:
Pumping lemma
Myhill-Nerode theorem
Closure properties
Summary
Pumping lemma: long strings in regular languages have pumpable parts
Proof uses pigeonhole principle on DFA states
Use: assume regular, find a counterexample string, show pumping fails