CIS 554 -- Prolog Quiz Name __________________________________
  1. (3 points) Resolve the following pairs of clauses:
    1. Turn the following into clause form:
      (dog(X) ⇒ mammal(X)) ∧ (fish(X) ⇒ ¬mammal(X))

      ¬dog ∨ mammal
      ¬fish ∨ ¬mammal


    2. Resolve the above clauses.

      ¬dog ∨ ¬fish

    3. State the conclusion in English.

      Nothing is both a dog and a fish; or
      Everything is either not a dog or not a fish.


  2. (1 point) Write a Prolog predicate first_dup that finds the first value in a list that is equal to the next value. For example, given the list [7, 3, 1, 3, 4, 4, 1, 6, 6], will find the value 4. The predicate should fail if the list does not contain equal adjacent values.

    first_dup([X, X|_], X).
    first_dup([_|Tail], X) :- first_dup(Tail, X).

    (1/2 point for just determining whether a doubled value exists.)


  3. (2 points) Consider the following code:
        mystery([H|T]) :- mys2(H, T).
    mys2(X, [X]). mys2(X, [_|T]) :- mys2(X, T).
    1. On what kind of lists will the mystery predicate succeed?

      Lists of length >= 2 where the first element is the same as the last element

    2. What will be the result of the call mys2(X, [1, 2, 3, 4]) ?

      X = 4

  4. (1 point) Consider the following code:
        dump(X) :- member(A, X), write(A), nl, fail.
        dump(_).

    What will be printed by the call dump([this, is, a, problem]) ?

    this
    is
    a
    problem
    (also either "yes" or "true")


  5. (1 point) Briefly define the term nonmonotonic logic.

    A logic in which facts, and therefore conclusions drawn from those facts, may change.

  6. (1 point) In "The Free Lunch is Over," what does Herb Sutter claim about the current status of Moore's Law?

    He claims two things: that (as of about 2003),
    (a) Moore's Law continues to apply to increasing hardware density (#transistors/chip)
    (b) Moore's Law no longer applies to increasing processor speed.


  7. (1 point) State as briefly as you can what the "Blub Paradox" is.

    A programmer used to a particular language ("Blub") sees languages missing some of Blub's features as inferior, but cannot see the value of features in other languages that are not in Blub.