ES

From WikiZMSI

Spis treści

Lectures

Lecture 1 - Expert systems - the introduction

Useful links:

Lecture 2 - Propositional logic for defining the knowledge

The source of slides: Artificial Intelligence: A Modern Approach by Stuart Russell and Peter Norvig

Lecture 3 - First order logic for defining the knowledge

The source of slides: Artificial Intelligence: A Modern Approach by Stuart Russell and Peter Norvig

Lecture 4 - Inference in first-order logic

The source of slides: Artificial Intelligence: A Modern Approach by Stuart Russell and Peter Norvig

Labs

Topic 1 - Introduction to rules based programming

  1. Reading - chapter 1 Just the facts
  2. Basic facts
>(assert (color green))
>(assert (color red))
>(retract 0)
>(facts)
>(deffacts planets
  (planet Earth)
  (planet Mars)
  (planet Jupiter))


Topic 2 - Rules syntax

  1. Reading - chapter 1 Following the Rules
  2. Rules pattern:
(defrule rule-name "optional comment"
 (pattern 1)
 (pattern 2)
 ...
 (pattern N)
 =>
 (action 1)
 (action 2)
 ...
 (action M))
  1. Rules examples:
(defrule moon
 (planet Earth)
=>
 (assert (satellite natural Moon))
  1. Variables: ?x, $?x, ?, $?
    1. binding: implicit (fact ?name) or explicite (bind ?x (random 1 100))
    2. anonymous e.g. (name ? ? Kennedy)
    3. example
(defrule r1
=>
(printout t "What is the result of 5+4 " crlf)
(bind ?answer (read))
(if (= ?answer 9)
   then (printout t "It is correct " crlf)
   else (printout t "It is wrong " crlf)))

Topic 3 - Rules practice

Create the list of facts:

(deffacts start
 (animal dog)
 (animal cat)
 (animal duck)
 (animal turtle)
 (warm-blooded dog)
 (warm-blooded cat)
 (warm-blooded duck)
 (lays-eggs duck)
 (layd-eggs turtle)
 (child-of dog puppy)
 (child-of cat kitten)
 (child-of turtle hatchling))