Download presentation
Presentation is loading. Please wait.
Published byKathryn Shaw Modified over 9 years ago
1
1 Logic Programming Robert Kowalski’s equation: Algorithm = Logic + Control Definite logic program: A B 1, B 2, …, B m (program clause) headbody A 1, A 2, …, A n (goal clause)
2
2 Logic Programming SLD-resolution: Resolvent: A 1, …, A k-1, A k, A k+1, …, A n A B 1, B 2, …, B m (A 1, …, A k-1, B 1, B 2, …, B m, A k+1, …, A n ) A k = A SL-resolution for Definite clauses - SL = Linear resolution with Selection function
3
3 Logic Programming SLD-resolution: SLD-derivation: G 0 = G, G 1, G 2, …, G n C 1, C 2, …, C n 1, 2, …, n (mgu’s) i+1 C i+1 = i+1 G i SLD-refutation: G n = empty Computed answer: n … 2 1
4
4 Logic Programming SLD-resolution: Soundness: if n … 2 1 is a computed answer, then P n … 2 1 G Completeness: if P G, then there exists a computed answer such that = for some Example: p(X,Z) q(X,Y), p(Y,Z) p(X,X) q(a,b)
5
5 Logic Programming 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 SLD-tree: Each branch is an SLD-derivation
6
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
7 Logic Programming p(X,b) q(X,b) {X/b} success q(b,X) q(X,b) Infinite SLD-tree:
8
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
9 Theorem Provers Accepts full first-order logic Keeps control distinct from logic A B C A C B
10
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 p 1 p 2 … act 1 act 2 … p i are literals act i are actions to delete or add elements to the working memory
11
11 Production Systems Forwarding chaining in each cycle: Match phase:computes 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
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
13 Production Systems AB D A=BC E A=Dadd E add D delete A RETE network A(1), A(2)B(2), B(3), B(4) A(2) B(2) C(5)D(2)
14
14 Exercises In Russell & Norvig’s AIMA (Chapter 10): 10.2, 10.4
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.