東京大学 情報理工学系研究科 コンピュータ科学専攻 2019年2月実施 問題3
Author
kainoj
Description
Let Σ be a finite alphabet (i.e., a finite set of letters).
We say that a word v∈Σ∗ is a subsequence of a word w=a1⋯an∈Σ∗ if v=ai1⋯ai2 for some k≥0 and 1≤ii<⋯<ik≤n.
For example, aab is a subsequence of acbabc (let k=3,i1=1,i2=4 and i3=5).
We write v⪯w if v is a subsequence of w.
Answer the following questions.
(1) Give a non-deterministic finite automaton with at most 4 states that accepts the language:
{w∈{a,b,c}∗∣aab⪯w}
(2) Suppost that L⊆Σ∗ is the language accepted by a deterministic finite automaton A=(Q,Σ,δ,q0,F) (where Q is a finite set of states, δ∈Q×Σ→Q is the transition function, q0∈Q is the initial state, and F⊆Q is the set of final states).
Give a non-deterministic finite automaton that accepts the language:
{w∈Σ∗∣v⪯w for some v∈L}
(3) Supposet that L⊆Σ∗ is the language accepted by a deterministic finite automaton A=(Q,Σ,δ,q0,F).
Assume that the transition function δ∈Q×Σ→Q is a total function.
Give a deterministic finite automaton that accepts the language:
{w∈Σ∗∣v∈L for every v∈Σ∗ such that v⪯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∈Σ∗∣v⪯w for some v∈L}
where v⪯w indicates that v is subsequence of w.
In other words, to in order to get a word from L2, we first fix a word v∈L and then intertwine its letters with some "garbage" from Σ∗.
Let's fix v∈L.
Let p1,p2,⋯p∣v∣ be sequence of states that A visits when reading v.
Label transitions between pi's with next letters of v.
Moreover, for each pi, add a loop to itself labeled with Σ.
Make p1 the start state.
(3)
First,
L′={w∈Σ∗∣v∈L for every v∈Σ∗ such that v⪯w}
is kinda quirky.
We already supposed that L⊆Σ∗, so why do we need v∈Σ∗ above?
Let's start with constructing a NFA N which accepts L′.
Let N be a copy of A, where we additionally put Σ-labeled loops on every state.
Intuitively, while traversing A, in every state, we can have a "detour", i.e. accept some garbage.
Having constructed NFA N, move to constructing equivalent DFA D.
It is feasible, and subset construction tells us how to it.
Formally, define automaton A accepting L as A=(Q,Σ,δ,qo,F).
NFA N such that L(N)=L′ is defined as:
N=(Q,Σ,δN,q0,F)
where
δN(q,a)={q}∪{δ(q,a)}
is a "loop" on every state.
Now, equivalent DFA D is obtained by subset construction:
DQDFDδD(X,a)=(QD,Σ,δD,q0,FD)=P(Q)={X∈QD∣X∩F=∅}=q∈X⋃δN(q,a)
(4)
Since every DFA has equivalent NFA and vice versa, I'll prove (Q3) for NFA N.
Two steps:
- w∈L′⇒N accepts w.Since w∈L′, then there must exits v∈L such that v⪯w.v is accepted both in A and N, since N has exactly the same states as A.Then, w must be accepted by N by following the loops on letters of w which do not contribute to v.
- N accepts w⇒w∈L′. To get v such that v⪯w, simulate N on w, skip the loops. Obviously v∈L, because states of N and A are the same and v and w will end up in the same final state of N.