All finite languages are regular, but not all regular languages are finite
Pumping Lemma
L is regular⟹(∃∣k≥0:(∀x,y,z∈L∧∣y∣≥k:(∃u,v,w∣y=uvw∧∣v∣>1:(∀i∣i≥0:xuviwz∈L))))
demon picks k
you pick x,y,z←xyz∈L∧∣y∣≥k
demon picks u,v,w←uvw=y∧∣v∣≥1
you pick an i≥0, and show xuv2wz∈/L
context-free grammar
G=(N,Σ,P,S)N:non-terminal symbolsΣ:terminal symbolss.tΣ∩N=∅P:production ruless.ta finite subset of N×(N∪Σ)∗S:start symbol∈N
Properties
∃ CFG∣L(G)=L⟺L is a context-free language
L is regular ⟹ L is context-free
L1,L2 are context-free⟹L1∪L2 are context-free
context-free languages are not closed under complement, and not closed under intersection. (L1∩L2,∼L1 are not context-free)
We know that {anbncn∣n≥0} is not CF
Pushdown Automata PDA
PDA=(Q,Σ,Γ,δ,s,⊥,F)Q:Finite set of stateΣ:Finite input alphabetΓ:Finite stack alphabetδ:⊂(Q×(Σ∪{ϵ})×Γ)×(Q×Γ∗)s:start state∈Q⊥:empty stack∈ΓF:final state∈Q
Properties
L(M)=L⟺L is context-free
Turing machine
TM=(Q,Σ,Γ,δ,s,qaccept,qreject,□)Q:Finite set of stateΣ:Finite input alphabetΓ:Finite tape alphabetδ:(Q×Γ)→Q×Γ×{L,R}s:start state∈Qqaccept:accept state∈Qqreject:reject state∈Q□:blank symbol∈Γ
Transition function: δ(q,x)=(p,y,D): when in state p scan symbol a, write b on tape cell, move the head in direction d and enter state q
transition to qaccept or qreject is a halting state and accept/reject respectively.
Properties
A TM is “total” iff it halts on all input
L(M)=L⟺(∀s∣s∈L⟺M accepts s)
L is recognizable: ⟺∃ TM M s.t L(M)=L
L is decidable: ⟺∃ total TM M s.t L(M)=L∧∀s∈Σ∗ M halts on s
L is decidable⟹L is recognizable
Church-Turing Thesis
Conjecture 1:
All reasonable models of computation are equivalent:
perfect memory
finite amount of time
Conjecture 2:
Anything a modern digital computer can do, a Turing machine can do.
Equivalence model
TMs with multiple tapes.
NTMs.
PDA with two stacks.
Finite Automata from Church-Turing Thesis
Finite automata can be encoded as a string:
Let 0n10m10j0k1…10kn be a DFA with n states, m input characters, j final states, k1…kn transitions
ADFAATM={M#w∣M is a DFA which accepts w}(1)={M#w∣M is a TM which accepts w}(2)
M is a “recognizer” ⟹M(x)={acceptreject or loopif x∈Lif x∈/L
M is a “decider” ⟹M(x)={acceptrejectif x∈Lif x∈/L
Decidability and Recognizability
(1) is deciable: Create a TM M′ such that M′(M#w) runs M on w, therefore M′ is total, or L(M)=ADFA > M#w∈L(M′)⟺M accepts w⟺M#w∈ADFA
(2) is recognizable: Create a TM M′ such that M′(M#w) runs M on w > M#w∈L(M′)⟺M accepts w⟺M#w∈ATM⟹L(M′)=ATM
Note that all regular language are deciable language
Proof for ATM is undeciable:
Assume ATM is decidable
∃ a decider for ATM, D.
Let P another TM such that P(M): Call D on M#M
Paradox machine: P never loops: P(M)={acceptrejectif P reject Mif P accepts M
Countability
A set S is countable infinite if ∃ a monotonic function f:S→N (isomorphism)
A set S is uncountable if there is NO injection from S
Theorem:
The set of all PDAs is countably infinite
Σ∗ is countably infinite (list out all string n in finite time)
The set of all TMs is countably infinite (Σ={0,1}∣set of all TMs that S⊆Σ∗, so does REC, DEC, CF, REG
The set of all languages is uncountable.
Diagonalization and Problems
The set of unrecognizable languages is uncountable.
The set of all languages is uncountable.
Proof: I can encode a language with a infinite string. Σ={0,1}
Consider a machine N that on input x∈{0,1}∗ such that L∗(i) is undeciable from the diagonalization. Make sure to use the negation of the dia
Theorem
L is deciable ⟺ L and ∼L are both recognizable
Proof: L is deciable ⟺∼L is deciable. L is deciable ⟹ L is recognizable
Let RL,R∼L be recognizer. Create TM M that runs RL and R∼L on x concurrently. if RL accepts ⟹ accept, R∼L accepts ⟹ reject.
If M never halts, M decides L. If x∈L⟹RL(x) halts, and x∈/L⟹R∼L(x) halts.
Reduction on universal TMs
∼ATM={M#w∣M does not accept w}. Which implies ∼ATM is unrecognizable
HP is undeciable, and recognizable.
Halting problem={M#w∣M halts on w}
Proof: Assume HP is deciable. ∃DMP(M#w)={acceptrejectif M halts on wif M loops on w
Build a TM M′ where M′(M#v):
calls $D_{MP}$ on $M\#v$:accepts: - run $M$ on $v$ - accept -> accept - reject -> rejectreject: reject
Therefore M′ is total. Since M#w∈L(M′)⟺M accepts w⟺M#w∈ATM. Therefore L(M′)=ATM. Which means M′ is a decider for ATM (which is a paradox) □