CMPS140, Winter 2012, Section 01: Lecture 2

2 equations: Expected Utility:  summation(Pi*Ui)
            Entropy = Diversity = expected surprise; summation(Pi*Log2(Pi))

Rational = Intelligent = Does what is theoretical best given what it knows
Agent function: maps percepts to actions Agentprogram: implements the agent function
PEAS: performance metric, evaluation metric, actions, sensors

LISP                      Answer
------------              ------
(+ 3 5)                      8
(* (+ 2 3) 7)               35
(setf x 5)                   5    declaring x special
x                            5
(* x x)                     25
(setf y '(a b c))           (a b c) declaring y special
(first y)                   a
(rest y)                    (b c)
(cons 'z y)                 (z a b c)
(reverse y)                 (c b a)
(append y (reverse y))      (a b c c b a)

(defun make-palindrome (lst)
    (append lst (reverse lst)))  make-palindrome

(make-palindrome '(a n))        (a n n a)

An S-expression is either atomic or composite:
   S-expressions are X, APPLE,+, 35, -1.75
   Composite S-Expressions are (+ 2 3), (X Y Z) and (FIRST LST).
       These are lists, there is something else called a "dotted pair"
       that we will live happily without.

An atom is a numeric atom: -25 or 107.3
       or a symbol, character, string or array.   There
       are others. ignore for now.
  Symbols are like identifiers in programming languages:
      X, APPLE, +, *, P1.   Case insensitive. Usually begin
      with character.

NIL is a symbol = () = "boolean value false" = -

Lists evaluate as follows:
    1. check that the head of the list is a  defined function name
    2. check that the number of arguments (the rest of the list) is correct
    3. evaluate arguments left to right
    4. apply function to the arguments
       and return the value.

Numbers and strings evaluate to themselves
'x evaluates to x where x is any s-expression
symbols evaluate to the value that has been attached to them.
NIL evaluates to NIL