Autonomy Reasoning Systems - PowerPoint PPT Presentation

1 / 128
About This Presentation
Title:

Autonomy Reasoning Systems

Description:

THEN vehicleType = automobile. Forward-Chaining Reasoning ... vehicleType = automobile. vehicle = MiniVan. Trigger rule MiniVan. Not added to the conflict set ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 129
Provided by: shyhka
Category:

less

Transcript and Presenter's Notes

Title: Autonomy Reasoning Systems


1
Autonomy Reasoning Systems
  • Shyh-Kang Jeng
  • Department of Electrical Engineering/
  • Graduate Institute of Communication Engineering
  • National Taiwan University

2
References
  • J. P. Bigus and J. Bigus, Constructing
    Intelligent Agents with Java, Wiley Computer
    Publishing, 1998
  • S. Russell and P. Norvig, Artificial
    Intelligence A Modern Approach, Englewood
    Cliffs, NJ Prentice Hall, 1995

3
Goal-Based Agents
Sensors
Environment
State
Environment Model
Options
Decision Maker
Goals
Agent
Effectors
4
Knowledge-Based Agents
Sensors
Environment
Knowledge Base Management System
Knowledge Base
Agent
Effectors
5
Knowledge Base
  • A set of representation of facts about the world
  • Each individual representation is a sentence
  • Sentences are expressed in a knowledge
    representation language
  • Knowledge representation languages are composed
    of symbols
  • Representation and reasoning support the
    operation of a knowledge-based agent
  • Accessed through a knowledge base management
    system (KBMS)

6
General Knowledge-Based Agent (1)
  • class KBAgent
  • KnowledgeBase kb
  • KBMS kbms
  • counter t // indicating time
  • public KBAgent()
  • kb new KnowledgeBase()
  • kbms new KBMS( kb )
  • t 0

7
General Knowledge-Based Agent (2)
  • public Action run(Percept percept)
  • kbms.tell(new
  • PerceptSentence(percept, t))
  • Action action kbms.ask( new
  • ActionQuery(t) )
  • kbms.tell( new
  • ActionSentence(action,t) )
  • t return action

8
Rule-Based System
  • Rule-basde processing system
  • Rule base
  • Working memory
  • Inference engine
  • Rules
  • Antecedent clauses
  • Consequent clauses
  • Trigger or ready to fire
  • Sensors and effectors
  • Retractions

9
Vehicles Rule Bases (1)
  • Bicycle IF vehicleType cycle
  • AND num_wheel 2
  • AND motor no
  • THEN vehicle Bicycle
  • Tricycle IF vehicleType cycle
  • AND num_wheel 3
  • AND motor no
  • THEN vehicle Tricycle

10
Vehicles Rule Bases (2)
  • Motorcycle IF vehicleType cycle
  • AND num_wheel 2
  • AND motor yes
  • THEN vehicle Motorcycle
  • SportsCar IF vehicleType automobile
  • AND size small
  • AND num_doors 2
  • THEN vehicle Sports_Car

11
Vehicles Rule Bases (3)
  • Sedan IF vehicleType automobile
  • AND size medium
  • AND num_doors 4
  • THEN vehicle Sedan
  • MiniVan IF vehicleType automobile
  • AND size medium
  • AND num_doors 3
  • THEN vehicle MiniVan

12
Vehicles Rule Bases (4)
  • SUV IF vehicleType automobile
  • AND size large
  • AND num_doors 4
  • THEN vehicle Sports_Utility_Vehicle
  • Cycle IF num_wheelslt4
  • THEN vehicleType cycle
  • Automobile IF num_wheels 4
  • AND motor yes
  • THEN vehicleType automobile

13
Forward-Chaining Reasoning
  • Load rule base to the inference engine, and any
    facts from the knowledge base into the working
    memory
  • Match the rules to obtain the conflict set
  • Use the conflict resolution procedure to select a
    single rule from the conflict set
  • Fire the selected rule
  • Repeat steps 2,3,4 until the conflict set is empty

