计算理论02_正则语言

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Let M be DFA with k states
ep69
此页可略
Create equivalent GNFA M‟ with k+2 states Reduce in k steps M‟ to M‟‟ with 2 states The resulting GNFA describes a single regular expressions R
• :(Q\{qaccept})(Q\{qstart}) R
除开起止点, 称为内部状态
The interior Q\{qaccept,qstart} is fully connected by From qstart only „outgoing transitions‟ To qaccept only „ingoing transitions‟ Impossible qiqj transitions are “(qi,qj) = ” Observation: This GNFA: recognizes the language L(R)
2016/5/26 计算理论 wbfeng@staff.edu.shu.cn 3
Thm 1.28: RL ~ RE ep66
cp40(读一下)
Thm 1.28 L is RL there exists RE E such that L=E 通常 L={ ..|….} E形如 (a+b)C+(d.g)*
2016/5/26
qj
qi
1
0
qj
becomes
计算理论 wbfeng@staff.edu.shu.cn
qi 01
qj
10
Remove Internal state of GNFA
给机造表达式 ep73
If the GNFA M has more than 2 states, „rip‟ internal qrip to get equivalent GNFA M‟ by: - Removing state qrip: Q‟=Q\{qrip} 逐步减少内态 -Changing the transition function by ‟(qi,qj) = (qi,qj) ((qi,qrip)((qrip,qrip))*(qrip,qj))
The regular language L(M) equals the language L(R) of the regular expression R
2016/5/26 计算理论 wbfeng@staff.edu.shu.cn 12
Regular Languages = Regular Expressions ep74 cp45 Let R be a regular expression, then there exists an NFA M such that L(R) = L(M) 正则有DFA
2016/5/26
qS
RR
qA
计算理论 wbfeng@staff.edu.shu.cn
8
Proof Idea of Lemma c2.32 给机造表达式
, ep69, cp41
Proof idea (given a DFA M):
Construct an equivalent GNFA M‟ with k2 states Reduce one-by-one the internal states until k=2 逐个等价地减少状态,把内部的表达式变大 This GNFA will be of the form
第二讲课程 • Chapter 1: • RL = Regular Languages, • nonregular languages
• RL pumping lemma
• Chapter 2: • Context-Free Languages (CFLs)
2016/5/26
计算理论 wbfeng@staff.edu.shu.cn
- Connect qstart to earlier q1:
qS

q1
qj
qA - Connect old accepting states to qaccept
qi

