Closed Thread
Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: Formal Languages and Automata

  1. #11
    Apprentice123 is offline Programming Expert
    Join Date
    Jun 2008
    Posts
    397
    Rep Power
    0

    Re: Formal Languages and Automata

    Quote Originally Posted by bobdark View Post
    G = ( {S,A,B}, {a,b}, P, B) - B should be the starting variable.
    Thank you very much!
    I have another question: How to determine a grammar equivalent to another grammar?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #12
    bobdark's Avatar
    bobdark is offline Programmer
    Join Date
    Jan 2010
    Location
    Haifa, Israel
    Posts
    164
    Rep Power
    9

    Re: Formal Languages and Automata

    If you mean for a computer to determnine whether two grammars are equivalent - it can be done in a very very very small and tiny group of cases. Its impossible as far as I know though, to program a computer, that given two grammars, to decide whether they are equivalent or not.
    If you're talking how a human can do that, by proving that for both of the grammars for each word one derives, the other one can derive the same word.
    To speak formally, you have to prove:
    1) L(G1) ⊆ L(G2)
    2)L(G2) ⊆ L(G1)
    That is, if by saying equivalent you mean that they produce the same language.

  4. #13
    Apprentice123 is offline Programming Expert
    Join Date
    Jun 2008
    Posts
    397
    Rep Power
    0

    Re: Formal Languages and Automata

    Quote Originally Posted by bobdark View Post
    If you mean for a computer to determnine whether two grammars are equivalent - it can be done in a very very very small and tiny group of cases. Its impossible as far as I know though, to program a computer, that given two grammars, to decide whether they are equivalent or not.
    If you're talking how a human can do that, by proving that for both of the grammars for each word one derives, the other one can derive the same word.
    To speak formally, you have to prove:
    1) L(G1) ⊆ L(G2)
    2)L(G2) ⊆ L(G1)
    That is, if by saying equivalent you mean that they produce the same language.
    Ok. Thank you.
    I was thinking if the language L = { a^n b^n c^n | n>=0 }
    Three letters there is the possibility of creating a grammar?

  5. #14
    bobdark's Avatar
    bobdark is offline Programmer
    Join Date
    Jan 2010
    Location
    Haifa, Israel
    Posts
    164
    Rep Power
    9

    Re: Formal Languages and Automata

    That is an interesting question. I don't know the precise answer. I can say that there is no context - free grammar for this language, i.e. grammar whos rules are of form V->a, where V is a variable and a is a string of terminals and variables. Context free means that you don't need anything "to surround" V to apply the rule. Why there is no context - free grammar? Read in wikipedia about: regular languages, context free languages and grammars, pumping lemma. I really have no idea whether there exists a non-context-free grammar that can derive this language. I'd be happy to know that too.

  6. #15
    Apprentice123 is offline Programming Expert
    Join Date
    Jun 2008
    Posts
    397
    Rep Power
    0

    Re: Formal Languages and Automata

    Quote Originally Posted by bobdark View Post
    That is an interesting question. I don't know the precise answer. I can say that there is no context - free grammar for this language, i.e. grammar whos rules are of form V->a, where V is a variable and a is a string of terminals and variables. Context free means that you don't need anything "to surround" V to apply the rule. Why there is no context - free grammar? Read in wikipedia about: regular languages, context free languages and grammars, pumping lemma. I really have no idea whether there exists a non-context-free grammar that can derive this language. I'd be happy to know that too.

    I tried a few derivation, I could not solve.
    S -> aAbBc
    A -> ab
    B -> c

    It only works for n = 1

  7. #16
    bobdark's Avatar
    bobdark is offline Programmer
    Join Date
    Jan 2010
    Location
    Haifa, Israel
    Posts
    164
    Rep Power
    9

    Re: Formal Languages and Automata

    Its a context free grammar. Context free grammar CANNOT derive that language. Theres a proof of this claim.
    A non context free grammar can though -
    E->aSS'bD
    S->aSS'b
    S'b->bS'
    S'D->DS'
    DS'->Dc
    D->epsilon

    The idea is to derive same number of a's, b's and S'. Then move each S' to the end of the word and derive c for each S'.

  8. #17
    Apprentice123 is offline Programming Expert
    Join Date
    Jun 2008
    Posts
    397
    Rep Power
    0

    Re: Formal Languages and Automata

    I found the Internet to written language differently
    L = { wcw | w is word of {a,b}*}

    How to develop a grammar for that language?

  9. #18
    bobdark's Avatar
    bobdark is offline Programmer
    Join Date
    Jan 2010
    Location
    Haifa, Israel
    Posts
    164
    Rep Power
    9

    Re: Formal Languages and Automata

    Ill leave for you to figure it out alone, based on the grammar for a^nb^nc^n that I've written.
    Basically a non-context free grammar is equivalent to a turing machine if Im not mistaken.
    One way to do it MAY be thinking how would a computer program for deriving those words look like ad try and implement it in grammars. This might be a bit hard though. You may also try to think how would an algorithm for a turing machine look like and try to import it to the grammars. This is very abstract tips but I can't think of another way I could help you.
    The fact that the grammar has to be non-context free means that you must non-context free derivation rules to insure that some terminals or variables will be derived in specific locations, and thus restrict the order of applying derivation rules.

  10. #19
    Apprentice123 is offline Programming Expert
    Join Date
    Jun 2008
    Posts
    397
    Rep Power
    0

    Re: Formal Languages and Automata

    L = { a^n b^n c^n | n>=0 }

    I did
    S -> XYZ
    X -> XaA | F
    Aa -> aA
    AY -> YbB
    Fa -> aF
    FY -> epsilon
    BZ -> c
    Bb -> bB
    BB -> BZB
    Correct ?

    You have ideia of how to get the solution with L = { www | w is word of {a,b}*} ?


    Another question:

    How to determine a grammar that generates e-mail?

    Example: jack2.program.crazy@cc.lol.gg

  11. #20
    satyakarn is offline Newbie
    Join Date
    Nov 2010
    Posts
    1
    Rep Power
    0

    Re: Formal Languages and Automata

    grammar to produce tokens of C++

    plzz help me regarding this...

Closed Thread
Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Cellular Automata Help
    By ahmed in forum Java Help
    Replies: 4
    Last Post: 04-01-2011, 01:41 PM
  2. Stack automata
    By Apprentice123 in forum General Programming
    Replies: 0
    Last Post: 08-24-2010, 12:58 PM
  3. formal aspect of computing problem~urgent
    By lazypeople in forum General Programming
    Replies: 3
    Last Post: 03-30-2010, 07:53 AM
  4. Replies: 6
    Last Post: 12-12-2009, 04:23 PM
  5. Formal Education?
    By KeilanS in forum The Lounge
    Replies: 10
    Last Post: 11-11-2008, 06:46 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts