Computer Science 3675
Fall 2015
Practice Questions for Quiz 9

  1. When you use a Prolog predicate, some of the parameters are typically in-parameters and others can be out-parameters. How do you indicate in a Prolog program that a given parameter is an out-parameter?

    Answer.

  2. In logic programming, you not only specialize a given axiom to prove a particular goal, but you also specialize the goal so that it can be proved using that axiom. What tool performs those specializations?

    Answer.

  3. What is the closed-world hypothesis?

    Answer.

  4. Explain negation-as-failure. What is its goal, and how does it work?

    Answer

  5. Does negation-as-failure always do correct logical negation?

    Answer

  6. Two individuals are cousins if they have a grandparent in common, but they are not the same person, and are not siblings. Using predicate grandparent(X, Y), meaning that X is a grandparent of Y, and predicate sibling(X, Y) meaning that X and Y are siblings, write a definition of cousin(X, Y) using Prolog notation, meaning that X and Y are cousins.

    Answer

  7. The append predicate is defined as follows in Prolog.

      append([], Y, Y).
      append([A|X], Y, [A|Z]) :- append(X, Y, Z).
    
    You would like to define a predicate double(X), which is true if list X has the form Y ++ Y, for some Y. For example, double([a,b,c,a,b,c]) is true, but double([a,b,c,a]) is false.

    Which of the following is a correct definition of double in Prolog?

    1. double(X) :- append(X,X,Y).
    2. double(X) :- append(Y,Y,X).
    3. double(X) :- append(X,Y,X).
    4. double(X) :- append(Y,X,X).

    Answer

  8. Using the correct definition of predicate double from the preceding exercise, can a Prolog interpreter handle goal double(Z), where Z is an unbound variable? If so, what will it do? If not, why not?

    Answer