Define a context-free language Assignment Help

Assignment Help: >> Derivations and Context-Free Languages >> Define a context-free language

Define a context-free language:

Given a context-free grammar G = (V, Σ, P, S), the language generated by G is the set 1708_Define a context-free language.png

A language L  Σ*  is a context-free language if L  = L(G) for some context-free grammar G.

It is technically quite useful to consider derivations in which the leftmost nonterminal is selected always for rewriting, derivations in which the rightmost nonterminal is selected always for rewriting.

Definition:  Given the context-free grammar G = (V, Σ, P, S), the leftmost derivation relation 739_Define a context-free language1.png associated with G is the binary relation  739_Define a context-free language1.png⊆ V* × V*  de?ned as follows: for all α, β V*, we have

α  739_Define a context-free language1.png  β

if there exist u Σ*, ρ V*, and some production  (A γP , so that

α = uAρ     and  β = ρ.

The transitive closure of 739_Define a context-free language1.png is denoted as1092_Define a context-free language4.pngand the transitive and re?exive closure of739_Define a context-free language1.pngis denoted as 2279_Define a context-free language3.png. The (one-step) rightmost derivation relation 394_Define a context-free language6.png related with G is the binary relation 394_Define a context-free language6.pngV*× V* de?ned as follows: for all α, β V*, we have

α  394_Define a context-free language6.png β

iff there exist λ V*, v Σ*, and some production  (A γ) P , so that

α = λAv     and  β = λγv.

The transitive closure of 394_Define a context-free language6.png is denoted as 720_Define a context-free language7.png and the reflexive and transitive closure of 394_Define a context-free language6.png is denoted as 793_Define a context-free language5.png.

 

Remarks:  It is compulsory to use the symbols a, b, c, d, e for terminal symbols, and symbols A, B, C, D, E for nonterminal symbols. The symbols u, v, w, x, y, z denote terminal strings, and the symbols α, β, γ, λ, ρ, µ denote strings in V*. The symbols X, Y, Z generally denote symbols in V .

Given a context-free grammar G = (V, Σ, P, S), parsing a string w consists in finding out whether ω L(G), and if so, in generating a derivation for ω.  The following lemma is technically significant. It shows that leftmost and rightmost derivations are "universal". This has significant practical implications for complication of the parsing algorithms.

Lemma: Let G  = (V, Σ, P, S) be the context free grammar. For each ω Σ*, for every derivation 2036_Define a context-free language8.pngω, there is a leftmost derivation 1092_Define a context-free language4.pngω, and there is a rightmost derivation 720_Define a context-free language7.png ω.

Proof . Certainly, we have to use induction on derivations, although this is a bit tricky, and it is essential to prove a stronger fact.


Claim
: For every w Σ*, for every α V+, for every n 1, if α 1652_Define a context-free language9.png ω, then there is a lef tmost derivation α 1314_Define a context-free language10.png ω.

The can be proved by induction on n.

For n = 1, there exist λ, ρ V* and production  A γ, such that α = λAρ and ω = λγρ. As w is a terminal string, λ, ρ, and γ, are the terminal strings. Therfore, A is the only nonterminal in α, and the derivation step α 2192_Define a context-free language11.png ω is a leftmost step (and a rightmost  step!).

If n > 1, then the derivation α 1652_Define a context-free language9.png ω is of the form

1280_Define a context-free language12.png

There are 2 subcases.


Case
1. If the derivation step α α1 is a leftmost step α 739_Define a context-free language1.png α1 , by induction hypothesis, there is a leftmost derivation α629_Define a context-free language13.png ω, and we get leftmost derivation

α 739_Define a context-free language1.pngα1629_Define a context-free language13.png ω

Case 2. The derivation step α α1   is a not a leftmost step. In this case, there should be some u Σ*, µ, ρ V*, some nonterminals  A and B, and some production  B δ, such that

where A is the leftmost nonterminal in α.  As we have a derivation  α1629_Define a context-free language13.pngw , by the induction hypothesis, there is a leftmost derivation ω of length

α1629_Define a context-free language13.png ω

Since α1   = uAµδρ  where A  is the leftmost terminal in α1 , the 1st step in the leftmost derivation α629_Define a context-free language13.png ω is of the form

uAµδρ  => µδρ,

for some production A γ. Therefore, we have a derivation of the form

 

466_Define a context-free language14.png

We can commute the 1st 2 steps involving the productions B  δ and A γ, and we get the derivation

 

512_Define a context-free language15.png

This may no longer be a leftmost derivation, but the 1st step is leftmost, and we are back in case 1. Therefore, we conclude by applying the induction hypothesis to the derivation uγµBρ 629_Define a context-free language13.png ω, as in case 1.

 

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 Define a context-free language 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