¬(xR:P(x))xR:¬P(x) ¬(xR:P(x))xR:¬P(x)\begin{align*} \neg (\exists x \mid R:P(x)) &\equiv \forall x \mid R:\neg P(x) \\\ \neg (\forall x \mid R:P(x)) &\equiv \exists x \mid R:\neg P(x) \end{align*}

regular language

δ^(q,ϵ)=q δ^(q,xa)=δ(δ^(q,x),a)\begin{align*} \hat{\delta}(q, \epsilon) &= q \\\ \hat{\delta}(q, xa) &= \delta(\hat{\delta}(q, x), a) \end{align*}

All finite languages are regular, but not all regular languages are finite

Pumping Lemma

L is regular    (k0:(x,y,zLyk:(u,v,wy=uvwv>1:(ii0:xuviwzL))))\text{L is regular} \implies (\exists \mid k \geq 0: (\forall x,y,z \in L \land |y| \geq k : (\exists u,v,w | y=uvw \land |v| > 1: (\forall i \mid i \geq 0: xuv^iwz \in L))))
  • demon picks kk
  • you pick x,y,zxyzLykx,y,z \leftarrow xyz \in L \land |y| \geq k
  • demon picks u,v,wuvw=yv1u,v,w \leftarrow uvw = y \land |v| \geq 1
  • you pick an i0i \geq 0, and show xuv2wzLxuv^2wz \notin L

context-free grammar

G=(N,Σ,P,S)N:non-terminal symbols Σ:terminal symbols s.t ΣN= P:production rules s.ta finite subset of N×(NΣ) S:start symbolN\begin{align*} \mathbb{G} = (N, \Sigma, P, S) &\quad N: \text{non-terminal symbols} \\\ &\quad \Sigma: \text{terminal symbols} \space s.t \space \Sigma \cap N = \emptyset \\\ &\quad P: \text{production rules} \space s.t \text{a finite subset of } N \times (N \cup \Sigma)^{*} \\\ &\quad S: \text{start symbol} \in N \end{align*}

Properties

  •  CFGL(G)=L    L is a context-free language\exists \text{ CFG} | L(G) = L \iff L \text{ is a context-free language}
  • L is regular     \implies L is context-free
  • L1,L2 are context-free    L1L2 are context-freeL_{1}, L_{2} \text{ are context-free} \implies L_{1} \cup L_{2} \text{ are context-free}
  • context-free languages are not closed under complement, and not closed under intersection. (L1L2,L1 are not context-freeL_1 \cap L_2, \sim{L_1} \text{ are not context-free})

