Efficiency/Redundancy in Chomsky normal form

I have a context-free grammar with the following production rules, S being the start symbol: S→ABA→aB→a Is this in Chomsky normal form? My problem is I thought CNF is supposed to be an efficient way to write a grammar, yet the grammar is not efficient in the sense that we can clean its rules as … Read more

Is there any difference in the expressiveness of boolean grammars versus definite clause grammars?

Definite clause grammars have been around a long time and are included in logic languages such as Prolog. They can be translated into (are just syntactic sugar for) Prolog programs and are therefore I assume turing complete (unless I have missed an important limitation of DCGs relative to full Prolog). Prolog is a logic programming … Read more

Why full Chomsky hierarchy is so detailed, if there are decidable recursive languages?

One can have a look on the Chomsky hierarchy https://en.wikipedia.org/wiki/Chomsky_hierarchy , especially the inset named “Automata theory: formal languages and formal grammars” at the bottom of the page. When one tries to model natural language (e.g. as http://www.grammaticalframework.org/ tries to do it), then one usually aims for the most expressive formal language that is still … Read more

Is the following Grammar LL(1)

I was given the following grammar S→S(S)S∣ϵ First I was asked to eliminate left recursion, yielding me the following : S→S′ S′→(S)SS′∣ϵ I was then asked If the grammar is LL(1). So I computed the FIRST and FOLLOW sets shown below: FIRST(S)=FIRST(S′)={(,ϵ}, FOLLOW(S)=FOLLOW(S′)={$,(,)}. I now tried building the LL(1) parsing table M as follow: Since … Read more

Is this context-free grammar correct for this regular expression?

I have created a context-free grammar S→S1∣S2S1→aS3bS4∣ϵS2→bS4S3→aS3∣ϵS4→aS4∣bS4∣ϵ for this regular expression (aa∗b(a∪b)∗)∪(b(a∪b)∗) Is the grammar correct or am I missing a certain route? Answer One way to check whether you have got correct grammar is to use plain English or regular expression to characterize each non-terminals, starting from the more basic blocks. S4→aS4∣bS4∣ϵ This rule … Read more

I want to design a context free grammar for the following [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question This below language L={w∈{a,b}n:|w| mod 3=0} where n≥0. Answer Since this seems very much like homework, i will give you a little … Read more