跳到主要内容

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

Author

zephyr

Description

Let Σ={a,b}\Sigma = \{a,b\}. Answer the following questions.

(1) Give a non-deterministic finite state automaton with 3 states that accepts the following language.

{wbawΣ}\{wba | w \in \Sigma^*\}

(2) Show the minimal deterministic finite state automaton that accepts the language given in question (1).

(3) Prove that the following language LL over Σ\Sigma is not regular. You may use the pumping lemma for regular languages.

L={wRbawwΣ}L = \{w^Rbaw | w \in \Sigma^*\}

Here, wRw^R denotes the reverse of ww. For example, (abb)R=bba(abb)^R = bba.

(4) Is the language LL in question (3) a context-free language? If it is, construct a context-free grammar that generates LL. If not, prove that LL is not a context-free language.


Σ={a,b}\Sigma = \{a,b\}。回答以下问题。

(1) 给出一个具有 3 个状态的非确定性有限状态自动机,该自动机接受以下语言。

{wbawΣ}\{wba | w \in \Sigma^*\}

(2) 展示接受问题 (1) 中给出的语言的最小确定性有限状态自动机。

(3) 证明以下语言 LLΣ\Sigma 上不是正则的。你可以使用正则语言的泵引理。

L={wRbawwΣ}L = \{w^Rbaw | w \in \Sigma^*\}

这里,wRw^R 表示 ww 的反转。例如,(abb)R=bba(abb)^R = bba

(4) 问题 (3) 中的语言 LL 是上下文无关语言吗?如果是,构造一个生成 LL 的上下文无关文法。如果不是,证明 LL 不是上下文无关语言。

题目描述

Σ={a,b}\Sigma=\{a,b\},回答下列问题。

(1)构造一个具有 33 个状态的 NFA,识别语言

{wbawΣ}.\{wba\mid w\in\Sigma^*\}.

(2)画出识别第(1)问语言的最小 DFA。

(3)证明语言

L={wRbawwΣ}L=\{w^Rbaw\mid w\in\Sigma^*\}

不是正则语言;可以使用正则语言泵引理。其中 wRw^R 表示 ww 的逆序,例如 (abb)R=bba(abb)^R=bba

(4)判断第(3)问的 LL 是否为上下文无关语言。若是,构造生成 LL 的上下文无关文法;若不是,证明其非上下文无关性。

考点

  • 后缀语言的 NFA 与最小 DFA:利用非确定性猜测后缀起点,并通过可区分后缀完成 DFA 最小化。
  • 正则语言泵引理:选取对称结构字符串并证明有限自动机无法记忆两侧对应关系。
  • 上下文无关文法:用递归产生式在固定中心串 ba 两侧同步生成互为逆序的字符串。

Kai

(1)

A non-deterministic finite state automaton (NFA) with 3 states that accepts the language {wbawΣ}\{wba \mid w \in \Sigma^*\} can be constructed as follows:

  • States: q0,q1,q2q_0, q_1, q_2
  • Alphabet: {a,b}\{a, b\}
  • Start state: q0q_0
  • Accept state: q2q_2
  • Transition function:
    • q0a,bq0q_0 \xrightarrow{a,b} q_0
    • q0bq1q_0 \xrightarrow{b} q_1
    • q1aq2q_1 \xrightarrow{a} q_2
    • q1bq0q_1 \xrightarrow{b} q_0
    • q2aq0q_2 \xrightarrow{a} q_0
    • q2bq1q_2 \xrightarrow{b} q_1

The state diagram for the NFA is as follows:

(2)

To construct the minimal deterministic finite state automaton (DFA) for the language {wbawΣ}\{wba \mid w \in \Sigma^*\}, we can use the subset construction method to convert the NFA to a DFA.

We can represent the NFA as a DFA with the following states:

  • δ(q0,a)=q0\delta(q_0, a) = q_0
  • δ(q0,b)={q0,q1}\delta(q_0, b) = \{q_0, q_1\}
  • δ({q0,q1},a)={q0,q2}\delta(\{q_0, q_1\}, a) = \{q_0, q_2\}
  • δ({q0,q1},b)={q0,q1}\delta(\{q_0, q_1\}, b) = \{q_0, q_1\}
  • δ({q0,q2},a)=q0\delta(\{q_0, q_2\}, a) = q_0
  • δ({q0,q2},b)={q0,q1}\delta(\{q_0, q_2\}, b) = \{q_0, q_1\}

