DOC PREVIEW
Berkeley COMPSCI 61A - Lecture 27

This preview shows page 1-2-3-18-19-36-37-38 out of 38 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 38 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 38 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 38 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 38 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 38 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 38 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 38 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 38 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 38 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS61A Lecture 27Clicker poll Slide 3Run (query) and tell it some factsQuery system goal:PowerPoint PresentationQuery: (?who is the parent of bart)Slide 8Query: (?who is the parent of bart)Query: (marge is the parent of ?x)Query: (marge is the parent of ?x)Query:Write a query that returns 0 resultsQuery: (female ?who)Query: (female ?who)Query System: andQuery: (and (?who is the parent of bart) (female ?who))Query: (and (?who is the parent of bart);q1 (female ?who)) ;q2Query 1: (?who is the parent of bart)Query 2: (female ?who)Slide 21Slide 22Slide 23Query: (and (?who is the parent of bart);q1 (female ?who)) ;q2(and (?who is the parent of bart) (female ?who))Query: (and (mona is the parent of ?x);q1 (?x is the parent of ?y)) ;q2Slide 27Slide 28andorSlide 31Slide 32Slide 33Slide 34Slide 35rulesSlide 37Slide 38CS61A Lecture 272011-08-04Colleen Lewis1Clicker poll  Have you been reading the provided solutions? A)To labs and/or homeworkB)To projectsC)To labs, homework & projectsD)No 2Clicker poll  Are you familiar with the characters from the TV show the Simpsons? A)Yes – very familiarB)Yes – the main charactersC)No – I’m not familiarD)No – I’ve never heard of the Simpsons3Run (query) and tell it some factsSTk> (load "query.scm")okaySTk> (query);;; Query input:(assert! (colleen likes cookies))Assertion added to data base.;;; Query input:4Like (mce): it starts an infinite loopTell the system factsQuery system goal:•Fill in the variables in the query (with all possible sets of values)•NEVER fill in the variables with an inconsistent set of variables56Query: (?who is the parent of bart)7TWO facts match: (?who is the parent of bart) ;query(homer is the parent of bart) ;fact(?who is the parent of bart) ;query(marge is the parent of bart) ;fact8Query: (?who is the parent of bart)?who = homer?who = margeThese are frames!9All facts?who = margeQEval ?who = homerQueryQuery: (?who is the parent of bart)Query: (marge is the parent of ?x)1011All factsQEvalQueryQuery: (marge is the parent of ?x)How many things did you figure out?A. 0 B. 1 C. 2 D. 3 E. ??12All factsQEvalQueryQuery: We can write a query that returns NOTHING•NO knowledge of ANY variables, return nothing.Write a query that returns 0 results13Query: (female ?who)1415All facts?who = monaQEvalQueryQuery: (female ?who)?who = jackie?who = marge?who = patty?who = selma?who = lisa?who = maggieQuery System:and16Query: (and (?who is the parent of bart)(female ?who))17Query Goals:•Fill in the variables in the query (with all possible sets of values)•NEVER fill in the variables with an inconsistent set of variablesLeft with TWO facts: (?who is the parent of bart) ;query(homer is the parent of bart) ;fact(?who is the parent of bart) ;query(marge is the parent of bart) ;fact18Query: (and (?who is the parent of bart);q1(female ?who)) ;q2?who = homer?who = marge19All facts?who = margeQEval ?who = homerQuery1Query 1: (?who is the parent of bart)20All factsQEvalQuery2Query 2: (female ?who)?who = marge?who = homerFor EACH frame we need to compare it to EVERY fact!(female ?who)(female mona) 21Query: (and (?who is the parent of bart);q1(female ?who)) ;q2?who = marge(female ?who)(female marge) … ?who = marge?who = marge?who = mona?who = marge?who = marge(female mona)(female jackie)(female marge)(female patty)(female selma)(female lisa)(female maggie)(female ling) 22Query: (and (?who is the parent of bart);q1(female ?who)) ;q2(female mona)(female jackie)(female marge)(female patty)(female selma)(female lisa)(female maggie)(female ling) ?who = marge?who = homer23All factsQEvalQuery2Query 2: (female ?who)?who = marge?who = homerFor EACH frame we need to compare it to EVERY fact! ?who = marge?who = margeQEval24All factsQuery2?who = marge?who = homer?who = marge?who = margeQEvalAll factsQuery1Query: (and (?who is the parent of bart);q1 (female ?who)) ;q2(and (?who is the parent of bart) (female ?who));;; Query results:(and (marge is the parent of bart) (female marge))25?who = marge?who = margeQuery Goals:•Fill in the variables in the query (with all possible sets of values)•NEVER fill in the variables with an inconsistent set of variablesQEval26All factsQuery2QEvalAll factsQuery1Query: (and (mona is the parent of ?x);q1 (?x is the parent of ?y)) ;q2How many results? A. 0 B. 1 C. 2 D. 3 E.?QEval27All factsQuery2QEvalAll factsQuery1Query: (and (mona is the parent of ?x);q1 (?x is the parent of ?y)) ;q2?x = homer?x = herb?x = homer?x = homer?y = bart?x = homer?x = homer?y = lisa?x = homer?x = homer?y = maggie;;; Query input:(and (mona is the parent of ?x) (?x is the parent of ?y));;; Query results:(and (mona is the parent of homer) (homer is the parent of bart))(and (mona is the parent of homer) (homer is the parent of lisa))(and (mona is the parent of homer) (homer is the parent of maggie))28?x = homer?x = homer?y = bart?x = homer?x = homer?y = lisa?x = homer?x = homer?y = maggieQEval29All factsQuery2QEvalAll factsQuery1and30QEvalAll factsQuery1orQEvalAll factsQuery2mergemerge31QEvalAll factsQuery1QEvalAll factsQuery2mergemerge(or (?x is the parent of bart) (?x is the parent of lisa))How many results do you think there SHOULD be? A. 2 B. 4 C.?32QEvalAll factsQuery1QEvalAll factsQuery2(or (?x is the parent of bart) (?x is the parent of lisa))mergemerge?x = marge?x = homer?x = marge?x = homer?x = marge?x = homer?x = marge?x = homer;;; Query input:(or (?x is the parent of bart) (?x is the parent of lisa));;; Query results:(or (marge is the parent of bart) (marge is the parent of lisa))(or (homer is the parent of bart) (homer is the parent of lisa))(or (marge is the parent of bart) (marge is the parent of lisa))(or (homer is the parent of bart) (homer is the parent of lisa))33?x = marge?x = homer?x = marge?x = homer;;; Query input:(or (?x is the parent of bart) (?x is the parent of ling));;; Query results:34;;; Query input:(or (?x is the parent of bart) (?x is the parent of ling));;; Query results:(or (marge is the parent of bart) (marge is the parent of ling))(or (homer is the parent of bart) (homer is the parent of ling))(or (selma is the parent of bart) (selma is the parent of ling))35?x = marge?x = homer?x = selmaQEval36All factsthe-bodyQEvalAll factsQueryrules;;; Query input:(assert! (rule <the-rule> <the-body>))When a rule (a type of fact) matches, do this:rules;;; Query input:(assert! (rule (parent-of-bart ?person)


View Full Document

Berkeley COMPSCI 61A - Lecture 27

Documents in this Course
Lecture 1

Lecture 1

68 pages

Midterm

Midterm

5 pages

Midterm

Midterm

6 pages

Lecture 35

Lecture 35

250 pages

Lecture 14

Lecture 14

125 pages

Lecture 2

Lecture 2

159 pages

Lecture 6

Lecture 6

113 pages

Lecture 3

Lecture 3

162 pages

Homework

Homework

25 pages

Lecture 13

Lecture 13

117 pages

Lecture 29

Lecture 29

104 pages

Lecture 11

Lecture 11

173 pages

Lecture 7

Lecture 7

104 pages

Midterm

Midterm

6 pages

Midterm

Midterm

6 pages

Lecture 8

Lecture 8

108 pages

Lab 4

Lab 4

4 pages

Lecture 7

Lecture 7

52 pages

Lecture 20

Lecture 20

129 pages

Lecture 15

Lecture 15

132 pages

Lecture 9

Lecture 9

95 pages

Lecture 30

Lecture 30

108 pages

Lecture 17

Lecture 17

106 pages

Load more
Download Lecture 27
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 27 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 27 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?