跳到主要内容

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

Author

zephyr

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:
    • vw=aawL4v \cdot w = aa \cdot w \in L_4
    • Possible ww are ϵ,a\epsilon, a
  2. For v=bv = b:
    • vw=bwL4v \cdot w = b \cdot w \in L_4
    • Possible ww are ϵ,b,ab,bab\epsilon,b, ab, bab
  3. For v=bbv = bb:
    • vw=bbwL4v \cdot w = bb \cdot w \in L_4
    • Possible ww are ϵ,ab\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 of the form (an1ban2bankb)(a^{n_1}ba^{n_2}b…a^{n_k}b) where k0k \geq 0 and ni0n_i \geq 0 for all ii.
  2. Words in L6L_6 are repetitions of abbaabba.
  3. The possible prefixes from L5L_5 that could start a word in L6L_6 are:
  • ϵ\epsilon (empty string)
  • abab
  • abbabb

Now, let's consider what ww would be in each case:

  • If v=ϵv = \epsilon, then ww can be any word in L6L_6, i.e., (abba)(abba)^*
  • If v=abv = ab, then ww must start with baba and then continue with (abba)(abba)^*, i.e., ba(abba)ba(abba)^*
  • If v=abbv = abb, then ww must start with aa and then continue with (abba)(abba)^*, i.e., a(abba)a(abba)^*

Therefore, L5L6L_5 \triangleleft L_6 can be expressed as the union of these possibilities:

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)^*

or

L5L6=(baa)(abba)L_5 \triangleleft L_6 = (ba \cup 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)

To construct a non-deterministic finite automaton (NFA) that accepts L(A1)L(A2)\mathbf{L(A_1)} \triangleleft \mathbf{L(A_2)}, we can follow these steps:

a) Start with the structure of A1\mathbf{A_1}.

b) Add ϵ\epsilon-transitions from each state of A1\mathbf{A_1} to the initial state of A2\mathbf{A_2}.

c) Make all final states of A1\mathbf{A_1} non-final.

d) Keep the final states of A2\mathbf{A_2} as final.

Formally, we can define the NFA A=(Q,Σ,δ,q1,0,F)\mathbf{A} = (Q, \Sigma, \delta, q_{1,0}, F) where:

  • Q=Q1Q2Q = Q_1 \cup Q_2
  • Σ\Sigma is the same as before
  • δ(q,a)=δ1(q,a)\delta(q, a) = \delta_1(q, a) for qQ1,aΣq \in Q_1, a \in \Sigma
  • δ(q,a)=δ2(q,a)\delta(q, a) = \delta_2(q, a) for qQ2,aΣq \in Q_2, a \in \Sigma
  • δ(q,ϵ)={qqQ2}\delta(q, \epsilon) = \{q | q \in Q_2\} for qQ1q \in Q_1
  • q1,0q_{1,0} is the initial state of A1\mathbf{A_1}
  • F=F2F = F_2

This NFA simulates A1\mathbf{A_1} until it non-deterministically decides to switch to A2\mathbf{A_2} using an ϵ\epsilon-transition, then continues in A2\mathbf{A_2} until it reaches a final state of A2\mathbf{A_2}.

(4)

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

Counterexample:

Let L={ambncnm,n0}L = \{a^mb^nc^n \mid m, n \geq 0\} (a context-free language that is not regular)

Let R=abcR = a^*b^*c^* (a regular language)

Then LR={bncnn0}L \triangleleft R = \{b^nc^n \mid n \geq 0\}, which is not a regular language.

This counterexample shows that the statement is false in general.

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).