RDM Chapter 2 : Introduction to Logic - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

RDM Chapter 2 : Introduction to Logic

Description:

Horn clause: n = 1 or n = 0. denial (query): n = 0. 9. more ... here specifically: Horn clauses and SLD-resolution. propositional (simpler, cf. Ex.2.27) ... – PowerPoint PPT presentation

Number of Views:136
Avg rating:3.0/5.0
Slides: 25
Provided by: xing75
Category:

less

Transcript and Presenter's Notes

Title: RDM Chapter 2 : Introduction to Logic


1
RDM Chapter 2 Introduction to Logic
  • prepared for COMP422/522-2008, Bernhard
    Pfahringer

2
2.1 A relational DB example
  • citation database (like CiteSeer)
  • authorOf(lloyd,logic_for_learning) lt-
  • reference(logic_for_learning,foundations_of_lp)
    lt-
  • Predicates authorOf/2 pname/arity
  • Constants start with lowercase letter
  • Facts p(t1,..,tn) lt- p/n name, ti terms,
    facts are also called tupels

3
Example 2.2
  • query
  • lt- authorOf(lloyd,logic_for_learning)
  • yes/no question
  • lt- authorOf(lloyd,Pub)
  • answer substitutions, which make the query
    true Pub/logic_for_learning, but also
    Pub/foundations_of_lp

4
Logical queries vs. SQL
  • lt- authorOf(lloyd,Pub)
  • SELECT Pub FROM authorOf WHERE Author lloyd
  • lt- authorOf(A,logic_for_learning), authorOf(A,
    foundations_of_lp)
  • SELECT A FROM authorOf t1, authorOf t2 WHERE
    t1.Author t2.Author AND t1.Pub
    logic_for_learning AND t2.Pub
    foundations_of_lp

5
More examples
  • who cites who
  • lt- authorOf(A,P),reference(P,Q),authorOf(B,Q)
  • turn into new predicate/clause
  • cites(A,B) lt- authorOf(A,P),reference(P,Q),authorO
    f(B,Q)
  • similar to a view (intensional relation) in SQL
  • CREATE VIEW cites AS SELECT a1.Author, a2.Author
    FROM authorOf a1, autherOf a2, reference r WHERE
    a1.Pub r.Pub1 AND a2.Pub r.Pub2 (try
    Exercise 2.3)

6
2.2 Syntax of Clausal Logic
  • term can be a
  • constant, like John
  • variable, like Pub
  • compound term, like card(queen,hearts) can be
    nested succ(succ(0)), , short cut for lists
    1,2,3 is actually cons(1,cons(2,cons(3,nil)))
  • Atom p(t1,..,tn), p/n is a predicate name and ti
    are terms
  • Ground atoms variable-free, are true or false
    pair(card(queen,hearts),card(queen,spades))

7
A clause
  • h1 .. hn lt- b1, .. , bm where all hi and bj
    are atoms
  • means disjuntion / or
  • , means conjunction / and
  • lt- means implication
  • variables are universally quantified / for all
  • female(X) male(X) lt- human(X)

8
Set notation
  • h1, ,hn, b1, , m or
  • h1 OR .. OR hn OR b1 OR .. OR bm
  • facts n 1, m 0
  • definite clause n 1
  • Horn clause n 1 or n 0
  • denial (query) n 0

9
more notation
  • a set of clauses also called
  • a (clausal) theory
  • a database (all ground facts ?)
  • a knowledge base
  • Substitution theta ? V1/t1, .. assigns term
    t1 to variable V1
  • card(X,Y)?
  • with ? X/queen,Y/hearts
  • denotes card(queen,hearts)

10
2.3 Semantics - Model Theory
  • Interpretation uses a domain (set of objects
    that exist), maps
  • constants gt objects
  • functions f/n gt objects
  • predicates p/n gt n-tupels of objects
  • e.g. john gt John Doe Jr.
  • fatherOf(john) gt John Doe Sr.
  • parent(fatherOf(john),john) lt- gt true (provided
    John Doe Sr. is really the father of John Doe
    Jr.)

11
Herbrand interpretation
  • Herbrand domain set of all ground terms
    constructed from all constants and functions
    occuring in any clause
  • Citation DB only constants lloyd,
    foundations_of_lp,
  • natural number theory
  • nat(0) lt-
  • nat(succ(X)) lt- nat(X)
  • Herbrand domain 0,succ(0), succ(succ(0)), ,
    i.e. is infinite
  • Herbrand interpretation maps every ground term
    onto itself

