Concepts of Programming Languages

(Sean Pound) #1
Programming Exercises 761


  1. Write the following English conditional statements as Prolog headed
    Horn clauses:


a. If Fred is the father of Mike, then Fred is an ances-
tor of Mike.


b. If Mike is the father of Joe and Mike is the father
of Mary, then Mary is the sister of Joe.


c. If Mike is the brother of Fred and Fred is the
father of Mary, then Mike is the uncle of Mary.



  1. Explain two ways in which the list-processing capabilities of Scheme and
    Prolog are similar.

  2. In what way are the list-processing capabilities of Scheme and Prolog
    different?

  3. Write a comparison of Prolog with ML, including two similarities and
    two differences.

  4. From a book on Prolog, learn and write a description of an occur-
    check problem. Why does Prolog allow this problem to exist in its
    implementation?

  5. Find a good source of information on Skolem normal form and write a
    brief but clear explanation of it.


PROGRAMMING EXERCISES



  1. Using the structures parent(X, Y), male(X), and female(X), write
    a structure that defines mother(X, Y).

  2. Using the structures parent(X, Y), male(X), and female(X), write
    a structure that defines sister(X, Y).

  3. Write a Prolog program that finds the maximum of a list of numbers.

  4. Write a Prolog program that succeeds if the intersection of two given list
    parameters is empty.

  5. Write a Prolog program that returns a list containing the union of the
    elements of two given lists.

  6. Write a Prolog program that returns the final element of a given list.

  7. Write a Prolog program that implements quicksort.

Free download pdf