第1頁共4頁 自動機理論與正規語言 期中考試 系級: 座號: 姓名: 一、 是非題(40%) ( ) 1. Compared to an accepter, a transducer is a more general automation, capable of producing strings of symbols as output. ( ) 2. Every language accepted by an nfa is regular. ( ) 3. The transition function of a deterministic finite accepter (dfa) should be a total function. ( ) 4. A linear grammar is a grammar in which at most one alphabet can occur on the right side of any production, without restriction on the position of this alphabet. ( ) 5. A language L is regular if and only if there exists a left-linear grammar G such that L = L(G). ( ) 6. The pumping lemma for regular languages can be defined as follows: Let L be a regular language. Then these exists some positive integer m such that any w L with | w | m can be decomposed as w xyz , with | xy | m , and | y | 1 , such theat wi xy i z is also in L for all i 0,1,2,3,... . ( ) 7. In the exhaustive search parsing, if we restrict ourselves to leftmost derivations, we can have no more than |P| sentential forms after one round, no more than |P|2 sentential forms after second round, and so on. (here P is the set of production rules of a context-free grammar G (V , T , S , P) ) ( ) 8. A regular language can be inherently ambiguous. ( ) 9. If G is an s-grammar, then any string w in L(G) can be parsed with an effort proportional to |w|. ( ) 10. L ww R : w {a, b}* ( ) 11. ( ) 12. Language L {a n bm c k : k n m , n, m, k 0} is not context-free. ( ) 13. Let L1 and L2 be regular languages, then L w : w L1 , w R L2 language. ( ) 14. Two finite accepters are said to be equivalent if they both accept the same language. ( ) 15. , , and a are all regular expressions. These are called primitive regular expressions. ( ) 16. Let G (V , T , S , P) be a context-free grammar. In its derivation tree, every leaf has a label from V T . ( ) 17. The family of regular languages is closed under union, intersection, concatenation, complementation, reversal, difference, and star-closure. L a b a n l k is a regular language. : n l k 5 is a context-free language. 1 is also a regular 第2頁共4頁 ( ) 18. Let L1 and L2 be a language on the same alphabet, then right quotient of L1 with L2 is defined as L1 L2 {x : xy L2 for some y L1} . ( ) 19. A context-free grammar G (V , T , S , P) is said to be a simple grammar if all its productions are of the form A ax , where A V , a T , and x T * . ( ) 20. If L is a context-free language for which there exists an ambiguous grammar, then L is said to be ambiguous. 二、 (9%)請寫出下列 grammars 所產生出的 languages。 1. (3%)The grammar G ({S},{a, b}, S , P) , with productions S aSa , S bSb , S a . Ans: 2. (3%)The grammar G ({S, S1 , S2 },{a, b}, S , P) , with productions S S1ab , S1 S1ab | S2 , S2 a . Ans: 3. (3%) The grammar G ({S , A, B},{a, b}, S , P) , with productions S aB | bA , A a | aS | bAA , B b | bS | aBB . Ans: 三、 (6%)針對下列各 regular languages,請寫出適當的 right-linear grammars。 1.(3%) L {w : na ( w) and nb ( w) are both odd} Ans: 2.(3%) L(( aab * ab)*) Ans: 四、 (3%)請寫出下列的 finite automata 所能接受的 language。 a b q1 q0 b q2 a a Ans: 2 第3頁共4頁 系級: 座號: 姓名: 五、 (6%)請寫出下列 regular languages 的 regular expressions。 1. (3%) L {vwv : v, w {a, b}*, | v | 2} Ans: 2. (3%) L(r) w {0,1}* : w has at least one pair of consequiti ve zeros Ans: 六、 (8%)請畫出可接受下列語言的 transition graph。(不可以畫 generalized transition graph) 1. (4%) L( ab * a*) L( a * b * a ) Ans: 2. (4%) L w {a, b}* : na ( w) is even and nb ( w) is odd Ans: 七、 (4%) Let L1 L(bba * baa*) and L2 L(ab*) . Find L1 L2 . Ans: 八、 (8%) 給定一 grammar G ({S , A, B},{a, b}, S , P) , with productions S aAB , A aBb , B A| 。 1. (4%)請畫出此一 grammar 的 dependency graph. Ans: 2. (4%)請畫出 string aaabb 的 derivation tree. Ans: 3 第4頁共4頁 九、 (8%)針對下列各 languages,請寫出適當的 context-free grammars。 1. (4%) L {a n b m | n m 3, n, m 0} Ans: 2. (4%) L {w {a, b}* : na (w) nb (w) and na (v) nb (v), where v is any prefix of w} Ans: 十、 (8%) Simplification of contest-free grammars. 1.(4%) Eliminate useless productions from the grammar S aS | AB Ans: A bA | Bc B AA C cSD | c D ddd what language does this grammar generate? 2.(4%) Eliminate all -productions from Ans: S ABaCD A BC B b| C D | Dd 4