14
Conflict Resolution Alternatives
  • Select the first rule
  • Select the rule with the highest specificity or
    number of antecedent clauses
  • Select the rule that refers to the data which has
    changed most recently
  • If the rule has fired on the previous cycle, do
    not add it to the conflict set
  • In case where there is a tie, select a rule
    randomly from this subset of the original
    conflict set

15
A Forward-Chaining Example (1)
  • Data in working memory
  • num_wheel 4
  • motor yes
  • num_doors 3
  • size medium
  • Trigger rule Automobile
  • Conflict set rule Automobile
  • Fire rule Automobile

16
A Forward-Chaining Example (2)
  • Data in working memory
  • num_wheels 4
  • motor yes
  • num_doors 3
  • size medium
  • vehicleType automobile
  • Trigger rule MiniVan
  • Conflict set rule MiniVan
  • Fire rule MiniVan

17
A Forward-Chaining Example (3)
  • Data in working memory
  • num_wheels 4
  • motor yes
  • num_doors 3
  • size medium
  • vehicleType automobile
  • vehicle MiniVan
  • Trigger rule MiniVan
  • Not added to the conflict set
  • Conflict set is empty

18
Forward-Chaining vs. Backward-Chaining Reasoning
  • Forward-chaining
  • Used to produce new information
  • Backward-chaining
  • Used to answer questions about whether a goal
    clause is true or not
  • Goal-directed inferencing
  • More focused

19
Backward-Chaining Reasoning (1)
  • Load the rule base into the inference engine, and
    any facts from the knowledge base into the
    working memory
  • Specify a goal variable for the inference engine
    to find
  • Find the set of rules which refer to the goal
    variable in a consequent clause. Put each rule
    on the goal stack
  • If the goal is empty, halt
  • Take the top rule off the goal stack

20
Backward-Chaining Reasoning (2)
  • 6. For each antecedent clause
  • If the clause is true, go on to the next
    antecedent clause
  • If the clause is false, pop the rule off the goal
    stack and go to step 4
  • If the truth value is unknown, go to step 3, with
    the antecedent variable as the new goal variable
  • If all antecedent clauses are true, fire the
    rule, setting the consequent variable to the
    consequent value, pop the rule off the goal
    stack, and go to step 4

21
A Backward-Chaining Example (1)
  • Query vehicle MiniVan?
  • Working memory empty
  • Goal stack (vehicle, rule Minivan)
  • Antecedent vehicleType automobile?
  • Goal stack (vehicleType, rule Automobile),
  • (vehicle, rule MiniVan)
  • Antecedent num_wheels 4?
  • No rules that have num_wheels 4 as a
    consequence

22
A Backward-Chaining Example (2)
  • Ask the user to obtain that num_wheels 4
  • Working memory
  • num_wheels 4
  • Antecedent motor yes?
  • Ask the user to know that motor yes
  • Working memory
  • num_wheels 4
  • motor yes

23
A Backward-Chaining Example (3)
  • Fire and pop off rule Automobile
  • Working memory
  • num_wheels 4
  • motor yes
  • vehicleType automobile
  • Goal stack (vehicle, rule MiniVan)
  • Antecedent size medium?

24
A Backward-Chaining Example (4)
  • Ask the user to find size medium
  • Working memory
  • num_wheels 4
  • motor yes
  • vehicleType automobile
  • size medium
  • Antecedent num_doors 3?
  • Ask the user to know num_doors 3
  • Fire and pop off rule MiniVan
  • vehicle MiniVan

25
Rule Applet
26
Class Diagram of Rule Applet
27
Class Rule (1)
  • import java.util.
  • import java.io.
  • import java.awt.
  • public class Rule
  • RuleBase rb
  • String name
  • Clause antecedents
  • Clause consequent
  • Boolean truth
  • boolean firedfalse

28
Class Rule (2)
  • Rule(RuleBase Rb, String Name, Clause lhs,
    Clause rhs)
  • rb Rb
  • name Name
  • antecedents new Clause1
  • antecedents0 lhs
  • lhs.addRuleRef(this)
  • consequent rhs
  • rhs.addRuleRef(this)
  • rhs.isConsequent()
  • rb.ruleList.addElement(this) truth null

