跳到主要内容

東京大学 情報理工学系研究科 コンピュータ科学専攻 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=a1⋯an∈Σ∗w = a_1 \cdots a_n \in \Sigma^* if v=ai1⋯aikv = a_{i_1} \cdots a_{i_k} for some k≥0k \geq 0 and 1≤i1<⋯<ik≤n1 \leq i_1 < \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 v⪯wv \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}∗∣aab⪯w}\{w \in \{a,b,c\}^* \mid aab \preceq w\}

(2) Suppose 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, q0∈Qq_0 \in Q is the initial state, and F⊆QF \subseteq Q is the set of final states). Give a non-deterministic finite automaton that accepts the language:

{w∈Σ∗∣v⪯w for some v∈L}\{w \in \Sigma^* \mid v \preceq w \text{ for some } v \in L\}

(3) Suppose 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∈Σ∗∣v∈L for every v∈Σ∗ such that v⪯w}\{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=a1⋯an∈Σ∗w=a_1\cdots a_n\in\Sigma^* 中按原顺序选取若干字符可以得到 vv,即存在 k≥0k\ge0 及 1≤i1<⋯<ik≤n1\le i_1<\cdots<i_k\le n,使 v=ai1⋯aikv=a_{i_1}\cdots a_{i_k},则称 vv 是 ww 的子序列,记作 v⪯wv\preceq w。例如 aab⪯acbabcaab\preceq acbabc。回答下列问题。

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

{w∈{a,b,c}∗∣aab⪯w}.\{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∈Σ∗∣存在 v∈L 使 v⪯w}.\{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∈Σ∗∣对每个满足 v⪯w 的 v∈Σ∗, v∈L}.\{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 v⪯wv\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):q∈X},FD={X⊆Q:X⊆F}.\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):v⪯w}.\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 v∈Lv\in L for every v⪯wv\preceq w.