0% found this document useful (0 votes)
6 views4 pages

Chapter 2 automata

The document provides an overview of Phase-Structure-Grammar (PSG), defining it as a formal language represented by a 4-tuple consisting of non-terminals, terminals, production rules, and a start symbol. It includes examples of grammars and derivations, illustrating how strings and languages can be generated from PSG. Additionally, it discusses the concepts of sentential forms and λ-free grammars.

Uploaded by

Robel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

Chapter 2 automata

The document provides an overview of Phase-Structure-Grammar (PSG), defining it as a formal language represented by a 4-tuple consisting of non-terminals, terminals, production rules, and a start symbol. It includes examples of grammars and derivations, illustrating how strings and languages can be generated from PSG. Additionally, it discusses the concepts of sentential forms and λ-free grammars.

Uploaded by

Robel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

MicroLink Information Technology College

Chapter Two
Phase-Structure-Grammar (PSG)

Introduction
Definition:
A formal language is a collection of words/sentences over Σ which is formed by rules of formation.
The rules of formations are called Grammars.
Notations in defining a grammar:
 Capital letters for non-terminals
 Small letters for terminals
 → for “is defined as”
 | for “or”
Three grammars
1. Phase-Structure-Grammar (PSG)
2. Regular Grammar (RG)
3. Context Free Grammar (CFG)

Phase-Structure-Grammar (PSG)
Definition:
PSG is a 4-tuple ( N, T, P, S ) where
1. N is finite set of non-terminals
2. T is finite set of terminals
3. P is finite set of production
Rules of the form α→ β, α Є (NUT)+ and β Є (NUT)*
4. S Є N is a Start symbol
Example:
1- Let G1 = (N, T, P, S) where
N = {A, B, S}
T = {a, b}
P is given by

Introduction to Formal Language and Automata Page 1


MicroLink Information Technology College

S=A|B
A → aA | a
B → bB | b
2- Let G2 = (N, T, P, S) where
N = { A, B, S}
T = {a}
P is production:
S → λ | AA | BA
aS → A
AA → aA | aBB
Derivation
Let G = (N, T, P, S) be a PSG
If α1 ==> α2
α2 ==> α3 ,,,,

αn-1==> αn
then α1 ==> α2 ==> α3 ==> α4 ==> . . . . . . . . ==> αn-1 ==> αn
it is equivalent to
α1 =*=> αn (α1 generate αn in zero or more steps)
+
α1 = => αn (α1 generates αn in one or more steps)
Example:
Let G = (N, T, P, S) be a grammar with productions
S→A
A → aA | a
Find strings can be generated from G
Solution:
S => A S => A S => A
S => a S => aA S => aA
S => aa S => aaA
S => aaaA
S => aa . . . . . . aA
S => a
{a, aa, a3, a4 , , , , , , } = { an | n > 1 } - set of strings generated by the grammar
Introduction to Formal Language and Automata Page 2
MicroLink Information Technology College

Let G be a grammar and β Є (NUT)*, then S =*=>β, β is called a sentential over G.


A sentence over G is a sentential in T*, i.e.
S =*=> α , α Є T*
Definition:
Let G be a grammar, the language generated from G is denoted by L(G) and
L (G) = { x Є T* | S =*=>x }
Example:
1. Find the language generated by the grammar given with the production
a. G: S→a|b
N = {S}
T = {a, b}
Solution:
S→a
S→b
L(G) = {a, b}
b. G: S → Saa | b
Solution:
S => b S => Saa S => Saa
S => baa S => Saa aa
S => Saa aa aa
S => baa aa aa aa aa
L(G) = { ba2n | n > 0}
c. G: S → aA | bB
A → aA | a
B → bB | b
Solution:
S => aA S => bB
S => a aA S => b bB
S => aa aA S => bb bB
S => aaaaa , , , , a S => bbbbb , , , , b
S => an, n > 2 S => bn, n > 2
L(G) = {an | n > 2} U {bn | n > 2}
Introduction to Formal Language and Automata Page 3
MicroLink Information Technology College

d. G: S → aB | A
Solution:
L(G) = ǿ
2. Find a grammar that generates
a. L = {cn | n > 0}
b. L = { wcwR | w Є {a, b}* }
Solution:
a) L = { λ, c, c2, c3, c4 , , , , , }
Let G = ( N, T, P, S) where
N = {S}
T = {c}
P is given by:
S → cS | λ
S => λ S => cS
S => c cS
S => cc , , , , , cS
S => cc , , , , , c => cn
b) L = { c, aca, bcb, abcba , , , , , }
Let G = ( N, T, P, S) where
N = {S}
T = {a, b, c}
P is given by:
S → c | aSa | bSb
Definitions:
Let G = (N,T, P, S) be a grammar
Let α → β be a production in P
a) If β Є (NUT)+ for every α → β production then G is said to be λ-free grammar.
b) If β = λ, then α → β is called a λ-production.

Introduction to Formal Language and Automata Page 4

You might also like