Escolar Documentos
Profissional Documentos
Cultura Documentos
Cap 02folhetos PDF
Cap 02folhetos PDF
Palavra
Linguagem formal
Gramtica
x alfabeto
Linguagem
2.1
2.2
2.3
2.4
2 Linguagens e Gramticas
Alfabeto
Palavra
Linguagem formal
Gramtica
2.1
2.2
2.3
2.4
2 Linguagens e Gramticas
2 Linguagens e Gramticas
1
2
3
4
5
6
7
P. Blauth Menezes
2.2 Palavra
Sobre um alfabeto
11
Alfabeto binrio { a, b }
Portanto
Def: Alfabeto
Smbolo ou caractere
2.1 Alfabeto
Alfabeto
Palavra
Linguagem Formal
Gramtica
Subpalavra
x qualquer sequncia de smbolos contguos da palavra
Prefixo (Sufixo)
x qualquer sequncia inicial (final) de smbolos da palavra
2.1
2.2
2.3
2.4
12
10
2 Linguagens e Gramticas
x { a, b, c }
x (conjunto vazio)
So alfabetos
Exp: Alfabeto
Passo de induo
x Se u e v so palavras de 6*,
Base de induo
x H 6*
x para qualquer x 6, vale x 6*
Se 6 um alfabeto
x w0 = H
x wn = w wn-1, para n > 0
wn
x v w = baaaabb
x v H = v = baaaa
17
15
13
16
14
w 6*
x qualquer elemento w de 6*
18
x an = aaa}a
x a5 = aaaaa
x w1 = w
x w3 = w w w
w palavra e a smbolo
Propriedades
x Elemento neutro: H w = w = w H
x Associativa: v(w t) = (v w)t
Notao
x justaposio dos smbolos que representam as palavras
componentes
L 6*
19
z {H }
21
Alfabeto
Palavra
Linguagem formal
Gramtica
2.1
2.2
2.3
2.4
23
2 Linguagens e Gramticas
6* z 6+
~H~ = 0
~abcb~ = 4
20
26*
22
Formalismo gramtica
24
Linguagem de programao
2.4 Gramtica
Alfabeto
Palavra
Linguagem formal
Gramtica
2.1
2.2
2.3
2.4
2 Linguagens e Gramticas
D o E1 ~ E2 ~ } ~ En
25
x I
Portanto, derivao
29
27
Derivao
Gramtica , basicamente
SE
26
L(G) = { w T* ~ S + w }
G = (V, T, P, S) gramtica
x aximtico
x de gerao
permite derivar ("gerar") todas as palavras da linguagem
Gramtica um formalismo
KUEV
30
28
DE
G = (V, T, P, S) gramtica
DoE
G = (V, T, P, S)
Def: Gramtica
31
S
XY
XaAY
XaYa
XbBaYa
XbaBYa
XbaYba
FbaYba
bFaYba
baFYba
baba
x
x
x
x
x
x
x
x
x
x
x
Derivao de baba
35
S o XY
X o XaA
AY o Ya
X o XbB
Ba o aB
BY o Yb
XoF
Fb o bF
Fa o aF
FY o H
33
x S 6 243
x S + 243
x S * 243
Portanto
N
DN
2N
2DN
24N
24D
243
32
N o DN
Do2
N o DN
Do4
NoD
Do3
Convenes
GERA(G1) = GERA(G2)
{ ww ~ w palavra de { a, b }* }
P = { S o XY,
X o XaA ~ XbB ~ F
Aa o aA, Ab o bA, AY o Ya,
Ba o aB, Bb o bB, BY o Yb,
Fa o aF, Fb o bF, FY o H }
gera a linguagem
x
x
x
x
x
na qual:
G = ({ S, X, Y, A, B, F }, { a, b }, P, S)
36
34
x
x
x
x
x
x
x
G = (V, T, P, N)
x V = { N, D }
x T = { 0, 1, 2,}, 9 }
x P = { N o D, N o DN, D o 0 ~ 1 ~ } ~ 9 }
G = (V, T, P, N)
x V = { N, D }
x T = { 0, 1, 2,}, 9 }
x P = { N o D, N o DN, D o 0 ~ 1 ~ } ~ 9 }
1
2
3
4
5
6
7
37
P. Blauth Menezes