Question

Write a prolog program that defines the predicate groundTerm(Term) which tests whether or not Term is...

Write a prolog program that defines the predicate groundTerm(Term) which tests whether or not Term is a ground term. Ground terms are those taht don't contain variables. Here are examples of how the predicate should behave. groundTerm(X). false. groundTerm(french(bic_mac,le_bic_mac)). true. groundTerm(french(whopper,X)). false. Also, the predicate should terminate execution immediately after producing its first (and only) solution.

Homework Answers

Answer #1

The prolog program to check for the ground term is given as follow:

----------------------------------------code-----------------------------------------------------------

groundterm(Term) :-
nonvar(Term),
Term =.. [_ | X],
groundterm_in_list(X).

groundterm_in_list([H|T]) :-
groundterm(H),
groundterm_in_list(T).

groundterm_in_list([]).

------------------------------------------------------------------------------------------------

The prolog program above checks for the groundterm.

--------------------------------------Please Upvote--------------------------------------------------------------------------------

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Define a predicate unifiable(List1,Term,List2) where List2 is the list of all members of List1 that unify...
Define a predicate unifiable(List1,Term,List2) where List2 is the list of all members of List1 that unify with Term. The elements of List2 should not be instantiated by the unification. For example, unifiable([X,b,t(Y)],t(a),List). List= [X,t(Y)]. Note that X and Y are still not instantiated. So the tricky part is: how do we check that they unify with t(a) without instantiating them? Write the predicate so that it terminates immediately after finding the correct answer. (That is, after prolog produces its first...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
c++ Program Description You are going to write a computer program/prototype to process mail packages that...
c++ Program Description You are going to write a computer program/prototype to process mail packages that are sent to different cities. For each destination city, a destination object is set up with the name of the city, the count of packages to the city and the total weight of all the packages. The destination object is updated periodically when new packages are collected. You will maintain a list of destination objects and use commands to process data in the list....
Sign In INNOVATION Deep Change: How Operational Innovation Can Transform Your Company by Michael Hammer From...
Sign In INNOVATION Deep Change: How Operational Innovation Can Transform Your Company by Michael Hammer From the April 2004 Issue Save Share 8.95 In 1991, Progressive Insurance, an automobile insurer based in Mayfield Village, Ohio, had approximately $1.3 billion in sales. By 2002, that figure had grown to $9.5 billion. What fashionable strategies did Progressive employ to achieve sevenfold growth in just over a decade? Was it positioned in a high-growth industry? Hardly. Auto insurance is a mature, 100-year-old industry...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT