Log Logic ic: : TD TD as se as sear arch ch, , Da Data talo log (v (var ariab ables) es) Co Computer ter Sc Scienc nce e cpsc sc322 322, , Lectu cture e 23 (Te Text xtbo book ok Chpt 5.2 & & some basic sic conce cepts pts from Ch Chpt 12) 12) Nov, No , 1, 2013 CPSC 322, Lecture 23 Slide 1
Lecture cture Ov Overview rview • Recap Top Down • TopDown Proofs as search • Datalog CPSC 322, Lecture 23 Slide 2
To Top-down own Gr Ground ound Proof oof Proce cedure dure Ke Key Idea: a: search backward from a query G to determine if it can be derived from KB . CPSC 322, Lecture 22 Slide 3
To Top-down down Proof oof Procedure: ocedure: Basic sic elements ements Not otat ation ion : An answer clause is of the form: yes ← a 1 ∧ a 2 ∧ … ∧ a m Expres Ex ess s query as an answer clause (e.g., query a 1 ∧ a 2 ∧ … ∧ a m ) yes ← Ru Rule of infere erenc nce (called SLD Resolution) Given an answer clause of the form: yes ← a 1 ∧ a 2 ∧ … ∧ a m and the clause: a i ← b 1 ∧ b 2 ∧ … ∧ b p You can generate the answer clause yes ← a 1 ∧ … ∧ a i-1 ∧ b 1 ∧ b 2 ∧ … ∧ b p ∧ a i+1 ∧ … ∧ a m CPSC 322, Lecture 22 Slide 4
• Su Succes essful sful Deriva vation on : 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. CPSC 322, Lecture 22 Slide 5
Lecture cture Ov Overview rview • Recap Top Down • TopDown Proofs as search • Datalog CPSC 322, Lecture 23 Slide 6
Syste stematic matic Sea earch ch in in di diff ffere erent nt R&R R sys ystems tems Constrai aint nt Satisfac facti tion on (Probl blems ems): • 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) Planni nning ng (forward) d) : • 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 l Infe nferen rence ce (top p Do Down wn) • 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 ……………….. CPSC 322, Lecture 11 Slide 7
Search Graph KB 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. Heuris istics? tics?
Search Graph KB 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 ble He Heuristi stic? c? Number of atoms in the answer clause Ad Admissi issible ble? A. Yes B. No C. It Depends
Search Graph Prove: ? ← a ∧ d. 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. Heuris istics? tics? CPSC 322, Lecture 23 Slide 10
Better tter Heuristics? uristics? 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 ? A. Zero B. Infinity C. Twice the number of clauses in the KB D. None of the above CPSC 322, Lecture 23 Slide 11
Lecture cture Ov Overview rview • Recap Top Down • TopDown Proofs as search • Datalog CPSC 322, Lecture 23 Slide 12
Represent presentation ation and d Reasoning asoning in Complex mplex domains mains • It is often natural to • In complex domains consider indiv ivid idua uals ls and expressing knowledge their proper erti ties es with propos ositi ition ons can be quite limiting up_s 2 up( s 2 ) up_s 3 up( s 3 ) ok_cb 1 ok( cb 1 ) ok_cb 2 ok( cb 2 ) live_w 1 live( w 1 ) connected_w 1 _w 2 connected( w 1 , w 2 ) There is no notion that up_s 2 live_w 1 up_s 3 connected_w 1 _w 2 CPSC 322, Lecture 23 Slide 13
What do we gain…. By breaking propositions into relations applied to individuals? • Express knowl wled edge ge that holds ds for set of indivi ividua duals ls (by introducing ) live(W) <- connected_to(W,W1) ∧ live(W1) ∧ wire(W) ∧ wire(W1). • We can ask generic ric queri ries es (i.e., containing ) ? connected_to(W, w 1 ) CPSC 322, Lecture 23 Slide 14
Datalog talog vs vs PDCL CL (better tter wi with colors) s) CPSC 322, Lecture 23 Slide 15
Datalog: Da og: a r relati ational nal 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 talog Syn yntax tax (co cont nt ’ d) 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 Examples: sunny, in(alan,X) 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 .'') Example: in(X,Z) ← in(X,Y) ∧ part-of(Y,Z) A knowledge base is a set of definite clauses
Datalog talog: : To Top Down wn Proof oof Proce cedure dure 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).
Exa xample mple proof oof of f a Datalog talog query ery 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
Exa xample mple proof oof of f a Datalog talog query ery 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(X,Y) Using clause: part_of(Z,Y) ∧ in(X,Z). in(alan, r123). With X = alan Y = r123 yes . yes part_of(Z, r123), in(alan, Z). No clause with matching head: fail part_of(Z,r123).
Tr Tracing cing Datalog talog proofs oofs in AIs Ispace pace • 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 asks you to use this applet
Datalog: talog: queries eries with th va variable iables 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: talog: queries eries with th va variable iables 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? Again, you can trace the SLD derivation for this yes(r123). query in the AIspace Deduction Applet yes(cs_building).
Lo Logi gics s in in AI AI: : Si Simi milar lar sli lide de to to th the e on one f e for or pl plan anni ning ng Propositional Definite Semantics and Proof Clause Logics Theory Satisfiability Testing Propositional First-Order (SAT) Logics Logics Description Hardware Verification Production Systems Logics Product Configuration Ontologies Cognitive Architectures Semantic Web Video Games Summarization Tutoring Systems Information CPSC 322, Lecture 8 Slide 24 Extraction
Big g Picture: cture: R&R R s systems tems En Enviro ronm nmen ent Stochastic Deterministic Pr Problem em Arc Consistency Search Constraint Vars + Satisfaction Constraints SLS Static Belief Nets Logics Query Var. Elimination Search Decision Nets Sequential STRIPS Var. Elimination Planning Markov Processes Search Representation Value Iteration Reasoning CPSC 322, Lecture 2 Slide 25 Technique
Recommend
More recommend