東京大学 情報理工学系研究科 コンピュータ科学専攻 2021年2月実施 問題3
Author
zephyr, 祭音Myyura
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, the only word of L4 having this prefix is aaa, so w=a.
- For v=b, the words b,bb,bbab give w=ϵ,b,bab.
- For v=bb, the words bb,bbab give w=ϵ,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 ϵ or words ending in b.
- Words in L6 are repetitions of
abba.
- A prefix of a word in L6 that belongs to L5 is either ϵ, (abba)tab, or (abba)tabb for some t≥0.
The corresponding suffixes are:
- for v=ϵ, any word in (abba)∗;
- after a prefix (abba)tab, a word in ba(abba)∗;
- after a prefix (abba)tabb, a word in a(abba)∗.
Therefore,
L5◃L6=(abba)∗∪ba(abba)∗∪a(abba)∗
This can be written more compactly as:
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)
Run the product automaton A1×A2 from
(q1,0,q2,0), and put
S={q∈Q2∣∃v∈Σ∗:δ1∗(q1,0,v)∈F1, δ2∗(q2,0,v)=q}.
Take a copy of A2, add a new initial state with
ϵ-transitions to every state in S, and retain F2 as the accepting set. It accepts w exactly when some v∈L(A1) satisfies vw∈L(A2).
(4)
The statement is true. Let a DFA A=(Q,Σ,δ,q0,F) accept
R, and set
S={δ∗(q0,v)∣v∈L}⊆Q.
An NFA consisting of A with all states in S as initial states accepts exactly
L◃R. Since Q is finite, this language is regular. (The argument in fact holds for arbitrary L.)
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).