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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:45:20+00:00 2026-06-15T23:45:20+00:00

This is a question from a past exam about unification in Prolog. we were

  • 0

This is a question from a past exam about unification in Prolog.
we were supposed to say if they unified and then the instantiations.

f(a,g(b,a)) and f(X,g(Y,X))

This unifies quite a = X, g(b,a) = g(Y,X) and is quite straight forward

f(g(Y),h(c,d)) and f(X,h(W,d)) 

I dont think this one unifies because of g(Y) =/ X, though h(c,d) does unify with h(W,d). Though is it possible that X = g(Y) since uppercase X looks until it finds a solution?

  • 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-15T23:45:20+00:00Added an answer on June 15, 2026 at 11:45 pm

    Yes, it does unify, and it does so because g(Y) is a term to be evaluated, as well as a — in the first example you pointed.

    You can check the evaluation in a prolog interpreter:

    ?- f(g(Y),h(c,d)) = f(X,h(W,d)).
    X = g(Y),
    W = c.
    

    The unification process works in a depth-first fashion, unifying members and returning each of the available answer, until no further combination is possible.

    This means the unification method is called for f(g(Y),h(c,d)) = f(X,h(W,d)), that finds out the available matchings: g(Y) = X, h(c, d) = h(W, d).

    Then, the unification is performed upon g(Y) = X, that, since there’s no further possible reduction, returns X = g(Y).

    Then, the same method is called upon the matching h(c, d) = h(W, d), which gives you c = W, and no other matching, resulting, thus, in W = c.

    The answers, after unification, are returned, and it’s usually returned false to point when no matching/further matching is possible.

    As pointed by CapelliC, the variable Y, after the unification process, is still unbound. The unification is performed upon unbound variables, which means:

    • the unification of h(c, d) = h(W, d) returns h(_) = h(_), and this allows the unification to continue, since h is a term, and not an unbound var;

    • the unification of d = d is a matching of terms, and does not form an attribution — or binding;

    • the unification of c = W forms an attribution, and the variable W is bound to the term c, since it was not bound before — a comparison would be performed otherwise;

    • the unification of X = g(Y) simply binds the unbound variable X to the term g(Y), and g(Y) is a term with an unbound variable, since there’s no available unification to g(Y).

    Regards!

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

Sidebar

Related Questions

This question is for revision purposes from a past exam paper I just want
This is a question from a past exam paper. The question asks to declare
This is a question from a past exam paper. I am not too sure
This is a question from a past exam paper. The code was given in
This is a question from a past exam paper. Why does the loop invariant
This is a question from an exam past paper. I have completed the question
Brief: This is a past exam question from a Miranda exam but the syntax
This question is from a past exam paper and it is used for revision
I'm doing a past Function Programming exam paper and have this question: Here are
I'm having difficulties with a question from a past exam paper. I'm trying 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.