Log Logic ic: : TD TD as se as sear arch ch, , Da Data talo - - PowerPoint PPT Presentation

log logic ic td td as se as sear arch ch da data talo log
SMART_READER_LITE
LIVE PREVIEW

Log Logic ic: : TD TD as se as sear arch ch, , Da Data talo - - PowerPoint PPT Presentation

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


slide-1
SLIDE 1

CPSC 322, Lecture 23 Slide 1

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

  • k Chpt 5.2 &

& some basic sic conce cepts pts from Ch Chpt 12) 12)

No Nov, , 1, 2013

slide-2
SLIDE 2

CPSC 322, Lecture 23 Slide 2

Lecture cture Ov Overview rview

  • Recap Top Down
  • TopDown Proofs as search
  • Datalog
slide-3
SLIDE 3

CPSC 322, Lecture 22 Slide 3

To Top-down

  • wn Gr

Ground

  • und Proof
  • of Proce

cedure dure

Ke Key Idea: a: search backward from a query G to determine if it can be derived from KB.

slide-4
SLIDE 4

CPSC 322, Lecture 22 Slide 4

To Top-down down Proof

  • of Procedure:
  • cedure: Basic

sic elements ements

Not

  • tat

ation ion: An answer clause is of the form:

yes ← a1 ∧ a2 ∧ … ∧ am

Ru Rule of infere erenc nce (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

Ex Expres ess s query as an answer clause (e.g., query a1 ∧ a2 ∧ … ∧ am )

yes ←

slide-5
SLIDE 5

CPSC 322, Lecture 22 Slide 5

  • Su

Succes essful sful Deriva vation

  • n: When by applying the inference

rule you obtain the answer clause yes ← . Query: a (two ways) yes ← a. yes ← a. a ← e ∧ f. a ← b ∧ c. b ← k ∧ f. c ← e. d ← k. e. f ← j ∧ e. f ← c. j ← c.

slide-6
SLIDE 6

CPSC 322, Lecture 23 Slide 6

Lecture cture Ov Overview rview

  • Recap Top Down
  • TopDown Proofs as search
  • Datalog
slide-7
SLIDE 7

CPSC 322, Lecture 11 Slide 7

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

  • n (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 ………………..
slide-8
SLIDE 8

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.

KB Heuris istics? tics?

slide-9
SLIDE 9

Search Graph

Possible ble He Heuristi stic? c? Number of atoms in the answer clause Ad Admissi issible ble? 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.

KB

  • A. Yes
  • B. No
  • C. It Depends
slide-10
SLIDE 10

CPSC 322, Lecture 23 Slide 10

Search Graph

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?

slide-11
SLIDE 11

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

slide-12
SLIDE 12

CPSC 322, Lecture 23 Slide 12

Lecture cture Ov Overview rview

  • Recap Top Down
  • TopDown Proofs as search
  • Datalog
slide-13
SLIDE 13

CPSC 322, Lecture 23 Slide 13

Represent presentation ation and d Reasoning asoning in Complex mplex domains mains

  • In complex domains

expressing knowledge with propos

  • siti

ition

  • ns can be

quite limiting

up_s2 up_s3

  • k_cb1
  • k_cb2

live_w1 connected_w1_w2 up( s2 ) up( s3 )

  • k( cb1 )
  • k( cb2 )

live( w1) connected( w1 , w2 )

  • It is often natural to

consider indiv ivid idua uals ls and their proper erti ties es There is no notion that up_s2

up_s3 live_w1 connected_w1_w2

slide-14
SLIDE 14

CPSC 322, Lecture 23 Slide 14

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, w1)

slide-15
SLIDE 15

CPSC 322, Lecture 23 Slide 15

Datalog talog vs vs PDCL CL (better

tter wi with colors) s)

slide-16
SLIDE 16

Da Datalog:

  • g: a r

relati ational nal rule language 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, Y Examples: alan, w1 Examples: live, connected, part-of, in Examples: X, Y, alan, w1

slide-17
SLIDE 17

Datalog talog Syn yntax tax (co cont nt’d)

An atom is a symbol of the form p or p(t1 …. tn) where p is a predicate symbol and ti are terms 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.'') 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)

slide-18
SLIDE 18

Datalog talog: : To Top Down wn Proof

  • of Proce

cedure dure

  • 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:

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 X = alan

slide-19
SLIDE 19

