跳到主要内容

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

Author

zephyr, 祭音Myyura

Description

Let Σ\Sigma be the set {a,b}\{a, b\} of letters. Given two languages L1,L2ΣL_1, L_2 \subseteq \Sigma^*, we define L1L2L_1 \triangleleft L_2 by:

L1L2={wΣvL1.vwL2}.L_1 \triangleleft L_2 = \{w \in \Sigma^* \mid \exists v \in L_1.vw \in L_2\}.

For example, if L1={ab,bb}L_1 = \{ab, bb\} and L2={aa,abb,bbab}L_2 = \{aa, abb, bbab\}, then

L1L2={b,ab}.L_1 \triangleleft L_2 = \{b, ab\}.

For a finite automaton A\mathbf{A}, we write L(A)\mathbf{L(A)} for the language accepted by A\mathbf{A}.

Answer the following questions.

(1) Let L3={aa,b,bb}L_3 = \{aa, b, bb\} and L4={a,b,ab,bb,aaa,bbab}L_4 = \{a, b, ab, bb, aaa, bbab\}. Give the set L3L4L_3 \triangleleft L_4.

(2) Let L5L_5 and L6L_6 be the languages expressed by the regular expressions (ab)(a^*b)^* and (abba)(abba)^*, respectively. Express L5L6L_5 \triangleleft L_6 by using a regular expression.

(3) Let A1=(Q1,Σ,δ1,q1,0,F1)\mathbf{A_1} = (Q_1, \Sigma, \delta_1, q_{1,0}, F_1) and A2=(Q2,Σ,δ2,q2,0,F2)\mathbf{A_2} = (Q_2, \Sigma, \delta_2, q_{2, 0}, F_2) be deterministic finite automata. Here, Qi,δi,qi,0,Q_i, \delta_i, q_{i, 0}, and FiF_i are the set of states, the transition function, the initial state, and the set of final states of Ai\mathbf{A_i} (i{1,2}i \in \{1, 2\}), respectively. Assume that the transition functions δi:Qi×ΣQi\delta_i : Q_i \times \Sigma \rightarrow Q_i (i{1,2}i \in \{1, 2\}) are total. Give a non-deterministic finite automaton that accepts L(A1)L(A2)\mathbf{L(A_1)} \triangleleft \mathbf{L(A_2)}, with a brief explanation. You may use ϵ\epsilon-transitions.

(4) Answer whether the following statement is true:

  • "For every context-free language LL and regular language RR, LRL \triangleleft R is a regular language."

Also, give a proof sketch if the answer is yes, and give a counterexample if the answer is no.


Σ\Sigma 为字母集合 {a,b}\{a, b\}。给定两个语言 L1,L2ΣL_1, L_2 \subseteq \Sigma^*,我们定义 L1L2L_1 \triangleleft L_2 如下:

L1L2={wΣvL1.vwL2}L_1 \triangleleft L_2 = \{w \in \Sigma^* \mid \exists v \in L_1.vw \in L_2\}。

例如,如果 L1={ab,bb}L_1 = \{ab, bb\}L2={aa,abb,bbab}L_2 = \{aa, abb, bbab\},则

L1L2={b,ab}L_1 \triangleleft L_2 = \{b, ab\}。

对于一个有限自动机 A\mathbf{A},我们用 L(A)\mathbf{L(A)} 表示 A\mathbf{A} 接受的语言。回答以下问题。

(1) 设 L3={aa,b,bb}L_3 = \{aa, b, bb\}L4={a,b,ab,bb,aaa,bbab}L_4 = \{a, b, ab, bb, aaa, bbab\}。给出集合 L3L4L_3 \triangleleft L_4

(2) 设 L5L_5L6L_6 分别由正则表达式 (ab)(a^*b)^*(abba)(abba)^* 表示。用正则表达式表示 L5L6L_5 \triangleleft L_6

