東京大学 情報理工学系研究科 コンピュータ科学専攻 2021年2月実施 問題3
Author
zephyr
Description
Let Σ be the set {a,b} of letters. Given two languages L1,L2⊆Σ∗, we define L1◃L2 by:
L1◃L2={w∈Σ∗∣∃v∈L1.vw∈L2}.
For example, if L1={ab,bb} and L2={aa,abb,bbab}, then
L1◃L2={b,ab}.
For a finite automaton A, we write L(A) for the language accepted by A.
Answer the following questions.
(1) Let L3={aa,b,bb} and L4={a,b,ab,bb,aaa,bbab}. Give the set L3◃L4.
(2) Let L5 and L6 be the languages expressed by the regular expressions (a∗b)∗ and (abba)∗, respectively. Express L5◃L6 by using a regular expression.
(3) Let A1=(Q1,Σ,δ1,q1,0,F1) and A2=(Q2,Σ,δ2,q2,0,F2) be deterministic finite automata. Here, Qi,δi,qi,0, and Fi are the set of states, the transition function, the initial state, and the set of final states of Ai (i∈{1,2}), respectively. Assume that the transition functions δi:Qi×Σ→Qi (i∈{1,2}) are total. Give a non-deterministic finite automaton that accepts L(A1)◃L(A2), with a brief explanation. You may use ϵ-transitions.
(4) Answer whether the following statement is true:
- "For every context-free language L and regular language R, L◃R is a regular language."
Also, give a proof sketch if the answer is yes, and give a counterexample if the answer is no.
设 Σ 为字母集合 {a,b}。给定两个语言 L1,L2⊆Σ∗,我们定义 L1◃L2 如下:
L1◃L2={w∈Σ∗∣∃v∈L1.vw∈L2}。
例如,如果 L1={ab,bb} 且 L2={aa,abb,bbab},则
L1◃L2={b,ab}。
对于一个有限自动机 A,我们用 L(A) 表示 A 接受的语言。回答以下问题。
(1) 设 L3={aa,b,bb} 和 L4={a,b,ab,bb,aaa,bbab}。给出集合 L3◃L4。
(2) 设 L5 和 L6 分别由正则表达式 (a∗b)∗ 和 (abba)∗ 表示。用正则表达式表示 L5◃L6。
(3) 设 A1=(Q1,Σ,δ1,q1,0,F1) 和 A2=(Q2,Σ,δ2,q2,0,F2) 为确定性有限自动机。这里,Qi,δi,qi,0, 和 Fi 是 Ai 的状态集合、转换函数、初态和终态集合(i∈{1,2})。假设转换函数 δi:Qi×Σ→Qi(i∈{1,2})是全函数。给出一个非确定性有限自动机,该自动机接受 L(A1)◃L(A2),并简要解释。你可以使用 ϵ-转换。
(4) 回答以下陈述是否正确:
- “对于每个上下文无关语言 L 和正则语言 R,L◃R 是正则语言。”
如果答案是肯定的,请给出证明草图;如果答案是否定的,请给出反例。
题目描述
令 Σ={a,b}。对语言 L1,L2⊆Σ∗,定义左商
L1◃L2={w∈Σ∗∣存在 v∈L1 使 vw∈L2}.
例如,若 L1={ab,bb}、L2={aa,abb,bbab},则
L1◃L2={b,ab}。记 L(A) 为有限自动机 A 接受的语言。
回答下列问题。
(1)令
L3={aa,b,bb}、
L4={a,b,ab,bb,aaa,bbab},求
L3◃L4。
(2)L5,L6 分别由正则表达式 (a∗b)∗ 和 (abba)∗ 表示。
用正则表达式表示 L5◃L6。
(3)设 DFA
Ai=(Qi,Σ,δi,qi,0,Fi) (i=1,2),且转移函数均为全函数。
构造识别 L(A1)◃L(A2) 的 NFA 并简要说明;允许使用
ε 转移。
(4)判断命题“对每个上下文无关语言 L 和正则语言 R,
L◃R 都是正则语言”是否正确。若正确,给出证明概要;若错误,给出反例。
Kai
(1)
Let L3={aa,b,bb} and L4={a,b,ab,bb,aaa,bbab}. We need to find the set L3◃L4.
L3◃L4={w∈Σ∗∣∃v∈L3 such that vw∈L4}
We check each element v∈L3:
- For v=aa:
- v⋅w=aa⋅w∈L4
- Possible w are ϵ,a
- For v=b:
- v⋅w=b⋅w∈L4
- Possible w are ϵ,b,ab,bab
- For v=bb:
- v⋅w=bb⋅w∈L4
- Possible w are ϵ,ab
Collecting all possible w:
L3◃L4={ϵ,a,b,ab,bab}
(2)
Let L5=(a∗b)∗ and L6=(abba)∗. We need to express L5◃L6 using a regular expression.
L5◃L6={w∈Σ∗∣∃v∈L5 such that vw∈L6}
Let's analyze this step by step:
- Words in L5 are of the form (an1ban2b…ankb) where k≥0 and ni≥0 for all i.
- Words in L6 are repetitions of abba.
- The possible prefixes from L5 that could start a word in L6 are:
- ϵ (empty string)
- ab
- abb
Now, let's consider what w would be in each case:
- If v=ϵ, then w can be any word in L6, i.e., (abba)∗
- If v=ab, then w must start with ba and then continue with (abba)∗, i.e., ba(abba)∗
- If v=abb, then w must start with a and then continue with (abba)∗, i.e., a(abba)∗
Therefore, L5◃L6 can be expressed as the union of these possibilities:
L5◃L6=(abba)∗∪ba(abba)∗∪a(abba)∗
This can be written more compactly as:
L5◃L6=(ϵ+ba+a)(abba)∗
or
L5◃L6=(ba∪a)(abba)∗
This regular expression captures all possible suffixes that, when concatenated with a word from L5, result in a word from L6.
(3)
To construct a non-deterministic finite automaton (NFA) that accepts L(A1)◃L(A2), we can follow these steps:
a) Start with the structure of A1.
b) Add ϵ-transitions from each state of A1 to the initial state of A2.
c) Make all final states of A1 non-final.
d) Keep the final states of A2 as final.
Formally, we can define the NFA A=(Q,Σ,δ,q1,0,F) where:
- Q=Q1∪Q2
- Σ is the same as before
- δ(q,a)=δ1(q,a) for q∈Q1,a∈Σ
- δ(q,a)=δ2(q,a) for q∈Q2,a∈Σ
- δ(q,ϵ)={q∣q∈Q2} for q∈Q1
- q1,0 is the initial state of A1
- F=F2
This NFA simulates A1 until it non-deterministically decides to switch to A2 using an ϵ-transition, then continues in A2 until it reaches a final state of A2.
(4)
The statement "For every context-free language L and regular language R, L◃R is a regular language" is false.
Counterexample:
Let L={ambncn∣m,n≥0} (a context-free language that is not regular)
Let R=a∗b∗c∗ (a regular language)
Then L◃R={bncn∣n≥0}, which is not a regular language.
This counterexample shows that the statement is false in general.
Knowledge
正则语言 上下文无关语言 NFA 正则表达式
难点思路
问题 3 和 4 可能对考生来说比较困难。
对于问题 3,关键是理解如何通过 NFA 的非确定性来模拟 ◃ 操作。我们使用 ϵ-转移来允许在 A1 的任何状态 " 猜测 " 是否应该开始匹配 A2 的部分。
对于问题 4,难点在于构造合适的反例。需要选择一个非正则的上下文无关语言,并找到一个合适的正则语言,使得它们的 ◃ 操作结果仍然是非正则的。
解题技巧和信息
- 对于涉及新定义操作的题目,先仔细理解定义,然后尝试用具体的例子来理解操作的含义。
- 在处理正则表达式时,考虑语言中单词的结构和可能的前缀。
- 构造 NFA 时,利用非确定性和 ϵ-转移来模拟复杂的操作。
- 在证明语言类别相关的陈述时,寻找反例通常比证明正确性更容易。尝试使用经典的非正则上下文无关语言作为起点。
重点词汇
- finite automaton 有限自动机
- non-deterministic finite automaton (NFA) 非确定性有限自动机
- regular expression 正则表达式
- context-free language 上下文无关语言
- ϵ-transition ϵ-转移
- counterexample 反例
参考资料
- 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).
- Sipser, M. (2012). Introduction to the Theory of Computation. Cengage Learning. Chapter 1 (Regular Languages) and Chapter 2 (Context-Free Languages).