Log Logic ic: : TD TD as se as sear arch ch, , Da Data talo log (v (var ariab ables) es) Computer ter Sc Science ce cpsc3 c322 22, , Lectur ture e 23 (Te Text xtbo book ok Chpt 5.2 & & some basic ic concep epts ts from Chpt 12) 12) Oct, ct, 31, 2012 CPSC 322, Lecture 23 Slide 1
Lecture cture Ov Overview view • Recap Top Down • TopDown Proofs as search • Datalog CPSC 322, Lecture 23 Slide 2
To Top-down own Gr Ground und Pr Proof of Pr Procedure cedure 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 of Procedure: cedure: Basic ic elements ments 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 renc 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 Derivati ation 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 view • Recap Top Down • TopDown Proofs as search • Datalog CPSC 322, Lecture 23 Slide 6
Syste stematic matic Sea earch h in in di diff ffer eren ent t R&R syste stems ms Constrai aint nt Satisfac facti tion on (Problems 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) : • 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) Logic ical l Infe feren rence ce (top 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 Heuristic? Number of atoms in the answer clause Admissible? Yes No
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
Lecture cture Ov Overview view • Recap Top Down • TopDown Proofs as search • Datalog CPSC 322, Lecture 23 Slide 11
Representation presentation and Reasoning soning in Complex mplex domains ains • It is often natural to • In complex domains consider indivi vidua uals ls and expressing knowledge their properti rties es with proposi sitio tions ns 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 12
What do we gain…. By breaking propositions into relations applied to individuals? • Express knowl wled edge ge that holds s for set of individ vidua uals ls (by introducing ) live(W) <- connected_to(W,W1) ∧ live(W1) ∧ wire(W) ∧ wire(W1). • We can ask generic ic queries es (i.e., containing ) ? connected_to(W, w 1 ) CPSC 322, Lecture 23 Slide 13
Datalog talog vs vs PD PDCL L (bett tter er wi with colors) s) CPSC 322, Lecture 23 Slide 14
Datalog: Da og: a r relati tional 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 Sy Syntax 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 n Pr Proof of Pr Procedure cedure 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). • We will not cover the formal details of this process, called unification . See P&M Section 12.4.2, p. 511 for the details.
Ex Example mple proof of of f a Datal talog og query ry 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 Datal talog og proofs ofs in AI AIsp space ace • 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 ries with th va variables 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 ries with th va variables 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 query yes(r123). in the AIspace Deduction Applet yes(cs_building).
Lo Logi gics s in in AI AI: : Si Simi mila lar r 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 22 Extraction
Big g Picture: ture: R&R s system 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 23 Technique
Midterm dterm review iew Av Avera erage ge 73 73.4 .4 Be Best 107 ! 20 studen ents ts > 90% 14 student ents s <50% How to learn more from midterm rm • Carefully examine your mistakes (and our feedback) • If you still do not see the correct answer/solution go back to your notes, the slides and the textbook • If you are still confused come to office hours with specific questions CPSC 322, Lecture 23 Slide 24
Recommend
More recommend