(3) 设 A1=(Q1,Σ,δ1,q1,0,F1)\mathbf{A_1} = (Q_1, \Sigma, \delta_1, q_{1, 0}, F_1)A2=(Q2,Σ,δ2,q2,0,F2)\mathbf{A_2} = (Q_2, \Sigma, \delta_2, q_{2, 0}, F_2) 为确定性有限自动机。这里,Qi,δi,qi,0,Q_i, \delta_i, q_{i, 0},FiF_iAi\mathbf{A_i} 的状态集合、转换函数、初态和终态集合(i{1,2}i \in \{1, 2\})。假设转换函数 δi:Qi×ΣQi\delta_i : Q_i \times \Sigma \rightarrow Q_ii{1,2}i \in \{1, 2\})是全函数。给出一个非确定性有限自动机,该自动机接受 L(A1)L(A2)\mathbf{L(A_1)} \triangleleft \mathbf{L(A_2)},并简要解释。你可以使用 ϵ\epsilon-转换。

(4) 回答以下陈述是否正确:

  • “对于每个上下文无关语言 LL 和正则语言 RRLRL \triangleleft R 是正则语言。”

如果答案是肯定的,请给出证明草图;如果答案是否定的,请给出反例。

题目描述

Σ={a,b}\Sigma=\{a,b\}。对语言 L1,L2ΣL_1,L_2\subseteq\Sigma^*,定义左商

L1L2={wΣ存在 vL1 使 vwL2}.L_1\triangleleft L_2 =\{w\in\Sigma^*\mid \text{存在 }v\in L_1\text{ 使 }vw\in L_2\}.

例如,若 L1={ab,bb}L_1=\{ab,bb\}L2={aa,abb,bbab}L_2=\{aa,abb,bbab\},则 L1L2={b,ab}L_1\triangleleft L_2=\{b,ab\}。记 L(A)L(A) 为有限自动机 AA 接受的语言。 回答下列问题。

(1)令 L3={aa,b,bb}L_3=\{aa,b,bb\}L4={a,b,ab,bb,aaa,bbab}L_4=\{a,b,ab,bb,aaa,bbab\},求 L3L4L_3\triangleleft L_4

(2)L5,L6L_5,L_6 分别由正则表达式 (ab)(a^*b)^*(abba)(abba)^* 表示。 用正则表达式表示 L5L6L_5\triangleleft L_6

(3)设 DFA Ai=(Qi,Σ,δi,qi,0,Fi) (i=1,2)A_i=(Q_i,\Sigma,\delta_i,q_{i,0},F_i)\ (i=1,2),且转移函数均为全函数。 构造识别 L(A1)L(A2)L(A_1)\triangleleft L(A_2) 的 NFA 并简要说明;允许使用 ε\varepsilon 转移。

(4)判断命题“对每个上下文无关语言 LL 和正则语言 RRLRL\triangleleft R 都是正则语言”是否正确。若正确,给出证明概要;若错误,给出反例。

Kai

(1)

Let L3={aa,b,bb}L_3 = \{aa, b, bb\} and L4={a,b,ab,bb,aaa,bbab}L_4 = \{a, b, ab, bb, aaa, bbab\}. We need to find the set L3L4L_3 \triangleleft L_4.

L3L4={wΣvL3 such that vwL4}L_3 \triangleleft L_4 = \{ w \in \Sigma^* \mid \exists v \in L_3 \text{ such that } vw \in L_4 \}

We check each element vL3v\in L_3:

  1. For v=aav=aa, the only word of L4L_4 having this prefix is aaaaaa, so w=aw=a.
  2. For v=bv=b, the words b,bb,bbabb,bb,bbab give w=ϵ,b,babw=\epsilon,b,bab.
  3. For v=bbv=bb, the words bb,bbabbb,bbab give w=ϵ,abw=\epsilon,ab.

Collecting all possible ww:

L3L4={ϵ,a,b,ab,bab}L_3 \triangleleft L_4 = \{\epsilon, a, b, ab, bab\}

(2)

Let L5=(ab)L_5 = (a^*b)^* and L6=(abba)L_6 = (abba)^*. We need to express L5L6L_5 \triangleleft L_6 using a regular expression.

L5L6={wΣvL5 such that vwL6}L_5 \triangleleft L_6 = \{w \in \Sigma^* \mid \exists v \in L_5 \text{ such that } vw \in L_6\}

