Logic Programming - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Logic Programming

Description:

1. Logic Programming. Robert Kowalski's equation: Algorithm = Logic Control ... RETE network. A(1), A(2) B(2), B(3), B(4) A(2) B(2) C(5) D(2) 14. Exercises ... – PowerPoint PPT presentation

Number of Views:136
Avg rating:3.0/5.0
Slides: 15
Provided by: TruHoa3
Category:

less

Transcript and Presenter's Notes

Title: Logic Programming


1
Logic Programming
  • Robert Kowalskis equation
  • Algorithm Logic Control
  • Definite logic program
  • A ? B1, B2, , Bm (program clause)
  • head body
  • ? A1, A2, , An (goal clause)

2
Logic Programming
  • SLD-resolution
  • Resolvent
  • ? A1, , Ak-1, Ak, Ak1, , An A ? B1, B2, ,
    Bm
  • ? ?(A1, , Ak-1, B1, B2, , Bm, Ak1, ,
    An) ?Ak ?A

SL-resolution for Definite clauses - SL Linear
resolution with Selection function
3
Logic Programming
  • SLD-resolution
  • SLD-derivation
  • G0 G, G1, G2, , Gn
  • C1, C2, , Cn
  • ?1, ?2, , ?n (mgus)
  • ?i1Ci1 ?i1Gi
  • SLD-refutation Gn empty
  • Computed answer ?n ?2?1

4
Logic Programming
  • SLD-resolution
  • Soundness
  • if ?n ?2?1 is a computed answer, then P ?n
    ?2?1G
  • Completeness
  • if P ?G, then there exists a computed answer
    s such that ? s? for some ?
  • Example p(X,Z) ? q(X,Y), p(Y,Z)
  • p(X,X)
  • q(a,b)

5
Logic Programming
SLD-tree
? p(X,b)
? q(X,Y), p(Y,b)
X/b success
? p(b,b)
? q(b,U), p(U,b) failure
X/b success
Each branch is an SLD-derivation
6
Logic Programming
  • PROLOG (Alain Colmerauer 1972)
  • Only Horn sentences are acceptable
  • The occur-check is omitted from the unification ?
    unsound
  • Example test ? p(X,X)
  • p(X,f(X))
  • Backward chaining with depth-first search ?
    incomplete
  • Example p(X,Y) ? q(X,Y)
  • p(X,X)
  • q(X,Y) ? q(Y,X)

7
Logic Programming
Infinite SLD-tree
? p(X,b)
? q(X,b)
X/b success
? q(b,X)
? q(X,b)
8
Logic Programming
  • PROLOG (Alain Colmerauer 1972)
  • Unsafe cut ? incomplete
  • Example A ? B, C ? A
  • B ? D, !, E
  • D ? ? B, C
  • ? D, !, E, C
  • ? !, E, C
  • Negation as failure ? P if fails to prove P

9
Theorem Provers
  • Accepts full first-order logic
  • Keeps control distinct from logic
  • A ? B ? C
  • A ? C ? B

10
Production Systems
  • Working memory contains a set of positive
    literals with no variables
  • Rule memory contains a set of reference rules of
    the form p1 ? p2 ? act1 ? act2
  • pi are literals
  • acti are actions to delete or add elements to
    the working memory

11
Production Systems
  • Forwarding chaining in each cycle
  • Match phasecomputes the subset of rules whose
    left-hand side is satisfied by the current
    contents of the working memory
  • Conflict resolution phase decides which of the
    rules to be executed
  • Act phase executes the actions in the chosen
    rules

12
Production Systems
  • Example
  • Working memory A(1), A(2), B(2), B(3), B(4),
    C(5)
  • Rule memory
  • A(x) ? B(x) ? C(y) ? add D(x)
  • A(x) ? B(y) ? D(x) ? add E(x)
  • A(x) ? B(x) ? E(x) ? delete A(x)

13
Production Systems
RETE network
D
AD
add E
A
B
AB
C
add D
C(5)
D(2)
A(1), A(2)
B(2), B(3), B(4)
A(2) B(2)
E
delete A
14
Exercises
  • In Russell Norvigs AIMA (Chapter 10) 10.2,
    10.4
Write a Comment
User Comments (0)
About PowerShow.com