Logic: TD as search, Datalog (variables)

Slides:



Advertisements
Similar presentations
Computer Science CPSC 322 Lecture 25 Top Down Proof Procedure (Ch 5.2.2)
Advertisements

Big Ideas in Cmput366. Search Blind Search State space representation Iterative deepening Heuristic Search A*, f(n)=g(n)+h(n), admissible heuristics Local.
Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 20
Logic.
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 26Slide 1 Reasoning Under Uncertainty: Belief Networks Computer Science cpsc322, Lecture 27 (Textbook Chpt 6.3) March, 16, 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 20Slide 1 Propositional Definite Clause Logic: Syntax, Semantics and Bottom-up Proofs Computer Science cpsc322, Lecture 20 (Textbook.
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.
Knowledge Representation I (Propositional Logic) CSE 473.
Knoweldge Representation & Reasoning
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 22Slide 1 Logic: Domain Modeling /Proofs + Top-Down Proofs Computer Science cpsc322, Lecture 22 (Textbook Chpt 5.2) March, 8, 2010.
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,
Logic: Datalog wrap-up CPSC 322 – Logic 5 Textbook §12.3 March 14, 2011.
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.
Proof Systems KB |- Q iff there is a sequence of wffs D1,..., Dn such that Dn is Q and for each Di in the sequence: a) either Di is in KB or b) Di can.
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 502 Lecture 6 Finish Planning Start Logic (Ch 5)
CPSC 322, Lecture 22Slide 1 Logic: Domain Modeling /Proofs + Top-Down Proofs Computer Science cpsc322, Lecture 22 (Textbook Chpt 5.2) Oct, 26, 2010.
Logical Agents Logic Propositional Logic Summary
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.
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)
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
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.
1 Propositional Logic Limits The expressive power of propositional logic is limited. The assumption is that everything can be expressed by simple facts.
Proof Methods for Propositional Logic CIS 391 – Intro to Artificial Intelligence.
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.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
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
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
The Propositional Calculus
Planning: Representation and Forward Search
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21
Planning: Heuristics and CSP Planning
Planning: Heuristics and CSP Planning
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Planning: Representation and Forward Search
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 20
Logic: Top-down proof procedure and Datalog
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 22
Assignment-2 due now Enterprise Architecture Conference Sat. Oct 27
Logic: Domain Modeling /Proofs + Computer Science cpsc322, Lecture 22
Computer Science cpsc322, Lecture 20
Bottom Up: Soundness and Completeness
Bottom Up: Soundness and Completeness
Representations & Reasoning Systems (RRS) (2.2)
Planning: Representation and Forward Search
Bottom Up: Soundness and Completeness
Presentation transcript:

Logic: TD as search, Datalog (variables) Computer Science cpsc322, Lecture 23 (Textbook Chpt 5.2 & some basic concepts from Chpt 12) June, 8, 2017 Lecture 23 CPSC 322, Lecture 23

TopDown Proofs as search Datalog Lecture Overview Recap Top Down TopDown Proofs as search Datalog CPSC 322, Lecture 23

Top-down Ground Proof Procedure Key Idea: search backward from a query G to determine if it can be derived from KB. Single inference rule that yields a complete inference algorithm when coupled with any complete search algorithm "SL resolution with Definite clauses". For SL http://en.wikipedia.org/wiki/SLD_resolution (not really critical for this lecture) CPSC 322, Lecture 22

Top-down Proof Procedure: Basic elements Notation: An answer clause is of the form: yes ← a1 ∧ a2 ∧ … ∧ am Express query as an answer clause (e.g., query a1 ∧ a2 ∧ … ∧ am ) yes ← Rule of inference (called SLD Resolution) Given an answer clause of the form: yes ← a1 ∧ a2 ∧ … ∧ am and the clause: ai ← b1 ∧ b2 ∧ … ∧ bp You can generate the answer clause yes ← a1 ∧ … ∧ ai-1 ∧ b1 ∧ b2 ∧ … ∧ bp ∧ ai+1 ∧ … ∧ am Answer clause means the antecedent are true SLD Resolution of this answer clause on atom ai CPSC 322, Lecture 22

