1 / 7

作业 1 例 构造一个文法 G3 使 L(G3)={a n b n |n≥1} 解 ; S→aSb|ab

作业 1 例 构造一个文法 G3 使 L(G3)={a n b n |n≥1} 解 ; S→aSb|ab 例 试构造生成语言 L={a n b n c i |n  1, i 0 } 的文法 解: G(Z): Z AB A aAb|ab B cB| (1) { a n b n a m b m | n , m>=0 } S→AA A→aAb|ε 或者 S→AB A→aAb|ε B→aBb|ε

taniel
Download Presentation

作业 1 例 构造一个文法 G3 使 L(G3)={a n b n |n≥1} 解 ; S→aSb|ab

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 作业1例 构造一个文法G3使 L(G3)={anbn|n≥1} 解; S→aSb|ab 例 试构造生成语言L={anbnci|n1, i 0}的文法 解:G(Z): ZAB A aAb|ab B cB| • (1) { an bn am bm | n,m>=0 } S→AA A→aAb|ε 或者 S→AB A→aAb|ε B→aBb|ε • (2) {1n 0m 1m 0n | n,m>=0 } S→1S0|A A→0A1|ε

  2. 例 构造一个文法G3使 L(G3)={anbn|n≥1} 解; S→aSb|ab 例 试构造生成语言L={anbnci|n1, i 0}的文法 解:G(Z): ZAB A aAb|ab B cB| • (3) { an b bn | n>=1 } a和b是以b为中心对称出现 S->aAb A->aAb|b

  3. (4) {anbncm| m,n≥1,n为奇数,m为偶数} S  AC A  aaAbb | ab C ccCcc | cc • (5) {ancmbn | m,n≥1 ,m为奇数,n为偶数} S  aaSbb | A A  ccA | c

  4. 作业2:给出生成下述语言的三型文法: (1) {anbm|n,m>=1 } S→aA A→aA|BB→bB|b (2) {anbmck|n,m,k>=0 } A→aA|BB→bB|CC→cC|ε

  5. 作业3:对于文法G(S): S->bMb M->(L|a L->Ma) 1). 写出句型b(Ma)b的最右推导并画出语法树。2). 写出上述句型的短语,直接短语和句柄。 答: 1. 2. 短语: Ma), (Ma), b(Ma)b 直接短语: Ma) 句柄: Ma)

  6. 作业4:对于文法G(E): ET|E+T TF|T*F F(E)|i 1. 写出句型T*F+i1*i2的最右推导。 2. 写出上述句型的短语,直接短语、句柄。 3.写出上述句型的素短语和最左素短语。 (第四章的作业) E E+T E+T*FE+T*i2 E+F*i2 E+i1*i2 • T*F +i1*i2 2. 短语:T*F +i1*i2, T*F, i1*i2 , i1, i2 直接短语:T*F, i1, i2 句柄:T*F 素短语:T*F, i1, i2 最左素短语:T*F

  7. 作业5:对于文法G(E): ET|E+T TF|T*F F(E)|i 1. 写出句型(T*F+i)的最右推导。 2. 写出上述句型的短语,直接短语、句柄。 3.写出上述句型的素短语和最左素短语。 (第四章的作业) ETF(E) (E+T) (E+F) (E+i) (T+i) (T*F+i) 2.短语:(T*F+i), T*F+i, T*F, i 直接短语:T*F, i 句柄:T*F 素短语:T*F, i

More Related