automata

Example of Non-Linear, UnAmbiguous and Non-Deterministic CFL?

别等时光非礼了梦想. 提交于 2019-12-17 06:51:18
问题 In the Chomsky classification of formal languages, I need some examples of Non-Linear, Unambiguous and also Non-Deterministic Context-Free-Language(N-CFL)? Linear Language : For which Linear grammar is possible( ⊆ CFG) e.g. L 1 = {a n b n | n ≥ 0 } Deterministic Context Free Language(D-CFG) : For which Deterministic Push-Down-Automata(D-PDA) is possible e.g. L 2 = {a n b n c m | n ≥ 0, m ≥ 0 } L 2 is unambiguous. A CF grammar that is not linear is nonlinear. L nl = {w: n a (w) = n b (w)} is

How to recursive the authomata Strange Planet exercise?

放肆的年华 提交于 2019-12-13 12:45:38
问题 The basic idea of this is that in a planet there is three diferent kinds of species, only two of the three species can came together to procreate, and the result is that this to species die a two new sobjects of the third species born, for example we have a b and c, and the species a and b came together and let 2 c new members born. It is like: 1a 1b and 1c (Sorry for the lenguage) When a and b want to have kids they came together and die but have two kids, these new kids are from the species

Union in context-free languages

我的未来我决定 提交于 2019-12-13 08:35:40
问题 Is the union of a collection of context-free languages always context-free ? Justify your answer ..... I know that the answer is yes, but how can I prove it ? 回答1: To show that the finite union of context-free languages is context-free you just have to build a context-free grammar for the union language, exactly as you would do to prove that the union of two context-free languages is context-free. If G1,...,GN are the context-free grammars for the N context-free languages you have, rename all

Prove that the languages are not context free?

僤鯓⒐⒋嵵緔 提交于 2019-12-11 04:27:12
问题 How can I prove the following language is not context-free? Any help will be appreciated. Thank you. L = {0^n| n is a prime} 回答1: The proof is by contradiction. Assume the language is context-free. Then, by the pumping lemma for context-free languages, any string in L can be written as uvxyz where |vxy| < p, |vy| > 0 and for all natural numbers k, u(v^k)x(y^k)z is in the language as well. Choose 0^m where m is any prime > p. Then we must be able to write 0^m as uvxyz so that |vy| > 0. Let |vy

Understanding (and forming) the regular expression of this finite automaton

萝らか妹 提交于 2019-12-11 03:49:23
问题 For the above automaton, the regular expression that has been given in my textbook is the following : a*(a*ba*ba*ba*)*(a+a*ba*ba*ba*) I am having trouble deriving this...the following is my attempt at it : aa* + aa*(ba*ba*ba*)* + ba*ba*ba* + ba*ba*ba*(ba*ba*ba*)* Either I am wrong or I am not being able to simplify it into the form given in the book. Can someone please guide me here, point out the mistake or explain it to me step-by-step? I'd really really thankful and appreciate that. 回答1:

Finding regular expressions for languages otherwise described

拥有回忆 提交于 2019-12-11 01:39:04
问题 Letting {a b} be the alphabet set, write a regular expression for: 1) The language of all those words in which the number of a's and the number of b's are both odd; 2) The language of all those words whose length is odd and which contain the substring ab. Also, if possible, please help me find two different expressions for each so as to help strengthen my understanding of how to go about solving such problems. 回答1: For the first one, there's an easy 4-state DFA you can construct to recognize

Construct Context free Grammar

大兔子大兔子 提交于 2019-12-10 10:51:23
问题 How can I construct a context free grammar for the following language: L = {a^l b^m c^n d^p | l+n==m+p; l,m,n,p >=1} I started by attempting: S -> abcd | aAbBcd | abcCdD | aAbcdD | AabBcCd and then A = something else... but I couldn't get this working. . I was wondering how can we remember how many c's shud be increased for the no. of b's increased? For example: string : abbccd 回答1: The grammar is : S1 -> a S1 d | S2 S2 -> S3 S4 S3 -> a S3 b | epsilon S4 -> S5 S6 S5 -> b S5 c | epsilon S6 ->

Recognize A^n B^n language in Prolog with no arithmetics

可紊 提交于 2019-12-10 10:07:55
问题 How to recognize A^n B^n language in Prolog without arithmetics and for any A, B where A != B? With known A = a and B = b we could write % For each 'a' save 'b' in a list, then check % whether constructed list is equal to the rest of input list anbn(L) :- anbn(L, []). anbn(L, L). anbn([a|L],A) :- anbn(L, [b|A]). For any A and B I was thinking of a solution starting with anbn(L) :- anbn(L, []). anbn([H|L],[]) :- anbn(L,[H]). % save an element anbn([H|L], [H|A]) :- anbn(L, [H,H|A]). % make sure

PDA to accept a language of strings containing more a's than b's

纵饮孤独 提交于 2019-12-09 06:54:34
问题 Produce a PDA to recognise the following language : the language of strings containing more a's than b's I have been struggling with this question for several days now, I seem to have hit a complete mental block. Would any one be able to provide some guidance or direction to how I can solve this problem? 回答1: Your problem of "more a's than b's" can be solved by PDA. All you have to do is: When input is a and the stack is either empty or has an a on the top, push a on the stack; pop b , if b

NPDA with exactly 2 states that might need 3 transitions to final state

孤街醉人 提交于 2019-12-08 09:10:00
问题 Let's say we want to draw the transition graph with two states of a NPDA that accepts that language L. And let's also say that this NPDA will have exactly 2 states. My thinking on this would be to do everything in the first state then use the second state as the grand finale. Like so: But I'm not sure that the lambda transitions will result in q1 or if there is a better way to do this, which there likely is a better way since I'm trying to teach this to myself. Perhaps someone can get me back