29
Class Rule (3)
  • Rule(RuleBase Rb, String Name, Clause lhs1,
    Clause lhs2,
  • Clause rhs)
  • rb Rb
  • name Name
  • antecedents new Clause2
  • antecedents0 lhs1
  • lhs1.addRuleRef(this)
  • antecedents1 lhs2
  • lhs2.addRuleRef(this)
  • consequent rhs
  • rhs.addRuleRef(this)
  • rhs.isConsequent()

30
Class Rule (4)
  • rb.ruleList.addElement(this) truth null
  • Rule(RuleBase Rb, String Name, Clause lhs1,
    Clause lhs2,
  • Clause lhs3, Clause rhs)
  • rb Rb
  • name Name
  • antecedents new Clause3
  • antecedents0 lhs1
  • lhs1.addRuleRef(this)
  • antecedents1 lhs2

31
Class Rule (5)
  • lhs2.addRuleRef(this)
  • antecedents2 lhs3
  • lhs3.addRuleRef(this)
  • consequent rhs
  • rhs.addRuleRef(this)
  • rhs.isConsequent()
  • rb.ruleList.addElement(this) truth null

32
Class Rule (6)
  • Rule(RuleBase Rb, String Name, Clause lhs1,
    Clause lhs2, Clause
    lhs3, Clause lhs4,
    Clause rhs)
  • rb Rb
  • name Name
  • antecedents new Clause4
  • antecedents0 lhs1
  • lhs1.addRuleRef(this)
  • antecedents1 lhs2
  • lhs2.addRuleRef(this)
  • antecedents2 lhs3

33
Class Rule (7)
  • lhs3.addRuleRef(this)
  • antecedents3 lhs4
  • lhs4.addRuleRef(this)
  • consequent rhs
  • rhs.addRuleRef(this)
  • rhs.isConsequent()
  • rb.ruleList.addElement(this) truth null

34
Class Rule (8)
  • long numAntecedents()
  • return antecedents.length
  • public static void checkRules(Vector
    clauseRefs)
  • Enumeration enum clauseRefs.elements()
  • while(enum.hasMoreElements())
  • Clause temp (Clause)enum.nextElement()
  • Enumeration enum2 temp.ruleRefs.elements()

35
Class Rule (9)
  • while(enum2.hasMoreElements())
  • ((Rule)enum2.nextElement()).check()
  • Boolean check()
  • RuleBase.appendText(
  • "\nTesting rule " name )
  • for (int i0 i lt antecedents.length i )
  • if (antecedentsi.truth null) return null

36
Class Rule (10)
  • if (antecedentsi.truth.
  • booleanValue() true)
  • continue
  • else
  • return truth new
  • Boolean(false)
  • return truth
  • new Boolean(true)

37
Class Rule (11)
  • void fire()
  • RuleBase.appendText(
  • "\nFiring rule " name )
  • truth new Boolean(true)
  • fired true
  • consequent.lhs.setValue(
  • consequent.rhs)
  • checkRules(consequent.lhs.
  • clauseRefs)

38
Class Rule (12)
  • Boolean backChain()
  • RuleBase.appendText(
  • "\nEvaluating rule " name)
  • for (int i0 i lt
  • antecedents.length i)
  • if (antecedentsi.truth
  • null) rb.backwardChain(
  • antecedentsi.lhs.name)
  • if (antecedentsi.truth
  • null)
  • antecedentsi.lhs.askUser() truth
    antecedentsi.check()

39
Class Rule (13)
  • if (antecedentsi.truth.
  • booleanValue() true)
  • continue
  • else
  • return truth new
  • Boolean(false)
  • return truth new Boolean(true)

40
Class Rule (14)
  • void display(TextArea textArea)
  • textArea.append(name " IF ")
  • for(int i0 i lt
  • antecedents.length i)
  • Clause nextClause
  • antecedentsi
  • textArea.append(
  • nextClause.lhs.name
    nextClause.cond.asString()
  • nextClause.rhs " ")

41
Class Rule (15)
  • if ((i1) lt antecedents.length)
    textArea.append("\n AND ")
  • textArea.append(
  • "\n THEN ")
  • textArea.append(
  • consequent.lhs.name
    consequent.cond.asString()
    consequent.rhs "\n")