Successful Derivation: When by applying the inference rule you obtain the answer clause yes ← . a ← e ∧ f. a ← b ∧ c. b ← k ∧ f. c ← e. d ← k. e. f ← j ∧ e. f ← c. j ← c. Query: a (two ways) yes ← a. yes ← a. Sound and complete When it has derived the answer, you can read a bottom-up proof in the opposite direction. Every top-down derivation corresponds to a bottom-up proof, and every bottom-up proof has a corresponding top-down derivation. This equivalence can be used to show the soundness and completeness of the derivation procedure. CPSC 322, Lecture 22

TopDown Proofs as search Datalog Lecture Overview Recap Top Down TopDown Proofs as search Datalog CPSC 322, Lecture 23

Systematic Search in different R&R systems Constraint Satisfaction (Problems): State: assignments of values to a subset of the variables Successor function: assign values to a “free” variable Goal test: set of constraints Solution: possible world that satisfies the constraints Heuristic function: none (all solutions at the same distance from start) Planning (forward) : State possible world Successor function states resulting from valid actions Goal test assignment to subset of vars Solution sequence of actions Heuristic function empty-delete-list (solve simplified problem) Logical Inference (top Down) State answer clause Successor function states resulting from substituting one atom with all the clauses of which it is the head Goal test empty answer clause Solution start state Heuristic function ……………….. Allows useful general-purpose algorithms with more power than standard search algorithms CPSC 322, Lecture 11

Search Graph KB Heuristics? 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. Prove: ?← a ∧ d. Heuristics?

Search Graph KB A. Yes B. No C. It Depends 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. Prove: ?← a ∧ d. Possible Heuristic? Number of atoms in the answer clause Admissible? A. Yes B. No C. It Depends

Search Graph Heuristics? Prove: ?← a ∧ d. a ← h. b ← j. b ← k. d ← m. 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. Node selection heuristics? Number of atoms Heuristics for selecting atoms Often you want to select the atom that results in the fewest neighbors as this reduces the branching factor of the search Heuristics? CPSC 322, Lecture 23

Better Heuristics? If the body of an answer clause contains a symbol that does not match the head of any clause in the KB what should the most informative heuristic value for that answer clause be ? Zero Infinity Twice the number of clauses in the KB None of the above CPSC 322, Lecture 23

TopDown Proofs as search Datalog Lecture Overview Recap Top Down TopDown Proofs as search Datalog CPSC 322, Lecture 23

Representation and Reasoning in Complex domains It is often natural to consider individuals and their properties In complex domains expressing knowledge with propositions can be quite limiting up_s2 up_s3 ok_cb1 ok_cb2 live_w1 connected_w1_w2 up( s2 ) up( s3 ) ok( cb1 ) ok( cb2 ) live( w1) connected( w1 , w2 ) the propositions up s2, up s3, ok s2 have no internal structure. There is no notion that the proposition up s2 and up s3 are about the same relation, but with different individuals, or that up s2 and ok s2 are about the same switch. There is no notion of individuals and relations. An alternative is to explicitly represent the individual switches s1, s2, s3, and the properties or relations, up and ok. Using this representation, “switch s2 is up” is represented as up(s2). A binary relation, like connected to, can be used to relate two individuals, such as connected to(w1, s1) There is no notion that up_s2 up_s3 live_w1 connected_w1_w2 CPSC 322, Lecture 23

What do we gain…. By breaking propositions into relations applied to individuals? Express knowledge that holds for set of individuals (by introducing ) live(W) <- connected_to(W,W1) ∧ live(W1) ∧ wire(W) ∧ wire(W1). We can ask generic queries (i.e., containing ) Economy of symbols: 10 individuals and 1 binary relation can express…. connected_to(X,Y) 1000 wires ? connected_to(W, w1) CPSC 322, Lecture 23

Datalog vs PDCL (better with colors) CPSC 322, Lecture 23

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

Datalog Syntax (cont’d) An atom is a symbol of the form p or p(t1 …. tn) where p is a predicate symbol and ti are terms Examples: sunny, in(alan,X) A definite clause is either an atom (a fact) or of the form: h ← b1 ∧… ∧ bm where h and the bi are atoms (Read this as ``h if b.'') Example: in(X,Z) ← in(X,Y) ∧ part-of(Y,Z) A knowledge base is a set of definite clauses

