Atividade sobre Gramática Hierarquia de Chomsky
Toda gramática regular é livre de contexto, toda livre de contexto é sensível ao contexto e toda sensível ao contexto é irrestrita.
1 - Construa as gramáticas para as seguintes linguagens a) L(G1) = {0
n1
m, m,n ≥ 0}
b) L(G2) = {(xyz)
p, p ≥ 1}
c)L(G3)={(011)
n0
p,p≥1,n≥p}
2 - Determinar o tipo da gramática e gerar 3 sentenças para G = ({A,B,S}, {a,b,c}, P, S)
3 - Descrever as linguagens geradas pelas gramáticas abaixo e classificá-las segundo a hierarquia de Chomsky.
Ricardo Luís de Freitas Notas de Aula - Compiladores
91.7 Hierarquia de Chomsky
Toda gramática regular é livre de contexto, toda livre de contexto é sensível ao contexto e toda sensível ao contexto é irrestrita.
Tipo 0
Tipo1 Tipo2 Tipo3
Ricardo Luís de Freitas Notas de Aula - Compiladores
11Lista de Exercícios n° 2
1) Indique qual o tipo das seguintes gramáticas :
a) G = ({M,N,O,P}, {x,y,z,w}, P, O) b) G = ({M,N,O,P}, {x,,z,w}, P, O)
P → OP P → OzP
P → zzz P → O
P : O → PNMx P: O → PNMx
O → zw OzO → zW
N → z NM → z
M → z
c) G = ({M,N,O,P}, {x,y,z,w}, P, O) d) G = ({M,N,O,P}, {x,y,z,w}, P, O)
P → OP | y0 O → Mx | Nw
P : O → PNMx | x P: N → z
OyO → zwxyO M → y
NM → zM
2) Construa as gramáticas para as seguintes linguagens a) L(G1) = {0
n1
m, m,n ≥ 0}
b) L(G2) = {(xyz)
p, p ≥ 1}
c) L(G3) = {(011)
n0
p, p ≥ 1, n ≥ p}
3) Determinar o tipo da gramática e gerar 3 sentenças para G = ({A,B,S}, {a,b,c}, P, S) S → Aa
P: A → c
A → Ba
B → abc
4) Seja A = {0,1} , x = 01 e y = 110
Escrever as cadeias xy, yx, xyx, x
2, (xy)
3, (xx)
25) Descrever as linguagens geradas pelas gramáticas abaixo e classificá-las segundo a hierarquia de Chomsky. Defina também V
t, V
n. S é o símbolo inicial.
a) S → A b) S → 1S
P: A → A0 P: S → 1A
A → 1A A → 0A
A0 → 10 A → 0
c) S → S0 P: S → A1 A → 0A0 A → 1
Ricardo Luís de Freitas Notas de Aula - Compiladores
11Lista de Exercícios n° 2
1) Indique qual o tipo das seguintes gramáticas :
a) G = ({M,N,O,P}, {x,y,z,w}, P, O) b) G = ({M,N,O,P}, {x,,z,w}, P, O)
P → OP P → OzP
P → zzz P → O
P : O → PNMx P: O → PNMx
O → zw OzO → zW
N → z NM → z
M → z
c) G = ({M,N,O,P}, {x,y,z,w}, P, O) d) G = ({M,N,O,P}, {x,y,z,w}, P, O)
P → OP | y0 O → Mx | Nw
P : O → PNMx | x P: N → z
OyO → zwxyO M → y
NM → zM
2) Construa as gramáticas para as seguintes linguagens a) L(G1) = {0
n1
m, m,n ≥ 0}
b) L(G2) = {(xyz)
p, p ≥ 1}
c) L(G3) = {(011)
n0
p, p ≥ 1, n ≥ p}
3) Determinar o tipo da gramática e gerar 3 sentenças para G = ({A,B,S}, {a,b,c}, P, S) S → Aa
P: A → c