This DFA is minimal and accepts the language {wbawΣ}\{wba \mid w \in \Sigma^*\}.

The transition table for the DFA is as follows:

So we can construct the minimal DFA as follows:

  • States: {Q0,Q1,Q2}\{Q_0, Q_1, Q_2\}
  • Alphabet: {a,b}\{a, b\}
  • Start state: Q0Q_0
  • Accept state: Q2Q_2
  • Transition function:
    • δ(Q0,a)=Q0\delta(Q_0, a) = Q_0
    • δ(Q0,b)=Q1\delta(Q_0, b) = Q_1
    • δ(Q1,a)=Q2\delta(Q_1, a) = Q_2
    • δ(Q1,b)=Q1\delta(Q_1, b) = Q_1
    • δ(Q2,a)=Q0\delta(Q_2, a) = Q_0
    • δ(Q2,b)=Q1\delta(Q_2, b) = Q_1

The state diagram for the minimal DFA is as follows:

(3)

To prove that the language L={wRbawwΣ}L = \{w^{\mathbf{R}}baw \mid w \in \Sigma^*\} is not regular, we will use the pumping lemma for regular languages.

Pumping Lemma for Regular Languages

If LL is a regular language, then there exists a pumping length pp such that any string sLs \in L with sp|s| \geq p can be split into three parts s=xyzs = xyz satisfying the following conditions:

  1. xyp|xy| \leq p
  2. y>0|y| > 0
  3. xyizLxy^iz \in L for all i0i \geq 0

Let w=apw = a^p, and consider the string s=wRbaw=apbaaps = w^{\mathbf{R}}baw = a^p b a a^p. According to the pumping lemma, ss can be decomposed into xyzxyz such that the conditions are met.

  • Let x=aix = a^i, y=ajy = a^j, z=apijbaapz = a^{p-i-j} b a a^p where 1i+jp1 \leq i+j \leq p and j>0j > 0.

If we pump yy, the resulting string is xy2z=aia2japijbaap=ap+jbaapxy^2z = a^i a^{2j} a^{p-i-j} b a a^p = a^{p+j} b a a^p.

This string is not in LL because it does not match the form wRbaww^{\mathbf{R}}baw where w=apw = a^p. Thus, LL is not a regular language.

(4)

To determine whether LL is a context-free language, we can use the context-free grammar (CFG) approach.

Constructing a CFG for LL

We need to create a CFG that generates strings of the form wRbaww^{\mathbf{R}}baw where wΣw \in \Sigma^*.

A CFG that generates this language can be defined as follows:

  • Non-terminals: S,AS, A
  • Terminals: a,ba, b
  • Start symbol: SS
  • Production rules:
    • SbaaSabSbS \rightarrow ba \mid a S a \mid b S b

This CFG generates strings of the form wRbaww^{\mathbf{R}}baw by recursively placing matching symbols aa and bb around the center substring bb.

Therefore, LL is a context-free language.

Knowledge

NFA DFA 正则语言 泵引理 上下文无关语言

难点解题思路

对于问题 3,使用抽象的语言对泵引理的证明往往会遇到困难。我们选择具体的字符串 w=apw = a^p 并展示在不同情况下的行为以证明该语言非正则性。问题 4 则是运用构造法,结合递归的生成规则,清晰地表达语言的上下文无关性质。

解题技巧和信息

  1. NFA 转换为 DFA 时,确保考虑每种状态转换的可能性,尽量简化状态数量。
  2. 利用泵引理证明非正则性时,选择一个能覆盖所有可能情况下的字符串。
  3. 构造 CFG 时,利用递归规则可以简洁地表达嵌套的结构。

重点词汇

  • Non-deterministic finite state automaton (NFA) 非确定性有限状态自动机
  • Deterministic finite state automaton (DFA) 确定性有限状态自动机
  • Pumping Lemma 泵引理
  • Context-free grammar (CFG) 上下文无关文法
  • Regular language 正则语言
  • Context-free language 上下文无关语言

参考资料

  1. "Introduction to the Theory of Computation" by Michael Sipser, Chapters 1-2 for Automata and Regular Languages, Chapter 4 for Context-Free Grammars.