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 9267777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:38:09+00:00 2026-06-18T14:38:09+00:00

New to logic programming (Prolog). Come across a simple question but dont know how

  • 0

New to logic programming (Prolog). Come across a simple question but dont know how to code it in prolog.

Question is like you have several arguements: argument(a),argument(b)…, and several attack relations like attack(a,b) which means argument a attacks argument b. So given an argument I want to find out if it is a grounded one. “Grounded” for an argument a means if b attacks a, then there exists another argument, say c attacks b. If no argument attacks c then we say a and c are grounded.

Can you give an example how to implement this grounded/1 program to achieve this goal.

Not sure I make it clear….But welcome to give any advice (or code)!!

  • 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-18T14:38:11+00:00Added an answer on June 18, 2026 at 2:38 pm

    What I’ve understand from your explanation, an argument is grounded when there are no other grounded arguments attacking it.

    You can define a procedure grounded/1 which obeys this rule straightforward in prolog:

    grounded(A):-
      argument(A),    % A is an argument
      \+              % for which there does not exist
      (
        attack(B, A), % an attacker
        grounded(B)   % which is grounded
      ).
    

    [Edit after comment by OP]:
    If you have to deal with cycles, then you will probably need to keep a list of visited “attacks”, no forbid cycles:

    grounded(A):-
      grounded(A, []).
    
    
    grounded(A, L):-
      argument(A),
      \+
      (
        attack(B, A),
        \+ member(B, L),  % Here we forbid cycles
        grounded(B, [A|L])  % We add the current argument to the list of forbidden arguments
      ).
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to VBA but have previous experience with PHP programming logic and
I am new to programming and javascript and i have a question ive been
I have been given a new project module which involves fuzzy logic. It is
While reading SICP I came across logic programming chapter 4.4. Then I started looking
I have a legacy code to maintain and while trying to understand the logic
I have this logic programming software that can output results in a text file
I am new to iPhone programming. I have two textfields in iPhone with numberPad
I'm new to iOS development but I have a big web development experience, this
I'm fairly new to c++ programming. I am trying to code a windows client
new here and really green to programming, so go easy.. I discovered I have

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.