CS 100 - Week 3 Lecture 2 - 9-6-12

NOW let's add RULES to Prolog...

*   Prolog rules are based on Horn clauses;
*   rule is like a fact, EXCEPT it has a right-hand-side,
    and a left-hand-side;

    there's a symbol: :-

    on the left-hand-side of the :-, you put a predicate,
        that (usually) has one or more variables as arguments

    on the right-hand-side of the :-, you put a boolean
        expression (that better use the variables from the
        left-hand-side)

    ex:

    like_pacific_nw(Place) :- cool(Place), rainy(Place).

    can read this as,
    I can prove that a Place is like the pacific northwest
    IF that Place is cool, AND that Place is rainy.

*   see posted examples!

NOW -- back to Chapter 2!
*   NEXT: we have the logical concept of a STATEMENT

*   logical: "A statement is a sentence that can be viewed
             as either true or false"

    EXAMPLES of STATEMENTS:
    "Red is a color."
    *   my theory: if you can easily express a sentence
        as a Prolog predicate, it is likely to be a
	logical statement;

        color(red).

    "Canada is in South America."
    *  yes, it is false! But a statement can be true or
       false...!
       a couple of Prolog possibilies might be:
       location(canada, south_america).
       is_in(canada, south_america).

    "The Easter Bunny does not exist."
    *   this can be true OR false -- so it is a logic
        statement
        a couple of Prolog possibilities might be:
        not(exists(easter_bunny)).
        \+(exists(easter_bunny)).

    "Trolling is morally wrong."
    *   this, too, can be true or false (although we
        may not get all of us ot agree on this)
        a Prolog possibility here might be:
        morally_wrong(trolling).

*   the text points out: IF you can reasonably precede
    the sentence with,
    "It is true that..."
    or
    "It is false that..."
    then it is probably a logic statement.

*   here are 4 more things about logic statements:
    1. a sentence may be used to express more than
       one statement. ("Roses are red and violets are blue")

    2. a statement can sometimes be expressed as a phrase
       or an incomplete clause (it doesn't have to be a
       complete declarative sentence)

    3. NOT ALL sentences are statements.
       (see examples in the course text)

    4. statements can be subjective matters of personal
       experience as well as verifiable matters of
       fact