Exa xample mple proof

  • of 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). yes  part_of(Z,cs_building) ∧ in(alan, Z).

  • B. yes  in(alan, r123).
  • A. yes  part_of(Z, r123) ∧ in(alan, Z).
  • C. yes .

Using clause: in(X,Y)  part_of(Z,Y) ∧ in(X,Z), with Y = cs_building X = alan Using clause: part_of(r123,cs_building) with Z = r123

  • D. None of the above

??????

slide-20
SLIDE 20

Exa xample mple proof

  • of 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). 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 X = alan 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 X = alan Y = r123

fail

No clause with matching head: part_of(Z,r123).

slide-21
SLIDE 21

Tr Tracing cing Datalog talog proofs

  • ofs 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

slide-22
SLIDE 22

Datalog: talog: queries eries with th va variable iables

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).

slide-23
SLIDE 23

Datalog: talog: queries eries with th va variable iables

What would the answer(s) be? yes(r123). yes(cs_building). 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).

Again, you can trace the SLD derivation for this query in the AIspace Deduction Applet

slide-24
SLIDE 24

CPSC 322, Lecture 8 Slide 24

Lo Logi gics s in in AI AI: : Si Simi milar lar sli lide de to to th the e on

  • ne f

e for

  • r pl

plan anni ning ng

Propositional Logics First-Order Logics Propositional Definite Clause Logics Semantics and Proof Theory Satisfiability Testing (SAT) Description Logics Cognitive Architectures Video Games Hardware Verification Product Configuration Ontologies Semantic Web Information Extraction Summarization Production Systems Tutoring Systems

slide-25
SLIDE 25

CPSC 322, Lecture 2 Slide 25

Big g Picture: cture: R&R R s systems tems

En Enviro ronm nmen ent Pr Problem em

Query Planning Deterministic Stochastic Search Arc Consistency Search Search Value Iteration

  • Var. Elimination

Constraint Satisfaction Logics STRIPS Belief Nets Vars + Constraints Decision Nets Markov Processes

  • Var. Elimination

Static Sequential Representation Reasoning Technique SLS

slide-26
SLIDE 26

CPSC 322, Lecture 23 Slide 26

Midterm dterm revie view

Av Avera erage ge 77 77 

Be Best 103! 32 stud uden ents ts > 90% 6 stud udents nts <50% How to learn rn more from midter erm

  • 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

slide-27
SLIDE 27

CPSC 502, Lecture 6 27

Fu Full ll Propositional

  • positional Logics

gics (not t fo for 322) 2)

DEFs.

Literal: ral: an atom or a negation of an atom Clause: e: is a disjunction of literals Conjunctive ctive Normal al Form (CNF): ): a conjunction of clauses

INFER EREN ENCE: E:

  • Convert

rt all formulas ulas in KB KB and in CNF

  • Apply Resoluti

ution n Proced edure ure (at t each step ep combin ine e two cla lauses es containing aining complem lemen entary tary li literals rals in into a new

  • ne)
  • ne)
  • Termin

inatio ation

  • No new cla

lause can be added

  • Two clause

e resolve

  • lve into an empty

ty clause

slide-28
SLIDE 28

CPSC 502, Lecture 6 28

Pr Propositional

  • positional Logics:

gics: Sa Satisfiability tisfiability (SA

SAT T problem) lem)

Does a set of formulas have a model? Is there an interpretation in which all the formulas are true? (St Stoch chas astic ic) ) Local al Se Search ch Al Algorith ithms ms can be used for

this task!

Ev Evaluat uation ion Fu Functio tion: n: number of unsatisfied clauses WalkSa Sat: 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)
  • 1. To minimize # of unsatisfied clauses
  • 2. Randomly
slide-29
SLIDE 29

CPSC 502, Lecture 6 29

Fu Full ll Fi First st-Order Order Logics gics (FO FOLs) Ls)

We have constant stant symbo bols, , predicate cate symbo bols s and and functi ction

  • n

symbols bols So interpr rpret etati ation

  • ns are much

h more re comple lex x (but t the same basic idea – one possible ble confi figurati guration

  • n of the world)

INFE FEREN ENCE: E:

  • Semidecida

ecidable ble: : algorithms exists that says yes for every entailed formulas, but no algorithm exists that also says no for every non-entailed sentence

  • Re

Resoluti ution

  • n Procedur

edure e can be ge general ralize zed d to FOL consta stant nt symbols

  • ls => individu

duals, als, entitie ties s predicat cate symbo bols s => relati tion

  • ns

funct ction n symbo bols s => functi ctions

  • ns