跳到主要内容

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

Author

kainoj, 祭音Myyura

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)L=\mathcal{L}(\mathcal{A}),则称 LL 为正则语言,其中

L(A)={wΣw 被 A 接受}.\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)设 Σ\Sigma 为有限字母表。证明任意有限语言 L={w1,,wn}ΣL=\{w_1,\ldots,w_n\}\subseteq\Sigma^* 都是正则语言,其中 nn 可以为非负整数。

(3)仍令 Σ={a,b}\Sigma=\{a,b\}。针对第(1)问的 L1L_1,构造一个状态数不超过 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)

Σ={a,b}\Sigma = \{a,b\}. Give NFA A1\mathcal{A}_1 with no more than 44 states recognizing L1={wΣlΣwl>1}L_1 = \{w\in \Sigma \:|\: \exists l\in \Sigma \: |w|_l > 1\}.

absq0q0,q1q0,q2q1q3q1q2q2q3q3q3q3\begin{array}{ll||l|l} & & a & b \\ \hline s & q_0 & q_0,q_1 & q_0,q_2 \\ & q_1 & q_3 & q_1 \\ & q_2 & q_2 & q_3 \\ * & q_3 & q_3 & q_3 \end{array}

(2)

We construct a finite automaton accepting LL. One construction is an ϵ\epsilon-NFA with nn branches, the ii-th branch spelling exactly wiw_i; every ϵ\epsilon-NFA has an equivalent DFA.

The DFA can also be constructed explicitly. Start with the path recognizing w1w_1: it has w1+1|w_1|+1 states, its transitions are labeled by the successive letters of w1w_1, and its last state is accepting. For each wiw_i with i2i\geq2, follow the already constructed transitions along its longest existing prefix, then attach a new path labeled by the remaining suffix. Mark the state reached after every complete wiw_i as accepting.

Finally, send each missing transition to one nonaccepting dead state, which has a self-loop for every letter of Σ\Sigma. The resulting finite prefix-trie DFA accepts exactly LL. If n=0n=0, the one-state nonaccepting DFA recognizes \varnothing.

(3)

Give DFA recognizing complement of L1L_1 from (Q1), i.e L2=ΣL1L_2 = \Sigma^* \setminus L_1.

Obviously L2={wΣlΣwl1}={ϵ,a,b,ab,ba}L_2 = \{w\in \Sigma \:|\: \forall l\in \Sigma \: |w|_l \leq 1\} = \{\epsilon, a, b, ab, ba\}.

abs,q1q2q3q2q5q4q3q4q5q4q5q5q5q5q5\begin{array}{ll||l|l} & & a & b \\ \hline s,* & q_1 & q_2 & q_3 \\ * & q_2 & q_5 & q_4 \\ * & q_3 & q_4 & q_5 \\ * & q_4 & q_5 & q_5 \\ & q_5 & q_5 & q_5 \end{array}

(4)

View A\mathcal A as a directed transition graph. Its language is infinite iff some state qq satisfies all three conditions:

  1. qq is reachable from an initial state;
  2. qq lies on a directed cycle;
  3. an accepting state is reachable from qq.

Indeed, such a cycle can be repeated arbitrarily often. Conversely, any accepting run of length at least the number of states repeats a state and contains such a cycle. Reachability and strongly connected components can be computed by graph search.