Derivations and Context-Free Languages Assignment Help

Assignment Help: >> Context-free grammars and languages >> Derivations and Context-Free Languages

Derivations and Context-Free Languages:

The productions of a grammar are used to generate strings. In this process, the productions are used as rewrite the rules.  

Formally, we define the derivation relation associated with the context-free grammar.  First, let us review the concepts of transitive closure and refiexive and transitive closure of the binary relation. Given a set A, of a binary relation R on A is any set of ordered pairs, that is R A × A. For short, instead of binary relation, we simply say relation. Given any 2 relations R, S on A, their composition o S can be defined as

RoS = {(x, y) A × A | z A, (x,  z) R and (z, y) S}.

The identity relation IA on A is relation IA defined as

IA = {(x, x) | x A}.

For short, we denote IA as I . Keep in mind that

o I = o R = R

for every relation R on A. Given a relation R on A, for any n 0 we define Rn as shown below:

R0  = I,

Rn+1 = Rn o R.

It is certain that R1= R.  It is easily verified by induction that Rn o R = o Rn . The transitive closure R+ of relation R can be defined as

 

1778_Derivations and Context-Free Languages.png

It is verified easily that R+  is the smallest transitive relation containing R, and that (x, y) R+ i there is n 1 and x0 , x1 ,..., xn A such that x0   = x, xn = y, and (xi , xi+1 ) R  for all i, 0 i n - 1.  The transitive and refiexive closure R∗  of relation R can be defined as

774_Derivations and Context-Free Languages1.png

Evidently, R* = R+ I . It is verified easily that Ris the smallest transitive and refiexive relation containing R.

 

Definition: Given a context-free grammar G = (V, Σ, P, S), the derivation relation G  associated with G is binary relation G V × V defined as follows: for all the α, β V , we have

α G β

If there exist λ, ρ V*, and some production (A γP , so that


α
= λAρ     and  β = λγρ.


The transitive closure of ⇒G denoted as 337_Derivations and Context-Free Languages2.pngand the refiexive and transitive closure of G  is denoted as2236_Derivations and Context-Free Languages3.png.

When the grammar G is clear from the context, we usually omit the subscript G in 337_Derivations and Context-Free Languages2.png and 2236_Derivations and Context-Free Languages3.png,


A string α V* such that 785_Derivations and Context-Free Languages4.pngα is called as sentential form, and a string ωΣsuch that 785_Derivations and Context-Free Languages4.png ω is called a sentence.  A derivation α 785_Derivations and Context-Free Languages4.png β  involving n steps is denoted as α750_Derivations and Context-Free Languages5.pngβ.

Note that a derivation step

α⇒Gβ

is nondeterministic.  Certainly, one can choose among various occurrences of nonterminals A in α, and among various productions A γ with left hand side A.

For instance, using the grammar G1  = ({E, a, b}, {a, b}, P, E), here P is the set of rules

E -aEb,

E -ab,

every derivation from E is of form

755_Derivations and Context-Free Languages6.png

here n 0.

Grammar G1 is simple: every string an bn  posses a unique derivation.  This is generally not the case. For instance, using the grammar G2  = ({E, +, , (, ), a}, {+, , (, ), a}, P, E), here P is the set of rules

E -E + E,

E -E E,

E -(E),

E -a,

the string a + a a has distinct derivations which are stated as follows, where the boldface indicates which occurrence of E can be rewritten:

E E E E + E E

a + E E a + a E a + a a,

 

and

E E + E a + E

a + E Ea + a E a + a a.

In the above derivations, the leftmost occurrence of the nonterminal is chosen at each step. This type of derivations is known as leftmost derivations. Rewrite the right occurrence of the nonterminal, getting the rightmost derivations.  The string a + a a also has the 2 rightmost derivations stated below, where the boldface indicates which occurrence of E can be rewritten:

E E + E E + E E

E + E a E + a a a + a a,

and

E EE E a

E + E a E + a a a + a a.

The language generated by the context-free grammar can be defined as follows.

Email based Automata assignment help - homework help

The study of automata is an important area of theory of computation. Students feel trouble in solving automata questions. We at www.expertsmind.com offers Automata assignment help - Automata homework help and online tutoring with best qualified and experienced computer science tutor's help. We cover all topics including Derivations and Context-Free Languages in assignment help - homework help service. Get solved problems in automata theory with step by step answers anytime from expert tutors at expertsmind.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd