Bài giảng Theory Of Automata - Lecture 40

Tài liệu Bài giảng Theory Of Automata - Lecture 40: 1Recap lecture 39 PDA corresponding to CFG, Examples of PDA corresponding to CFG 2Example Consider the following CFG S  XY X  aX | bX |a Y  Ya | Yb | a First of all, converting the CFG to be in CNF, introduce the nonterminals A and B as A  a B  b The following CFG is in CNF 3Example continued S  XY X  AX | BX |a Y  YA | YB | a A  a B  b The PDA corresponding to the above CFG will be PH S ATST RD1 a RD2 A PP ∆Y ∆ RD3 RD5 PH Y PH X PH X PH B X a a PH X PH A S RD4 b B PH A PH Y PH B PH Y X X Y Y 5Theorem Given a PDA that accepts the language L, there exists a CFG that generates exactly L. Before the CFG corresponding to the given PDA is determined, the PDA is converted into the standard form which is called the conversion form. Before the PDA is converted into conversion form a new state HERE is defined which is placed in the middle of any edge. 6CFG corresponding to PDA continued Like READ and POP states,...

pdf17 trang | Chia sẻ: honghanh66 | Lượt xem: 1208 | Lượt tải: 0download
Bạn đang xem nội dung tài liệu Bài giảng Theory Of Automata - Lecture 40, để tải tài liệu về máy bạn click vào nút DOWNLOAD ở trên
1Recap lecture 39 PDA corresponding to CFG, Examples of PDA corresponding to CFG 2Example Consider the following CFG S  XY X  aX | bX |a Y  Ya | Yb | a First of all, converting the CFG to be in CNF, introduce the nonterminals A and B as A  a B  b The following CFG is in CNF 3Example continued S  XY X  AX | BX |a Y  YA | YB | a A  a B  b The PDA corresponding to the above CFG will be PH S ATST RD1 a RD2 A PP ∆Y ∆ RD3 RD5 PH Y PH X PH X PH B X a a PH X PH A S RD4 b B PH A PH Y PH B PH Y X X Y Y 5Theorem Given a PDA that accepts the language L, there exists a CFG that generates exactly L. Before the CFG corresponding to the given PDA is determined, the PDA is converted into the standard form which is called the conversion form. Before the PDA is converted into conversion form a new state HERE is defined which is placed in the middle of any edge. 6CFG corresponding to PDA continued Like READ and POP states, HERE states are also numbered e.g. becomes RD7 RD9 a RD7 HERE3 a RD9 b b 7Conversion form of PDA Definition: A PDA is in conversion form if it fulfills the following conditions: 1. There is only one ACCEPT state. 2. There are no REJECT states. 3. Every READ or HERE is followed immediately by a POP i.e. every edge leading out of any READ or HERE state goes directly into a POP state. 8CFG corresponding to PDA 4. No two POPs exist in a row on the same path without a READ or HERE between them whether or not there are any intervening PUSH states (i.e. the POP states must be separated by READs or HEREs). 5. All branching, deterministic or nondeterministic occurs at READ or HERE states, none at POP states and every edge has only one label. 9CFG corresponding to PDA 6. Even before we get to START, a “bottom of STACK” symbol $ is placed on the STACK. If this symbol is ever popped in the processing it must be replaced immediately. The STACK is never popped beneath this symbol. Right before entering ACCEPT this symbol is popped out and left. 10 CFG corresponding to PDA 7. The PDA must begin with the sequence 8. The entire input string must be read before the machine can accept the word. Different situations of a PDA to be converted into conversion form are discussed as follows START PUSH $ HEREPOP $ 11 CFG corresponding to PDA contd. becomes RD7 POP a b PUSH b PUSH a PUSH $ RD7 a b $ b RD7 RD8 a b b To satisfy condition 3, 12 CFG corresponding to PDA contd. becomes To satisfy condition 4, POP4 POP5 a b POP4 HERE a POP5 b 13 CFG corresponding to PDA contd. RD1 POP1 a RD2 RD3 a b To satisfy condition 5 becomes as follows 14 CFG corresponding to PDA contd. RD1 POP2 a RD2 b POP3 a RD3 a 15 CFG corresponding to PDA contd. RD1 POP a PUSH a PUSH b RD2 a b RD1 POP1 PUSH a PUSH b RD2 a bPOP2 a a To satisfy condition 5 becomes 16 CFG corresponding to PDA contd.  $ STACK To satisfy condition 6, it is supposed that the STACK is initially in the position shown below 17 Summing Up • Recap of example of PDA corresponding to CFG, CFG corresponding to PDA. Theorem, HERE state, Definition of Conversion form, different situations of PDA to be converted into conversion form

Các file đính kèm theo tài liệu này:

  • pdftheory_of_automata_cs402_power_point_slides_lecture_40_642.pdf