東京大学 情報理工学系研究科 コンピュータ科学専攻 2021年8月実施 専門科目 問題3
Author
Description
Let
In other words,
For example,
Answer the following questions.
(1) Compute
(2) Express
(3) Suppose that a word
(4) If the following proposition is true, then give a proof sketch (it suffices to show a pushdown automaton that accepts
Proposition: "For every word
设
换句话说,
例如,
回答以下问题。
(1) 计算
(2) 使用正则表达式表示
(3) 假设一个单词
(4) 如果以下命题为真,则给出一个证明草图(证明接受
命题:“对于每个单词
Kai
(1)
Let's analyze the string babababa
and mark the positions where "aba" appears as a subword:
b a b a b a b a
^ ^ ^
^ ^ ^
^ ^ ^
Now, let's replace these starting positions with 't' and the rest with 'f':
(2)
To construct this regular expression, we need to consider all possible ways aba
can appear in a string:
- The string might start with
aba
: - There might be any number of a's or b's before
ab
: - The string might end with any number of a's or b's:
Combining these, we get:
Therefore,
(3)
Let
- For the transition function
: - For each
and : - If
and : - Add
-transition from to
- Add
- If
and : - Add
-transition from to
- Add
- If
: - Add
-transition from to
- Add
- If
- For each
This NFA simulates the DFA
(4)
This proposition is true. We can prove it by constructing a pushdown automaton (PDA) that accepts
Proof Sketch:
Let
- For the transition function
: - For each
: - If
and : - For each
, add to
- For each
- If
and : - For each
, add to
- For each
- If
and : - For each
and , add to
- For each
- If
- For each
Explanation:
- Similar to the NFA construction in Question 3, the state
represents that we are in state of the original PDA and have matched symbols of . - The
-transitions simulate the original PDA's transitions for matching the next symbol of . - The
-transition occurs for positions where is not matched, resetting the match counter to 0. - The
-transition occurs when we complete a match of , also resetting the match counter to 0.
This PDA
Note: The key difference between this construction and the one in Question 3 is that we're now working with a PDA instead of a DFA, which allows us to handle the stack operations necessary for context-free languages. However, the core idea of tracking partial matches of
Knowledge
DFA NFA PDA 正则表达式 上下文无关语言 下推自动机
难点思路
- 理解函数
和 的定义及其在字符串和语言上的作用。 - 构造接受
的非确定性有限自动机,需要巧妙地结合原 DFA 和模式匹配。 - 将 NFA 构造的思路扩展到 PDA,以证明
的上下文无关性。
解题技巧和信息
- 在处理形式语言问题时,尝试从简单的例子开始,然后推广到一般情况。
- 在构造自动机或文法时,考虑如何将问题的不同方面(如这里的 PDA 转换和模式匹配)结合起来。
- 对于复杂的语言操作,考虑如何使用现有的形式语言工具(如 NFA、PDA)来模拟这些操作。
- 注意识别问题之间的联系,如第三问和第四问之间的关系,可以帮助简化解题过程。
- 在扩展 NFA 到 PDA 时,要注意保持状态转换的基本结构,同时增加对栈操作的处理。
重点词汇
- deterministic finite automaton (DFA) 确定性有限自动机
- non-deterministic finite automaton (NFA) 非确定性有限自动机
- pushdown automaton (PDA) 下推自动机
- context-free grammar (CFG) 上下文无关文法
- regular expression 正则表达式
-transition -转换
参考资料
- Introduction to Automata Theory, Languages, and Computation by John E. Hopcroft, Rajeev Motwani, Jeffrey D. Ullman. Chapter 2 (Finite Automata), Chapter 3 (Regular Expressions and Languages), Chapter 5 (Context-Free Grammars and Languages), Chapter 6 (Pushdown Automata)
- Formal Languages and Automata Theory by C. K. Nagpal. Chapters on Regular Languages, Context-Free Languages, and Pushdown Automata