context-free-language

I can't find the leftmost and rightmost derivations of strings because there is no Non-terminal state linked to another non-terminal state

青春壹個敷衍的年華 提交于 2020-08-10 19:58:26
问题 The following grammar generates the language of regular expression S → A | B | C A → 0A1 | 1 | A1 B → 0B1 | 0 | 0B C → D10D D → empty | 0D | 1D Give leftmost and rightmost derivations of the following strings: 010100 000011 来源: https://stackoverflow.com/questions/62273171/i-cant-find-the-leftmost-and-rightmost-derivations-of-strings-because-there-is

Find a grammar of binary number divisible by 5 with 1 as MSB

青春壹個敷衍的年華 提交于 2020-01-14 03:41:08
问题 How can I find a grammar of binary number divisible by 5 with 1 as MSB and find the reversal of L So, I need a grammar that generates numbers like.. 5 = 101 10 = 1010 15 = 1111 20 = 10100 25 = 110011 and so on 回答1: I'm assuming this is homework and you just want a hint. Let's consider a somewhat similar question, but in base 10. How can we write a CFG for numbers divisible by 3. At first glance, this seems unlikely, but it's actually pretty simple. We start with the observation that: 10 k ≅ 1

Determine if a language is context free

早过忘川 提交于 2019-12-13 22:30:55
问题 Lets say you have a language L and you want to determine if it is context free. Context free languages intersected with regular languages are context free. Is that enough to prove that L is context free? Meaning, L intersect P = T Where P is a regular language and T is context free. Does this imply that L is context free? 回答1: No, your statement is not true. Consider the following counter-example: L = {0 n 1 n 2 n | n > 0}, P = T = Ø . Clearly we have L ∩ P = L ∩ Ø = Ø = T , and Ø is both

Find a grammar of binary number divisible by 5 with 1 as MSB

点点圈 提交于 2019-12-08 12:41:36
How can I find a grammar of binary number divisible by 5 with 1 as MSB and find the reversal of L So, I need a grammar that generates numbers like.. 5 = 101 10 = 1010 15 = 1111 20 = 10100 25 = 110011 and so on I'm assuming this is homework and you just want a hint. Let's consider a somewhat similar question, but in base 10. How can we write a CFG for numbers divisible by 3. At first glance, this seems unlikely, but it's actually pretty simple. We start with the observation that: 10 k ≅ 1 (mod 3) for any non-negative integer k . Now consider an integer dδ , where d is a decimal digit and δ is a

The difference between Chomsky type 3 and Chomsky type 2 grammar

三世轮回 提交于 2019-11-27 01:23:14
问题 I'm having trouble articulating the difference between Chomsky type 2 (context free languages) and Chomsky type 3 (Regular languages). Can someone out there give me an answer in plain English? I'm having trouble understanding the whole hierarchy thing. 回答1: A Type II grammar is a Type III grammar with a stack A Type II grammar is basically a Type III grammar with nesting. Type III grammar (Regular): Use Case - CSV (Comma Separated Values) Characteristics: can be read with a using a FSM