Datalog: Top Down Proof Procedure in(alan, r123). part_of(r123,cs_building). in(X,Y)  part_of(Z,Y) ∧ in(X,Z). Extension of Top-Down procedure for PDCL. How do we deal with variables? Idea: Find a clause with head that matches the query Substitute variables in the clause with their matching constants Example: Query: yes  in(alan, cs_building). in(X,Y)  part_of(Z,Y) ∧ in(X,Z). with Y = cs_building X = alan yes  part_of(Z,cs_building) ∧ in(alan, Z).

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). Using clause: in(X,Y)  part_of(Z,Y) ∧ in(X,Z), with Y = cs_building X = alan yes  part_of(Z,cs_building) ∧ in(alan, Z). Using clause: part_of(r123,cs_building) with Z = r123 ?????? A. yes  part_of(Z, r123) ∧ in(alan, Z). B. yes  in(alan, r123). C. yes . D. None of the above

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). Using clause: in(X,Y)  part_of(Z,Y) ∧ in(X,Z), with Y = cs_building X = alan yes  part_of(Z,cs_building) ∧ in(alan, Z). Using clause: part_of(r123,cs_building) with Z = r123 yes  in(alan, r123). Using clause: in(alan, r123). Using clause: in(X,Y)  part_of(Z,Y) ∧ in(X,Z). With X = alan Y = r123 yes . yes  part_of(Z, r123), in(alan, Z). No clause with matching head: part_of(Z,r123). fail

Tracing Datalog proofs in AIspace You can trace the example from the last slide in the AIspace Deduction Applet at http://aispace.org/deduction/ using file ex-Datalog available in course schedule Question 4 of assignment 3 will ask you to use this applet

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

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

Logics in AI: Similar slide to the one for planning Propositional Definite Clause Logics Semantics and Proof Theory Satisfiability Testing (SAT) Propositional Logics First-Order Logics Description Logics Hardware Verification Production Systems Product Configuration Ontologies Cognitive Architectures Semantic Web Video Games Summarization Tutoring Systems Information Extraction CPSC 322, Lecture 8

Big Picture: R&R systems Environment Stochastic Deterministic Problem Arc Consistency Search Constraint Satisfaction Vars + Constraints SLS Static Belief Nets Logics Query Var. Elimination Search R&R Sys Representation and reasoning Systems Each cell is a R&R system STRIPS actions preconditions and effects Sequential Decision Nets STRIPS Var. Elimination Planning Search Markov Processes Representation Value Iteration Reasoning Technique CPSC 322, Lecture 2

Assignment-3: will be posted before Tue Next Class on Tue Intro to probability Random Variable Prob. Distribution Marginalization Conditional Probability Chain Rule Bayes' Rule Marginal and Conditional Independence Assignment-3: will be posted before Tue CPSC 322, Lecture 24

Full Propositional Logics (not for 322) DEFs. Literal: an atom or a negation of an atom Clause: is a disjunction of literals Conjunctive Normal Form (CNF): a conjunction of clauses INFERENCE: Convert all formulas in KB and in CNF Apply Resolution Procedure (at each step combine two clauses containing complementary literals into a new one) Termination No new clause can be added Two clause resolve into an empty clause KB entails alpha iff KB and (not alpha) is unsatisfiable CPSC 502, Lecture 6

Propositional Logics: Satisfiability (SAT problem) Does a set of formulas have a model? Is there an interpretation in which all the formulas are true? (Stochastic) Local Search Algorithms can be used for this task! Evaluation Function: number of unsatisfied clauses WalkSat: One of the simplest and most effective algorithms: Start from a randomly generated interpretation Pick an unsatisfied clause Pick an proposition to flip (randomly 1 or 2) To minimize # of unsatisfied clauses Randomly KB entails alpha iff KB and (not alpha) is unsatisfiable CPSC 502, Lecture 6

Full First-Order Logics (FOLs) We have constant symbols, predicate symbols and function symbols So interpretations are much more complex (but the same basic idea – one possible configuration of the world) constant symbols => individuals, entities predicate symbols => relations function symbols => functions INFERENCE: Semidecidable: algorithms exists that says yes for every entailed formulas, but no algorithm exists that also says no for every non-entailed sentence Resolution Procedure can be generalized to FOL KB entails alpha iff KB and (not alpha) is unsatisfiable CPSC 502, Lecture 6