50 likes | 191 Views
Grammar. G = (V N , V T , P, S) V N : Nonterminal symbols V T : Terminal symbols V N V T = , V N ∪ V T = V P : a finite set of production rules α β, α∈ V + , β∈ V * S : start symbol(sentence symbol). Chomsky Hierarchy. 생성 규칙 α -> β ∈ P 의 종류에 따라
E N D
Grammar • G = (VN, VT, P, S) • VN : Nonterminal symbols • VT : Terminal symbols • VN VT = , VN∪ VT = V • P : a finite set of production rules • α β, α∈ V+, β∈ V* • S : start symbol(sentence symbol)
Chomsky Hierarchy • 생성 규칙 α -> β ∈ P의 종류에 따라 • Type 0 : No restrictions(unrestricted grammar) • Type 1 : Context-sensitive grammar(CSG). -> β, | | | β| • Type 2 : Context-free grammar(CFG). A -> , where A ∈ VN S, ∈ V* • Type 3 : Regular grammar(RG). A -> tB or A -> t, (right-linear) A -> Bt or A -> t, (left-linear) where, A, B ∈ VNS, t ∈ VT*
Examples • Type 3 : Regular grammar • G1=({S}, {a, b}, P, S) • P: S aS, S Sb, S a, S b, S • 정규식: a*b* • 언어 L(G1) = {anbm| n0, m0} • “aab”의 유도 과정: S aS (by S aS) aaS (by S aS) aab (by S b)
Examples • Type 2 : Context Free Grammar • G2=({S}, {a, b}, P, S) • P: S aSb, S ab • 정규식: anbn • 언어 L(G2) = {anbn| n1} • “aaabbb”의 유도 과정: S aSb (by S aSb) aaSbb (by S aSb) aaabbb (by S ab)
Examples • Type 1 : Context Sensitive Grammar • G3=({S,A,C}, {a, b}, P, S) • P: S A, A abC, bB bb, A aABC, CB BC, bC bb • 정규식: anbn • 언어 L(G3) = {anbn| n1}