1 / 37

Incorporating Specialized Algorithms into General Inference Procedures

Incorporating Specialized Algorithms into General Inference Procedures. Motivating Example. Set intersection. Relational Logic. Speed of Epilog. Epilog. (in ?x AintB) <= (in ?x A) ^ (in ?x B) (in 1 A) ^ (in 2 A) ^ (in 3 A) ^ (in 4 A) ^ (in 5 A)

duane
Download Presentation

Incorporating Specialized Algorithms into General Inference Procedures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Incorporating Specialized Algorithms into General Inference Procedures

  2. Motivating Example Setintersection Relational Logic

  3. Speed of Epilog Epilog (in ?x AintB) <= (in ?x A) ^ (in ?x B) (in 1 A) ^ (in 2 A) ^ (in 3 A) ^ (in 4 A) ^ (in 5 A) (in 2 B) ^ (in 3 B) ^ (in 4 B) ^ (in 5 B) ^ (in 6 B) Goal: (in ?x AintB) Epilog takes at O(m*n) steps to find AintB

  4. Speed of Subroutine Pseudo-code function set_intersect (Set A, Set B){ MarkingDS m; Set AintB; foreach item in A { m.mark(item); } foreach item in B { if (m.marked(item)) AintB.add(item); } return AintB; } set-intersect takes O(m+n) steps to find AintB

  5. Overall Approach In order to solve problems efficiently, let’s give our theorem prover a set of data structures and hard-coded subroutines. We need to do the following: • Describe the subroutines/data structures in the language of the theorem prover • Recognize when to apply them a.) when able—taken care of by #1 b.) when appropriate—Algorithm analysis 3. Apply the subroutines/data structures

  6. Example • <~(in x A), ~(in x B), (in x AintB)> P • <(in 5 A)> P • <(in 5 B)> P • <(in 6 A)> P • <(in 6 B)> P • <(in 7 A)> P • <~(in x AintB), goal(x)> Goal • Recognize we can use set intersection routine to eliminate ~(in x AintB) by binding x to 5 and 6. 9. <goal(5)> 7,? 10. <goal(6)> 7,?

  7. Proof vs. Computation • Proof: solutions derived from logical deduction. Use model elimination, resolution, etc. to create a proof system. • Computation: solutions derived from the use of data structures and specialized procedures. Use a programming language, a compiler, and a computer to create a computation system.

  8. Universal Attachments Example arithmetic: {plus(3,4)=7} In general, we either need all addition facts or we need to specify the axioms for addition (Peano). 1. Zero is a number. 2. If a is a number, the successor of a is a number. 3. zero is not the successor of a number. 4. Two numbers of which the successors are equal are themselves equal. 5. (induction axiom.) If a set S of numbers contains zero and also the successor of every number in S, then every number is in S.

  9. Peano Axioms? • Computers add really fast. Why not use the built in +? • Universal Attachment for plus(x,y) plus(x,y)  <+, Aint, Dint> Aint([x,y]) = [num(x), num(y)] (attachment map) Dint(n) = num-1(n) (detachment map) num maps “1” to 1, “2” to 2, “3” to 3, etc. • When we see “plus(3,4)”, we now know to ask the CPU for 3+4.

  10. Filter Sets • Not all symbols can be converted to numbers. The domain of plus(x,y)  <+, Aint, Dint> is too large. • F= {type(x,integer), type(y,integer)} The above universal attachment only applies if all the constraints in F are satisfied. <plus(x,y), F>  <+, Aint, Dint> Aint([x,y]) = [num(x), num(y)] (attachment map) Dint(n) = num-1(n) (detachment map) num maps “1” to 1, “2” to 2, “3” to 3, etc. F = {type(x,integer), type(y,integer)}

  11. Formalization Universal Attachment: the attachment pattern ( plus(x,y) ) F, the filter set, defined for x1,…,xn p, the attached program of arity m A, (logical ground terms)n(computer terms)m D, (computer terms)(logical expression)

  12. Rule of Inference Attachment for a pattern {p(x)} • {p(x)} Yes • {p(x), q(x)} No ({p(x)} might evaluate to false  {q(x)}) • {p(x), r, t(y)} Yes • {~p(a)} Yes Attachment for a pattern {h(x,y)} • {h(x,x), R} No

  13. UAR Rule of Inference • Universal Attachment for Resolution (resolution is sound when augmented with UAR, but incomplete)

  14. C-FOL • Computational First Order Logic – Sikka, 1996 • Combines a proof system (FOL) and a computational system (C) • Syntax • Semantics • Inference method

  15. C-FOL Syntax • Start with Relational (First-order) Logic • Add a set of procedure names, P, that correspond to the specialized procedures in C • Add a set of data structure names, D, that correspond to the data structures in C • Add a new function symbol apply. • Add tr: (logical ground term)  D tr-1: D  (logical ground term) • Add maps(x,y): (ground term x D) maps-1(x,y): (D x ground term)

  16. Examples What if x is Mike’sAge?

  17. C-FOL Semantics • Start with Relational (First-order) semantics • Each member of P corresponds to a specialized procedure in C. • Each member of D corresponds to a data structure in C. • apply(p,t1,…,tn) is a function mapped to the result of applying the procedure in C corresponding to p with the arguments t1,…,tn. • tr maps every ground term in FOL into a data structure in C • maps(x,y)relates a ground term in FOL to a data structure in C

  18. C-FOL Inference • Start with resolution and paramodulation • Add C-substitution • Theorem: Sound and complete system • Theorem: More powerful (general) than Universal attachments

  19. Example • {~p(x,z), ~p(y,z), p(plus(x,y),z)} P • {p(3,2)} P • {p(4,2)} P • {~p(7,2)} Goal • {plus(x,y) = apply(+,x,y)} SP • {~p(y,2), p(plus(3, y), 2)} 1,2 • {p(plus(3, 4), 2)} 6,3 • {p(apply(+, 3, 4), 2)} 7,5 • {p(7,2)} 8 • {} 9,4

  20. Overall Approach In order to solve problems efficiently, let’s give our theorem prover a set of data structures and hard-coded subroutines. We need to do the following: • Describe the subroutines/data structures in the language of the theorem prover • Recognize when to apply them a.) when able—taken care of by #1 b.) when appropriate—Algorithm analysis—cost?? 3. Apply the subroutines/data structures

  21. Algorithm Definitions If we are going to analyze an algorithm, we need to define what an algorithm actually is. • Valid sequence of Turing machine states Alan Turing, 1930s • Algorithm = Logic + Control Robert Kowalski, 1979

  22. Algorithm = Logic + Control Algorithm = • definition of problem • + how logic component is used to solve problem • expression of the knowledge used in solving a problem • + specification of how that knowledge can be • used • definition of the problem-domain-specific part, • the meaning of the algorithm • + effects of changing the behavior without • changing the meaning

  23. A = L + C example fibonacci(x) is 1 if x = 0 or x = 1 is u if v+w=u and v is fibonacci(x-1) and w is fibonacci(x-2) How might we compute fibonacci(7) ? • Top down: fib(7) = fib(6)+fib(5) = fib(5)+fib(4)+fib(4)+… • Bottom Up: fib(7) = find fib(0), find fib(1),… • Randomly guess v,w: u is v+w. Check if v,w correct. • Parallelize • Combinations of the above

  24. Motivating L+C • To improve the efficiency of an algorithm, we can either complicate the logic or alter the control. By dividing an algorithm into logic and control, we modularize the work toward this goal of increased efficiency. • To determine the correctness of an algorithm, just check its Logic. We assume sound Control.

  25. Use Logic to Improve Efficiency • Changing the logic of sort to that of quicksort sorting x gives y <= y is a permutation of x, y is ordered sorting x gives y <= x is empty, y is empty sorting x gives y <= first element of x is x1, rest of x is x2, partitioning x2 by x1 gives u and v, sorting u gives u’, sorting v gives v’, appending w to u’ gives y, first element of rest of w is v’

  26. Use Control to Improve Efficiency Example of fibonacci: fib(7) • Top down (exponential in n) fib(6)+fib(5)= fib(5)+fib(4)+fib(4)+fib(3)= fib(4)+fib(3)+fib(3)+fib(2)+fib(3)+fib(2)+fib(2)+fib(1)=… • Bottom up (linear in n) fib(0)=1, fib(1)=1, fib(2)=1+1=2, fib(3)=2+1=3, fib(4)=3+2=5, fib(5)=5+3=8, fib(6)=8+5=13, fib(7)=13+8=21

  27. Logic: Horn Clauses • Facts: B <= • Goals: <= A1, A2,…, An • Contradiction: <= • Procedures: B <= A1, A2,…, An sorting x gives y <= y is a permutation of x, y is ordered sort(x) { while (true) { y = permutation(x); if (inorder(y)) return y; } }

  28. Control: Embedded in Proof Procedures Given facts, procedures, goals • Top down (backward chaining from goal): model elimination, resolution • Bottom up (forward chaining from facts): hyper resolution • Parallelization (orthogonal to first two)

  29. Parent(x,y) <= Mother(x,y) Parent(x,y) <= Father(x,y) Grandparent(x,y) <= Parent(x,z), Parent(z,y) Father(Zeus, Ares) <= Father(Ares, Harmonia) <= <= Grandparent(Zeus,Harmonia) Example Problem

  30. Top Down* <= Grandp(Zeus,Harmonia) <= Parent(Zeus,z), Parent(z,Harmonia) <= Father(Zeus,z), Father(z,Harmonia) <=Father(Ares, Harmonia) Bottom Up Father(Zeus, Ares) <= Parent(Zeus, Ares) <= Father(Ares, Harmonia) <= Parent(Ares, Harmonia) <= Grandp(Zeus,Harmonia) <= Example Execution

  31. Data structures • Included in the Logic component—must specify how to access the data • Definition of a List data structure: nil is empty <= first element of cons(x,y) is x <= rest of cons(x,y) is y <= • Use ME to merge the definition of List with that of quicksort. Resolve “empty”, “first”, “rest”.

  32. Quicksort With Data Structure sorting nil gives nil <= sorting cons(x1,x2) gives y <= partitioning x2 by x1 gives u and v, sorting u gives u’, sorting v gives v’, appending to u’ the list cons(x1,v’) gives y

  33. A = L + C Summary • Split A into L and C to modularize algorithm analysis. • L says what is to be done. C says how to do it. • Execute the L top down, bottom up, in parallel • Data structures are included in the L • Results: Kowalski formalized the notion of an ‘algorithm’ at a more abstract level than Turing did.

  34. Issues • A = L1 + C1 = L2 + C2 • Formulation affects analysis • Example: Path-finding

  35. Formulation 1 • Use the Go(x) predicate Go(A) <= Go(C) <= Go(A) Go(D) <= Go(C) Go(B) <= Go(A) Go(F) <= Go(D) Go(E) <= Go(H) Go(D) <= Go(B) Go(G) <= Go(F) …

  36. Formulation 2 • Use the Go*(x,y) predicate Go*(A,B) <= Go*(F,D) <= Go*(F,H) <= Go*(A,C) <= Go*(E,H) <= … Go*(B,D) <= Go*(F,G) <= Go*(x,y) ^ Go*(y,z) => Go*(x,z)

  37. Conclusions • We can describe and apply specialized procedures soundly and completely. • We want to apply them only when efficient. This requires we do some form of algorithm analysis. But, algorithm analysis comes at a cost. • How do we balance the cycles spent on meta-level analysis and the cycles spent on theorem-proving? • These are open questions. Anyone want to write a few Ph.D. theses?

More Related