Context-free Grammar Question
I'm working on some homework for Theory of Computation. There is this one problem that I can't figure out:
Define and Design a context-free grammar that generates the language L1 = { w | |w| mod 2 != 0}
I sort of understand how simple grammars work but if you could explain the process behind it I'd appreciate it.
Thanks
Let's see what the language is.
|w| is length of w
|w| mod 2 != 0
means the length of the word shouldn't be evenly divisible by
2
In turn length shouldn't be even that means it should be odd
GRAMMAR
S -> aA | bA | a | b
A -> aS | bS
EXPLANATION
S is to have odd number of symbols. S -> a | b is to have the
least odd number which is 1.
A is to go back to S on any symbol
-- Please up vote or comment if you have any doubts.
Happy Learning!
Context-free Grammar Question I'm working on some homework for Theory of Computation. There is this one...
Please help and show full steps will upvote thanks!
Define a context-free grammar (CFG) that generates exactly the following language. B = {1'0'ik | i+j = k or i+k=j with i, j, k > 0} Both ambiguous and unambiguous grammars are acceptable (it does not matter in this question). For grading purposes, please use as the starting variable. Alphabet E = {0,1}
Consider the following languages Li and L2, respectively, and construct a context free grammar for it if it is a context free language; if not, using the pumping lemma to disprove it. Let na(w) denote the number if a is w, same notation for to now) and nc(w). • L1 = {w we {a,b}* and na(w) = nb(w)} • L2 = {w I w€ {a,b,c}* and na(w) = n5(w) = nc(w)}
Homework. Section 5.1 #m}. Hint: Think of this language 1. Design a context-free grammar for the language {a" b n as the union of {a"b" | n > m} and {a") n<m}. 2. Consider the context-free grammar G = (N,T, P, S), defined by N = {S}, T = {a,b), and P = {S + Sbs | bSaS | }. Find derivations, and corresponding parse trees, for the following strings: aaabbb, bbbaaa, ababab. What is L(G)?
Automata Theory Give a context-free grammar producing the following language over Σ = {0, 1}: {w : every odd position of w is 1 and w = wR} (HINT: All strings in the language will be of odd length).
Theory of Computation - Push Down Automata (PDA) and Context
Free Grammars (CFG)
Problem 1. From a language description to a PDA Show state diagrams of PDAs for the following languages: a. The set of strings over the alphabet fa, b) with twice as many a's as b's. Hint: in class, we showed a PDA when the number of as is the same as the number of bs, based on the idea of a counter. + Can we use a...
Theory of Computation
7. Write down the Chomsky Normal Form for the context-free language de- fined by the productions: S bAļaB. A bAA laSla, and B aBB bS b, where S, A, B are nonterminal symbols and a, b are terminal symbol 8. For the context-free grammar Ģ -(X, T, R, S) with X (A, B. C, a, b), T a, b and productions R: SAB |BC, ABAa, BCClb,C AB la, check by applying the CYK Theorem whether the string...
Construct context-free grammars that generate the given set of
strings. If the grammar has more than one variable, we will ask to
write a sentence describing what sets of strings expect each
variable in the grammar to generate. For example, if the grammar
was:
I could say "C generates binary strings of length one, E
generates (non-empty) even length binary strings, and O generates
odd length binary strings." It is also fine to use a regular
expression, rather than English,...
Construct context-free grammars that generate the given set of
strings. If the grammar has more than one variable, we will ask to
write a sentence describing what sets of strings expect each
variable in the grammar to generate. For example, if the grammar
was:
I could say "C generates binary strings of length one, E
generates (non-empty) even length binary strings, and O generates
odd length binary strings." It is also fine to use a regular
expression, rather than English,...
please read this articel and write one page summary atleast 250 words: MLB managers learn Spanish to unite teams and clubhouses: At spring training of 1962, the newly hired manager of the San Francisco Giants, Alvin Dark, gathered several of his side's Latin American players together behind second base. Once there, he gave an order that left them surprised, stunned and outraged. "He told us that we couldn't speak Spanish to each other in the clubhouse", said Orlando Cepeda, who...
Why did the Energy Telematics project fail and why was Joel's
tram vaught off guard by the hostile reaction of the truck drivers
at the Omaha depot?
MINI CASE Working Smarter at Continental Furniture International Joel Parsons hurried down the hall to the monthly executive committee meeting doing a mental checklist of all the things he was responsible for: sales analysis-check; mar keting stats-check; quarterly and YTD financials-check; operating statistics-check trends in each of these areas-check. Parsons was right hand...