跳到主要内容

東京大学 情報理工学系研究科 コンピュータ科学専攻 2016年8月実施 専門科目I 問題1

Author

祭音Myyura (co-authored with GPT 5.6 SOL)

Description

A language LΣL\subseteq\Sigma^* over a finite alphabet Σ\Sigma is said to be regular if there exists a finite automaton A\mathcal A such that L=L(A)L=\mathcal L(\mathcal A). Here

L(A)={wΣw is accepted by A}.\mathcal L(\mathcal A)=\{w\in\Sigma^*\mid w\text{ is accepted by }\mathcal A\}.

Answer the following questions.

(1) We fix an alphabet Σ\Sigma by Σ={a,b}\Sigma=\{a,b\}. For the language L1L_1 below, present a nondeterministic finite automaton (NFA) A1\mathcal A_1 such that: L(A1)=L1\mathcal L(\mathcal A_1)=L_1, and the number of states of A1\mathcal A_1 is not greater than 44.

L1={wΣthere is a character lΣ that occurs more than once in w}.L_1=\{w\in\Sigma^*\mid\text{there is a character }l\in\Sigma\text{ that occurs more than once in }w\}.

(2) Assume that Σ\Sigma is a finite alphabet. Prove the following: any finite language L={w1,,wn}ΣL=\{w_1,\ldots,w_n\}\subseteq\Sigma^* is regular. Here nn is a nonnegative integer.

(3) We fix an alphabet Σ\Sigma by Σ={a,b}\Sigma=\{a,b\}. For the language L1L_1 in Question (1), present a deterministic finite automaton (DFA) A2\mathcal A_2 such that: L(A2)=ΣL1\mathcal L(\mathcal A_2)=\Sigma^*\setminus L_1, and the number of states of A2\mathcal A_2 is not greater than 55. Here ΣL1\Sigma^*\setminus L_1 denotes the complement of L1ΣL_1\subseteq\Sigma^*.

(4) Give a decision procedure for the following problem, and explain it briefly.

  • Input nondeterministic finite automaton A\mathcal A.
  • Output whether the language L(A)\mathcal L(\mathcal A) is an infinite set or not.

题目描述

有限字母表 Σ\Sigma 上的语言 LΣL\subseteq\Sigma^* 称为正则语言,是指存在有限自动机 A\mathcal A 使

L=L(A)={wΣw 被 A 接受}.L=\mathcal L(\mathcal A)=\{w\in\Sigma^*\mid w\text{ 被 }\mathcal A\text{ 接受}\}.

(1)令 Σ={a,b}\Sigma=\{a,b\}。对

L1={wΣw 中至少有一种字符出现两次以上},L_1=\{w\in\Sigma^*\mid w\text{ 中至少有一种字符出现两次以上}\},

构造状态数不超过 44 的 NFA A1\mathcal A_1,使 L(A1)=L1\mathcal L(\mathcal A_1)=L_1

(2)证明有限字母表上的任意有限语言 L={w1,,wn}L=\{w_1,\ldots,w_n\} 都是正则语言,其中 nn 可为 00

(3)构造状态数不超过 55 的 DFA A2\mathcal A_2,使 L(A2)=ΣL1\mathcal L(\mathcal A_2)=\Sigma^*\setminus L_1

(4)给出判定 NFA A\mathcal A 的语言 L(A)\mathcal L(\mathcal A) 是否为无限集的算法,并简述理由。

Kai

(1)

取初态 q0q_0、终态 qfq_f,构造如下。未画出的转移均为空。

自动机可在第一次读到某个字符时猜测它,并在再次读到同一字符时进入 qfq_f,故恰好接受 L1L_1

(2)

LL 中所有单词的前缀(含空串)为状态,读入字符 cc 时从前缀 uu 转到前缀 ucuc;若 ucuc 不是任何 wiw_i 的前缀,则转入非接受的陷阱状态。把每个完整单词 wiw_i 对应的状态标为接受态。所得前缀树 DFA 状态有限,且恰好接受 LL。当 n=0n=0 时,一个非接受的陷阱状态即可接受空语言。

(3)

补语言为 {ε,a,b,ab,ba}\{\varepsilon,a,b,ab,ba\}。下图中 q0,qa,qb,qabq_0,q_a,q_b,q_{ab} 为接受态,qdq_d 为陷阱态。

这里 qabq_{ab} 表示两个字符各出现一次,与先后次序无关。

(4)

把 NFA 看成有向转移图。语言无限,当且仅当存在状态 qq 同时满足:

  1. qq 从初态可达;
  2. qq 位于一个有向环上;
  3. 某个接受态从 qq 可达。

分别对原图和反图做可达性搜索,再用强连通分量找环即可判定。若三条件成立,可重复该环而得到任意长的接受串;反之,任意长度不少于状态数的接受路径必重复状态,因而含有满足三条件的环。

上述环判据用于每条边都读入一个字符的 NFA。若输入自动机允许 ε\varepsilon 转移,可先消去 ε\varepsilon 转移,再应用此判据;等价地,在原图中要求该环至少包含一条读入实际字符的边。