- Complete missing transitions by - Join multiple transitions:合并标号
Hence: RE NFA = DFA GNFA RE 它们的表达能 力等价
2016/5/26 计算理论 wbfeng@staff.edu.shu.cn 13
Nonregular Languages §1.4 ep 77
学,然后知”不足”,正则语言表达能力有限 绝大多数语言是NRL
Which languages cannot be recognized by finite automata? Example: L={ 0n1n | nN } NRL • „Playing around‟ with FA convinces you that the „finiteness‟ of FA is problematic for “all nN” • The problem occurs between the 0n and the 1n
The language L(M) of a DFA M is equivalent to a language L(M‟) of a GNFA = M‟, which can be converted to a two-staቤተ መጻሕፍቲ ባይዱe M‟‟ DFA等价于GNFA
The transition qstart R qacceptof M‟‟ obeys L(R) = L(M‟‟) GNFA等价于正则语言
1
Regular Expressions
(Def. 1.26 中文:定义1.26 ) ep64 cp39 递归法下定义,适合本身是递归结构的对象
例 N! 或记为 F(N) 定义为 F(0)=1; 递归基础 (程序终止条件) F(N)=N*F(N-1) 当 N >= 1 //递归 (减1)结构
Int Factor(int n) { if (n<0) printf(“error”); if n==0 return 1; //无此语句,会导致error else return n*Factor(n-1); //通常用栈结构实现 } 如第1,2句均无,则死循环,称为 图灵机不停机,
思想:言多必复 :设一个罗嗦老太婆, 有n个论点,当说 话多于n句时,至少有一个地方在打圈, (发言激动时尤其 如此),以后遇此,可笑谈:泵定理其作用了。 正则语言是靠打圈,才描述无限集合的
2016/5/26 计算理论 wbfeng@staff.edu.shu.cn 4
Thm 1.28: RL ~ RE 给机造表达式
ep66 cp40(读一下)
Today we do the second part: 左边 右边, 即: •If a language is regular, then it can be described by a regular expression (Lemma 1.32)
2016/5/26
计算理论 wbfeng@staff.edu.shu.cn
6
Example GNFA 与ep70图稍有不同
0110
0

qS
子自动机 01*
qA
0* 11
2016/5/26 计算理论 wbfeng@staff.edu.shu.cn 7
Characteristics of GNFA’s
•要证明它不是NRL需要泵定理引入泵定理
• Informal: the memory of a FA is limited by the the number of states |Q|, 原因,FA的软硬件太少
2016/5/26 计算理论 wbfeng@staff.edu.shu.cn 14
将讨论 Pumping 定理
2016/5/26 计算理论 wbfeng@staff.edu.shu.cn 2
Regular Expressions 正则表达式
(Def. 1.26 中文:定义1.26 ) ep64 cp38
递归法下定义,适合本身是递归结构的对象,构造性的
Given an alphabet , R is a regular expression if 1. R = a, with a 2. R = 递归基础 3. R = 4. R = (R1R2), with R1 and R2 regular expressions 5. R = (R1R2), with R1 and R2 regular expressions 6. R = (R1*), with R1 a regular expression 递归结构,增加 一个运算符号 的 构造方法
•分两部 •1 RL 有 DFA M识别(定义),把DFA 转化称广义的GNFA •2 把广义的GNFA转化成正则表达式 RE •下页先引入广义的GNFA •普通的NFA中一个边相当于一个语句 •广义的GNFA 自动机的边可以是正则表达式(自动机),相 当相当于 程序可以调用(子)程序
2016/5/26
(无穷) 集合表达式 有限字母 有限运算 构造,可计算 We need to prove both ways: 左边 右边 • If a language is described by a regular expression, then it is regular (Lemma 1.29)上次实际上已证 左边 右边 •(Last week we saw how we can convert a regular expression R into an NFA M such that L(R)=L(M))上次已完 成FA的确定化 • Today we do the second part: 左边 右边, 给机造表达式 •If a language is regular, then it can be described by a regular expression (Lemma 1.32)
法则:用力拉首尾,拓扑变形。以星换圈,以并 换 多路
for every qiQ‟\{qaccept} and qjQ‟\{qstart}
R1 q rip
qi
R4
2016/5/26
R2 R3 = qi
R4(R1R2*R3)
qj
11
qj
计算理论 wbfeng@staff.edu.shu.cn
Proof Lemma 1.32 给机造表达式
计算理论 wbfeng@staff.edu.shu.cn
5
Generalized NFA 给机造表达式 ep70-73 ,
cp41-42
Generalized nondeterministic finite automaton M=(Q, , , qstart, qaccept) with • Q finite set of states 状态 不包括终点 • the input alphabet • qstart the start state 下一状态, 不包括起点 • qaccept the accept state • :(Q\{qaccept})(Q\{qstart}) R the transition function • (R is the set of regular expressions over ) • 惟一区别 自动机的边是 RE (子程序,子自动机)
This regular expression R will be such that L(R) = L(M)
qS
R
qA
2016/5/26
计算理论 wbfeng@staff.edu.shu.cn
9
DFA M Equivalent GNFA M’
给机造表达式 ep73 cp42
Let M have k states Q={q1,…,qk} - Add two states qaccept and qstart 加首 尾 补空边
相关文档
最新文档