Writing prolog programs

8 important questions on Writing prolog programs

It is important that we have included enough clauses to allow Prolog to draw appropriate conclusions involving the predicates. What does this mean?

We should include enough atomic and conditional sentences describing the environment

Prolog programs are just knowledge bases made up of facts. True or false?

True

Does the following predicate hold? parent (X, Y) :- child (X, Y).

Logically incorrect % "If X is a child of Y, then X is a parent of Y"
  • Higher grades + faster learning
  • Never study anything twice
  • 100% sure, 100% understanding
Discover Study Smart

Does the following predicate hold? my_predicate (X, Y) :- child (X, Y).

Yes, they are both syntactically and logically correct (prolog is not concerned about the meaning of predicates and atoms, we should be)

What is the concept of recursion?

The predicate of the head is the same as a predicate in the body ("If X is on Z and Z is above Y, then X is above Y")

What are the two cases we have to define in mathematical induction?

The base case and the recursive case

What does this example of recursion clause mean? Above (X, Y) :- on (X,Z), above (Z,Y).

If X is on Z, and Z is above Y, then X is above Y.

What is the rule of thumb to make sure that a program will terminate?

The body should contain at least one atom before the recursive one to provide a new value for one of the variables (Instead of (above (X,Y) :- above (Z,Y), on (X,Z) use above (X,Y) :- on (X,Z), above(Z,Y).

The question on the page originate from the summary of the following study material:

  • A unique study and practice tool
  • Never study anything twice again
  • Get the grades you hope for
  • 100% sure, 100% understanding
Remember faster, study better. Scientifically proven.
Trustpilot Logo