Production Useful substitution rule Removing lproductions unitproductions useless
개요 Production의 우측에 허용된 자유를 약간 희생하여 큰 효과를 보자는 얘기! * 문법을 변환하는 방법들 - Useful substitution rule - Removing l-productions / unit-productions / useless productions * 정규형식 - Chomsky normal form : 우측항의 변수의 수 제한 - Greibach normal form : 우측항의 변수와 terminal의 위치 제한 * CFG를 위한 간단한 Parsing방법 : CYK algorithm - membership algorithm : 주어진 string이 문법에 맞는지? L-{l}로 얻어진 결론이 쉽게 L로 적용될 수 있다!
Methods for Transforming Grammars ① A Useful Substitution Rule simplification = removal of certain types of undesirable productions 수의 감소와는 무관! 간단하지만 한번 증명해볼까요?
Methods for Transforming Grammars ② Removing Useless Productions 어떤 derivation에도 공헌하지 못하는 production의 제거
Useless Productions : 증명
Methods for Transforming Grammars ③ Removing λ-Productions no λ 또, 증명을 해놔야 안심!
Methods for Transforming Grammars ④ Removing Unit-Productions 증명도 중요하지만 예를 들어 이해합시다.
Unit-Productions : 예 S A B useless
Normal Forms ① Chomsky NF : restriction on length of right sides = no more than 2 symbols CNF No CNF
Chomsky Normal Form
Chomsky Normal Form: 예예 예: S Aa. BCb A abb B a. C C a. Cb | ac A 3 BA 4 CA 5 S AA 1 A 2 A 3 A 2 a A B 1 B 2 B 1 a B 2 B 3 B 4 B C 1 C C 1 a C D 1 D 2 | E 1 E 2 D 1 a D 2 CD 3 B 3 b B 4 b D 3 b E 1 a A 5 b E 2 c
Greibach Normal Form ② Greibach NF : restrictions on positions of T and V 책을 한번 봅시다
Greibach Normal Form: 예 CFG: S SA | Be. A A AS | a Step 1: B b S Be. AC | Be. A A a. D | a B b C AC | A D SD | S Step 2: S be. AC | be. A A a. D | a B b C a. DC | a. D | a D be. ACD | be. AC | be. A Step 3: S b. EAC | b. EA A a. D | a B b C a. DC | a. D | a D b. EACD | b. EAC | b. EA E e
Normal Forms : Homework (Exercises 6. 2) 4 4 : Chomsky normal form으로의 변환 연습 4 10 : Greibach normal form으로의 변환 연습
Membership Algorithm for CFG • CYK algorithm: O(|w|3) for membership and parsing – originators: J. Cocke, D. H. Younger, T. Kasami – grammar in Chomsky normal form – basic idea: breaking problem into a sequence of smaller ones • Compute Vij – Compute Vii : – Compute Vij :
- Slides: 27