1 / 12

CSC312 Automata Theory Lecture # 28 Chapter # 13 by Cohen Grammatical Format

CSC312 Automata Theory Lecture # 28 Chapter # 13 by Cohen Grammatical Format. Semiword: A semiword is a string of terminal (maybenone) concaenated with exactly one nonterminal (on the right). i.e. of the shape (terminal) (terminal) … (terminal)(Nonterminal) Theorem 22:

Download Presentation

CSC312 Automata Theory Lecture # 28 Chapter # 13 by Cohen Grammatical Format

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. CSC312 Automata Theory Lecture # 28 Chapter # 13 by Cohen Grammatical Format

  2. Semiword: A semiword is a string of terminal (maybenone) concaenated with exactly one nonterminal (on the right). i.e. of the shape (terminal) (terminal) … (terminal)(Nonterminal) Theorem 22: If all the productions in a given CFG fit one of the two forms: Nonterminal  semiword or Nonterminal  word ( where the word may be ), then the language generated by this CFG is regular.

  3. Regular Grammar: A CFG is called a regular grammar if each of its productions is of one of the two forms Nonterminal  semiword or Nonterminal  word Example: Consider the CFG S  aaS | bbS |  Example: Consider the regular CFG S  aaS | bbS | abX | baX |  S  aaS | bbS | abS | baS

  4. NULL-Productions: -Productions The production of the form Non-terminal   is said to be NULL production. Note: If a CFG has a Null production, then it is possible to construct another CFG without Null production accepting the same language with the exception of the word . Removing Null-Production: Delete all the Null productions and add new productions by substituting the  in the old productions.

  5. Example: Consider the CFG S  aSbSa |  Now remove the  and add new productions as Old production New productions S  aSbSa S  aSba S  abSa S  aba So the new CFG without  is S  aSbSa |aSba | abSa | aba

  6. Nullable-Productions: A production is called nullable if is of the form N   or there is derivation that starts at N and leads to  i.e. N1  N2  N3  … Nn   where N1,N2,…,Nn are non-terminals Example: S  AA | bB A  aa | B B  aS |  .

  7. Example: S  AA | bB A  aa | B B  aS |  Here S  AA and A  B are nullable productions while B   is null production Removing Nullable-Production: Remove all -productions by substituting the  in the old productions and also substitute  for the nullable productions.

  8. Example: S  XY X  Zb Y  bW Z  AB W  Z A  aA | bA |  B  Ba | Bb |  Here A   and B   are null productions, whereas Z  AB, W  Z are nullable productions Now removing all the null productions we get the following new productions

  9. Old productions New Productions S  XY A  a | b X  Zb B  a | b Y  bW X  b Z  AB Y  b W  Z Z  A (by substituting  for B) A  aA | bA Z  B B  Ba | Bb So the final CFG is S  XY A  aA | bA | a | b X  Zb | b B  Ba | Bb | a | b Y  bW | b Z  AB | A | B W  Z

  10. Unit Production: The production of the form nonterminal  one terminal, is called unit production. Removing Unit Production: Examples: Consider the following CFG S  A | bb A  B | b B  S | a Separate the unit production from non-unit productions. Now delete unit productions and add the new productions that can be generated by using the deleted unit productions.

  11. Chomsky Normal Form (CNF): A CFG is said to be in CNF if it has all its productions of the form nonterminal  string of two nonterminals nonterminal  on terminal Note: Any CFG can be converted into CNF, if the null productions and the unit productions are remobed. Also if a CFG contains nullable productions as well then the corresponding new productions are also to be added.

  12. Examples: Consider the following CFG S  aSa | bSb | a | b | aa | bb Convert it into equivalent CNF. Steps for converting any CFG into CNF • Remove all the null and nullable productions • Kill all the unit productions • Convert all the productions of multiple letters into the form nonterminal  string of two nonterminal by converting all terminal in strings of multiple letters into nonterminals and then introduce new productions in the form of pairs of nonterminals.

More Related