17.04.2013 Views

Exercícios linguagens livre de contexto com respostas

Exercícios linguagens livre de contexto com respostas

Exercícios linguagens livre de contexto com respostas

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Respostas:<br />

1)<br />

a) G=(V,T,P,S)<br />

V={S}<br />

T={a,b}<br />

P={S→a | aS | b | bS | ε}<br />

b) G=(V,T,P,S)<br />

V={S}<br />

T={a,b}<br />

P={S→ aSa | bSb | a | b | ε}<br />

c) G=(V,T,P,S)<br />

V={S}<br />

T={a,b}<br />

P={S→ abb | aSbb}<br />

d) G=(V,T,P,S)<br />

V={S,A,B,C,D,E}<br />

T={a,b,c}<br />

P={S→ AB | CD, A→ aA | ε, B→ bBc | E | cD, C→ aCb | E | aA, D→ cD | ε, E→ bE | b}<br />

2)<br />

A linguagem é <strong>livre</strong> <strong>de</strong> <strong>contexto</strong> e regular.<br />

É <strong>livre</strong> <strong>de</strong> <strong>contexto</strong> porque po<strong>de</strong> ser representada por gramática <strong>livre</strong> <strong>de</strong> <strong>contexto</strong>.<br />

E é regular, pois é <strong>de</strong>notada pela seguinte expressão regular 0*1(0+1)*.<br />

(Note que se uma linguagem é regular, por <strong>de</strong>finição ela também é <strong>livre</strong> <strong>de</strong> <strong>contexto</strong>.)<br />

3)<br />

G=(V,T,P,S)<br />

V={S}<br />

T={0,1,(,),+,*,∅,e}<br />

P={S→ S+S | SS | S* | (S) | 0 | 1 | ∅ | e}<br />

4)<br />

Sim, é ambígua, pois possui duas árvores <strong>de</strong> <strong>de</strong>rivação para a palavra "aa".<br />

S<br />

S S<br />

a S a e<br />

e<br />

5) G=(V,T,P,E)<br />

S<br />

e<br />

S<br />

S<br />

a S a<br />

e

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!