We know that {anbncnn0}\{a^nb^nc^n\mid n \geq 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 stateQ :empty stackΓ F:final stateQ\begin{align*} \text{PDA} = (Q, \Sigma, \Gamma, \delta, s, \bot, F) &\quad Q: \text{Finite set of state} \\\ &\quad \Sigma: \text{Finite input alphabet} \\\ &\quad \Gamma: \text{Finite stack alphabet} \\\ &\quad \delta: \subset (Q \times (\Sigma \cup \{\epsilon\}) \times \Gamma) \times (Q \times \Gamma^{*}) \\\ &\quad s: \text{start state} \in Q \\\ &\quad \bot: \text{empty stack} \in \Gamma \\\ &\quad F: \text{final state} \in Q \end{align*}

Properties

L(M)=L    L is context-free\mathcal{L}(M) = L \iff L \text{ 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 stateQ qaccept:accept stateQ qreject:reject stateQ :blank symbolΓ\begin{align*} \text{TM} = (Q, \Sigma, \Gamma, \delta, s, q_{\text{accept}}, q_{\text{reject}}, \square) &\quad Q: \text{Finite set of state} \\\ &\quad \Sigma: \text{Finite input alphabet} \\\ &\quad \Gamma: \text{Finite tape alphabet} \\\ &\quad \delta: (Q \times \Gamma) \rightarrow Q \times \Gamma \times \{L, R\} \\\ &\quad s: \text{start state} \in Q \\\ &\quad q_{\text{accept}}: \text{accept state} \in Q \\\ &\quad q_{\text{reject}}: \text{reject state} \in Q \\\ &\quad \square: \text{blank symbol} \in \Gamma \end{align*}

Transition function: δ(q,x)=(p,y,D)\delta(q, x) = (p, y, D): when in state pp scan symbol aa, write bb on tape cell, move the head in direction dd and enter state qq

transition to qacceptq_{\text{accept}} or qrejectq_{\text{reject}} is a halting state and accept/reject respectively.

Properties

  • A TM is “total” iff it halts on all input
  • L(M)=L    (ssL    M accepts s)\mathcal{L}(M) = L \iff (\forall s \mid s \in L \iff M \text{ accepts s})
  • L is recognizable:      TM M s.t L(M)=L\iff \exists \text{ TM M s.t } \mathcal{L}(M)=L
  • L is decidable:      total TM M s.t L(M)=LsΣ M halts on s\iff \exists \text{ total TM M s.t } \mathcal{L}(M)=L \land \forall s \in \Sigma^{*} \text{ M halts on s}
  • L is decidable    L is recognizable\text{L is decidable} \implies \text{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 0n10m10j0k110kn0^n10^m10^j0^{k_1}\ldots 10^{k_n} be a DFA with nn states, mm input characters, jj final states, k1knk_1\ldots k_n transitions

ADFA={M#wM is a DFA which accepts w}(1) ATM={M#wM is a TM which accepts w}(2)\begin{align*} A_{\text{DFA}} &= \{M\#w \mid M \text{ is a DFA which accepts } w\} (1) \\\ A_{\text{TM}} &= \{M\#w \mid M \text{ is a TM which accepts } w\} (2) \end{align*}

M is a “recognizer”     M(x)={acceptif xL reject or loopif xL\implies M(x) = \begin{cases} \text{accept} & \text{if } x \in L \\\ \text{reject or loop} & \text{if } x \notin L \end{cases}

M is a “decider”     M(x)={acceptif xL rejectif xL\implies M(x) = \begin{cases} \text{accept} & \text{if } x \in L \\\ \text{reject} & \text{if } x \notin L \end{cases}

Decidability and Recognizability

(1) is deciable: Create a TM MM^{'} such that M(M#w)M^{'}(M\#w) runs MM on ww, therefore MM' is total, or L(M)=ADFA\mathcal{L}(M) = A_{\text{DFA}} > M#wL(M)    M accepts w    M#wADFAM\#w \in \mathcal{L}(M^{'}) \iff M \text{ accepts } w \iff M\#w \in A_{\text{DFA}}

(2) is recognizable: Create a TM MM^{'} such that M(M#w)M^{'}(M\#w) runs MM on ww > M#wL(M)    M accepts w    M#wATM    L(M)=ATMM\#w \in \mathcal{L}(M^{'}) \iff M \text{ accepts } w \iff M\#w \in A_{\text{TM}} \implies \mathcal{L}(M^{'}) = A_{\text{TM}}

Note that all regular language are deciable language

Proof for ATMA_{\text{TM}} is undeciable:

Assume ATMA_{\text{TM}} is decidable

\exists a decider for ATMA_{\text{TM}}, DD.

Let PP another TM such that P(M)P(M): Call DD on M#MM\#M

Paradox machine: P never loops: P(M)={acceptif P reject M rejectif P accepts MP(M) = \begin{cases} \text{accept} & \text{if P reject M} \\\ \text{reject} & \text{if P accepts M} \end{cases}

Countability

  • A set SS is countable infinite if \exists a monotonic function f:SNf: S \rightarrow \mathbb{N} (isomorphism)
  • A set SS is uncountable if there is NO injection from SS

Theorem:

  • The set of all PDAs is countably infinite
  • Σ\Sigma^{*} 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Σ\Sigma = \{0,1\} \mid \text{set of all TMs that } S \subseteq \Sigma^{*}, 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}\Sigma = \{0,1\} Consider a machine NN that on input x{0,1}x \in \{0,1\}^{*} such that L(i)L^{*}(i) is undeciable from the diagonalization. Make sure to use the negation of the dia

Theorem

  • L is deciable     \iff L and L\sim L are both recognizable

Proof: LL is deciable     L\iff \sim L is deciable. LL is deciable     \implies L is recognizable

Let RL,RLR_L, R_{\sim L} be recognizer. Create TM MM that runs RLR_L and RLR_{\sim L} on xx concurrently. if RLR_L accepts     \implies accept, RLR_{\sim L} accepts     \implies reject.

If M never halts, M decides L. If xL    RL(x) haltsx \in L \implies R_L(x) \text{ halts}, and xL    RL(x) haltsx \notin L \implies R_{\sim L}(x) \text{ halts}.

Reduction on universal TMs

ATM={M#wM does not accept w}\sim A_{\text{TM}} = \{M\#w \mid M \text{ does not accept w}\}. Which implies ATM\sim A_{\text{TM}} is unrecognizable

HP is undeciable, and recognizable.

Halting problem={M#wM halts on w}\text{Halting problem} = \{M\#w \mid M \text{ halts on w} \}

Proof: Assume HP is deciable. DMP(M#w)={acceptif M halts on w rejectif M loops on w\exists D_{MP}(M\#w) = \begin{cases} \text{accept} & \text{if M halts on w} \\\ \text{reject} & \text{if M loops on w} \end{cases}