Prolog cheat sheet

Facts:   
     sunny.
     mortal(socrates).
     loves(john, mary).
     likes(_, ice_cream). /* _ means "don't care" /*

Rules:
     hot :- summertime.
     mortal(X) :- man(X).
     loves(chuck, F) :- female(F), rich(F).
     smaller(x, y) :- larger(y, x).

Queries: Same format as facts or rules.

Strings: Use single (not double) quotes. To put a single quote inside a string, type it twice, or backslash it.

Lists:
     [] is the empty list.
     [1, 2, 3] is the list whose head is 1 and whose tail is [2, 3].
     [H | T] is the list whose head is H and whose tail is T.

Operators:
     ,   and
     ;   
or
    \+   
not
     =     unification
    is    evaluate the right hand side, then try to unify
   =:=  evaluate boths sides, then try to unify
     !  cut

Built-in predicates:
     consult('path to file')
     write(value)
     nl
     assert(new fact)
     retract(old fact)