Logic: Datalog wrap-up CPSC 322 – Logic 5 Textbook §12.3 March 14, 2011.

Slides:



Advertisements
Similar presentations
Department of Computer Science Undergraduate Events More
Advertisements

Computer Science CPSC 322 Lecture 25 Top Down Proof Procedure (Ch 5.2.2)
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Mar, 4, 2015 Slide credit: some slides adapted from Stuart.
CPSC 322, Lecture 2Slide 1 Representational Dimensions Computer Science cpsc322, Lecture 2 (Textbook Chpt1) Sept, 6, 2013.
CPSC 322, Lecture 21Slide 1 Bottom Up: Soundness and Completeness Computer Science cpsc322, Lecture 21 (Textbook Chpt 5.2) February, 27, 2009.
CPSC 322, Lecture 23Slide 1 Logic: TD as search, Datalog (variables) Computer Science cpsc322, Lecture 23 (Textbook Chpt 5.2 & some basic concepts from.
CPSC 322, Lecture 19Slide 1 Propositional Logic Intro, Syntax Computer Science cpsc322, Lecture 19 (Textbook Chpt ) February, 23, 2009.
Outline Recap Knowledge Representation I Textbook: Chapters 6, 7, 9 and 10.
CPSC 322, Lecture 18Slide 1 Planning: Heuristics and CSP Planning Computer Science cpsc322, Lecture 18 (Textbook Chpt 8) February, 12, 2010.
CPSC 322, Lecture 11Slide 1 Constraint Satisfaction Problems (CSPs) Introduction Computer Science cpsc322, Lecture 11 (Textbook Chpt 4.0 – 4.2) January,
CPSC 322, Lecture 20Slide 1 Propositional Definite Clause Logic: Syntax, Semantics and Bottom-up Proofs Computer Science cpsc322, Lecture 20 (Textbook.
CPSC 322 Introduction to Artificial Intelligence September 20, 2004.
CPSC 322, Lecture 23Slide 1 Logic: TD as search, Datalog (variables) Computer Science cpsc322, Lecture 23 (Textbook Chpt 5.2 & some basic concepts from.
CPSC 322, Lecture 12Slide 1 CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12 (Textbook Chpt ) January, 29, 2010.
CPSC 322, Lecture 17Slide 1 Planning: Representation and Forward Search Computer Science cpsc322, Lecture 17 (Textbook Chpt 8.1 (Skip )- 8.2) February,
CPSC 322, Lecture 21Slide 1 Bottom Up: Soundness and Completeness Computer Science cpsc322, Lecture 21 (Textbook Chpt 5.2) March, 5, 2010.
CPSC 322, Lecture 31Slide 1 Probability and Time: Markov Models Computer Science cpsc322, Lecture 31 (Textbook Chpt 6.5) March, 25, 2009.
CPSC 322, Lecture 22Slide 1 Logic: Domain Modeling /Proofs + Top-Down Proofs Computer Science cpsc322, Lecture 22 (Textbook Chpt 5.2) March, 8, 2010.
CPSC 322, Lecture 32Slide 1 Probability and Time: Hidden Markov Models (HMMs) Computer Science cpsc322, Lecture 32 (Textbook Chpt 6.5) March, 27, 2009.
CPSC 322, Lecture 24Slide 1 Reasoning under Uncertainty: Intro to Probability Computer Science cpsc322, Lecture 24 (Textbook Chpt 6.1, 6.1.1) March, 15,
Slide 1 Logic: TD as search, Datalog (variables) Jim Little UBC CS 322 – CSP October 24, 2014 Textbook §5.2 and 12.
CPSC 322, Lecture 24Slide 1 Finish Logics… Reasoning under Uncertainty: Intro to Probability Computer Science cpsc322, Lecture 24 (Textbook Chpt 6.1, 6.1.1)
Planning: Wrap up CSP Planning. Logic: Intro CPSC 322 – Planning 3 Textbook §8.4, §5.1 March 2, 2011.
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
Computer Science CPSC 322 Lecture 25 Logic Wrap Up Intro to Probability Slide 1.
Slide 1 Logic: Domain Modeling /Proofs + Top-Down Proofs Jim Little UBC CS 322 – CSP October 22, 2014.
Computer Science CPSC 322 Lecture 3 AI Applications 1.
Slide 1 Constraint Satisfaction Problems (CSPs) Introduction Jim Little UBC CS 322 – CSP 1 September 27, 2014 Textbook §
Computer Science CPSC 502 Lecture 6 Finish Planning Start Logic (Ch 5)
Computer Science CPSC 322 Lecture 26 Uncertainty and Probability (Ch. 6.1, 6.1.1, 6.1.3)
CPSC 322, Lecture 22Slide 1 Logic: Domain Modeling /Proofs + Top-Down Proofs Computer Science cpsc322, Lecture 22 (Textbook Chpt 5.2) Oct, 26, 2010.
Constraint Satisfaction Problems (CSPs) CPSC 322 – CSP 1 Poole & Mackworth textbook: Sections § Lecturer: Alan Mackworth September 28, 2012.
Logic Programming Module 2AIT202 Website Lecturer: Dave Sharp Room: AG15
Logic: Intro & Propositional Definite Clause Logic CPSC 322 – Logic 1 Textbook §5.1 March 4, 2011.
Slide 1 Propositional Definite Clause Logic: Syntax, Semantics and Bottom-up Proofs Jim Little UBC CS 322 – CSP October 20, 2014.
CPSC 322, Lecture 23Slide 1 Logic: TD as search, Datalog (variables) Computer Science cpsc322, Lecture 23 (Textbook Chpt 5.2 & some basic concepts from.
Reasoning Under Uncertainty: Introduction to Probability CPSC 322 – Uncertainty 1 Textbook §6.1 March 16, 2011.
CPSC 322, Lecture 19Slide 1 (finish Planning) Propositional Logic Intro, Syntax Computer Science cpsc322, Lecture 19 (Textbook Chpt – 5.2) Oct,
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Oct, 30, 2015 Slide credit: some slides adapted from Stuart.
Computer Science CPSC 322 Lecture 22 Logical Consequences, Proof Procedures (Ch 5.2.2)
Arc Consistency CPSC 322 – CSP 3 Textbook § 4.5 February 2, 2011.
Slide 1 Propositional Logic Intro, Syntax Jim Little UBC CS 322 – CSP October 17, 2014 Textbook § – 5.2.
Logic: Proof procedures, soundness and correctness CPSC 322 – Logic 2 Textbook §5.2 March 7, 2011.
CPSC 322, Lecture 2Slide 1 Representational Dimensions Computer Science cpsc322, Lecture 2 (Textbook Chpt1) Sept, 7, 2012.
Domain Splitting, Local Search CPSC 322 – CSP 4 Textbook §4.6, §4.8 February 4, 2011.
Computing & Information Sciences Kansas State University Wednesday, 04 Oct 2006CIS 490 / 730: Artificial Intelligence Lecture 17 of 42 Wednesday, 04 October.
Computer Science CPSC 322 Lecture 16 Logic Wrap Up Intro to Probability 1.
Computer Science CPSC 322 Lecture 14 Intro to Logic (5.1, 5.1.1) 1.
CPSC 322, Lecture 22Slide 1 Logic: Domain Modeling /Proofs + Top-Down Proofs Computer Science cpsc322, Lecture 22 (Textbook Chpt 5.2) Oct, 30, 2013.
Constraint Satisfaction Problems (CSPs) Introduction
Logic: TD as search, Datalog (variables)
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Computer Science cpsc322, Lecture 20
Finish Logics… Reasoning under Uncertainty: Intro to Probability
Propositional Logic Intro, Syntax Computer Science cpsc322, Lecture 19
Propositional Logic Intro, Syntax Computer Science cpsc322, Lecture 19
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Propositional Definite Clause Logic: Syntax, Semantics, R&R and Proofs
Reasoning Under Uncertainty: Conditioning, Bayes Rule & Chain Rule
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 20
Logic: Top-down proof procedure and Datalog
Probability and Time: Markov Models
Assignment-2 due now Enterprise Architecture Conference Sat. Oct 27
Logic: Domain Modeling /Proofs + Computer Science cpsc322, Lecture 22
Probability and Time: Markov Models
Computer Science cpsc322, Lecture 20
Bottom Up: Soundness and Completeness
Domain Splitting CPSC 322 – CSP 4 Textbook §4.6 February 4, 2011.
Representations & Reasoning Systems (RRS) (2.2)
Presentation transcript:

Logic: Datalog wrap-up CPSC 322 – Logic 5 Textbook §12.3 March 14, 2011

Crisis in Japan There are resources available if you are affected –UBC counseling (Brock Hall) –Talk to me about anything regarding the course It is always good to be proactive me for an appointment: 2

Lecture Overview Invited Presentation: –Chris Fawcett on scheduling UBC's exams using SLS Recap: Top-down Proof Procedure Datalog Logics: big picture 3

Lecture Overview Invited Presentation: –Chris Fawcett on scheduling UBC's exams using SLS Recap: Top-down Proof Procedure Datalog Logics: big picture 4

5 Bottom-up vs. Top-down Key Idea of top-down: search backward from a query g to determine if it can be derived from KB. KB C g is proved if g  C BU never looks at the query g It derives the same C regardless of the query KB answer Query g Bottom-up Top-down TD performs a backward search starting at g

 1 : yes  e  f  3 : yes  Example for (successful) SLD derivation  0 : yes  a  2 : yes  e a  b  c.a  e  f.b  f  k. c  e.d  k e. f  j  e. f. j  c. Query: ?a Done. “Can we derive a?” -Answer:“Yes, we can”

Correspondence between BU and TD proofs If the following is a top-down (TD) derivation in a given KB, what would be the bottom-up (BU) derivation of the same query? TD derivation yes  a. yes  b  f. yes  b  g  h. yes  c  d  g  h. yes  d  g  h. yes  g  h. yes  h. yes . 7 BU derivation {} {h} {g,h} {d,g,h} {c,d,g,h} {b,c,d,g,h} {b,c,d,f,g,h} {a,b,c,d,f,g,h} Part of KB: a  b  f f  g  h b  c  d c. d. h. g.

Inference (Top-down/SLD resolution) – State: answer clause of the form yes  q 1 ...  q k – Successor function: all states resulting from substituting first atom a with b 1  …  b m if there is a clause a ← b 1  …  b m – Goal test: is the answer clause empty (i.e. yes  ) ? – Solution: the proof, i.e. the sequence of SLD resolutions – Heuristic function: number of atoms in the query clause Inference as Standard Search 8 a ← b ∧ c. a ← g. a ← h.b ← j. b ← k. d ← m. d ← p. f ← m. f ← p. g ← m. g ← f. k ← m. h ←m. p.

Lecture Overview Invited Presentation: –Chris Fawcett on scheduling UBC's exams using SLS Recap: Top-down Proof Procedure Datalog Logics: big picture 9

Datalog An extension of propositional definite clause (PDC) logic –We now have variables –We now have relationships between variables –We can write more powerful clauses, such as – We can ask generic queries, E.g. “which wires are connected to w 1 ?“ 10 live(W)  wire(W) ∧ connected_to(W,W 1 ) ∧ wire(W 1 ) ∧ live(W 1 ). ? connected_to(W, w 1 )

Datalog syntax A variable is a symbol starting with an upper case letter A constant is a symbol starting with lower-case letter or a sequence of digits. A predicate symbol is a symbol starting with a lower-case letter. A term is either a variable or a constant. Datalog expands the syntax of PDCL…. Examples: X, W 1 Examples: alan, w1 Examples: live, connected, part-of, in Examples: X, Y, alan, w1

Datalog Syntax (continued) An atom is a symbol of the form p or p(t 1 …. t n ) where p is a predicate symbol and t i are terms A definite clause is either an atom (a fact) or of the form: h ← b 1 ∧ … ∧ b m where h and the b i are atoms (Read this as ``h if b.'') A knowledge base is a set of definite clauses Examples: sunny, in(alan,X) Example: in(X,Z) ← in(X,Y) ∧ part-of(Y,Z)

Datalog Semantics Semantics still connect symbols and sentences in the language with the target domain. Main difference: need to create correspondence both between terms and individuals, as well as between predicate symbols and relations We won’t cover the formal definition of Datalog semantics, but if you are interested see and in the textbook

Example proof of a Datalog query in(alan, r123). part_of(r123,cs_building). in(X,Y)  part_of(Z,Y) & in(X,Z). Query: yes  in(alan, cs_building). yes  part_of(Z,cs_building), in(alan, Z). yes  in(alan, r123). yes  part_of(Z, r123), in(alan, Z). yes . Using clause: in(X,Y)  part_of(Z,Y) & in(X,Z), with Y = cs_building Using clause: part_of(r123,cs_building) with Z = r123 Using clause: in(alan, r123). Using clause: in(X,Y)  part_of(Z,Y) & in(X,Z). fail No clause with matching head: part_of(Z,r123).

Datalog: Top Down Proof Procedure Extension of Top-Down procedure for PDCL. How do we deal with variables? Idea: -Find clauses with heads that match the query -Substitute variable in the clause with the matching constant Example: We will not cover the formal details of this process (called unification) in(alan, r123). part_of(r123,cs_building). in(X,Y)  part_of(Z,Y) & in(X,Z). Query: yes  in(alan, cs_building). yes  part_of(Z,cs_building), in(alan, Z). in(X,Y)  part_of(Z,Y) & in(X,Z). with Y = cs_building

Example proof of a Datalog query in(alan, r123). part_of(r123,cs_building). in(X,Y)  part_of(Z,Y) & in(X,Z). Query: yes  in(alan, cs_building). yes  part_of(Z,cs_building), in(alan, Z). yes  in(alan, r123). yes  part_of(Z, r123), in(alan, Z). yes . Using clause: in(X,Y)  part_of(Z,Y) & in(X,Z), with Y = cs_building Using clause: part_of(r123,cs_building) with Z = r123 Using clause: in(alan, r123). Using clause: in(X,Y)  part_of(Z,Y) & in(X,Z). With Z = alan fail No clause with matching head: part_of(Z,r123).

One important Datalog detail In its SLD resolution proof, Datalog always chooses the first clause with a matching head it finds in KB What does that mean for recursive function definitions? 17 You cannot have recursive definitions You need tail recursion The clause(s) defining your base case(s) have to appear first in KB

One important Datalog detail In its SLD resolution proof, Datalog always chooses the first clause with a matching head it finds in KB What does that mean for recursive function definitions? -The clause(s) defining your base case(s) have to appear first in KB -Otherwise, you can get infinite recursions -This is similar to recursion in imperative programming languages 18

Tracing Datalog proofs in AIspace You can trace the example from the last slide in the AIspace Deduction Applet, using file Question 4 of assignment 3 asks you to use this applet 19

20 Datalog: queries with variables What would the answer(s) be? Query: in(alan, X1). in(alan, r123). part_of(r123,cs_building). in(X,Y)  part_of(Z,Y) & in(X,Z). Yes(X1)  in(alan, X1).

21 Datalog: queries with variables What would the answer(s) be? Yes(r123). Yes(cs_building). Query: in(alan, X1). You can trace the SLD derivation for this query in the AIspace Deduction Applet, using file in(alan, r123). part_of(r123,cs_building). in(X,Y)  part_of(Z,Y) & in(X,Z). Yes(X1)  in(alan, X1).

PDCL syntax & semantics - Verify whether a logical statement belongs to the language of propositional definite clauses - Verify whether an interpretation is a model of a PDCL KB. - Verify when a conjunction of atoms is a logical consequence of a KB Bottom-up proof procedure  Define/read/write/trace/debug the Bottom Up (BU) proof procedure  Prove that the BU proof procedure is sound and complete Top-down proof procedure  Define/read/write/trace/debug the Top-down (SLD) proof procedure (as a search problem) Datalog  Represent simple domains in Datalog  Apply the Top-down proof procedure in Datalog Learning Goals For Logic 22

Lecture Overview Invited Presentation: –Chris Fawcett on scheduling UBC's exams using SLS Recap: Top-down Proof Procedure Datalog Logics: big picture 23

24 Logics: Big picture Propositional Logics First-Order Logics Propositional Definite Clause Logics Semantics and Proof Theory Description Logics Cognitive Architectures Video Games Hardware Verification Product Configuration Ontologies Semantic Web Information Extraction Summarization Production Systems Tutoring Systems Satisfiability Testing (SAT) Software Verification PDCL Soundness & Completeness Datalog From CSP module

Logics: Big picture We only covered rather simple logics –There are much more powerful representation and reasoning systems based on logics There are many important applications of logic –For example, software agents roaming the web on our behalf Based on a more structured representation: the semantic web This is just one example for how logics are used 25

Example problem: automated travel agent Examples for typical queries –How much is a typical flight to Mexico for a given date? –What’s the cheapest vacation package to some place in the Caribbean in a given week? Plus, the hotel should have a white sandy beach and scuba diving If webpages are based on basic HTML –Humans need to scout for the information and integrate it –Computers are not reliable enough (yet?) Natural language processing can be powerful (see Watson!) But some information may be in pictures (beach), or implicit in the text, so simple approaches like Watson still don’t get 26

More structured representation: the Semantic Web Beyond HTML pages only made for humans Languages and formalisms based on logics that allow websites to include information in a more structured format –Goal: software agents that can roam the web and carry out sophisticated tasks on our behalf. –This is different than searching content for keywords and popularity! For further references, see, e.g. tutorial given at 2009 Semantic Technology Conference:

Examples of ontologies for the Semantic Web “Ontology”: logic-based representation of the world eClassOwl: eBusiness ontology –for products and services –75,000 classes (types of individuals) and 5,500 properties National Cancer Institute’s ontology: 58,000 classes Open Biomedical Ontologies Foundry: several ontologies –including the Gene Ontology to describe gene and gene product attributes in any organism or protein sequence annotation terminology and data OpenCyc project: a 150,000-concept ontology including –Top-level ontology describes general concepts such as numbers, time, space, etc –Hierarchical composition: superclasses and subclasses –Many specific concepts such as “OLED display”, “iPhone” 28

29 Course Overview Environment Problem Type Logic Planning Deterministic Stochastic Constraint Satisfaction Search Arc Consistency Search Logics STRIPS Variables + Constraints Variable Elimination Bayesian Networks Decision Networks Markov Processes Static Sequential Representation Reasoning Technique Uncertainty Decision Theory Course Module Variable Elimination Value Iteration Planning This concludes the logic module As CSP (using arc consistency)

30 Course Overview Environment Problem Type Logic Planning Deterministic Stochastic Constraint Satisfaction Search Arc Consistency Search Logics STRIPS Variables + Constraints Variable Elimination Bayesian Networks Decision Networks Markov Processes Static Sequential Representation Reasoning Technique Uncertainty Decision Theory Course Module Variable Elimination Value Iteration Planning For the rest of the course, we will consider uncertainty As CSP (using arc consistency)

Types of uncertainty (from Lecture 2) Sensing Uncertainty: – The agent cannot fully observe a state of interest – E.g.: Right now, how many people are in this room? In this building? Effect Uncertainty: – T he agent cannot be certain about the effects of its actions – E.g.: If I work hard, will I get an A? Motivation for uncertainty: in the real world, we almost always have to handle uncertainty (both types) – Deterministic domains are an abstraction Sometimes this abstraction enables much more powerful inference – Now we don’t make this abstraction anymore Our representations and reasoning techniques will now handle uncertainty 31

More motivation for uncertainty Interesting article: “The machine age” –by Peter Norvig (head of research at Google) –New York Post, 12 February 2011 – chine_age_tM7xPAv4pI4JslK0M1JtxIhttp:// chine_age_tM7xPAv4pI4JslK0M1JtxI –“The things we thought were hard turned out to be easier.” Playing grandmaster level chess, or proving theorems in integral calculus –“Tasks that we at first thought were easy turned out to be hard.” A toddler (or a dog) can distinguish hundreds of objects (ball, bottle, blanket, mother, etc.) just by glancing at them Very difficult for computer vision to perform at this level –“Dealing with uncertainty turned out to be more important than thinking with logical precision.” AI’s focus shifted from Logic to Probability in the late 1980s 32

Learning Goals For Logic PDCL syntax & semantics - Verify whether a logical statement belongs to the language of propositional definite clauses - Verify whether an interpretation is a model of a PDCL KB. - Verify when a conjunction of atoms is a logical consequence of a KB Bottom-up proof procedure  Define/read/write/trace/debug the Bottom Up (BU) proof procedure  Prove that the BU proof procedure is sound and complete Top-down proof procedure  Define/read/write/trace/debug the Top-down (SLD) proof procedure (as a search problem) Datalog  Represent simple domains in Datalog  Apply the Top-down proof procedure in Datalog Assignment 3 is due on Wednesday Posted short answer questions up to logic on WebCT (to be updated)