12
Definition 2.7. Herbrand interpretation
  • Herbrand interpretation of a set of clauses is a
    set of ground atoms over the constants,
    functions, and predicate symbols occuring in
    these clauses
  • e.g. for natural numbers
  • I3
  • I4 nat(0),nat(succ(0))
  • I5 nat(0),nat(succ(0)), nat(succ(succ(0))),

13
Def 2.10. Herbrand model
  • A Herbrand interpretation I is a Herbrand model
    for a set of clauses C if and only if for all
    clauses h1hn lt- bi,,bm in C and for all
    ground substitutions ? b1?, , bm? in I -gt
    h1?,,hn? ? I ?
  • I.e. if the preconditions of any rule are
    satisfied, then at least one of its consequences
    must also be part of the interpretation
  • cf. Examples 2.11 and 2.12

14
Def 2.13. Logical Entailment based on model theory
  • A set of clauses C logically entails another
    clause c (C c), if and only if all models of C
    are also models of c.
  • Theorem 2.14. A set of clauses C has a model if
    and only if C has a Herbrand model
  • Theorem 2.15. C c if and only if C /\ c is
    unsatisfiable, I.e. C /\ c
  • cf. Examples 2.16, 2.17

15
Range-restriced clauses
  • A clause is range-restricted if all variables in
    the head also appear in its body. This also
    implies that all facts are ground (because they
    have no body, so cannot have any variables)
  • cites(A,B) lt- authorOf(A,P),reference(P,Q),authorO
    f(B,Q)
  • cites(A,B,X) lt- authorOf(A,P),reference(P,Q),autho
    rOf(B,Q)

16
Algorithm 2.1. Generating models
  • M
  • while M is not a model of C do
  • if there is a denial lt- b1,,bm that is violated
    by M then backtrack
  • select a clause where all body atoms are
    satisfied (are in M) but none of the consequences
    is (are not in M), and non-deterministically add
    one of the consequences to M (choice-point)

17
Properties
  • can fail if no model exists
  • can loop infinitely for infinite models
  • cf Examples 2.18 - 2.20, exercise 2.21
  • there may be multiple models, and some may be
    subsets of others
  • a model is minimal if no subset is a model

18
Least Herbrand model
  • for definite clauses the minimal model is unique,
    called least Herbrand model, denoted as M(C)
  • Property 2.24 If C is a set of definite clauses
    and f some ground fact, then C f if and only
    if f is in M(C)
  • can improve Algorithm 2.1

19
Algorithm 2.2 Forward chaining
  • no backtracking
  • M1 f f lt- is a fact in C
  • I 1
  • while Mi ! Mi-1 do
  • Mi1 Mi
  • for all h lt- b1,,bn in C do
  • for all ? such that b1?,,bn? ? Mi do
  • add h? to Mi1
  • i i1
  • cf. Example 2.25, exercise 2.26

20
Inference - Proof theory
  • Resolution, Robinson (1965) was a break-through
    in logic,
  • here specifically Horn clauses and
    SLD-resolution
  • propositional (simpler, cf. Ex.2.27)
  • l lt- b1,,bn and
  • h lt- c1,ci-1,l,ci,,cm
  • THEN hlt- c1,ci-1,b1,,bm,ci,,cm

21
Resolution proofs
  • Resolution is sound, I.e. c1 /\ c2 -res c then
    also c1 /\ c2 c
  • (cf. Example 2.28, Fig 2.2., 2.3.)
  • Resolution is NOT complete (see 2.29) but it is
    refutation-complete
  • for Horn clauses C hlt-b1,,bn
  • negate c into T lt-h, b1lt-,,bnlt-
  • derive from C /\ T, I.e. C /\ T -

22
First-order terms Unification
  • father(X,Y) lt- parent(X,Y), male(X)
  • lt- father(luc,maarten)
  • s X/luc,Y/marteen
  • lt- parent(luc,maarten),male(luc)
  • cf. Examples 2.32
  • unifiers do not always exist
  • most general unifier (def 2.33, example 2.34,
    algorithm 2.3)

23
First-order resolution
  • l lt- b1,,bn and
  • h lt- c1,ci-1,l,ci,,cm
  • AND ? mgu(l,l)
  • THEN h? lt- c1?,ci-1?, b1?, , bm?, ci?,
    ,cm?
  • can still do refutation proofs, but need to
    introduce skolem-constants

24
Decidability
  • propositional logic decidable
  • first-order semi-decidable, I.e. may not
    terminate if C / c
  • but if we only allow constants and variables (no
    function symbols), also called relational
    definite clause logic or Datalog, then this is
    decidable!
Write a Comment
User Comments (0)
About PowerShow.com