CSE 4/572: Knowledge-Based Artificial Intelligence Spring, 2000

Course Notes
Stuart C. Shapiro
Department of Computer Science
State University of New York at Buffalo


Introduction

These notes will comment on and supplement the text. They will serve as an outline for the class meetings, and will be quite informal. Quotes not otherwise attributed are to the text.

Chapter 1: Introduction

"Artificial Intelligence (AI) is a field of computer science and engineering concerned with the computational understanding of what is commonly called intelligent behavior, and with the creation of artifacts that exhibit such behavior." [Stuart C. Shapiro, Artificial Intelligence. In S. C. Shapiro, Ed. Encyclopedia of Artificial Intelligence, Second Edition. John Wiley & Sons, Inc., New York, 1992, p. 54.]

See also, Russell & Norvig's Slides for Chapter 1.

Chapter 2: Intelligent Agents

An agent perceives the environment via its sensors, reasons, chooses an action, and uses its effectors to change the environment.

Autonomous agent: "not under the immediate control of a human"
or "A system is autonomous to the extent that its behavior is determined by its own experience." [p. 35]

See Russell & Norvig's Slides for Chapter 2.

Environment Types:
Accessible
Agent can sense the complete (relevant) state of the environment.
Deterministic
The next state is entirely determined by the previous state and the action of the agent.
Episodic
Each perceive-act episode is independent on previous episodes. Agent needn't think ahead.
Static
Environment doesn't change while agent is thinking. Semidynamic: environment doesn't change, but performance score does.
Discrete
Discrete precepts and actions.

Agent Types:
  • Simple Reflex agent
  • Reflex agent with state
  • Goal-based agent
  • Utilitybased agent
Discussion question: Describe a Turing Machine as an agent.

See pictures of a seriously proposed vacuum agent, the dustbot.

Chapter 3: Solving Problems by Search

See Russell & Norvig's Slides for Chapter 3.

State Space Problem-Solving Terminology
State:
A representation of all relevant aspects of current situation.
The problem:
Get from the start state to a goal state.
Goalp:
A function that recognizes goal states, goalp: states --> {T, F}.
Operators:
Set of operators, each of which is a partial function from a state to another state, op: states --> states.
On-line Problem Solving:
Start at start state; follow a path of operators to a goal state; return the goal state or SUCCESS (or FAIL).
Off-line Problem Solving:
Start at start state; find a path of operators (or of states) ending at a goal state; return the path (or FAIL).
State Space:
A directed graph: nodes are states; an arc labeled with operator o goes from state s1 to state s2 iff o(s1) = s2.
State Space leaf:
A state such that no operator applies to it: a dead end if not a goal.
Search Tree (Graph):
A node for every state examined during search, arcs show how nodes were expanded. Nodes may contain other search-related information.
Expanding a search tree node:
Generating (or identifying) all successor states, and updating the search tree.
Search tree leaf:
A node of the search tree that has not yet been expanded.

A general search function:

(defun search (start goalp operators inserter &key trace)
  "Searches the state space starting at START,
      using the OPERATORS for node expansion,
      and using the INSERTER function to place new nodes on the open list.
   If finds a state satisfying GOALP, returns a solution path.
   If searches entire space without finding a goal, returns NIL."
  (if (funcall goalp start) (return (path start))
    (let ((open (list start))
	  closed
	  node)
      (loop
	(unless open (return-from search NIL))
	(setf node (pop open))
	(push node closed)
	(when trace (format t "~&Expanding: ~A~%" node))
	(when (funcall goalp node)
	  (return-from search (path node))) ; Success point A
	(dolist (op operators)
	  (let ((child (funcall op node)))
	    (when child
	      (when trace (format t "~&Generated: ~A~%" child))
	      (when (funcall goalp child)
		(return-from search (path child))) ; Success point B
	      (setf open (funcall inserter child open)))))))))
