跳到主要内容

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

Author

祭音Myyura (co-authored with GPT 5.6 SOL)

Description

Let Σ\Sigma be a finite alphabet (i.e., a finite set of letters), and ϵ\epsilon be the empty sequence. We define the shuffle w1w2Σw_1 \otimes w_2 \subseteq \Sigma^* of two words w1,w2Σw_1, w_2 \in \Sigma^* as follows.

  • For every wΣw \in \Sigma^*,
ϵw=wϵ={w}.\epsilon \otimes w = w \otimes \epsilon = \{w\}.
  • For every a,bΣa, b \in \Sigma and w1,w2Σw_1, w_2 \in \Sigma^*,
(aw1)(bw2)={awww1(bw2)}{bww(aw1)w2}.(aw_1) \otimes (bw_2) = \{aw \mid w \in w_1 \otimes (bw_2)\} \cup \{bw \mid w \in (aw_1) \otimes w_2\}.

Furthermore, for two languages L1,L2ΣL_1, L_2 \subseteq \Sigma^*, their shuffle L1L2ΣL_1 \otimes L_2 \subseteq \Sigma^* is defined by:

L1L2=w1L1,w2L2w1w2.L_1 \otimes L_2 = \bigcup_{w_1 \in L_1, w_2 \in L_2} w_1 \otimes w_2.

For example, we have:

{ab,ba}{ϵ,c}=(abϵ)(abc)(baϵ)(bac)={ab,cab,acb,abc,ba,cba,bca,bac}.\{ab, ba\} \otimes \{\epsilon, c\} = (ab \otimes \epsilon) \cup (ab \otimes c) \cup (ba \otimes \epsilon) \cup (ba \otimes c) = \{ab, cab, acb, abc, ba, cba, bca, bac\}.

Answer the following questions.

(1) Compute {a,bb}{ab,cc}\{a, bb\} \otimes \{ab, cc\}.

(2) Suppose that deterministic finite automata A1=(Q1,Σ,δ1,q1,0,F1)\mathcal{A}_1 = (Q_1, \Sigma, \delta_1, q_{1,0}, F_1) and A2=(Q2,Σ,δ2,q2,0,F2)\mathcal{A}_2 = (Q_2, \Sigma, \delta_2, q_{2,0}, F_2) accept languages L1L_1 and L2L_2, respectively. Here, Qi,δi,qi,0,Q_i, \delta_i, q_{i,0}, and FiF_i are respectively the set of states, the transition function, the initial state, and the set of final states of Ai (i{1,2})\mathcal{A}_i \ (i \in \{1, 2\}). You may assume that the transition functions δiQi×ΣQi (i{1,2})\delta_i \in Q_i \times \Sigma \rightarrow Q_i\ (i \in \{1, 2\}) are total functions. Give a non-deterministic automaton that accepts L1L2L_1 \otimes L_2.

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

(4) Let L3={anbnn0}L_3 = \{a^nb^n \mid n \geq 0\} and L4={cmdmm0}L_4 = \{c^md^m \mid m \geq 0\}. Prove that L3L4L_3 \otimes L_4 is not a context-free language. Here, you may use the pumping lemma for context-free languages.

题目描述

Σ\Sigma 为有限字母表,ε\varepsilon 为空串。对 w1,w2Σw_1,w_2\in\Sigma^*,递归定义它们的洗牌(shuffle) w1w2Σw_1\otimes w_2\subseteq\Sigma^*

εw=wε={w},\varepsilon\otimes w=w\otimes\varepsilon=\{w\},

且对 a,bΣa,b\in\Sigmaw1,w2Σw_1,w_2\in\Sigma^*

(aw1)(bw2)={awww1(bw2)}{bww(aw1)w2}.(aw_1)\otimes(bw_2) =\{aw\mid w\in w_1\otimes(bw_2)\} \cup \{bw\mid w\in(aw_1)\otimes w_2\}.

对语言 L1,L2ΣL_1,L_2\subseteq\Sigma^*,定义

L1L2=w1L1, w2L2w1w2.L_1\otimes L_2 =\bigcup_{w_1\in L_1,\ w_2\in L_2}w_1\otimes w_2.

例如

{ab,ba}{ε,c}={ab,cab,acb,abc,ba,cba,bca,bac}.\{ab,ba\}\otimes\{\varepsilon,c\} =\{ab,cab,acb,abc,ba,cba,bca,bac\}.

回答下列问题。

(1)计算 {a,bb}{ab,cc}\{a,bb\}\otimes\{ab,cc\}

(2)设 DFA Ai=(Qi,Σ,δi,qi,0,Fi)\mathcal A_i=(Q_i,\Sigma,\delta_i,q_{i,0},F_i) 分别识别语言 Li (i=1,2)L_i\ (i=1,2),并假定两个转移函数均为全函数。构造一个识别 L1L2L_1\otimes L_2 的 NFA。

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

(4)令 L3={anbnn0}L_3=\{a^nb^n\mid n\ge0\}L4={cmdmm0}L_4=\{c^md^m\mid m\ge0\}。证明 L3L4L_3\otimes L_4 不是上下文无关语言。可以使用上下文无关语言泵引理。

Kai

(1)

分别计算四组洗牌并去重,得

{a,bb}{ab,cc}={aab,aba,acc,cac,cca,abbb,babb,bbab,bbcc,bcbc,bccb,cbbc,cbcb,ccbb}.\begin{aligned} \{a,bb\}\otimes\{ab,cc\}=\{&aab,aba,acc,cac,cca,\\ &abbb,babb,bbab,bbcc,bcbc,bccb,cbbc,cbcb,ccbb\}. \end{aligned}

(2)

取 NFA A=(Q1×Q2,Σ,Δ,(q1,0,q2,0),F1×F2)\mathcal A=(Q_1\times Q_2,\Sigma,\Delta,(q_{1,0},q_{2,0}),F_1\times F_2),其中

Δ((q1,q2),a)={(δ1(q1,a),q2),(q1,δ2(q2,a))}.\Delta((q_1,q_2),a) =\{(\delta_1(q_1,a),q_2),(q_1,\delta_2(q_2,a))\}.

即每读一个字符,非确定地选择交给其中一台 DFA,另一台保持原状态。

(3)

ww 被接受,将运行中交给第一、第二台 DFA 的字符分别按原序组成 w1,w2w_1,w_2。最终两台都在接受状态,故 w1L1,w2L2w_1\in L_1,w_2\in L_2,且 ww1w2w\in w_1\otimes w_2

反之,若 ww1w2w\in w_1\otimes w_2,其中 wiLiw_i\in L_i,则按该交错方式选择转移,运行结束于 F1×F2F_1\times F_2,故接受 ww

(4)

L=L3L4L=L_3\otimes L_4 是上下文无关语言,则与正则语言 acbda^*c^*b^*d^* 的交

K=Lacbd={ancmbndmn,m0}K=L\cap a^*c^*b^*d^*=\{a^nc^mb^nd^m\mid n,m\ge0\}

也是上下文无关语言。设其泵长度为 pp,取 w=apcpbpdpw=a^pc^pb^pd^p。任意满足 w=uvxyzw=uvxyzvxyp|vxy|\le pvy>0|vy|>0 的分解中,vxyvxy 至多涉及两个相邻字符块,因而不能同时涉及 a,ba,b 两块,也不能同时涉及 c,dc,d 两块。

令泵次数为 00。删除 v,yv,y 后至少一种字符减少,而与它要求等量的另一种字符没有减少。因此所得串不在 KK,与泵引理矛盾。故 L3L4L_3\otimes L_4 不是上下文无关语言。