计算理论复习

考点列表

常见单词 / 术语

Language

常见的 Language 及其属于的范畴

运算符闭包性

Operator Regular Context-free recursive recursively enumerable
×
× ×

Finite Automata and Regular Languages

Sequence of Configurations

Problem
Consider the following DFA. What sequence of configurations does the machine go through on input aab?
image.png

Solution

(q1,aab)M(q2,ab)M(q3,b)M(q1,e)
NFA ⇒ RL

解题思路

  1. 将 NFA 的起点和终点剥离出来
  2. 将中间状态依次等价转换
    • 只关注 Simple Path 和 Simple Cycle
  3. 最终获得起点到终点的等价式

Problem
将以下的 NFA 转化为 RL
image.png

Solution
image.png

NFA ⇒ DFA

解题思路

  1. 构造 2|K| 个状态的 DFA(不要忘记
  2. 建立转移关系
  3. 删除无用状态

Problem
Convert the following NFA to an equivalent DFA. Give only the portion of the DFA that is reachable from the initial state.
image.png
Answer
image.png

Prove languages are regular

简单的 画出有限自动机即可;复杂的 构造 (K,σ,δ,s,F) 就更好了

Problem1
The set of all binary strings that end with 00.
Solution1


Problem2
Let A and B be two regular languages over some alphabet Σ. Let # be a symbol not in Σ. Consider the following language.

L={w1#w2:w1Aw2B}

Solution2
Contruct a new FA M3=(K3,Σ,δ3,s3,F3) as following.
(需要为接收到 # 的非法情况建立新的状态 q0

Σ= Σ{#}K3= K1K2{q0}s3= s1F3= F2δ3= δ1δ2{((q,#),q0)|q((K1F1)K2)}{((q0,a),q0)|aΣ}{((q,#),s2)|qF1}
& e &

  • 是什么都没有的意思
  • e 表示接受空串
  • e
  • R=
  • R=R
  • R=R

Construct NFA which accepts Regular Expressions

Problem
Construct a NFA that accepts (ababa).

Solution

Regular Language

  • 判断题:If A is regular and B is non-regular, then AB must be non-regular.
    • 错误
    • 反例:A= 的时候。
  • 判断题:Language { aibjck | i,j,kN and i+jkmod3 } is not regular.
    • 错误
    • 同余的情况只有有限种,可以拆封成类似 {a3ib3jc3k} 的形式。
  • 判断题:If L1L2 is a regular language, then either L1 or L2 is regular.
    • 错误
    • 反例:Assume A is non-regular ⇒ A is non-regular ⇒ A{e} and A{e} are non-regular ⇒ (A{e})(A{e})=Σ is regular.

Pumping Theorem

Problem1
L1={wtw | w,t{a,b}+} is regular or not.
Solution1
Pumping Theorem.
假设 Pumping length 为 p,构造 w=apbaapb=xyzL1,
因为 (2) |y|>0 (3) |xy≤p|,所以 y=ai
xy2z=an+ibaanbL2(特别小心这里的判断)

Problem2
L4={uvuR | u,v{a,b}+} is regular or not.
Solution2
注意 L4 其实只用判断首尾内容是否一致就行,故是正则的

Context Free Language

Suppose that L is context-free and R is regular, then LR is context-free language.

正确。

  1. LR=LR
  2. L is CFL, R is RL, CFL RL = CFL
  3. LR is CFL
CFL ⇒ CFG

Problem1
Construct a context-free grammar that generatesthe following language.

{xy{0,1}:x has equal number of 0s and 1s, and y=yR}

Solution1
SAB
AAA | 0A1 | 1A0 | e
B0B0 | 1B1 | 0 | 1 | e

Problem2
L={ w{a,b} | ab },试用 CFG 写出能表示 L 的文法

Solution2
SP | Q
QXAX | QQ
PXBX | PP
XaXb | bXa | XX | e
AaA | a
BbB | b

CFL ⇒ PDA

Problem
Construct a pushdown automaton that accepts the following language.

{w{a,b}:in w,2#a=#b+3}

Solution

P=(K,Σ,Γ,Δ,s,F)K={s,f}Σ={a,b}Γ={A,B}s=sF={f}

The list of ((q,α,β),(p,γ)) shown below contains all elements in Δ
image.png

Parse tree

Problem
Consider the following context-free grammar.

EE+EEE×EEa

Show two distinct parse trees with root E and yield a×a+a
Solution
image.png

Turing Machine and Undecidability

Turing Machine

从基本定义出发构造图灵机

Problem
image.png
Solution

注意事项

图灵机之间状态转移时可能会出现不合法的情况

image.png

Design a right-shifting machine S that transforms w into w, where w is a string that contains no blank symbol.

image.png

Try to construct a Turing Machine to decide the following language. L={wwR|w{0,1}}.

p.s. You can assume the start configuration of the Turing machine is w.
image.png

Undecidability

使用 Reduction 的基本定义

Problem
Let A and B be two languages. Suppose that we have a reduction f from A to B. If B is recursively enumerable, what conclusion can you draw about A?
Solution
A is also recursively enumerable.
根据定义,wA if and only if f(w)B
对于 MB semidecides B, 我们可以构造
M = on input w, run MB on f(w)
L(M)=A,故 A is recursively enumerable.

for ArB

  • If B is recursive, A is recursive.
  • If B is recursively enumerable, A is recursively enumerable.
  • If A is not recursive, B is not recursive.
  • If A is not recursively enumerable, B is not recursively enumerable.

一些关于 Recursive 的判断题

  • 判断题 1:If A is recursive and BA, then B is recursive as well.
  • 回答:错误,因为 Recursive Language 的子集不一定 Recursive。
  • 判断题 2:There's a function ϕ such that ϕ can be computed by some Turing machines, yet ϕ is not a primitive recursive function.
  • 回答:正确,因为 primitive recursive function 是 recursive function 的子集。
flowchart LR
	subgraph recursive function = μ-recursive function
		p[primitive recursive function]
	end
  • 判断题 3:If L1,L2, and L3 are all recursively enumerable, then L1(L2L3) must be recursively enumerable.
  • 判断题 4:Let L be a recursively enumerable language and LrH, then L is recursive, where H = { “M”“w” | Turing machine M halts on w }.
  • 回答:正确。因为 LrHL is recursively enumerable ⇒ L is recursive。 - 回答:正确,因为 Recursive Language 在 , 下封闭。

Let L1 and L2 be two recursively enumerable languages. If