Questions
  1. How could search go into an infinite loop? (How could you know it won't?)
  2. Should goalp be tested at point A or B? Which is the first opportunity to test a given node?
  3. What to do if child is already on open?
  4. What to do if child is already on closed?
  5. How should inserter be defined?
  6. Is the search Complete? Will it find a solution whenever there is one?
  7. Is the search Optimal (Admissible)? Will it find a "best" solution when there are several? What is meant by "best"?
  8. What is the time complexity?
  9. What is the space complexity?

Example problem class---Water Jugs:
States:
(i j), contents of 3 gallon jug and 4 gallon jug
Operators:
  • f3: fill the 3 gallon jug from a tap
  • f4: fill the 4 gallon jug from a tap
  • e3: empty the 3 gallon jug down a drain
  • e4: empty the 4 gallon jug down a drain
  • p34: pour the contents of the 3 gallon jug into the 4 gallon jug until either the 3 gallon jug is empty or the 4 gallon jug is full
  • p43: pour the contents of the 4 gallon jug into the 3 gallon jug until either the 4 gallon jug is empty or the 3 gallon jug is full
Example problem:
(0 0) --> (0 2)

Search Methods
Uninformed (Blind) Search Methods
  • Depth-First
  • Breadth-First
  • Depth-Limited
  • Iterative Deepening

Chapter 4: Informed Search Methods

See Russell & Norvig's Slides for Informed Search

Let c(ni, nj) be the actual cost of a minimal cost path from ni to nj whenever there is a path from ni to nj.

Informed Search Methods, Conservative
Let g*(n) = c(s, n), where s is the start node. (Actual minimal cost from start to n.)

Let g(n) be the cost of the minimal cost path found so far from s to n.

  • Uniform Cost (Branch and Bound)
    keep open ordered by g, smallest first.

Informed Search Methods, Rash (or Greedy)
Let h*(n) = minngc(n, ng) over all goal nodes, ng. (Actual minimal cost from n to a goal.)

Let h(n) be an estimate of h*(n). (Heuristic function.)

  • Hill-Climbing
    Having expanded node n, choose next that child, c, of n with minimum h.
    Forget all nodes not chosen for expansion.
    If h(n) < h(c), terminate with n.

  • Best-First
    Keep open sorted by h, smallest first.

Informed Search Methods, Total path
Let f*(n) = g*(n) + h*(n). (Actual cost of minimal cost path from start to a goal through n. Notice that if s is the start node, ng is an optimal goal, and n is any node along an optimal path from s to ng, then f*(s) = f*(n) = f*(ng).)

Let f(n) = g(n) + h(n). (An estimate of f*.)

  • A*
    Keep open sorted by f, smallest first.

    Theorem: Optimality (Admissibility) of A*
    If
    • Every node n has a finite number of successors (possibly 0).
    • There is some e such that for all ni, nj, c(ni, nj) > e > 0.
    • For all n, h(n) <= h*(n).
    then A* is complete and optimal (admissible).

    Theorem:
    If for all ni, nj, where there is a path from ni to nj, h(ni) <= c(ni, nj) + h(nj),
    then whenever A* chooses a node n for expansion, g(n) = g*(n).

  • Iterative Deepening A* (IDA*)

  • Simplified Memory-Bounded A* (SMA*)

Constraint Satisfaction

See slides illustrating map coloring as depth-first (backtracking) search vs. forward checking.

See Russell & Norvig's Slides for Constraint Satisfaction.

Chapter 5: Game Playing

See Russell & Norvig's Slides for Chapter 5.

Minimax Theorem (Von Neumann and Morgenstern) applies to two person, zero sum, perfect information games.

Contemplate which move you'd pick, 1 or 2:

                 Y <---Your move
                / \
              1/   \2
              /     \
             O       O <---Your opponent's move
            3/\4   5/\6
            /  \   /  \
           W    L T   T <---Value to you

A general minimax search function:

(defun GameValue (state max?)
  "Returns the value of STATE to the player about to move.
   Uses MiniMax on the entire game tree.
   MAX? is T if max is to move; NIL if min is to move."
  ;; Assumes the folowing functions:
  ;; (terminal state): T if state represents the end of the game;
  ;;                   NIL otherwise.
  ;; (StateValue state): returns the value of the terminal STATE.
  ;; (successors state max?): returns a list of all successor states
  ;;                          given that MAX? is to move.
  (let ((pbv (if max? minusInfinity infinity)))
    (if (terminal state) (StateValue state)
      (dolist (successor (successors state max?) pbv)
	(setf pbv (if max? (max pbv (GameValue successor (not max?)))
		    (min pbv (GameValue successor (not max?)))))))))

A general minimax search function with alpha-beta pruning:

(defun ABGameValue (state max? alpha beta level)
  "Returns the value of STATE to the player about to move.
   Uses MiniMax with alpha-beta pruning.
   MAX? is T if max is to move; NIL if min is to move.
   ALPHA is the maximum value of maximizing ancestor states.
   BETA is the minimum value of minimizing ancestor states.
   LEVEL is the level of this state from the starting state."
  ;; Assumes the folowing functions:
  ;; (Quiescent state level): T if state a leaf of the search tree;
  ;;                          NIL otherwise.
  ;; (StaticValue state): returns the value of the STATE.
  ;; (successors state max?): returns a list of all successor states
  ;;                          given that MAX? is to move.
  (let ((pbv (if max? minusInfinity infinity)))
    (if (Quiescent state level max?) (StaticValue state)
      (dolist (successor (successors state max?) pbv)
	(when (if max? (>= pbv beta) (<= pbv alpha)) ; cutoff
	  (return pbv))
	(setf pbv
	  (if max?
	      (max pbv 
		   (ABGameValue successor
				(not max?)
				(max pbv alpha)
				beta
				(1+ level)))
	    (min pbv
		 (ABGameValue successor 
			      (not max?) 
			      alpha 
			      (min pbv beta) 
			      (1+ level)))))))))

Chapter 6: Agents that Reason Logically

See Russell & Norvig's Slides for Chapter 6.

See my paper, Propositional, First-Order And Higher-Order Logics: Basic Definitions, Rules of Inference, Examples.

See my notes on Wang's Algorithm in the slides for Foundations of Logic & Inference, p. 59. The code is readable on the web and is available at /projects/shapiro/AIclass/wang.

Chapter 7: First-Order Logic

See Russell & Norvig's Slides for Chapter 7.

See my paper, Propositional, First-Order And Higher-Order Logics: Basic Definitions, Rules of Inference, Examples.

See my slides for Foundations of Logic & Inference, starting at p. 82.

Taking account of change:
For an example of using successor-state axioms, see /projects/shapiro/AIclass/Projects/frame.snepslog.
For an example of removing wffs that are no longer true, see /projects/shapiro/AIclass/Projects/revise.snepslog.

You can run these two files by running SNePSLOG (see the instructions), and then, within the SNePSLOG read-eval-print loop, entering demo "file"
If you want, you may consult the SNePS 2.5 User's Manual, either the PS version, or the HTML version.

Chapter 8: Building a Knowledge Base

Read this chapter for the general approach to knowledge engineering, and for the issues that one must deal with in each of the discussed domains. However, don't bother trying to learn the complete details of the text's formalization of these domains.

If this approach to knowledge engineering seems like the approach to programming in a declarative language or in an object-oriented language, that is no coincidence---those languages came out of AI KR work.

Ontology: AI use of the term is not exactly the philosophical use. Philosophy: What there is. AI: Hierarchy of categories of things in the domain. "Tangled" Hierarchy. E.g., page 229:

                               Things
                                 /\
                                /  \
                               /    \
                              /      \
                           Animals  Agents
                              \      /
                               \    /
                                \  /
                                 \/
                               Humans

Reification: Turning an abstraction (or a predicate or function) into an object.

Category Hierarchy: Need to distinguish subcategory (subclass) from instance. A category can be both a subcategory and an instance. E.g. Dodoes are birds. but Dodoes are a genus.

Categories, classes, and collections (bunches) are different.

Property Inheritance: Distinguish inheritable properties of instances from non-inheritable properties of the category itself. E.g. Dodoes are flightless. but Dodoes are extinct. Structure of Subcategories, if c1 and c2 are subcategories of s:
   None: if i in c1 says nothing about whether or not i in c2
   Disjoint: if i in c1, i not in c2
   Exhaustive Decomposition: if i in s and i not in c1, i in c2
   Partion: if i in s, i in exactly one of c1 or c2

Necessary and sufficient conditions on membership in a category.
   Necessary: Dodoes are flightless birds.
   Sufficient: A rectangle is a quadrilateral
   Necessary & Sufficient: A person with a child is a parent

Mereology: Study of parts
Might want to distinguish different kinds of part/whole relations
   Assemblies, like a car assembled from originally separate parts
   Integral components, like fingers, hands, arms, bodies
   Components of collections, like dishes in a stack
   Portions, like pieces of a pie
   Substances & stuff, like gin and vermouth in a manhattan
   etc.

Places, events, processes, actions are complicated---see the text for a beginning.

Some issue regarding Time

Substances & Objects
An object passed through the "universal grinder" becomes a substance cat all over my lap
A portion of a substance is an object 3 glasses of water
A multiplicity of objects is a substance 40 acres of mountain lakes

Roles, like President of USA
Time slices, like John at age 10.

Intensional vs. extensional entities.
The morning star is the evening star.
George IV wanted to know if Scott was the author of Waverly.

Mental objects, like propositions reified.

Chapter 9: Inference in First-Order Logic

See Russell & Norvig's Slides for Chapter 9, Sections 1-4 and Sections 5-6.

Also see my slides for Foundations of Logic & Inference.

Chapter 10: Logical Reasoning Systems

Theorem Provers and Logic Programming Languages
Indexing: Avoids search through all rules to find a relevant one.
Backward chaining vs. Forward chaining: Difference is whether a rule, A => Q is accessed via its antecedent or its consequent.
Unification: Needed when backward chaining wh questions; Else pattern matching. Unification is correct pattern matching when both structures have variables.
Prolog: Uses Horn clauses, depth-first search, no occurs check, extra-logical constructs such as cut and semantic attachment.
Parallel processing possibilities: OR-parallelism for different applicable rules; AND-parallelism for conjunctive antecedents.
Compilation vs. interleaved Tell and Ask. (Is Prolog interactive?)

Theorem Provers: To prove wffs, not just conjunctions of atoms
Some use resolution, some use natural deduction.
Note missing rules of inference on p. 265, 266.

Production Systems
Working Memory: ground positive literals, or symbol structures
Rule Memory: pattern-action rules; Forward chaining.
Conflict Resolution: triggering vs. firing.
Rete Algorithm: Makes finding triggered rules efficient.

Semantic Networks and Frames
First semantic network in AI, 1966 Ph.D. dissertation by M. Ross Quillian: see separate figures.
Semantic nets of Collins and Quillian psychologically validated (except for fast negatives). Compare text, Fig. 10.7, p. 318.
Semantic problems with exceptions
Worse semantic problems with conflicting multiple inheritance ("Nixon diamond"). See text Fig. 10.9, p. 320.
Propositional semantic networks can be as expressive as first-order logic. See SNePS Figure and screen shot.
Frames: Slots and fillers; if-added, if-needed

Description Logics
TBox: Definitional, structural information

ABox: Assertional

TBox
Hierarchy of Concepts and Relations
Generic Concepts
Importance of Subsumption and Classification
Defined Concepts contain Necessary and Sufficient conditions
Primitive Concepts contain only Necessary conditions
Necessary: All x [C(x) -> P(x)]
Sufficient: All x [P(x) -> C(x)]

Individual Concepts are classes with a single element.

A Generic Concept is defined as a subconcept of others with certain roles.

ABox
Concepts provide Unary Predicates
Roles provide Binary Relations

Defining an arch

(cdef Arch
      (and (atleast 1 lintel)
           (atmost 1 lintel)
           (all lintel Block)
           (atleast 2 upright)
           (atmost 2 upright)
           (all upright Block)
           (sd NotTouch (upright objects))
           (sd Support (lintel supported)
                       (upright supporter))))

Managing Retractions, Assumptions, and Explanations
Justification-Based TMSs

Whenever a rule of inference is used to infer C from P and Q, record that P and Q are the "justifications" of C, so that later one can find P and Q from C, or find C from P and/or Q.

If one ever has a contradiction, P and ~P, one can then trace back through the justifications of P and ~P to find the original premises, and delete one of them.

Similarly, if belief in some proposition P is removed, one can trace forward through the propositions P justifies and remove belief in all dependent consequents, at least those which do not have some other justification.

JTMSs are often separate facilities from the problem solvers they support, and often only record justifications among atomic propositions.

A Negative: The paths of justifications sometimes form loops that prevent belief revision from being performed.

Example of a loop from [E. Charniak, C. Riesbeck, & D. McDermott, Artificial Intelligence Programming, Hillsdale, NJ: Lawrence Erlbaum, 1980, p 197.]
KB:
  • all(x)(Man(x) => Person(x))
  • all(x)(Person(x) => Human(x))
  • all(x)(Human(x) => Person(x))
  • Man(Fred)

Dependency Network:
Man(Fred) ---->o<---- all(x)(Man(x) => Person(x)
               |
               |
               v
        Person(Fred) --->o<---- all(x)(Person(x) => Human(x))
            ^            |
            |            |
            |            v
            o<----Human(Fred)
            ^
            |
            |
all(x)(Human(x) => Person(x)) 

Now if Man(Fred) is retracted, one justification of Person(Fred) goes away, but it has another justification!

A Positive: Justifications are useful for explanation.

Assumption-Based TMSs

ATMSs record with every consequent the original premises (assumptions) on which it depends. This eliminates the possibility of loops and the necessity of tracing through justifications to find the premises. Unfortunately, assumptions are not as useful as justifications for explanation.

A technique for keeping track of assumptions was borrowed from a technique used for Fitch-Style proofs in the Logic of Relevant Implication.

Chapter 11: Planning

See Russell & Norvig's Slides for Chapter 11.

Chapter 22: Agents that Communicate

See the small grammars at

  • /projects/shapiro/AIclass/grammar.prolog
  • /projects/shapiro/AIclass/grammar1.prolog
  • /projects/shapiro/AIclass/grammar3.prolog

Stuart C. Shapiro <shapiro@cse.buffalo.edu>