收藏 分享(赏)

chap5 deciding context-free languages.ppt

上传人:天天快乐 文档编号:1240715 上传时间:2018-06-20 格式:PPT 页数:92 大小:881KB
下载 相关 举报
chap5 deciding context-free languages.ppt_第1页
第1页 / 共92页
chap5 deciding context-free languages.ppt_第2页
第2页 / 共92页
chap5 deciding context-free languages.ppt_第3页
第3页 / 共92页
chap5 deciding context-free languages.ppt_第4页
第4页 / 共92页
chap5 deciding context-free languages.ppt_第5页
第5页 / 共92页
点击查看更多>>
资源描述

1、2018/6/20,1/92,Lecture Notes for Computation,Book :计算理论导引 Introduction to the Theory of Computation Chap5 Deciding context-free languagesProfessor : 唐常杰TangC Http:/ : Ph.D. 2000-2009, SCUStyle : Lecture / Seminar,2018/6/20,2/92,上次已经讲完定理 4.14.8 本周稍作复习, 可从停机问题开始。两个PPT,2018/6/20,3/92,2018/6/20,4/92,201

2、8/6/20,5/92,今天课程 两个PPT,Chapter 4: 4.1.1 Deciding RL properties 复习上周 4.1.2 Deciding context-free languages 4.2 The Halting Problem 4.2 Countable and uncountable infinities 4.2 Diagonalization arguments,2018/6/20,6/92,Deciding Languages 准备引入通用图灵机 cp107,复习 : 下列问题可判定ADFA = B,w | B is a DFA that accepts

3、w ACFG = G,w | G is a CFG that generates w are TM decidable. 。内涵:可写出算法,算出 成员籍的 (yes / no ),不断提出问题 ,满足好奇心是基础研究的方法之一。问题 :What about the obvious next candidate ATM = M,w | M is a TM that accepts w ?Is one TM M1 capable of simulating all other TMs?,2018/6/20,7/92,Deciding Languages 准备引入通用图灵机 cp107,复习 :

4、下列问题可判定ADFA = B,w | B is a DFA that accepts w ACFG = G,w | G is a CFG that generates w are TM decidable. 。即:可写出算法,算出 关于 成员籍的 yes / no,不断提出问题 ,满足好奇心是基础研究的方法之一。问题 :What about the obvious next candidate ATM = M,w | M is a TM that accepts w ?Is one TM M1 capable of simulating all other TMs?,造出一个图灵机M1 ,

5、对一切机串对M,w M1判断M,w是否在集合ATM中,2018/6/20,8/92,Deciding Languages 准备引入停机问题 cp107,不断提出问题 ,满足好奇心是基础研究的方法之一。问题 : ATM = M,w | M is a TM that accepts w ?是否可判定?) A -Accept),机串对,ATM 又称为 接受问题 或 停机问题(名称来源稍后解释)后面将证,停机问题 可被识别, 但不能被判定),2018/6/20,9/92,Deciding Languages 准备引入通用图灵机 cp107,问题 :下列想法是否正确,说出理由。 ATM = M,w |

6、M is a TM that accepts w ?是否可判定?(正确答案,它可识别,但不能被判定) 如果有个通用机U,对任意 对子 ,判断出它是否在ATM中,即M是否接受w,下面试图用它来解决哥德巴赫猜想. 造 TM G 如下:bool G(2n) start: stop=false; result=true; 把2n分解为 (1,2n-1),(3,2n-3), 如果所有 对子 中,至少有一个非素数, stop=true; result=false; /找到了一个大偶数,不能分成1+1,猜想为假 if stop return(result) else n=n+2; goto start; 再

7、用 Deter_Accept 去判断 是否在ATM中。不在,则该猜想为假。,直观解释:不能写出一个通用程序, 它可以判断一切程序是否 无限循环(死机)。 如果 能写出一个这样的程序计算机就神了,可轻易解决很多问题。且看 下页分解。,2018/6/20,10/92,Deciding Languages 准备引入通用图灵机 cp107,问题 :下列想法是否正确,说出理由。 ATM = M,w | M is a TM that accepts w ?是否可判定?(正确答案,它可识别,但不能被判定) 如果有个通用机U,对任意 对子 ,判断出它是否在ATM中,下面试图用它来解决哥德巴赫猜想. 造 TM

8、G 如下:bool G(2n) start: stop=false; result=true; 把2n分解为 (1,2n-1),(3,2n-3), 如果所有 对子 中,至少有一个非素数, stop=true; result=false; /找到了一个大偶数,不能分成1+1,猜想为假 if stop return(result) else n=n+2; goto start; 再用 U 去判断 是否在ATM中。不在,则该猜想为假。在,则该猜想为真。,遗憾的是,将要证明这样的U不存在,2018/6/20,11/92,Deciding Languages 准备引入通用图灵机 cp107,问题 :下列

