3
votes

I need help writing a predicate ground( Term) that returns true if Term doesn't have any uninstantiated variables.

I know i need to use the built-in predicates functor, arg, and '=..' but I think i need help just getting started...

My idea is that I need to go down the Term (Term could be a list of multiple variables). Check the Head, Then recursively look at the the rest of the list and check if the rest of the list is uninstantiated.

But my problem is... How do i check if it's uninstantiated?

1
I hate to mention that this is kind of a duplicate of the question you asked 10 minutes ago. You should also learn to add the homework tag to questions that are ... homework. On the other hand, kudos for the obvious effort put into the question this time. - vzwick
Ah sorry ya i'll add homework next time to the tags - Bob Smith
Also, does this help you in any way? I know about prolog nearly as much as I do about the specifics of submarine resource mining (== nothing) but it sounds like a very similar problem to me. - vzwick

1 Answers

1
votes

You can use the var/1 predicate to test whether a term is an uninstantiated variable.

?- var(X).
true.

?- var(x).
false.

?- var((X,Y)).
false.

?- var(t(Y,Z)).
false.