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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:15:40+00:00 2026-05-13T08:15:40+00:00

I had a quick question re. existential qualifier using setof in prolog (i.e. ^).

  • 0

I had a quick question re. existential qualifier using setof in prolog (i.e. ^).

using SICStus it seems that (despite what a number of websites claim), S does indeed appear to be quantified in the code below (using the bog standard, mother of / child of facts, which i havent included here):

child(M,F,C) :- setof(X,(mother(S,X)),C).

i check the unification using:

child(M,F,C) :- setof(X-S,(mother(S,X)),C).

so the following code, with the existential operator seem to make no difference:

child(M,F,C) :- setof(X,S^(mother(S,X)),C).

Any ideas why this is? What would be a situation where you would need the unifier then?

thanks!

  • 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-13T08:15:41+00:00Added an answer on May 13, 2026 at 8:15 am

    Ok, I’m not sure I can explain it perfectly, but let me try.

    It has to do with the fact that you are querying over a 2-ary relation, mother/2. In that case using X-S as the template has a similar effect on the result set C as using S^ in front of the goal. In X-S you are using both variables in the template, and therefore each possible binding of X and S is included in C. You get the same effect using S^ in front of the goal, as this is saying “ignore bindings of S when constructing the result”.

    But the difference between the two becomes clearer when you query over a 3-ary relation. The SWI manual has this example:

    foo(a, b, c).
    foo(a, b, d).
    foo(b, c, e).
    foo(b, c, f).
    foo(c, c, g).
    

    Now do similar queries as in your example

    setof(X-Z, foo(X,Y,Z), C).
    

    and

    setof(Z, X^foo(X,Y,Z), C).
    

    and you get different results.

    It’s not just checking unification, X-Z effectively changes your result set.

    Hope that helps.

    Edit: Maybe it clarifies things when I include the results of the two queries above. The first one goes like this:

    ?- setof(X-Z, foo(X,Y,Z), C).   
    Y = b
    C = [a-c, a-d] ;
    Y = c
    C = [b-e, b-f, c-g] ;
    No
    

    The second one yields:

    ?- setof(Z, X^foo(X,Y,Z), C).
    Y = b
    C = [c, d] ;
    Y = c
    C = [e, f, g] ;
    No
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 369k
  • Answers 369k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Warning: This does not consider newlines. For a more in-depth… May 14, 2026 at 6:21 pm
  • Editorial Team
    Editorial Team added an answer Note: A more complete list of features, explanations and references… May 14, 2026 at 6:21 pm
  • Editorial Team
    Editorial Team added an answer I finally ended up by implementing my own filter. May 14, 2026 at 6:21 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.