
README: Lab5
============

lab5 will involve implementing a prolog database to support queries about rectangles.

   Rectangles in this case are aligned with the x/y axis, and
   are specified by four integer values:
     - the x coordinate of the left side of the rectangle
     - the x coordinate of the right side of the rectangle
     - the y coordinate of the top side of the rectangle
     - the y coordinate of the bottom side of the rectangle
   i.e. rectangle(L,R,T,B)

   For a rectangle to be valid the following must also apply:
     - the value of the left x must be less than the value of the right x
     - the value of the bottom y must be less than the value of the top y
   e.g. rectangle(-3, 4, 5, 2) would have its four corners
       at (x,y) positions (-3,2) (-3,5) (4,5) and (4,2)

lab5.pl currently has rules to support queries of the following forms:

   chkSep.   - this will prompt the user to enter stats for two rectangles
               and succeed if the stats are valid for two rectangles and
               the two rectangles are separate (do not overlap).

   chkOvr.   - this will prompt the user to enter stats for two rectangles
               and succeed if the stats are valid for two rectangles and
               the two rectangles overlap.

   getR(R).  - this will prompt the user to enter stats for a single rectangle,
               and (if valid) unify the rectangle with R.


Task:
-----
The queries above depend on several rule sets that you will need to implement.
You need to add support for queries of the following forms:

   rectangle(Left,Right,Top,Bottom) - succeeds if the values describe a valid rectangle,
      prints an error message and fails otherwise.
      For example:
         rectangle(1,3,5,2) should succeed
         rectangle("foo",1,5,2) should fail and print an error message because
                                of the non-integer coordinate)
         rectangle(3,3,5,2) should fail and print an error message because left >= right

   separate(R1,R2) - succeeds if R1 and R2 are rectangles that do not overlap.
      For example:
         separate(rectangle(1,3,5,2), rectangle(4,6,4,3)) should succeed
            (the first rectangle is entirely "left" of the second)
         separate(rectangle(1,3,5,2), rectangle(2,4,6,4)) should fail
            (since the two rectangles overlap)
         separate(rectangle(1,3,5,"foo"), rectangle(2,4,6,4)) should fail
            (since the first rectangle is invalid)

   overlap(R1,R2) - succeeds if R1 and R2 are rectangles that overlap
         (i.e. overlap should succeed iff separate fails).

Testing:
--------
You can test your functions manually by starting prolog and
    loading your lab5.pl then entering queries.

An automated prolog test script is also available in the repository,
    tester.pl
To run this script (from the linux command line) simply enter
    ./tester.pl
It will run a set of tests on each of the three functions
    and display PASS/FAIL results for your functions
    on each test case.