Let's analyze this step by step:

  1. Words in L5L_5 are ϵ\epsilon or words ending in bb.
  2. Words in L6L_6 are repetitions of abba.
  3. A prefix of a word in L6L_6 that belongs to L5L_5 is either ϵ\epsilon, (abba)tab(abba)^t ab, or (abba)tabb(abba)^t abb for some t0t\ge0.

The corresponding suffixes are:

  • for v=ϵv=\epsilon, any word in (abba)(abba)^*;
  • after a prefix (abba)tab(abba)^t ab, a word in ba(abba)ba(abba)^*;
  • after a prefix (abba)tabb(abba)^t abb, a word in a(abba)a(abba)^*.

Therefore,

L5L6=(abba)ba(abba)a(abba)L_5 \triangleleft L_6 = (abba)^* \cup ba(abba)^* \cup a(abba)^*

This can be written more compactly as:

L5L6=(ϵ+ba+a)(abba)L_5 \triangleleft L_6 = (\epsilon + ba + a)(abba)^*

This regular expression captures all possible suffixes that, when concatenated with a word from L5L_5, result in a word from L6L_6.

(3)

Run the product automaton A1×A2A_1\times A_2 from (q1,0,q2,0)(q_{1,0},q_{2,0}), and put

S={qQ2vΣ:δ1(q1,0,v)F1, δ2(q2,0,v)=q}.S=\{q\in Q_2\mid \exists v\in\Sigma^*:\delta_1^*(q_{1,0},v)\in F_1, \ \delta_2^*(q_{2,0},v)=q\}.

Take a copy of A2A_2, add a new initial state with ϵ\epsilon-transitions to every state in SS, and retain F2F_2 as the accepting set. It accepts ww exactly when some vL(A1)v\in L(A_1) satisfies vwL(A2)vw\in L(A_2).

(4)

The statement is true. Let a DFA A=(Q,Σ,δ,q0,F)A=(Q,\Sigma,\delta,q_0,F) accept RR, and set

S={δ(q0,v)vL}Q.S=\{\delta^*(q_0,v)\mid v\in L\}\subseteq Q.

An NFA consisting of AA with all states in SS as initial states accepts exactly LRL\triangleleft R. Since QQ is finite, this language is regular. (The argument in fact holds for arbitrary LL.)

Knowledge

正则语言 上下文无关语言 NFA 正则表达式

难点思路

问题 3 和 4 可能对考生来说比较困难。

对于问题 3,关键是理解如何通过 NFA 的非确定性来模拟 \triangleleft 操作。我们使用 ϵ\epsilon-转移来允许在 A1\mathbf{A_1} 的任何状态 " 猜测 " 是否应该开始匹配 A2\mathbf{A_2} 的部分。

对于问题 4,难点在于构造合适的反例。需要选择一个非正则的上下文无关语言,并找到一个合适的正则语言,使得它们的 \triangleleft 操作结果仍然是非正则的。

解题技巧和信息

  1. 对于涉及新定义操作的题目,先仔细理解定义,然后尝试用具体的例子来理解操作的含义。
  2. 在处理正则表达式时,考虑语言中单词的结构和可能的前缀。
  3. 构造 NFA 时,利用非确定性和 ϵ\epsilon-转移来模拟复杂的操作。
  4. 在证明语言类别相关的陈述时,寻找反例通常比证明正确性更容易。尝试使用经典的非正则上下文无关语言作为起点。

重点词汇

  • finite automaton 有限自动机
  • non-deterministic finite automaton (NFA) 非确定性有限自动机
  • regular expression 正则表达式
  • context-free language 上下文无关语言
  • ϵ\epsilon-transition ϵ\epsilon-转移
  • counterexample 反例

参考资料

  1. Introduction to Automata Theory, Languages, and Computation by John E. Hopcroft, Rajeev Motwani, Jeffrey D. Ullman. Chapter 2 (Finite Automata) and Chapter 4 (Context-Free Grammars).
  2. Sipser, M. (2012). Introduction to the Theory of Computation. Cengage Learning. Chapter 1 (Regular Languages) and Chapter 2 (Context-Free Languages).