東京大学 情報理工学系研究科 コンピュータ科学専攻 2023年8月実施 専門科目 問題1
Author
Description
Given an integer , we define a language over an alphabet by:
Here, is the set of integers and . That is, is the language that consists of words whose -th symbol from the last is .
Answer the following questions.
(1) Give a non-deterministic finite automaton that accepts .
(2) Describe using a regular expression. You may write the -time concatenation of a regular expression as .
(3) Is a regular language? If so, give a finite automaton that accepts . If not, prove that is not regular. You may use the pumping lemma for regular languages.
(4) Prove that any deterministic finite automaton that accepts has at least states.
给定一个整数 ,我们通过以下方式定义了一个字母表 上的语言 :
这里, 是整数集,并且 。也就是说, 是由那些倒数第 个符号是 的单词组成的语言。
回答以下问题。
(1) 给出一个接受 的非确定性有限自动机。
(2) 使用正则表达式描述 。你可以将正则表达式 的 次连接写为 。
(3) 是正则语言吗?如果是,给出一个接受 的有限自动机。如果不是,证明 不是正则的。你可以使用正则语言的抽水引理。
(4) 证明任何接受 的确定性有限自动机至少有 个状态。
题目描述
给定整数 ,在字母表 上定义
也就是说, 由倒数第 个字符为 的字符串构成。回答下列问题。
(1)构造识别 的 NFA。
(2)用正则表达式表示 ;正则表达式 的 次连接可记作 。
(3)判断
是否为正则语言。若是,给出识别它的有限自动机;若不是,证明其非正则性。可以使用正则语言泵引理。
(4)证明任何识别 的 DFA 都至少具有 个状态。
Kai
(1)
To construct an NFA that accepts , we need to ensure that the third symbol from the end is 'a'. Here is the NFA:
- States:
- Alphabet:
- Transitions:
- From (start state):
- On reading any symbol or , move to (this loop represents reading any number of symbols at the start).
- On reading any symbol, move to (non-deterministically guess that we might be three symbols away from the end).
- From :
- On reading any symbol or , move to .
- From :
- On reading any symbol or , move to (final state).
- From (start state):
- Final State:
This NFA accepts a string if it non-deterministically guesses that it is three symbols away from the end, and then checks if the third-to-last symbol is 'a'.
(2)
To describe using a regular expression:
Here, represents any string of length , followed by the symbol 'a', and then followed by any string of arbitrary length. This ensures that the -th symbol from the end is 'a'.
(3)
Claim: The language is not a regular language.
Proof:
To prove that is not a regular language, we will use the pumping lemma. The pumping lemma states that if a language is regular, then any sufficiently long string in the language can be "pumped" — that is, a portion of the string can be repeated multiple times, and the resulting strings will still belong to the language.
String Selection
Let's consider a string carefully crafted to belong to for some integer . For example, consider the string:
This string belongs to because the -th symbol from the end is 'a', and all other characters are 'b'.
Pumping Lemma Application
Assume that is a regular language. Then by the pumping lemma, there exists a pumping length such that any string with length at least can be decomposed as , where:
- ,
- , and
- for all .
Given that , the substring is confined to the first characters, which consist entirely of 'b's followed by a single 'a' and another some 'b's. Thus, the substring consists of only 'b's (say for some ).
Pumped String
Consider the string . After pumping, the string becomes:
Here, the block of 'b's after the 'a' has increased by , shifting the position of the 'a' forward by positions. The length of is now greater than by .
Why May not Belong to Any
- Original Position: In the original string , the 'a' was exactly at the -th position from the end.
- New Position: After pumping, in , the 'a' is now at the -th position from the end.
For to belong to any , the position of 'a' from the end should be exactly for some integer . However:
- For , , meaning that may not be a perfect square number, so does not always belong to any .
- Therefore, the string for any .
(4)
Claim: Any DFA that accepts must have at least states.
Proof:
Consider the DFA accepting . This DFA must remember the last symbols it has seen in order to determine whether the -th symbol from the end is 'a'.
There are possible sequences of symbols over the alphabet , and the DFA must distinguish between each of these sequences because each sequence can determine whether the current string belongs to . Thus, the DFA must have a unique state for each possible sequence of symbols.
Therefore, the DFA must have at least states to correctly accept all strings in .
Knowledge
NFA DFA 正则语言 泵引理
语言的取并操作
重点词汇
- NFA: 非确定性有限自动机
- DFA: 确定性有限自动机
- Pumping Lemma: 抽象引理
- Regular Expression: 正则表达式
参考资料
- "Introduction to the Theory of Computation" by Michael Sipser, Chap. 1, 2
- "Automata Theory, Languages, and Computation" by Hopcroft, Motwani, and Ullman, Chap. 2