東京大学 情報理工学系研究科 コンピュータ科学専攻 2016年8月実施 専門科目I 問題1
Author
祭音Myyura (co-authored with GPT 5.6 SOL)
Description
A language L⊆Σ∗ over a finite alphabet Σ is said to be regular if there exists a finite automaton A such that L=L(A). Here
L(A)={w∈Σ∗∣w is accepted by A}.
Answer the following questions.
(1) We fix an alphabet Σ by Σ={a,b}. For the language L1 below, present a nondeterministic finite automaton (NFA) A1 such that: L(A1)=L1, and the number of states of A1 is not greater than 4.
L1={w∈Σ∗∣there is a character l∈Σ that occurs more than once in w}.
(2) Assume that Σ is a finite alphabet. Prove the following: any finite language L={w1,…,wn}⊆Σ∗ is regular. Here n is a nonnegative integer.
(3) We fix an alphabet Σ by Σ={a,b}. For the language L1 in Question (1), present a deterministic finite automaton (DFA) A2 such that: L(A2)=Σ∗∖L1, and the number of states of A2 is not greater than 5. Here Σ∗∖L1 denotes the complement of L1⊆Σ∗.
(4) Give a decision procedure for the following problem, and explain it briefly.
- Input nondeterministic finite automaton A.
- Output whether the language L(A) is an infinite set or not.
题目描述
有限字母表 Σ 上的语言 L⊆Σ∗ 称为正则语言,是指存在有限自动机 A 使
L=L(A)={w∈Σ∗∣w 被 A 接受}.
(1)令 Σ={a,b}。对
L1={w∈Σ∗∣w 中至少有一种字符出现两次以上},
构造状态数不超过 4 的 NFA A1,使 L(A1)=L1。
(2)证明有限字母表上的任意有限语言 L={w1,…,wn} 都是正则语言,其中 n 可为 0。
(3)构造状态数不超过 5 的 DFA A2,使
L(A2)=Σ∗∖L1。
(4)给出判定 NFA A 的语言 L(A) 是否为无限集的算法,并简述理由。
Kai
(1)
取初态 q0、终态 qf,构造如下。未画出的转移均为空。
自动机可在第一次读到某个字符时猜测它,并在再次读到同一字符时进入 qf,故恰好接受 L1。
(2)
以 L 中所有单词的前缀(含空串)为状态,读入字符 c 时从前缀 u 转到前缀 uc;若 uc 不是任何 wi 的前缀,则转入非接受的陷阱状态。把每个完整单词 wi 对应的状态标为接受态。所得前缀树 DFA 状态有限,且恰好接受 L。当 n=0 时,一个非接受的陷阱状态即可接受空语言。
(3)
补语言为 {ε,a,b,ab,ba}。下图中 q0,qa,qb,qab 为接受态,qd 为陷阱态。
这里 qab 表示两个字符各出现一次,与先后次序无关。
(4)
把 NFA 看成有向转移图。语言无限,当且仅当存在状态 q 同时满足:
- q 从初态可达;
- q 位于一个有向环上;
- 某个接受态从 q 可达。
分别对原图和反图做可达性搜索,再用强连通分量找环即可判定。若三条件成立,可重复该环而得到任意长的接受串;反之,任意长度不少于状态数的接受路径必重复状态,因而含有满足三条件的环。
上述环判据用于每条边都读入一个字符的 NFA。若输入自动机允许 ε 转移,可先消去 ε 转移,再应用此判据;等价地,在原图中要求该环至少包含一条读入实际字符的边。