1 CSC 550: Introduction to Artificial Intelligence Spring 2004 AI programs  Eliza  knowledge representation  pattern-matching  Predicate Calculus 

Slides:



Advertisements
Similar presentations
Artificial Intelligence
Advertisements

1 Knowledge Representation Introduction KR and Logic.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Heuristic Search techniques
Inference Rules Universal Instantiation Existential Generalization
1 Programming Languages (CS 550) Mini Language Interpreter Jeremy R. Johnson.
Inference and Reasoning. Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and.
Logic Use mathematical deduction to derive new knowledge.
1 CSC 550: Introduction to Artificial Intelligence Spring 2004 More neural nets  neural net (backpropagation) examples  associative memory Hopfield networks.
13 Automated Reasoning 13.0 Introduction to Weak Methods in Theorem Proving 13.1 The General Problem Solver and Difference Tables 13.2 Resolution.
Knowledge Representation Methods
ISBN Chapter 3 Describing Syntax and Semantics.
Logic & Prolog  predicate calculus syntax: terms, predicates, sentences semantics: interpretations, logical consequence, inference rules, proof procedures.
Artificial Intelligence Lecture 2. Logic & Prolog Predicate calculus –syntax: terms, predicates, sentences –semantics: interpretations, logical consequence,
CPSC 322 Introduction to Artificial Intelligence September 15, 2004.
CSE (c) S. Tanimoto, 2008 Propositional Logic
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
CPSC 322 Introduction to Artificial Intelligence September 20, 2004.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Lecture 9 Jim Martin.
1 CSC 550: Introduction to Artificial Intelligence Fall 2004 Scheme programming  S-expressions: atoms, lists, functional expressions, evaluation  primitive.
Logical Agents Chapter 7. Why Do We Need Logic? Problem-solving agents were very inflexible: hard code every possible state. Search is almost always exponential.
Describing Syntax and Semantics
1 CSC 550: Introduction to Artificial Intelligence Fall 2004 heuristics & informed search  heuristics  hill-climbing bold + informed search potential.
Artificial Intelligence Introduction (2). What is Artificial Intelligence ?  making computers that think?  the automation of activities we associate.
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
Inference is a process of building a proof of a sentence, or put it differently inference is an implementation of the entailment relation between sentences.
Systems Architecture I1 Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they.
CSC3315 (Spring 2009)1 CSC 3315 Programming Paradigms Scheme Language Hamid Harroud School of Science and Engineering, Akhawayn University
Declarative vs Procedural Programming  Procedural programming requires that – the programmer tell the computer what to do. That is, how to get the output.
110/19/2015CS360 AI & Robotics AI Application Areas  Neural Networks and Genetic Algorithms  These model the structure of neurons in the brain  Humans.
1 Sections 1.5 & 3.1 Methods of Proof / Proof Strategy.
Pattern-directed inference systems
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Slide 1 Propositional Definite Clause Logic: Syntax, Semantics and Bottom-up Proofs Jim Little UBC CS 322 – CSP October 20, 2014.
ARTIFICIAL INTELLIGENCE DR. ABRAHAM AI a field of computer science that is concerned with mechanizing things people do that require intelligent.
Machine Learning Chapter 5. Artificial IntelligenceChapter 52 Learning 1. Rote learning rote( โรท ) n. วิถีทาง, ทางเดิน, วิธีการตามปกติ, (by rote จากความทรงจำ.
1 CS 385 Fall 2006 Chapter 1 AI: Early History and Applications.
CS4026 Formal Models of Computation Part II The Logic Model Lecture 2 – Prolog: History and Introduction.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Automated Reasoning Early AI explored how to automate several reasoning tasks – these were solved by what we might call weak problem solving methods as.
CS6133 Software Specification and Verification
Computer Science CPSC 322 Lecture 22 Logical Consequences, Proof Procedures (Ch 5.2.2)
1/32 This Lecture Substitution model An example using the substitution model Designing recursive procedures Designing iterative procedures Proving that.
11 Artificial Intelligence CS 165A Thursday, October 25, 2007  Knowledge and reasoning (Ch 7) Propositional logic 1.
Chapter 7. Propositional and Predicate Logic Fall 2013 Comp3710 Artificial Intelligence Computing Science Thompson Rivers University.
Knowledge Representation Fall 2013 COMP3710 Artificial Intelligence Computing Science Thompson Rivers University.
Logic: Proof procedures, soundness and correctness CPSC 322 – Logic 2 Textbook §5.2 March 7, 2011.
1 Programming Languages (CS 550) Lecture 2 Summary Mini Language Interpreter Jeremy R. Johnson.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
Lecture 041 Predicate Calculus Learning outcomes Students are able to: 1. Evaluate predicate 2. Translate predicate into human language and vice versa.
1 Section 7.1 First-Order Predicate Calculus Predicate calculus studies the internal structure of sentences where subjects are applied to predicates existentially.
COMP 412, FALL Type Systems C OMP 412 Rice University Houston, Texas Fall 2000 Copyright 2000, Robert Cartwright, all rights reserved. Students.
Artificial Intelligence Logical Agents Chapter 7.
Chapter 7. Propositional and Predicate Logic
Functional Programming Languages
CS 4700: Foundations of Artificial Intelligence
Knowledge Representation
Mini Language Interpreter Programming Languages (CS 550)
The Metacircular Evaluator
Logic Use mathematical deduction to derive new knowledge.
CPSC 322 Introduction to Artificial Intelligence
The Metacircular Evaluator (Continued)
Chapter 7. Propositional and Predicate Logic
This Lecture Substitution model
Representations & Reasoning Systems (RRS) (2.2)
Presentation transcript:

1 CSC 550: Introduction to Artificial Intelligence Spring 2004 AI programs  Eliza  knowledge representation  pattern-matching  Predicate Calculus  logical deduction  Prolog  logic programming

2 Weizenbaum's Eliza In 1965, Joseph Weizenbaum wrote a program called Eliza  intended as a critique on Weak AI researchers of the time  utilized a variety of programming tricks to mimic a Rogerian psychotherapist USER: Men are all alike. ELIZA: In what way. USER: They are always bugging us about one thing or another. ELIZA: Can you think of a specific example? USER: Well, my boyfriend made me come here. ELIZA: Your boyfriend made you come here. USER: He says I am depressed most of the time. ELIZA: I am sorry to hear you are depressed.. Eliza's knowledge consisted of a set of rules  each rule described a possible pattern to the user's entry & possible responses  for each user entry, the program searched for a rule that matched then randomly selected from the possible responses  to make the responses more realistic, they could utilize phrases from the user's entry

3 Eliza rules in Scheme (define ELIZA-RULES '((((VAR X) hello (VAR Y)) (how do you do. please state your problem)) (((VAR X) computer (VAR Y)) (do computers worry you) (what do you think about machines) (why do you mention computers) (what do you think machines have to do with your problem)) (((VAR X) name (VAR Y)) (i am not interested in names)). (((VAR X) are you (VAR Y)) (why are you interested in whether i am (VAR Y) or not) (would you prefer it if i weren't (VAR Y)) (perhaps i am (VAR Y) in your fantasies)).. (((VAR X)) (very interesting) (i am not sure i understand you fully) (what does that suggest to you) (please continue) (go on) (do you feel strongly about discussing such things)))) each rule is written as a list -- SURPRISE! : (USER-PATTERN1 RESPONSE-PATTERN1-A RESPONSE-PATTERN1-B … ) (VAR X) specifies a variable – part of pattern that can match any text

