跳到主要内容

東京大学 情報理工学系研究科 コンピュータ科学専攻 2019年2月実施 問題3

Author

kainoj, 祭音Myyura

Description

Let Σ\Sigma be a finite alphabet (i.e., a finite set of letters). We say that a word vΣv \in \Sigma^* is a subsequence of a word w=a1anΣw = a_1 \cdots a_n \in \Sigma^* if v=ai1ai2v = a_{i_1} \cdots a_{i_2} for some k0k \geq 0 and 1ii<<ikn1 \leq i_i < \cdots < i_k \leq n. For example, aabaab is a subsequence of acbabcacbabc (let k=3,i1=1,i2=4k=3, i_1=1, i_2=4 and i3=5i_3=5). We write vwv \preceq w if vv is a subsequence of ww. Answer the following questions.

(1) Give a non-deterministic finite automaton with at most 44 states that accepts the language:

{w{a,b,c}aabw}\{w \in \{a,b,c\}^* \mid aab \preceq w\}

(2) Suppost that LΣL \subseteq \Sigma^* is the language accepted by a deterministic finite automaton A=(Q,Σ,δ,q0,F)\mathcal{A} = (Q, \Sigma, \delta, q_0, F) (where QQ is a finite set of states, δQ×ΣQ\delta \in Q \times \Sigma \rightarrow Q is the transition function, q0Qq_0 \in Q is the initial state, and FQF \subseteq Q is the set of final states). Give a non-deterministic finite automaton that accepts the language:

{wΣvw for some vL}\{w \in \Sigma^* \mid v \preceq w \text{ for some } v \in L\}

(3) Supposet that LΣL \subseteq \Sigma^* is the language accepted by a deterministic finite automaton A=(Q,Σ,δ,q0,F)\mathcal{A} = (Q, \Sigma, \delta, q_0, F). Assume that the transition function δQ×ΣQ\delta \in Q \times \Sigma \rightarrow Q is a total function. Give a deterministic finite automaton that accepts the language:

{wΣvL for every vΣ such that vw}\{w \in \Sigma^* \mid v \in L \text{ for every } v \in \Sigma^* \text{ such that } v \preceq w\}

(4) Prove the correctness of your answer for question (3) above.

题目描述

Σ\Sigma 为有限字母表。若从字符串 w=a1anΣw=a_1\cdots a_n\in\Sigma^* 中按原顺序选取若干字符可以得到 vv,即存在 k0k\ge01i1<<ikn1\le i_1<\cdots<i_k\le n,使 v=ai1aikv=a_{i_1}\cdots a_{i_k},则称 vvww 的子序列,记作 vwv\preceq w。例如 aabacbabcaab\preceq acbabc。回答下列问题。

(1)构造一个状态数不超过 44 的 NFA,识别语言

{w{a,b,c}aabw}.\{w\in\{a,b,c\}^*\mid aab\preceq w\}.

(2)设 DFA A=(Q,Σ,δ,q0,F)\mathcal A=(Q,\Sigma,\delta,q_0,F) 识别语言 LΣL\subseteq\Sigma^*。构造一个 NFA,识别语言

{wΣ存在 vL 使 vw}.\{w\in\Sigma^*\mid \text{存在 }v\in L\text{ 使 }v\preceq w\}.

(3)设 DFA A=(Q,Σ,δ,q0,F)\mathcal A=(Q,\Sigma,\delta,q_0,F) 识别 LΣL\subseteq\Sigma^*,并假定 δ:Q×ΣQ\delta:Q\times\Sigma\to Q 为全函数。 构造一个 DFA,识别语言

{wΣ对每个满足 vw 的 vΣ, vL}.\{w\in\Sigma^*\mid \text{对每个满足 }v\preceq w\text{ 的 }v\in\Sigma^*, \ v\in L\}.

(4)证明第(3)问构造的正确性。

Kai

(1)

--> o --a--> o --a--> o --b--> (o)
/ \ / \ / \ / \
\ / \ / \ / \ /
E E E E

Here each loop labeled E denotes one loop for every symbol in {a,b,c}\{a,b,c\}.

(2)

Use the NFA N=(Q,Σ,Δ,q0,F)\mathcal N=(Q,\Sigma,\Delta,q_0,F), where

Δ(q,a)={q,δ(q,a)}.\Delta(q,a)=\{q,\delta(q,a)\}.

The transition to qq skips the current input symbol; the other transition selects it for the simulated subsequence. Hence N\mathcal N accepts ww iff some vwv\preceq w is accepted by A\mathcal A.

(3)

Define the DFA D\mathcal D by

QD=P(Q),qD={q0},δD(X,a)=X{δ(q,a):qX},FD={XQ:XF}.\begin{aligned} Q_D&=\mathcal P(Q), & q_D&=\{q_0\},\\ \delta_D(X,a)&=X\cup\{\delta(q,a):q\in X\}, &F_D&=\{X\subseteq Q:X\subseteq F\}. \end{aligned}

(4)

For every ww, induction on w|w| gives the invariant

δD({q0},w)={δ(q0,v):vw}.\delta_D^*(\{q_0\},w) =\{\delta^*(q_0,v):v\preceq w\}.

Indeed, on reading the next symbol aa, a subsequence either omits aa or appends it. Therefore the reached subset is accepting exactly when every state in it lies in FF, which is equivalent to vLv\in L for every vwv\preceq w.