Course Notes
Stuart C. Shapiro
Department of Computer Science
State University of New York at
Buffalo
See also, Russell & Norvig's Slides for Chapter 1.
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.
See pictures of a seriously proposed vacuum agent, the dustbot.
See Russell & Norvig's Slides for Chapter 3.
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)))))))))
search
go into an infinite loop? (How
could you know it won't?)
goalp
be tested at point A
or
B
? Which is the first opportunity to test a given node?
child
is already on open
?
child
is already on closed
?
inserter
be defined?
(i j)
, contents of 3 gallon jug and 4 gallon jug
(0 0)
--> (0 2)
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.
Let g(n) be the cost of the minimal cost path found so far from s to n.
open
ordered by g, smallest first.
Let h(n) be an estimate of h*(n). (Heuristic function.)
open
sorted by h, smallest first.
Let f(n) = g(n) + h(n). (An estimate of f*.)
open
sorted by f, smallest first.
See slides illustrating map coloring as depth-first (backtracking) search vs. forward checking.
See Russell & Norvig's Slides for Constraint Satisfaction.
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)))))))))
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
.
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.
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.
See Russell & Norvig's Slides for Chapter 9, Sections 1-4 and Sections 5-6.
Also see my slides for Foundations of Logic & Inference.
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.
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))))
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.
See Russell & Norvig's Slides for Chapter 11.
See the small grammars at
/projects/shapiro/AIclass/grammar.prolog
/projects/shapiro/AIclass/grammar1.prolog
/projects/shapiro/AIclass/grammar3.prolog