Introduction to Genifer – deduction source code:  deduction.lisp
 
 
 
In my Lisp code variables are denoted by  ?1 ,  ?2 , … etc
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... )
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.
* 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.
First order logic has 2  quantifiers : Universal : " 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  " 's.
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 )
Deduction can start from the  goal  to the  facts .
This is known as  backward chaining . The  red  link indicates a conjunction (“AND”) that requires  all  its arguments;
The black links represent “OR” (ie, the goal G can be solved by applying
either  rule1, rule2, rule3, ... etc.
The simplest search is  depth-first search   but it may not be flexible enough.
I think  best-first  search may be better, which uses a  priority queue  to  rank  the nodes. Each element in the priority queue points to a tree node.  priority queue
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
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, ...}
A successful matching results in a
new  set of substitutions .
Over time, a goal node can acquire

introduction to Genifer -- Deduction

  • 1.
    Introduction to Genifer– deduction source code: deduction.lisp
  • 2.
  • 3.
  • 4.
  • 5.
    In my Lispcode variables are denoted by ?1 , ?2 , … etc
  • 6.
    First order logichas 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... )
  • 7.
    Horn form Ifa 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.
  • 8.
    * Optional: Somefirst-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.
  • 9.
    First order logichas 2 quantifiers : Universal : " 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 " 's.
  • 10.
    When we havea 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 )
  • 11.
    Deduction can startfrom the goal to the facts .
  • 12.
    This is knownas backward chaining . The red link indicates a conjunction (“AND”) that requires all its arguments;
  • 13.
    The black linksrepresent “OR” (ie, the goal G can be solved by applying
  • 14.
    either rule1,rule2, rule3, ... etc.
  • 15.
    The simplest searchis depth-first search but it may not be flexible enough.
  • 16.
    I think best-first search may be better, which uses a priority queue to rank the nodes. Each element in the priority queue points to a tree node. priority queue
  • 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
  • 18.
    To satisfy agoal, 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, ...}
  • 19.
  • 20.
    new setof substitutions .
  • 21.
    Over time, agoal node can acquire