9、想法是否正确,说出理由。 ATM = M,w | M is a TM that accepts w ?是否可判定?(正确答案,它可识别,但不能被判定) 如果有个通用机U,对任意 对子 ,判断出它是否在ATM中,下面试图用它来解决哥德巴赫猜想. 造 TM G 如下:bool G(2n) start: stop=false; result=true; 把2n分解为 (1,2n-1),(3,2n-3), 如果所有 对子 中,至少有一个非素数, stop=true; result=false; /找到了一个大偶数,不能分成1+1,猜想为假 if stop return(result) else n=n

10、+2; goto start; 再用 U 去判断 是否在ATM中。不在,则该猜想为假。在,则该猜想为真。,遗憾的是,将要证明这样的U不存在,2018/6/20,12/92,The Universal TM U 仿真的直观感觉,Win中模拟DOS上的dirWin 是TM, Dos 是TM, Dos可以编码成为串”M”仿真时 Win相当于 通用图灵机Win(“M”,”dir”)分配M所需的空间S,把”M”复制到S上去;在Win的监控下,在S上运行DOS,运行 dir善后,退出; 用3带机Win 仿真控制带 被模拟机带S: Dos演算带,Buff当前内容,2018/6/20,13/92,The Un

11、iversal TM U 仿真的直观感觉,Win中模拟DOS上的dir WinExec(“ 是TM, Dos 是TM, Dos可以编码成为串”M”仿真时 Win相当于 通用图灵机Win(“M”,”dir”)分配M所需的空间S,把”M”复制到S上去;在Win的监控下,在S上运行DOS,运行 dir善后,退出; 用3带机Win 仿真控制带 被模拟机带S: Dos演算带,Buff当前内容,Win垂帘听DOS 之政或Win 挟天子以令诸侯,2018/6/20,14/92,仿真例子,在调试 智能手机程序时目前一些智能手机 运行 OS= Windows Mobile 6.0Micro soft 有 Dev

12、ice Emulator 2.0在Windows XP 上 仿真 智能手机 (如多普达)很爽,2018/6/20,15/92,The Universal TM U:ATM是图灵可识别的, cp108,Given a description M,w of a TM M and input w, can U simulates M on w?,We can do so via a universal TM U (2-tape):Check if M is a proper TMLet M = (Q,q0,qaccept,qreject)Write down the starting configu

13、ration q0w on the second tapeRepeat until halting configuration is reached:Replace configuration on tape 2 by nextconfiguration according to “Accept” if qaccept is reached; “reject” if qreject简言之:bool U(M,w) return( M (w) ) ; /如果M不死循环,U也不,看成语言,其成员籍是可以识别的造一个通用图灵机,2018/6/20,16/92,The Universal TM U:AT

14、M是图灵可识别的, cp108,Given a description M,w of a TM M and input w, can U simulates M on w?,We can do so via a universal TM U (2-tape):Check if M is a proper TMLet M = (Q,q0,qaccept,qreject)Write down the starting configuration q0w on the second tapeRepeat until halting configuration is reached:Replace c

15、onfiguration on tape 2 by nextconfiguration according to “Accept” if qaccept is reached; “reject” if qreject简言之:bool U(M,w) return( M (w) ) ; /如果M不死循环,U也不,造一个通用图灵机,识别ATM,2018/6/20,17/92,The Universal TM U:ATM是图灵可识别的, cp108,Given a description M,w of a TM M and input w, can U simulates M on w?,We can

16、 do so via a universal TM U (2-tape):Check if M is a proper TMLet M = (Q,q0,qaccept,qreject)Write down the starting configuration q0w on the second tapeRepeat until halting configuration is reached:Replace configuration on tape 2 by nextconfiguration according to “Accept” if qaccept is reached; “rej

17、ect” if qreject简言之:bool U(M,w) return( M (w) ) ; /如果M不死循环,U也不,U垂帘听M 之政,或M做事,U出头露面,2018/6/20,18/92,4.2 The Halting Problem ATM cp108,上页已经证明 可识性 ATM = M,w | M is a TM that accepts w is TM-recognizable, but can we also decide it ?,The problem lies with the cases when M does not halt on w. In short: the

18、 halting problem.问题焦点 :M 死循环的判断。 所以ATM又称停机问题,We will see that this is an insurmountable problem: in general one cannot decide if a TMwill halt on w or not, hence ATM is undecidable.先揭谜底:停机问题不可判定, 从而ATM不可判定为证明它(下周),先补充一系列预备知识,,2018/6/20,19/92,4.2 The Halting Problem ATM cp108,上页已经证明 可识性 ATM = M,w | M

19、 is a TM that accepts w is TM-recognizable, but can we also decide it ?,The problem lies with the cases when M does not halt on w. In short: the halting problem.,We will see that this is an insurmountable problem: in general one cannot decide if a TMwill halt on w or not, hence ATM is undecidable.先揭

20、谜底:停机问题不可判定, 从而ATM不可判定为证明它(下周),先补充一系列预备知识,,问题焦点 :M 死循环的判断。 所以ATM又称停机问题,2018/6/20,20/92,4.2 The Halting Problem ATM,U上页已经证明 可识性 ATM = M,w | M is a TM that accepts w is TM-recognizable, but can we also decide it ?,The problem lies with the cases when M does not halt on w. In short: the halting problem

21、.,We will see that this is an insurmountable problem: in general one cannot decide if a TMwill halt on w or not, hence ATM is undecidable.,先揭谜底:停机问题不可判定, 从而ATM不可判定 为证明它,先补充一系列预备知识,,2018/6/20,21/92,How Many Languages? 康托 cp109,停机问题不可判定为证明它,先补充一系列预备知识,,2018/6/20,22/92,长度为10的串 组成的语言有多少个?,长度为10的串 组成的语言有

22、多少个? 10个 错 1024个?错 有限个 超出简单想象,2018/6/20,23/92,长度为10的串 组成的语言有多少个?,长度为10的串 组成的语言有多少个? 10个 1024个?错 有限个 . Right but not exact 超出简单想象,2018/6/20,24/92,How Many Languages? 康托 cp109,For =0,1, there are 2k words of length k.Hence, there are languages L k.Proof: L has two options for every word k;L can be rep

23、resented by a string .当k=10,共有21024个语言Thats a lot, but finite.There are infinitely many languages *.But we can say more than thatGeorg Cantor defined a way of comparing infinities.,长度为10的串 组成的语言有多少个?,2018/6/20,25/92,How Many Languages? 康托 cp109,For =0,1, there are 2k words of length k.Hence, there a

24、re languages L k.Proof: L has two options for every word k;L can be represented by a string .当k=10,共有21024个语言Thats a lot, but finite.There are infinitely many languages *.But we can say more than thatGeorg Cantor defined a way of comparing infinities.,不限制长度超级无穷个,2018/6/20,26/92,Mappings and Function

25、s 用映射比较集合大小 cp109,The function F:ABmaps one set A to another set B:,A,B,F,F is one-to-one (injective 内射, 不同源 有 不同像 ,源像) if every xA has a unique image F(x): If F(x)=F(y) then x=y.,F is onto (surjective满射) if every zB is hit by F:If zB then there is an xA such that F(x)=z.,F is a correspondence (bije

26、ction双射) between A and B if it is both one-to-one and onto. 一样多,2018/6/20,27/92,Mappings and Functions 用映射比较集合大小 cp109,The function F:ABmaps one set A to another set B:,A,B,F,F is one-to-one (injective 内射, 不同源 有 不同像 ,源像) if every xA has a unique image F(x): If F(x)=F(y) then x=y.,F is onto (surjecti

27、ve满射) if every zB is hit by F:If zB then there is an xA such that F(x)=z.,F is a correspondence (bijection双射) between A and B if it is both one-to-one and onto. 一样多,2018/6/20,28/92,Mappings and Functions 用映射比较集合大小 cp109,The function F:ABmaps one set A to another set B:,A,B,F,F is one-to-one (injecti

28、ve 内射, 不同源 有 不同像 ,源=自然数集数“The set N has not more elements than S.”,A set S is countable infinite if there exists a bijective function F:NS. 可数无穷 与N 等势“The sets N and S are of equal size.”,满映射,2018/6/20,32/92,Countable Infinite Sets 可数无穷集 cp110,A set S is countable if there exists a surjectivefunctio

29、n F:NS “The set S has not more elements than N.”,A set S is infinite if there exists a surjectivefunction F:SN. 基数=自然数集数“The set N has not more elements than S.”,A set S is countable infinite if there exists a bijective function F:NS. 可数无穷 与N 等势“The sets N and S are of equal size.”,有限集可数,与自然数集合等势 的

30、集合可数,满映射,2018/6/20,33/92,Countable Infinite Sets 可数无穷集 cp110,A set S is countable if there exists a surjectivefunction F:NS “The set S has not more elements than N.”,A set S is infinite if there exists a surjectivefunction F:SN. 基数=自然数集数“The set N has not more elements than S.”,A set S is countable

31、infinite if there exists a bijective function F:NS. “The sets N and S are of equal size.”,可数无穷 与N 等势,2018/6/20,34/92,Countable Infinite Sets 可数无穷集 cp110,有理数集合可数 ,每个 n/m 都能被数到,2018/6/20,35/92,Some Countable Infinite Sets,One can make bijections between N andZ, N2, a*, a,b*:,2018/6/20,36/92,A Big Coun

32、table Set N*,Consider the set N*, the set of finite sequencesof numbers: (0)N*, (4,63)N*, (1,0,1)N*.,This set is also countable infinite. How do make the bijection between N* and N?There are infinitely many primes p1=2, p2=3, p3=5, Every number n2,3, has a unique primefactorization: 84 = p1p1 p2p4,用

33、素因子为作为整数的 正交 坐标基,2018/6/20,37/92,Bijection between N and N*,Let (n1,n2,nk)N*(n1,n2,nk) | N* N是1-1满映射所以N* 是可数的,每个整数有 唯一表达形式,m比Nk大很多,寅吃卯粮,但还够,总能放下 映像,2018/6/20,38/92,A set S is countable infinite if there is a bijectionpossible between 0,1,2, and S. 可数无穷ep 161A set S is countable, if you can make a li

34、sts1,s2, of all the elements of S.The sets N, N 2, 0,1*, N * are all countable infinite.Example for 0,1*: the lexicographical ordering: 0,1* = ,0,1,00,01,10,11,000,按字典序排,2018/6/20,39/92,Uncountable Sets 从可数集 造 不可数集合,cp111,There are infinite sized sets that are not countable.Typical examples are P (N

35、 ) and P (0,1*),用对角线方法: 从 可数集 造 不可数集合We prove this by a diagonalization argument.In short, if S is countable, then you can make alist s1,s2, of all elements of S.Diagonalization shows that given such a list,there will always be an element x of S thatdoes not occur in s1,s2,2018/6/20,40/92,Uncountabl

36、e Sets 可数集 造 不可数集合,cp111,There are infinite sized sets that are not countable.Typical examples are P (N ) and P (0,1*),用对角线方法: 从 可数集 造 不可数集合We prove this by a diagonalization argument.In short, if S is countable, then you can make alist s1,s2, of all elements of S.Diagonalization shows that given su

37、ch a list,there will always be an element x of S thatdoes not occur in s1,s2,典型不可数集合,2018/6/20,41/92,先证明Uncountability of P (N),The set P (N) contains all the subsets of 0,1,2,.Each subset X can be identified by an infinitestring of bits x0x1x2. such that xj=1 iff jX.命题 There is bijection between P

38、(N) and 0,1N 1,2,3,4 11110000000 1,3,4,5 10111000000,Proof by contradiction: 反设Assume P (N) countable. Hence there must exist a surjection F from N to the set of infinite bit strings. “There is a list of all infinite bit strings.”,2018/6/20,42/92,Uncountability of P (N),The set P (N) contains all th

39、e subsets of 0,1,2,.Each subset X can be identified by an infinitestring of bits x0x1x2. such that xj=1 iff jX.命题 There is bijection between P (N) and 0,1N 1,2,3,4 11110000000 1,3,4,5 10111000000,Proof by contradiction: 反设Assume P (N) countable. Hence there must exist a surjection F from N to the se

40、t of infinite bit strings. “There is a list of all infinite bit strings.”,满映射,2018/6/20,43/92,Uncountability of P (N),The set P (N) contains all the subsets of 0,1,2,.Each subset X can be identified by an infinitestring of bits x0x1x2. such that xj=1 iff jX.命题 There is bijection between P (N) and 0,

41、1N 1,2,3,4 11110000000 1,3,4,5 10111000000,Proof by contradiction: 反设Assume P (N) countable. Hence there must exist a surjection F from N to the set of infinite bit strings. “There is a list of all infinite bit strings.”,2018/6/20,44/92,Diagonalization 对角线方法 比cp111 更一般,Try to list all possible infinite bit strings,假定可数,就依次列出如下:,Look at the bit string on the diagonal of this table:对角线上元素 0101 The negation of this string 反码串 (“1010”) does not appear in the table. 它的第K分量与第K列的第K分量相反,所以不同于第K列,(K=1,2), 即被漏数,与该集合 可数 矛盾,2018/6/20,45/92,Diagonalization 对角线方法 比cp111 更一般,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 经营企划

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报