跳到主要内容

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

Author

kainoj

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.

Kai

(1)

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

(2)

Write

L2={wΣvw for some vL} L_2 = \{w \in \Sigma^* | v \preceq w \text{ for some } v \in L \}

where vwv \preceq w indicates that vv is subsequence of ww. In other words, to in order to get a word from L2L_2, we first fix a word vLv \in L and then intertwine its letters with some "garbage" from Σ\Sigma^*.

Let's fix vLv\in L. Let p1,p2,pvp_1, p_2, \cdots p_{|v|} be sequence of states that A\mathcal{A} visits when reading vv. Label transitions between pip_i's with next letters of vv. Moreover, for each pip_i, add a loop to itself labeled with Σ\Sigma. Make p1p_1 the start state.

(3)

First,

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

is kinda quirky. We already supposed that LΣL \subseteq \Sigma^*, so why do we need vΣv\in \Sigma^* above?

Let's start with constructing a NFA N\mathcal{N} which accepts LL'. Let N\mathcal{N} be a copy of A\mathcal{A}, where we additionally put Σ\Sigma-labeled loops on every state. Intuitively, while traversing A\mathcal{A}, in every state, we can have a "detour", i.e. accept some garbage.

Having constructed NFA N\mathcal{N}, move to constructing equivalent DFA D\mathcal{D}. It is feasible, and subset construction tells us how to it. Formally, define automaton A\mathcal{A} accepting LL as A=(Q,Σ,δ,qo,F)\mathcal{A} = (Q, \Sigma, \delta, q_o, F). NFA N\mathcal{N} such that L(N)=L\mathcal{L}(\mathcal{N}) = L' is defined as:

N=(Q,Σ,δN,q0,F)\begin{aligned} \mathcal{N} &= (Q, \Sigma, \delta_N, q_0, F) \end{aligned}

where

δN(q,a)={q}{δ(q,a)} \delta_N(q, a) = \{q\} \cup \{\delta(q,a)\}

is a "loop" on every state. Now, equivalent DFA D\mathcal{D} is obtained by subset construction:

D=(QD,Σ,δD,q0,FD)QD=P(Q)FD={XQDXF}δD(X,a)=qXδN(q,a)\begin{aligned} \mathcal{D} &= (Q_D, \Sigma, \delta_D, {q_0}, F_D) \\ Q_D &= \mathcal{P}(Q) \\ F_D &= \{ X\in Q_D | X\cap F \neq \emptyset\} \\ \delta_D(X,a) &= \bigcup_{q \in X} \delta_N(q,a) \end{aligned}

(4)

Since every DFA has equivalent NFA and vice versa, I'll prove (Q3) for NFA N\mathcal{N}.

Two steps:

  • wLN accepts ww \in L' \Rightarrow \mathcal{N} \text{ accepts } w.Since wLw\in L', then there must exits vLv\in L such that vwv\preceq w.vv is accepted both in A\mathcal{A} and N\mathcal{N}, since N\mathcal{N} has exactly the same states as A\mathcal{A}.Then, ww must be accepted by N\mathcal{N} by following the loops on letters of ww which do not contribute to vv.
  • N accepts wwL\mathcal{N} \text{ accepts } w \Rightarrow w \in L'. To get vv such that vwv\preceq w, simulate N\mathcal{N} on ww, skip the loops. Obviously vLv\in L, because states of N\mathcal{N} and A\mathcal{A} are the same and vv and ww will end up in the same final state of N\mathcal{N}.