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) Computer ter Sc Science ce cpsc3 c322 22, , Lectur ture e 23 (Te Text xtbo book ok Chpt 5.2 & & some basic ic concep


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)

Computer ter Sc Science ce cpsc3 c322 22, , Lectur ture e 23 (Te Text xtbo book

  • k Chpt 5.2 &

& some basic ic concep epts ts from Chpt 12) 12)

Oct, ct, 31, 2012

slide-2
SLIDE 2

CPSC 322, Lecture 23 Slide 2

Lecture cture Ov Overview view

  • 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 Pr Proof

  • f Pr

Procedure cedure

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

  • f Procedure:

cedure: Basic ic elements ments

Not

  • tat

ation ion: An answer clause is of the form:

yes ← a1 ∧ a2 ∧ … ∧ am

Ru Rule of infere renc 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 Derivati ation

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

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

CPSC 322, Lecture 11 Slide 7

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

  • n (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 ………………..
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 Heuristic? Number of atoms in the answer clause Admissible?

Yes No

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

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

CPSC 322, Lecture 23 Slide 11

Lecture cture Ov Overview view

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

CPSC 322, Lecture 23 Slide 12

Representation presentation and Reasoning soning in Complex mplex domains ains

  • In complex domains

expressing knowledge with proposi sitio tions 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 indivi vidua uals ls and their properti rties es There is no notion that up_s2

up_s3 live_w1 connected_w1_w2

slide-13
SLIDE 13

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

slide-14
SLIDE 14

CPSC 322, Lecture 23 Slide 14

Datalog talog vs vs PD PDCL L (bett

tter er wi with colors) s)

slide-15
SLIDE 15

Da Datalog:

  • g: a r

relati tional 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-16
SLIDE 16

Datalog talog Sy Syntax 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-17
SLIDE 17

Datalog talog: : To Top Down n Pr Proof

  • f Pr

Procedure cedure

  • 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:
  • We will not cover the formal details of this process, called unification. See

P&M Section 12.4.2, p. 511 for the details. 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-18
SLIDE 18

Ex Example mple proof

  • f of

f a Datal talog

  • g 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). 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-19
SLIDE 19

Tr Tracing cing Datal talog

  • g proofs
  • fs 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

slide-20
SLIDE 20

Datalog: talog: queries ries with th va variables 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-21
SLIDE 21

Datalog: talog: queries ries with th va variables 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-22
SLIDE 22

CPSC 322, Lecture 8 Slide 22

Lo Logi gics s in in AI AI: : Si Simi mila lar r 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-23
SLIDE 23

CPSC 322, Lecture 2 Slide 23

Big g Picture: ture: R&R s system 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-24
SLIDE 24

CPSC 322, Lecture 23 Slide 24

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

slide-25
SLIDE 25

CPSC 502, Lecture 6 25

Full ll Propos positional itional Logics ics

DEFs Fs.

Lit iteral: ral: an atom or a negation of an atom Cl Clause: e: is a disjunction of literals Co Conjunctive ctive No Normal Form (CN CNF): ): a conjunction of clauses

INFE FEREN ENCE: E:

  • Co

Convert rt all formulas ulas in KB KB and in CN CNF

  • Apply Re

Resoluti tion n Procedure ure (at each step combine e two wo cla lauses es containi ining ng comple lementary mentary li literals als in into a new w

  • ne)
  • ne)
  • Termin

mination ation

  • No

No new w clause can be added

  • Two

wo clause resolve ve into an empty y clause

slide-26
SLIDE 26

CPSC 502, Lecture 6 26

Pr Propositional

  • positional Logics:

gics: Sa Sati tisfia sfiability bility (SAT problem)

m)

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 l Se Search Al Algorithms thms can be used for

this task!

Ev Evalua uatio tion Fu Functio ion: 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-27
SLIDE 27

CPSC 502, Lecture 6 27

Fu Full ll Fi First-Order Order Logics ics (FO FOLs) s)

We have constant tant symbols, , predicate ate symbols s and and functi tion

  • n

symbols bols So interpret pretati ation

  • ns are much more complex

x (but the same basic idea – one possible configurati guration

  • n of the wo

world)

INF NFER EREN ENCE CE:

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

dure re can be ge generali alize zed d to FOL consta stant nt symbols => individuals, als, entities ies predicat cate symbols s => relation

  • ns

funct ctio ion n symbols ls => functi tion

  • ns