Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3356762
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:33:06+00:00 2026-05-18T02:33:06+00:00

I’m taking a class on Finite Automata. I’m preparing for a midterm and am

  • 0

I’m taking a class on Finite Automata. I’m preparing for a midterm and am having trouble creating Grammars for specific languages. While I find the simple ones very intuitive, when they become more complex, I don’t seem to know where to start. For example:

L = { w E { a,b,c}* : nb(w) != na(w) + nc(w) }

The answer is:

S→S1 | S2
S1→bS3 | S3b | S3bS3
S3→S0 | S1
S2→XS4 | S4X | S4XS4
S4→S | S2
S0→bS0XS0 | XS0bS0 | e
X→a | c

If anyone could give me a little guidance on the thought process involved, it would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:33:07+00:00Added an answer on May 18, 2026 at 2:33 am

    The language you listed is unclear. I’m assuming w E {a,b,c}* means w ε {a,b,c}* and nb(w) != na(w) + nc(w) means that all strings in the language have a number of b’s not equal to the sum of the number of a’s and the number of c’s.

    If this is the case, you have to think about the characteristics of all the strings that will be in the language, and all of the characteristics that will exclude a string from being in this language.

    This language accepts strings where the number of b’s =/= the number of a’s + number of c’s. We can reformulate this language to be one that accepts strings that:

    number a‘s + number c‘s > number of b‘s
    OR
    number a‘s + number c‘s < number of b‘s

    This explains the first S –> S1 | S2

    S1 ensures that there is at least 1 b (S3), and then forces either an equal amount of b‘s as a‘s and c‘s (S0) or more b‘s than a‘s and c‘s (S1). The net result of the S1 rule is a string with more b‘s than a‘s and c‘s.

    S2 ensures that there is more a‘s and/or c‘s than b‘s. It does this by forcing an a or c (X), then allowing an equal amount of a‘s/c‘s (S0) or more a‘s/c‘s than b‘s (S2 again).

    This is specific to your example, but you can kind of see how the thought process that goes into creating this grammar:

    1. Formulate the language as concrete cases (a‘s/c‘s > or < b‘s)
    2. For each of the cases, start by making sure the case will hold (force # b‘s > than a‘s/c‘s by forcing at least one b) then expanding the string to include all possibilities of equal a‘s/c‘s and b‘s, or less a‘s/c‘s than b‘s.
    3. Symmetrically handle the other case.

    The issue is that you need to make sure that every string in the language is generated, and all strings not in the language are not generated. (re-read this until it’s implication sinks in)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.