Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
×

# introduction to Genifer -- Deduction

327 views

Published on

Published in: Technology
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• NOTE: This set of slides is old. Please go to Genifer at Google Code:
and you'll find many more slides at the 'downloads' page.
Enjoy =)
YKY

Are you sure you want to  Yes  No
Your message goes here
• Be the first to like this

### introduction to Genifer -- Deduction

1. 1. Introduction to Genifer – deduction source code: deduction.lisp
2. 5. In my Lisp code variables are denoted by ?1 , ?2 , … etc
3. 6. First order logic has the following connectives and operators : / (AND) / (OR) ┐ (NOT) -> (IMPLY) ↔ (EQUIVALENCE) For example A -> B is equivalent to (┐A / B) and its truth table is: A B A->B T T T T F F F T T F F T ( I assume you still remember this stuff... )
4. 7. Horn form If a bunch of formulae can be written as: A ← B / C / D / … B ← E / F / G / ... and if A is the goal we want to solve: A then we can cross out A and replace it with A, B, C, D, … as the new sub-goals and repeat the process: B, C, D, ..., E, F, G, … This makes solving the goals very efficient (similar to production systems in the old days). Formulae written in this form is called the Horn form and is the basis of the language Prolog . Genifer's logic is also based on Horn.
5. 8. * Optional: Some first-order formulae cannot be expressed in Horn form. If we want to prove theorems in full first-order logic, we need to use a more general algorithm such as resolution . The general procedure is: 1. convert all the formulae into CNF (conjunctive normal form) 2. eliminate all existential quantifiers  by a process called Skolemization (see next slide) 3. repeatedly apply the resolution rule to formulae in the KB, until nothing more changes If we restrict resolution to Horn formulae we get SLD-resolution which is very fast and is the search procedure in Prolog. I think Horn is expressive enough for making a first AGI prototype.
6. 9. First order logic has 2 quantifiers : Universal : &quot; X liar(X)  for all X, X is a liar  “Everyone is a liar”. Existential :  X brother(john, X)  exists X such that X is John's brother The existential quantifier can be eliminated by Skolemization :  X brother(john, X) “Exists X such that X is John's bro”  brother(john, f(john)) where f() is called a Skolem function . Its purpose is to map X to X's brother. With existential quantifiers eliminated, we can assume all variables are implicitly universally quantified, and omit the &quot; 's.
7. 10. When we have a goal to prove... goal G KB knowledge base We try to fetch facts and rules from the KB to satisfy the goal. eg: bachelor(john) ? (defined in memory.lisp )
8. 11. <ul><li>Deduction can start from the goal to the facts .
9. 12. This is known as backward chaining . </li></ul><ul><li>The red link indicates a conjunction (“AND”) that requires all its arguments;
10. 13. The black links represent “OR” (ie, the goal G can be solved by applying
11. 14. either rule1, rule2, rule3, ... etc. </li></ul>
12. 15. <ul><li>The simplest search is depth-first search but it may not be flexible enough.
13. 16. I think best-first search may be better, </li></ul>which uses a priority queue to rank the nodes. Each element in the priority queue points to a tree node. priority queue
14. 17. A goal / sub-goal can be satisfied by either facts or rules . example of a fact: bachelor(john) example of a rule: bachelor(?1) ← male(?1) / single(?1) this is a variable A B
15. 18. To satisfy a goal, some variable substitutions occur. We need to make these 2 terms identical; this is done by a n algorithm known as unification . The result of unification is a set of substitutions , for example: {?1/john, ...}
16. 19. <ul><li>A successful matching results in a
17. 20. new set of substitutions .
18. 21. Over time, a goal node can acquire
19. 22. multiple sets of substitutions. </li></ul>{?1/john} {?1/pete} {?1/paul} … etc these are 3 substitution sets stored in the node Managing these set of substitutions can be a great source of complexity, as the next few slides illustrate...
20. 23. Each substitution set is associated with a truth value (TV). {?1/john} {?1/pete} {?1/paul} … etc TV1 TV2 TV3 ...
21. 24. {?1/john} {?1/pete} {?1/paul} … etc {?1/mary} {?1/paul} {?1/john} … etc male(john), male(pete), male(paul), … etc single(mary), single(paul), single(john), … etc male(?1) single(?1) bachelor(?1) ← male(?1) / single(?1) facts from KB that matches the sub-goals These 2 blocks of substitution-sets must be merged to give the result to the parent node. When handling substitution sets of a conjunction / ...
22. 25. {?1/john} {?1/pete} {?1/paul} … etc {?1/mary} {?1/paul} {?1/john} … etc Each set on the left block has to be matched with each set of the right block. for example: {?1 / john} {?1 / mary} fail {?1 / john} {?1 / john} match Because the variable ?1 can only take on one value on each instance.
23. 26. {?1/john} {?1/pete} {?1/paul} … etc {?1/mary} {?1/paul} {?1/john} … etc <ul><li>The merging of substitution-sets is handled in the </li></ul>function propagate . <ul><li>Instead of trying all possible combinations between 2 blocks,
24. 27. we try to do the matching when a new substitution-set arrives.
25. 28. When we get a new set, say {?1 / john}, </li></ul>we try to merge it with each set in the other existing blocks: {?1 / mary } {?1 / sam } {?1 / paul } {?1 / john } .... etc new result from unification
26. 29. {?1/john} {?1/pete} {?1/paul} … etc {?1/mary} {?1/paul} {?1/john} … etc Substitution-sets propagate upwards along the proof tree. parent's block of substitution sets This part of the Lisp code may still need developing.
27. 30. The Lisp code contains these functions: backward-chain main function, manages the priority queue process-subgoal process-fact builds up the proof tree during search process-rule retract deletes a dead proof tree node propagate propagates TVs up the proof tree TO-DO: * some comments are excessive