42
Class Clause (1)
  • import java.util.
  • import java.io.
  • public class Clause
  • Vector ruleRefs
  • RuleVariable lhs
  • String rhs
  • Condition cond
  • Boolean consequent
  • Boolean truth

43
Class Clause (2)
  • Clause(RuleVariable Lhs,
  • Condition Cond, String Rhs)
  • lhs Lhs cond Cond
  • rhs Rhs
  • lhs.addClauseRef(this)
  • ruleRefs new Vector()
  • truth null
  • consequent new
  • Boolean(false)

44
Class Clause (3)
  • void addRuleRef(Rule ref) ruleRefs.addElement(re
    f)
  • Boolean check()
  • if (consequent.booleanValue() true)
    return null
  • if (lhs.value null)
  • return truth null else
  • switch(cond.index)
  • case 1 truth new Boolean(lhs.value.equal
    s(rhs))

45
Class Clause (4)
  • RuleBase.appendText(
  • "\nTesting Clause " lhs.name " " rhs
    " " truth)
  • break
  • case 2 truth new Boolean(
  • lhs.value.compareTo(rhs) gt 0)
  • RuleBase.appendText(
  • "\nTesting Clause " lhs.name " gt " rhs
    " " truth)
  • break
  • case 3 truth new Boolean(
  • lhs.value.compareTo(rhs) lt 0)

