Jump to content

I am currently tying to work on a Prolog example from a course that has something like the fallowing

 

start(state(e, e, e, e)).

rule( (move(state(F1, W1, G1, C1), Ed) :- (start(state(F1, W1, G1, C1)), otherRandomPredicates(Ed....) ) ), 100)

 

The predicate is a bit confusing and a bit vague but my question is, when I run using SWI-Prolog (or even GNU Prolog for that matter), the variables F1, W1, G1 and C1 aren't assigned the value of e, e, e and e as would happen if I just ran

 

start(state(F1, W1, G1, C1)).

 

outside of the "rule" predicate.

 

Does anyone know why this is?

Travis

Link to comment
https://linustechtips.com/topic/967711-prolog-questions/
Share on other sites

Link to post
Share on other sites

2 minutes ago, Sauron said:

I don't know much about prolog, but are you sure you can assign the same name to 4 different values? (e)

In Prolog, Variables start with capitals and atoms/predicates start with lower case. So yes, the 4 variables can all have the save value of 'e'.

Travis

Link to comment
https://linustechtips.com/topic/967711-prolog-questions/#findComment-11712589
Share on other sites

Link to post
Share on other sites

My guess is that the unification is failing because although, yes, you can unify the variables in (start(state(F1, W1, G1, C1)) with start(state(e, e, e, e)), the unification fails for  rule((move(state(F1, W1, G1, C1)... Since there is no satisfying assignment for the variables in BOTH terms

Link to comment
https://linustechtips.com/topic/967711-prolog-questions/#findComment-11720626
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×