CS 139 // 2020-03-26
$A_\text{DFA}$
$$A_\text{DFA} = \{\langle B,w\rangle \mid B\text{ is a DFA that accepts }w\}$$
M = On input <B,w> 1. Simulate B on w 2. If B accepts, then ACCEPT 3. If B rejects, then REJECT
$B$
$w$
$$ALL_\text{DFA} = \{\langle A\rangle \mid A\text{ is a DFA and }L(A)=\Sigma^\ast\}$$
M = On input <A> where A is a DFA 1. Simulate the DFA A on all strings 2. If it rejects any string, then REJECT 3. If it accepts all strings, then ACCEPT
Again, I find it useful to think about Python:
def dfa_accepts_everything(A): """Returns True if the DFA A accepts every string""" ...
$ALL_\text{DFA}$
Check all the reachable states of $A$ and make sure all of them are in $F$—if so, accept—otherwise reject
$A$
$F$
This is basically a breadth-first search through a graph data structure
M = On input <A> where A is a DFA 1. Mark the starting state of A 2. Repeat until no more states can be marked this way: a. Iterate over each marked state and mark the states that are immediately adjacent to it 3. Check to see if every marked state is an accepting state, if so, ACCEPT, if not, REJECT
$$A = \{a_1, a_2, a_3, a_4\}$$ $$B = \{b_1, b_2, b_3, b_4\}$$
$$A = \{a_1, a_2, a_3, a_4\}$$
$$B = \{b_1, b_2, b_3, b_4\}$$
$$\mathbb{N} = \{1, 2, 3, 4, 5, \ldots\}$$
$$\mathbb{E} = \{2, 4, 6, 8, 10, \ldots\}$$
3-2-1-GO Question: Which set has more elements?
$\mathbb{E}\subset\mathbb{N}$
$\mathbb{N}$
$\mathbb{E}$
$$\mathbb{N} = \{1, 2, 3, 4, 5, \ldots\},\quad \mathbb{E} = \{2, 4, 6, 8, 10, \ldots\}$$
$n\in \mathbb{N}$
$f(n)\in \mathbb{E}$
$f(n) = 2n$
$f$
$|\mathbb{N}| = |\mathbb{E}|$
$S$
$|S|=|\mathbb{N}|$
Claim: $\{0,1\}^\ast$ is countable
$\{0,1\}^\ast$
Theorem: $\{0,1\}^\ast$ is countable
$\{0,1\}^\ast = \{\epsilon, 0, 1, 00, 01, 10, 11, 000, \ldots\}$
$\{0,1\}^\ast = \{s_1, s_2, s_3, \ldots \}$
$f(s_n) = n$
$f:\{0,1\}^\ast\rightarrow\mathbb{N}$
$$f(w) = 2^{|w|}+\text{val}(w)$$
$\text{val}:\{0,1\}^\ast\rightarrow\mathbb{Z}_{\ge 0}$
$w\in\{0,1\}^\ast$
$\text{val}(011) = 3$
$\text{val}(1001) = 9$
$|\{0,1\}^\ast|=|\mathbb{N}|$
$A\subseteq\{0,1\}^\ast$
$\chi_A = b_1b_2b_3b_4\cdots$
$$ b_i = \begin{cases} 1, &\text{if }s_i \in A\\ 0, &\text{if }s_i \not\in A \end{cases} $$
$L = \{00, 1, 10\}$
$\chi_L$
$\chi_L = 0011010000\cdots$
$\chi_A$
$\mathbb{B} = \{0,1\}^\infty$
$\{0, 1\}$
The set of languages $\mathbb{B}$ is uncountable
$\mathbb{B}$
$f:\mathbb{N}\rightarrow\mathbb{B}$
$s\in\mathbb{B}$
$s = b_1b_2b_3b_4\cdots$
$$b_i = \begin{cases} 1, &\text{if the $i$th bit of $f(i)$ is $0$}\\ 0, &\text{if the $i$th bit of $f(i)$ is $1$} \end{cases}$$
$n\in\mathbb{N}$
$s$
$f(n)$
$n$
$f(n) = s$
$\langle M\rangle$
$\{\langle M\rangle \mid M\text{ is a TM}\}\subseteq\{0,1\}^\ast$
Theorem: The following language is Turing recognizable: $$A_\text{TM} = \{\langle M, w\rangle \mid M\text{ is a TM that accepts } w\}$$
$$A_\text{TM} = \{\langle M, w\rangle \mid M\text{ is a TM that accepts } w\}$$
U = On input <M,w> where M is a Turing machine 1. Simulate M on w 2. If M halts and accepts, then ACCEPT 3. If M halts rejects, then REJECT
$U$
$\langle U, w\rangle$
gcc
program.py
f = open("program.py")
$$\text{HALT} = \{\langle M, w\rangle \mid M\text{ is a TM that halts on }w\}$$
$\text{HALT}$
$K$
$\langle M, w\rangle$
$$K(M,w) = \begin{cases} \text{ACCEPT}, &\text{if $M$ halts on $w$}\\ \text{REJECT}, &\text{if $M$ loops forever on $w$} \end{cases}$$
$M_1, M_2, M_3, \ldots$
$\epsilon$
$0$
$1$
$00$
$01$
$\cdots$
$\vdots$
$K(M,w)$
$M$
$N$
N = "On input string s_n, 1. Run K on <M_n, s_n> 2. If K accepts, then enter an infinite loop 3. If K rejects, then ACCEPT"
$K(M_n, s_n)$
$N(s_n)$
$N \ne M_n$
$N = M_n$
$\langle N, s_n\rangle$