Title: Logic: TD as search, Datalog variables
1Logic TD as search, Datalog (variables)
Computer Science cpsc322, Lecture 23 (Textbook
Chpt 5.4, 6.1- 6.3) March, 7, 2008
2Lecture Overview
- Recap Top Down
- TopDown Proofs as search
- Datalog
3TD Example derivations
- a ? b ? c. a ? e ? f. b ? k ? f.
- c ? e. d ? k. e.
- f ? j ? e. f ? c. j ? c.
-
-
-
-
-
-
Query a (two ways)
yes ? a.
yes ? a.
4Top-down definite clause interpreter
- To solve the query ?q1 ? ? qk
- ac yes ? q1 ? ? qk
- repeat
- select atom qi from the body of ac
- choose clause C from KB with qi as head
- replace qi in the body of ac by the body of C
- until ac is an answer.
5Lecture Overview
- Recap Top Down
- TopDown Proofs as search
- Datalog
6TopDown Proofs as Searching
- The non-deterministic interpreter we just saw a
selection strategy (to pick which atom to work
on) - Can be implemented as a search problem
- Each node represents .
- The neighbors of a node
- With qi as the selected atom
- The goal node is of the form?
7Search 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.
-
-
Heuristics?
8Recap Logics so far
9Lecture Overview
- Recap Top Down
- TopDown Proofs as search
- Datalog
10Representation and Reasoning in Complex domains
- In complex domains expressing knowledge with
propositions can be quite limiting - It is often natural to consider individuals and
their properties
down(s1) up(s2) up(s3) ok(cb1) ok(cb2)
live(outside) live(w1)
down_s1. up_s2. up_s3. ok_cb1. ok_cb2.
live_outside, live_w1
11Individuals and Properties (aka Predicates /
Relations)
- Some key advantages
- Economy of symbols 10 individuals and 1 binary
relation can express. - Express knowledge that hold for set of
individuals (by introducing variables)
live(W) lt- connected_to(W,W1) live(W1)
wire(W) wire(W1).
- Also by introducing variables, we can ask generic
queries (i.e., containing variables)
? connected_to(W, w1)
12Datalog a relational rule language
It expands the syntax of PDCL.
Definition (variable) An variable is a symbol
starting with an upper case letter
Definition (constant) A constant is a symbol
starting with lower-case letter or a sequence of
digits.
Definition (predicate symbol) A predicate symbol
is a symbol starting with lower-case letter.
Definition (term) A term is either a variable or
a constant.
13Datalog Syntax (cont)
Definition (atom) An atomic symbol (atom) is a
of the form p or p(t1 . tn) where p is a
predicate symbol and ti are terms
Definition (definite clause) A definite clause is
an atomic symbol (a fact) or of the form
h ? b1 ? ? bm where h and the bi are
atomic symbol (Read this as h if b.'')
Definition (knowledge base) A knowledge base is a
set of definite clauses
14Datalog Semantics (only general idea)
In propositional definite clause logic an
interpretation is A model of a KB is
- In datalog an interpretation specifies
- What objects are in the world
- The correspondence between symbols in the KB and
objects and relations in the world - Constants
- Predicates
- A model of a KB is
15Datalog Top Down Proof
Extension of TD for PDCL. How do you deal with
variables? Example
in(alan, r123). part_of(r123,cs_building). in(X,Y)
lt- part_of(Z,Y) in(X,Z).
Query in(alan, cs_building).
yes lt- in(alan, cs_building).
16Datalog queries with variables
in(alan, r123). part_of(r123,cs_building). in(X,Y)
lt- part_of(Z,Y) in(X,Z).
Query in(alan, X1).
Yes(X1) lt- in(alan, X1).
17Midterm review
Average 67 Best 101, Worst 11
- 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
18Very common misconceptions
- Breadth First is always optimal. This is the case
only if.. - The 3queen problem has 9 states. They are 84
- The difference between a goal and a preference
- A goal function is a boolean condition. For each
state it tells you whether it is a goal state or
not. - A preference function tells you for each state
how desirable that state is (typically range
between 0 and 1)
19Next class
Environment
Stochastic
Deterministic
Search
Single Action
Constraint Satisfaction (CSPs)
Decision
Logics
Search
Sequence of Actions
Constraint Satisfaction (CSPs)
Planning