4 Eliza code (define (eliza) (begin (display 'Eliza>) (display (apply-rule ELIZA-RULES (read))) (newline) (eliza))) top-level function: display prompt, read user entry find, apply & display matching rule recurse to handle next entry (define (apply-rule rules input) (let ((result (pattern-match (caar rules) input '()))) (if (equal? result 'failed) (apply-rule (cdr rules) input) (apply-substs (switch-viewpoint result) (random-ele (cdar rules)))))) e.g., > (pattern-match '(i hate (VAR X)) '(i hate my computer) '()) (((var x) <-- my computer)) > (apply-rule '(((i hate (VAR X)) (why do you hate (VAR X)) (calm down)) ((VAR X) (please go on) (say what))) '(i hate my computer)) (why do you hate your computer) to find and apply a rule pattern match with variables if no match, recurse on cdr otherwise, pick a random response & switch viewpoint of words like me/you

5 Eliza code (cont.) (define (apply-substs substs target) (cond ((null? target) '()) ((and (list? (car target)) (not (variable? (car target)))) (cons (apply-substs substs (car target)) (apply-substs substs (cdr target)))) (else (let ((value (assoc (car target) substs))) (if (list? value) (append (cddr value) (apply-substs substs (cdr target))) (cons (car target) (apply-substs substs (cdr target)))))))) (define (switch-viewpoint words) (apply-substs '((i <-- you) (you <-- i) (me <-- you) (you <-- me) (am <-- are) (are <-- am) (my <-- your) (your <-- my) (yourself <-- myself) (myself <-- yourself)) words)) e.g., > (apply-substs '(((VAR X) <-- your computer)) '(why do you hate (VAR X))) (why do you hate your computer) > (switch-viewpoint '(((VAR X) <-- my computer))) (((var x) <-- your computer))

6 In-class exercise modifications to Eliza? additions to Eliza?

7 Symbolic AI "Good Old-Fashioned AI" relies on the Physical Symbol System Hypothesis : intelligent activity is achieved through the use of symbol patterns to represent the problem operations on those patterns to generate potential solutions search to select a solution among the possibilities an AI representation language must  handle qualitative knowledge  allow new knowledge to be inferred from facts & rules  allow representation of general principles  capture complex semantic meaning  allow for meta-level reasoning e.g., Predicate Calculus

8 Predicate calculus: syntax the predicate calculus (PC) is a language for representing knowledge, amenable to reasoning using inference rules the syntax of a language defines the form of statements  the building blocks of statements in the PC are terms and predicates terms denote objects and properties dave redBlock happy X Person predicates define relationships between objects mother/1 above/2 likes/2  sentences are statements about the world male(dave) parent(dave, jack) ¬happy(chris) parent(dave, jack)  parent(dave, charlie) happy(chris)  ¬happy(chris) healthy(kelly)  happy(kelly)  X (healthy(X)  happy(X))  X parent(dave, X)

9 Predicate calculus: semantics the semantics of a language defines the meaning of statements  must focus on a particular domain (universe of objects) terms are assigned values from the domain predicate symbols are assigned mappings from arguments to true/false  an interpretation assigns true/false value to sentences based on domain mappings e.g. DOMAIN: students in this class mike, sean, pengynan, ken, cedric, richard : mapped to actual people undergrad/1 & grad/1: map a student to true if right classification, else false male/1 & female/1: map a student to true if right gender, else false undergrad(sean) male(ken);;; true if predicate maps objects to true ¬grad(mike) ¬female(cedric) ;;; ¬X is true if X is false undergrad(pengynan)  undergrad(richard) ;;; X  Y is true if X is true and Y is true undergrad(mike)  grad(sean) ;;; X  Y is true if X is true or Y is true  X (male(X)  female(X)) ;;;  X S is true if S is true for all X  G undergrad(G);;;  X S is true if S is true for all X  X (undergrad(X)  ¬ grad(X));;; X  Y is true if

10 Predicate calculus: logical deduction the semantics of the predicate calculus provides a basis for a formal theory of logical inference  S is a logical consequence of a {S 1, …, S n } if every interpretation that makes {S 1, …, S n } true also makes S true a proof procedure can automate the derivation of logical consequences  a proof procedure is a combination of inference rules and an algorithm for applying the rules to generate logical consequences  example inference rules: Modus Ponens: if S 1 and S 1  S 2 are true, then infer S 2 And Elimination: if S 1  S 2 is true, then infer S 1 and infer S 2 And Introduction: if S 1 and S 2 are true, then infer S 1  S 2 Universal Instantiation: if  X p(X) is true, then infer p(a) for any a

11 Logic programming the Prolog programming language is based on logical deduction  programs are collections of facts and rules of the form: P 1  …  P n  C  a simple but efficient proof procedure is built into the Prolog interpreter repeatedly use rules to reduce goals to subgoals, eventually to facts logic programming : computation = logical deduction from program statements FACTS: itRains isCold RULES:itSnows  isCold itRains  getWet isCold  getWet  getSick GOAL:getSick  according to first rule, can reduce getSick isCold  getWet  isCold is a fact getWet  according to second rule, can reduce get_wet itRains  itRains is a fact DONE (getSick is a logical consequence) FACTS: human(socrates) RULES:  P (human(P)  mortal(P)) GOAL:mortal(socrates) according to first rule (when  P = socrates), can reduce mortal(socrates) human(socrates)  is a fact DONE (human(socrates) is a logical consequence)

12 Prolog deduction in Scheme we can implement a simplified version of Prolog's deduction in Scheme  represent facts and rules as lists – SURPRISE!  collect all knowledge about a situation (facts & rules) in a single list (define KNOWLEDGE '((itRains <-- ) (isCold <-- ) (isCold <-- itSnows) (getSick <-- isCold getWet) (getWet <-- itRains)))  note: facts are represented as rules with no premises  for simplicity: we will not consider variables (but not too difficult to extend)  want to be able to deduce new knowledge from existing knowledge > (deduce 'itRains KNOWLEDGE) #t > (deduce 'getWet KNOWLEDGE) #t > (deduce 'getSick KNOWLEDGE) #t > (deduce '(getSick itSnows) KNOWLEDGE) #f

13 Prolog deduction in Scheme (cont.) our program will follow the approach of Prolog  start with a goal or goals to be derived (i.e., shown to follow from knowledge)  pick one of the goals (e.g., leftmost), find a rule that reduces it to subgoals, and replace that goal with the new subgoals (getSick)  (isCold getWet) ;;; via (getSick <-- isCold getWet)  (getWet) ;;; via (isCold <-- )  (itRains) ;;; via (getWet <-- itRains)  ;;; via (itRains <-- )  finding a rule that matches is not hard, but there may be more than one QUESTION: how do you choose? ANSWER: you don't! you have to be able to try every possibility  must maintain a list of goal lists, any of which is sufficient to derive original goal ((getSick))  ((isCold getWet)) ;;; reduces only goal list  ((itSnows getWet)(getWet)) ;;; introduces 2 goal lists ;;; since 2 matches  ((getWet)) ;;; first goal list is dead end  ((itRains)) ;;; so go to second goal list  (()) ;;; no remaining goals in list

14 Deduction in Scheme (define (deduce goal known) (define (deduce-any goal-lists) (cond ((null? goal-lists) #f) ((null? (car goal-lists)) #t) (else (deduce-any (append (extend (car goal-lists) known) (cdr goal-lists)))))) (define (extend anded-goals known-step) (cond ((null? known-step) '()) ((equal? (car anded-goals) (caar known-step)) (cons (append (cddar known-step) (cdr anded-goals)) (extend anded-goals (cdr known-step)))) (else (extend anded-goals (cdr known-step))))) (if (list? goal) (deduce-any (list goal)) (deduce-any (list (list goal))))) deduce first turns user's goal into a list of goal lists, (deduce 'itRains X) calls (deduce-any '((itRains)) X) (deduce '(getSick itSnows) X) calls (deduce-any '((getSick itSnows)) X) deduce-any takes a list of goal lists, returns #t if any goal list is derivable, else #f (deduce-any '((itRains)))  #t (deduce-any '((getSick itSnows)(itRains)))  #t (deduce-any '((getSick itSnows)(itSnows)))  #f exend reduces a goal list every possible way (extend '(isCold getWet) KNOWLEDGE)  ((getWet) (itSnows getWet))

15 Next week… AI as search  problem states, state spaces  uninformed search strategies  depth first search  depth first search with cycle checking  breadth first search  iterative deepening Read Chapter 3 Be prepared for a quiz on  this week’s lecture (moderately thorough)  the reading (superficial)