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

  • Home
  • SEARCH
  • 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 7726035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:06:35+00:00 2026-06-01T05:06:35+00:00

how to change this gramma to be deterministic e –> []. e –> *.

  • 0

how to change this gramma to be deterministic

e --> [].
e --> "*".
e --> s_e.
e --> e, s_e.
s_e --> ("a",e);("b",e).

I just dont know where to put cut to avoid backtracking.

  • 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-06-01T05:06:37+00:00Added an answer on June 1, 2026 at 5:06 am

    You can rewrite the last rule as follows:

    s_e --> "a", e.
    s_e --> "b", e.
    

    Now it makes probably sense to place the following cuts:

    s_e --> "a", !, e.
    s_e --> "b", !, e.
    

    You can also place the cuts in the original compact
    form with (;)/2, but I find the above more transparent.
    The above is valid if s_e is not invoked multiple
    times with the same input list.

    But your grammar has a flaw, e is left recursive,
    and s_e will be called multiple times with the same
    input list. Means your grammar will for example
    loop for negative sentences, i.e. it will not be able
    to reject them, and your grammar will loop after
    redo for a positive sentences, i.e. when the input
    has be accepted.

    So you need additionally to eliminate the left
    recursion since normal Prolog depth fist search
    cannot deal with it. The easiest is to replace it by
    right recursion with a new non-terminal. Namely you
    can write the productions for e as follows:

     e --> s_e, rest_e.
     e --> "*", rest_e.
     e --> [].
    
     rest_e --> s_e, rest_e.
     rest_e --> "*", rest_e.
     rest_e --> [].
    

    And we can place cuts as well:

     e --> s_e, !, rest_e.
     e --> "*", !, rest_e.
     e --> [].
    
     rest_e --> s_e, !, rest_e.
     rest_e --> "*", !, rest_e.
     rest_e --> [].
    

    Also the above grammar is slightly modified in
    the sense that multiple empty e productions don’t
    go anymore into e itself via s_e. It is also more
    greedy, in that sub e productions are always fully
    parsed. So for example the sentence:

     aaa
    

    Is only parsed as:

     a(a(a))
    

    And not as:

     a(a)a
    

    Or:

     aa(a)
    

    Or:

     aaa
    

    But otherwise it should accept the same sentences as if the DCG
    would be executed bottom up and would not have
    problems with left recursion.

    Best Regards

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

Sidebar

Related Questions

How do I change this bit of code so that I only allow pdf
I would like to change this: // use appropiate lang.xx.php file according to the
How to change this method to check the login and password and after it
I need to change this array's keys to 0-5, why isn't this working? $arr
I need to change this code to cpp code This is the c# code
How do I change this format 11/16/2002 12:00:00 PM to something that MySQL will
I want to change this date format: Tue Apr 3 15:00:03 GMT+0300 2012 to
How do I change this code minDate: '2012/3/4'+'5D', var dates = $( #from, #to
ShowImage.java /* * To change this template, choose Tools | Templates * and open
I had just taken the decision to change as many variables from unsigned to

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.