46
Class Clause (5)
  • RuleBase.appendText(
  • "\nTesting Clause " lhs.name " lt " rhs "
    " truth)
  • break
  • case 4 truth new Boolean(
  • lhs.value.compareTo(rhs) ! 0)
  • RuleBase.appendText(
  • "\nTesting Clause " lhs.name " ! " rhs
    " " truth)
  • break

47
Class Clause (6)
  • return truth
  • void isConsequent()
  • consequent new Boolean(true)
  • Rule getRule() if (consequent.booleanValue()
    true)
  • return (Rule)ruleRefs.firstElement()
  • else return null

48
Class Condition (1)
  • import java.util.
  • import java.io.
  • public class Condition
  • int index
  • String symbol
  • Condition(String Symbol)
  • symbol Symbol
  • if (Symbol.equals(""))
  • index 1
  • else if (Symbol.equals("gt"))
  • index 2

49
Class Condition (2)
  • else if (Symbol.equals("lt")) index 3
  • else if (Symbol.equals("!")) index 4
  • else index -1
  • String asString()
  • String temp new String()
  • switch (index)
  • case 1 temp ""
  • break

50
Class Condition (3)
  • case 2 temp "gt"
  • break
  • case 3 temp "lt"
  • break
  • case 4 temp "!"
  • break
  • return temp

51
Class Variable (1)
  • import java.util.
  • import java.io.
  • public abstract class Variable
  • String name
  • String value
  • int column
  • public Variable()
  • public Variable(String Name) name Name value
    null
  • void setValue(String val)
  • value val
  • String getValue()
  • return value

52
Class Variable (2)
  • Vector labels
  • void setLabels(String Labels)
  • labels new Vector()
  • StringTokenizer tok new
  • StringTokenizer(Labels," ")
  • while (tok.hasMoreTokens())
  • labels.addElement(new
  • String(tok.nextToken()))

53
Class Variable (3)
  • String getLabel(int index)
  • return
  • (String)labels.elementAt(index)
  • String getLabels()
  • String labelList new String()
  • Enumeration enum
  • labels.elements()
  • while(enum.hasMoreElements())
  • labelList
  • enum.nextElement() " "
  • return labelList

54
Class Variable (4)
  • int getIndex(String label)
  • int i 0, index 0
  • Enumeration enum
  • labels.elements()
  • while(enum.hasMoreElements())
  • if (label.equals(enum.nextElement()))
  • index i break
  • i
  • return i

55
Class Variable (5)
  • boolean categorical()
  • if (labels ! null)
  • return true
  • else
  • return false
  • public void setColumn(int col) column col

56
Class Variable (6)
  • public abstract void computeStatistics(
  • String inValue)
  • public abstract int normalize(String inValue,
  • float outArray, int inx)
  • public int normalizedSize() return 1
  • public String getDecodedValue(float act,
  • int index) return String.valueOf(actindex)

57
Class RuleVariables (1)
  • import java.util.
  • import java.awt.
  • public class RuleVariable extends Variable
  • public RuleVariable(String Name)
  • super(Name)
  • clauseRefs new Vector()
  • void setValue(String val)
  • value val
    updateClauses()

58
Class RuleVariables (2)
  • String askUser()
  • String answer RuleApplet.waitForAnswer(
  • promptText, getLabels()) RuleBase.appendText(
  • "\n !!! Looking for " name ". User
    entered " answer)
  • setValue(answer)
  • return value

59
Class RuleVariables (3)
  • Vector clauseRefs
  • void addClauseRef(Clause ref)
    clauseRefs.addElement(ref)
  • void updateClauses()
  • Enumeration enum clauseRefs.elements()
  • while(enum.hasMoreElements())
  • ((Clause)enum.nextElement()).
  • check()

60
Class RuleVariables (4)
  • String promptText
  • String ruleName
  • void setRuleName(String rname) ruleName
    rname
  • void setPromptText(String text) promptText
    text
  • public void computeStatistics(
  • String inValue)
  • public int normalize(String inValue, float
    outArray, int inx) return inx

61
Class RuleBase (1)
  • import java.util.
  • import java.io.
  • import java.awt.
  • public class RuleBase
  • String name
  • Hashtable variableList
  • Clause clauseVarList
  • Vector ruleList
  • Vector conclusionVarList
  • Rule rulePtr
  • Clause clausePtr
  • Stack goalClauseStack

62
Class RuleBase (2)
  • static TextArea textArea1
  • public void setDisplay(
  • TextArea txtArea)
  • textArea1 txtArea
  • RuleBase(String Name)
  • name Name
  • public static void appendText(String text)
    textArea1.append(text)

63
Class RuleBase (3)
  • public void displayVariables(
  • TextArea textArea)
  • Enumeration enum variableList.elements()
  • while(enum.hasMoreElements())
  • RuleVariable temp (RuleVariable)enum.
  • nextElement()
  • textArea.append("\n"
  • temp.name " value "
  • temp.value)

64
Class RuleBase (4)
  • public void displayRules(
  • TextArea textArea)
  • textArea.append("\n" name
  • " Rule Base " "\n")
  • Enumeration enum
  • ruleList.elements()
  • while(enum.hasMoreElements())
  • Rule temp
  • (Rule)enum.nextElement()
  • temp.display(textArea)

65
Class RuleBase (5)
  • public void displayConflictSet(Vector ruleSet)
  • textArea1.append("\n"
  • " -- Rules in conflict set\n")
  • Enumeration enum
  • ruleSet.elements()
  • while(enum.hasMoreElements())
  • Rule temp
  • (Rule)enum.nextElement()
  • textArea1.append(temp.name
  • "(" temp.numAntecedents()
  • "), " )

66
Class RuleBase (6)
  • public void reset()
  • textArea1.append(
  • "\n --- Setting all " name
  • " variables to null")
  • Enumeration enum
  • variableList.elements()
  • while(enum.hasMoreElements())
  • RuleVariable temp
  • (RuleVariable)enum.
  • nextElement()
  • temp.setValue(null)

67
Class RuleBase (7)
  • public void backwardChain(
  • String goalVarName)
  • RuleVariable goalVar
  • (RuleVariable)variableList.get(
  • goalVarName)
  • Enumeration goalClauses goalVar.clauseRefs.el
    ements()
  • while (goalClauses.hasMoreElements())
  • Clause goalClause (Clause)goalClauses.nextE
    lement()

68
Class RuleBase (8)
  • if (goalClause.consequent.
  • booleanValue()false)continue
    goalClauseStack.push(goalClause)
  • Rule goalRule
  • goalClause.getRule()
  • Boolean ruleTruth goalRule.backChain()
  • if (ruleTruth null)
  • textArea1.append("\nRule " goalRule.name
    " is null, can't
    determine truth value.")

69
Class RuleBase (9)
  • else if (ruleTruth.booleanValue() true)
  • goalVar.setValue(goalClause.rhs)
    goalVar.setRuleName(
  • goalRule.name)
  • goalClauseStack.pop() textArea1.append("\nRule
    " goalRule.name
  • " is true, setting " goalVar.name " "
    goalVar.value)

70
Class RuleBase (10)
  • if (
  • goalClauseStack.empty() true)
  • textArea1.append(
  • "\n Found Solution for goal "
    goalVar.name)
  • break
  • else
  • goalClauseStack.pop()
  • textArea1.append("\nRule "
  • goalRule.name
  • " is false, can't set " goalVar.name)

71
Class RuleBase (11)
  • if (goalVar.value null)
  • textArea1.append(
  • "\n Could Not Find Solution for goal "
    goalVar.name)
  • public Vector match(boolean test)
  • Vector matchList new
  • Vector()
  • Enumeration enum
  • ruleList.elements()

72
Class RuleBase (12)
  • while (enum.hasMoreElements())
  • Rule testRule (Rule)enum.nextElement()
  • if (test) testRule.check()
  • if (testRule.truth null) continue
  • if ((testRule.truth.booleanValue()
  • true)
  • (testRule.fired false)) matchList.addEleme
    nt(testRule)

73
Class RuleBase (13)
  • displayConflictSet(matchList)
  • return matchList
  • public Rule selectRule(
  • Vector ruleSet)
  • Enumeration enum
  • ruleSet.elements()
  • long numClauses
  • Rule nextRule
  • Rule bestRule
  • (Rule)enum.nextElement()

74
Class RuleBase (14)
  • long max bestRule.numAntecedents()
  • while (enum.hasMoreElements())
  • nextRule
  • (Rule)enum.nextElement()
  • if ((numClauses
  • nextRule.numAntecedents())
  • gt max)
  • max numClauses
  • bestRule nextRule
  • return bestRule

75
Class RuleBase (15)
  • public void forwardChain()
  • Vector conflictRuleSet new
  • Vector()
  • conflictRuleSet match(true)
  • while(
  • conflictRuleSet.size() gt 0)
  • Rule selected
  • selectRule(conflictRuleSet) selected.fire()
  • conflictRuleSet match(false)

76
Class RuleVarDialog (1)
  • import java.awt.
  • public class RuleVarDialog extends Dialog
  • void button1_Clicked(
  • java.awt.event.ActionEvent event)
  • answer
  • textField1.getText().trim() dispose()

77
Class RuleVarDialog (2)
  • public RuleVarDialog(Frame parent,
  • boolean modal)
  • super(parent, modal)
  • panel1.setLayout(null)
  • panel1.setSize(360, 220)
  • add(panel1)
  • setSize(getInsets().left
  • getInsets().right
  • 352,getInsets().top getInsets().bottom
    214)
  • label1 new java.awt.Label("")
  • label1.setBounds(getInsets().left
    0,getInsets().top 12,407,61)

78
Class RuleVarDialog (3)
  • panel1.add(label1)
  • textField1 new
  • java.awt.TextField()
  • textField1.setText("")
  • textField1.setBounds(
  • getInsets().left
  • 192,getInsets().top 84,97,39)
  • panel1.add(textField1)
  • button1 new
  • java.awt.Button("Set")
  • button1.setBounds(getInsets().
  • left 24,getInsets().top
  • 144,124,41)

79
Class RuleVarDialog (4)
  • panel1.add(button1)
  • setTitle(
  • "Rule Applet -- Ask User")
  • SymAction lSymAction
  • new SymAction() button1.addActionListener(
  • lSymAction)
  • this.addWindowListener(
  • new windowEvents())

80
Class RuleVarDialog (5)
  • public RuleVarDialog(Frame parent, String title,
    boolean modal)
  • this(parent, modal)
  • setTitle(title)
  • class SymAction implements java.awt.event.Action
    Listener
  • public void actionPerformed(
  • java.awt.event.ActionEvent event)
  • Object object
  • event.getSource()

81
Class RuleVarDialog (6)
  • if (object button1)
  • button1_Clicked(event)
  • class windowEvents extends java.awt.event.WindowA
    dapter
  • public void windowClosing(
  • java.awt.event.WindowEvent event)
  • answer "" dispose()

82
Class RuleVarDialog (7)
  • public String getText()
  • return answer
  • java.awt.Panel panel1
  • new Panel()
  • java.awt.Label label1
  • new Label()
  • java.awt.TextField textField1
  • java.awt.Button button1
  • String answer new String("")

83
Logics
  • A logic consists of
  • A formal system for describing states of affairs,
    consisting of the syntax and the semantics of the
    language
  • A proof theory
  • The ontological commitments of a logic have to do
    with the nature of reality in the related world
  • The epistemological commitments of a logic have
    to do with states of knowledge an agent can have

84
Some Formal Languages
85
Propositional Logic Syntax
  • Syntax in Backs-Naur Form (BNF)
  • Example

86
Inference Rules (1)
  • The soundness of an inference can also be
    established through truth tables
  • Inference rules are some inference patterns that
    occur frequently
  • Inference rules can be used to make inferences
    without going through the tedious process of
    building truth tables
  • The inference rule that b can be derived from a
    is denoted as

87
Inference Rules (2)
  • Conjunctions and conjuncts
  • Disjunctions and disjuncts

88
Inference Rules (3)
  • Modus Ponens or Implication-Elimination
  • And Elimination

89
Inference Rules (4)
  • And-Introduction
  • Or-Introduction

90
Inference Rules (5)
  • Double-Negation Elimination
  • Unit Resolution

91
Inference Rules (6)
  • Resolution
  • b cannot be both true and false, one of the
    other disjuncts must be true in one of the
    premises
  • Or, equivalently, implication is transitive

92
First-Order Logic Syntax
93
Inference Rules Involving Quantifiers (1)
  • Substitution
  • Example
  • Universal Elimination

94
Inference Rules Involving Quantifiers (2)
  • Existential Elimination
  • Existential Introduction

95
An Example Proof (1)
  • Situation
  • The law says that it is a crime for an American
    to sell weapons to hostile nations. The country
    Nono, an enemy of America, has some missiles, and
    all of its missiles were sold to it by Colonel
    West, who is American
  • To be proved
  • West is a criminal

96
An Example Proof (2)
  • Facts in first-order logic

97
An Example Proof (3)
  • Proof

98
An Example Proof (4)
99
Proof as a Search Process
  • Initial state Knowledge base
  • Operators applicable inference rules
  • Goal test Knowledge base containing the
    sentence to be proved
  • The branching factor increases as the knowledge
    base grows
  • Universal Elimination can have enormous branching
    factor on its own

100
Generalized Modus Ponens (1)
  • And-Introduction, Universal Elimination, and
    Modus Ponens can be combined
  • Example

101
Generalized Modus Ponens (2)
  • There is a substitution q such that

102
Canonical Form
  • Horn sentences
  • Horn Normal Form
  • A knowledge base consisting of only Horn
    sentences
  • An inferencing mechanism with one inference rule,
    the generalized Modus Ponens, can be built

103
Unification
  • A unification routine, UNIFY, takes two atomic
    sentences and returns a substitution that would
    make both sentences look the same, i.e.,
  • Example

104
Standardize Apart
  • Rename the variables of one or both sentences,
    when two sentences are being unified
  • Example

105
Sample Proof Revisited (1)
  • Facts

106
Sample Proof Revisited (2)
  • Proof

107
Composition of Substitution
  • Composition of substitution is the substitution
    whose effect is identical to the effect of
    applying each substitution in turn
  • SUBST(COMPOSE(q1, q2), p)
  • SUBST(q2, SUBST(q1, p))

108
Algorithm FORWARD-CHAIN(KB, p)
  • If there is a sentence in KB that is a renaming
    of p then return
  • Add p to KB
  • For each in KB
  • such that for some i, UNIFY(pi, p) q
  • succeeds do

109
Algorithm FIND-AND-INFER(KB, premises,
conclusion, q)
  • If premise then
  • FORWARD-CHAIN(KB,
  • SUBST(q,conclusion))
  • else for each p in KB such that
  • UNIFY(p,SUBST(q,FIRST(premises)))q2
  • do
  • FIND-AND-INFER(KB, REST(premises),
  • conclusion, COMPOSE(q1, q2))

110
Example of Forward-Chaining (1)
  • Knowledge base

111
Example of Forward-Chaining (2)
  • FORWARD-CHAIN(KB,American(West))
  • FORWARD-CHAIN(KB,Nation(Nono))
  • FORWARD-CHAIN(KB,Enemy(Nono,America))
  • FORWARD-CHAIN(KB,Hostile(Nono))
  • FORWARD-CHAIN(KB,Owns(Nono,M1))
  • FORWARD-CHAIN(KB,Missile(M1))
  • FORWARD-CHAIN(KB,Sells(West, Nono, M1)
  • FORWARD-CHAIN(KB,Missile(M1))
  • FORWARD-CHAIN(KB,Weapon(M1))
  • FORWARD-CHAIN(KB,Criminal(West))

112
Algorithm BACK-CHAIN(KB,q)
  • BACK-CHAIN-LIST(KB,q,)

113
Algorithm BACK-CHAIN-LIST(KB, qlist, q)(1)
  • answers empty
  • If qlist is empty return q
  • qFIRST(qlist)
  • For each atomic sentence qi in KB such that
  • qi UNIFY(q,qi ) succeeds do
  • Add COMPOSE(q,qi) to answers

114
Algorithm BACK-CHAIN-LIST(KB, qlist, q)(2)
  • 5. For each sentence
  • in KB such that qi UNIFY(q,qi) succeeds do
  • Return the union of

115
Proof Tree
Criminal(x)
Sells(West,Nono,M1)
American(x)
Yes, x/West
Weapon(y)
Hostile(Nono)
Owns(Nono,M1)
Missile(y)
Yes,
Yes, y/M1
Missile(M1)
Nation(z)
Enemy(Nono,America)
Yes,
Yes, z/Nono
Yes,
116
Incompleteness of Modus Ponens
  • A proof procedure using Modus Ponens is
    incomplete
  • Example We can not derive S(A) using chaining of
    Modus Ponens from the following knowledge base

117
Gödels Completeness Theorem
  • For first-order logic, any sentence that is
    entailed by another set of sentences can be
    proved from that set
  • In other words, a complete proof procedure can be
    generated to prove a sentence entailed by another
    set of sentences
  • A such procedure is the resolution algorithm
    proposed by Robinson

118
Resolution
  • Resolution
  • b cannot be both true and false, one of the
    other disjuncts must be true in one of the
    premises
  • Or, equivalently, implication is transitive

119
The Resolution Inference Rule
  • Generalized resolution (disjunctions)
  • Generalized resolution (implications)

120
Canonical Forms for Resolution
  • Conjunctive Normal Form
  • Example
  • Implicative Normal Form
  • Example

121
Resolution Proofs Using Forward-Chaining Algorithm
y/w
w/x
x/A,z/A
122
Resolution with Refutation
  • Chaining with resolution is still not complete
  • Example For an empty KB, we can do nothing with
  • Proof by contradiction (reduction ad absurdum)
  • Example
  • To prove P, assume that P is false, and prove a
    contradiction

123
Proofs Using Resolution with Refutation
124
Conversion to Normal Form (1)
  • Any first-order logic sentence can be put into
    implicative (or conjunctive) normal form
  • Conversion procedure
  • 1. Eliminate implications
  • 2. Move negation inwards by de Morgans law

125
Conversion to Normal Form (2)
  • Conversion procedure (continue)
  • 3. Standardize variables
  • 4. Move quantifiers left
  • 5. Skolemize

126
Conversion to Normal Form (3)
  • Conversion procedure (continue)
  • 6. Distribute AND over OR
  • 7. Flatten nested conjunctions and disjunctions
  • 8. Convert disjunctions to implications

127
Dealing with Equality
  • Demodulation rule

128
Resolution Strategies
  • Unit preference
  • Set of support
  • Input resolution
  • Subsumption
Write a Comment
User Comments (0)
About PowerShow.com