Artificial Intelligence

Homework #2

Exploring Prolog

Due: March 21

Please turn in a printed listing of your Prolog clauses and a sample run of the execution testing your program.  No email is necessary.

  1. Write the Prolog clauses for Ackerman's function. 
  2. A(m, n) n + 1 m == 0,
    A(m-1, 1) m > 0, n == 0
    A(m-1, A(m, n-1)) otherwise

  3. Design a Prolog database to represent the structure of the United States Government. It should use a vocabulary including the following:
    executive_arm legislative_arm judicial_arm
    president congress supreme_court
    vice_president senate house_of_representatives
    courts_of_appeal dept_of_treasury dept_of_state
    budget bills laws
    veto suits override
    sec_of_state sec_of_treasury  
    head_of has_veto_power_over has_review_power_over
    can_override_veto_by must_initiate can_impeach
    can_invalidate is_apart_of reports_to

    Construct Prolog queries interpreting the following questions

    1. Who has review power over laws?
    2. What can the House of Representatives invalidate?
    3. Who is the head of the Department of Treasury?
    4. Who reports to the President?

  4. Design a Prolog system for basic computational geometry. Develop the following relations.  Demonstrate Points, Segments (both vertical and horizontal), Rectangles, Triangles, and Regular Rectangles.

    Point(X, Y)
    Seg( P1, P2 )
    Vertical( Seg( P1, P2 ))
    Horizontal( Seg( P1, P2 ))
    Rectangle( P1, P2, P3, P4 )
    Triangle( P1, P2, P3 )
    Regular( R )