Introduction to Rule-Based Reasoning - PowerPoint PPT Presentation

1 / 95
About This Presentation
Title:

Introduction to Rule-Based Reasoning

Description:

Introduction to Rule-Based Reasoning Jacques Robin Outline Rules as a knowledge representation formalism Common characteristics of rule-based systems Roadmap of rule ... – PowerPoint PPT presentation

Number of Views:129
Avg rating:3.0/5.0
Slides: 96
Provided by: JR93
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Rule-Based Reasoning


1
Introduction to Rule-Based Reasoning
  • Jacques Robin

2
Outline
  • Rules as a knowledge representation formalism
  • Common characteristics of rule-based systems
  • Roadmap of rule-based languages
  • Common advantages and limitations
  • Example practical application of rules
    declarative business rules
  • History of rule-based systems
  • Production Systems
  • Term Rewriting Systems
  • Logic Programming and Prolog

3
Rules as a Knowledge Representation Formalism
  • What is a rule?
  • A statement that specifies that
  • If a determined logical combination of
    conditions is satisfied,
  • over the set of an agents percepts
  • and/or facts in its Knowledge Base (KB)
  • that represent the current, past and/or
    hypothetical future of its environment model, its
    goals and/or its preferences,
  • then a logico-temporal combination of actions
    can or must be executed by the agent,
  • directly on its environment (through actuators)
    or on the facts in its KB.
  • A KB agent such that the persistent part of its
    KB consists entirely of such rules is called a
    rule-base agent
  • In such case, the inference engine used by the KB
    agent is an interpreter or a compiler for a
    specific rule language.

4
Rule-Based Agent
Environment
Sensors
Ask
Tell
Retract
  • Rule Engine
  • Problem class independent
  • Only dependent on rule language
  • Declarative code interpreter or compiler

Ask
  • Rule Base
  • Persistant intentional knowledge
  • Dependent on problem class, not instance
  • Declarative code

Effectors
5
Rule Languages Common Characteristics
  • Syntax generally
  • Extends a host programming language and/or
  • Restricts a formal logic and/or
  • Uses a semi-natural language with
  • closed keyword set expressing logical
    connectives and actions classes,
  • and an open keyword set to refer to the entities
    and relations appearing in the agents fact base
  • Some systems provide 3 distinct syntax layers
    for different users with automated tools to
    translate a rule across the various layers
  • Declarative semantics generally based on some
    formal logic
  • Operational semantics
  • Generally based on transition systems, automata
    or similar procedural formalisms
  • Formalizes the essence of the rule interpreter
    algorithm.

6
Rule Languages General Advantages
  • Human experts in many domains (medicine, law,
    finance, marketing, administration, design,
    engineering, equipment maintenance, games,
    sports, etc.) find it intuitive and easy to
    formalize their knowledge as a rule base
  • Facilitates knowledge acquisition
  • Rules can be easily paraphrased in semi-natural
    language syntax, friendlier to experts averse to
    computational languages
  • Facilitates knowledge acquisition
  • Rule bases easy to formalize as logical formulas
    (conjunctions of equivalences and/or
    implications)
  • Facilitates building rule engine that perform
    sound, logic-based inference
  • Each rule largely independent of others in the
    base (but to precisely what degree depends highly
    of the rule engine algorithm)
  • Can thus be viewed as an encapsulated,
    declarative piece of knowledge
  • Facilitates life cycle evolution and composition
    of knowledge bases
  • Very sophisticated, mature rule base compilation
    techniques available
  • Allows scalable inference in practice
  • Some engines for simple rule languages can
    efficiently handle millions of rules

7
Rule Languages General Limitations
  • Subtle interactions between rules hard to debug
    without
  • sophisticated rule explanation GUI
  • detailed knowledge of the rule engines
    algorithm
  • Especially serious with
  • Object-oriented rule languages for combining
    rule-based deduction or abduction with
    class-based inheritance
  • Probabilistic rule languages for combining
    logical and Bayesian inference
  • But purely logical relational rule language do
    not naturally
  • Embed within mainstream object-oriented modeling
    and programming languages
  • Represent inherently procedural, taxonomic and
    uncertain knowledge
  • Current research challenge
  • User-friendly reasoning engine for probabilistic
    object-oriented rules

8
Business Rules
  • Example of modern commercial application of
    rule-based knowledge representation

9
Semi-Natural Language Syntaxfor Business Rules
  • Associate key word or key phrase to
  • Each domain model entity or relation name
  • Each rule language syntactic construct
  • Each host programming language construct used in
    rules
  • Substitute in place of these constructs and
    symbols the associated words or phrase
  • Example Is West Criminal? in semi-natural
    language syntax
  • IF P is American AND P sells a W to N AND
    W is a weapon
  • AND N is a nation AND N is hostile
  • THEN P is a criminal
  • IF nono owns a W AND W is a missile THEN west
    sells W to nono
  • IF W is a missile THEN W is a weapon
  • IF N is an enemy of America THEN N is hostile

10
Roadmap of Rule-Based Languages
11
Rewrite Rules Abstract Syntax
Rewrite Rule Base
  • plus(X,0) ? X
  • fib(suc(suc(N)))
  • ? plus(fib(suc(N)),fib(N))

12
Rewrite Rules Operational Semantics
13
Rewrite Rule Base Computation Example
  • plus(X,0) ? X
  • plus(X,suc(Y)) ? suc(plus(X,Y))
  • fib(0) ? suc(0)
  • fib(suc(0)) ? suc(0)
  • fib(suc(suc(N)) ? plus(fib(suc(N)),fib(N))
  1. fib(suc(suc(suc(0)))) w/ rule
    e?
  2. plus(fib(suc(suc(0))),fib(suc(0))) w/ rule d?
  3. plus(fib(suc(suc(0))),suc(0)) w/ rule b?
  4. suc(plus(fib(suc(suc(0))),0)) w/ rule a?
  5. suc(fib(suc(suc(0)))) w/ rule
    e?
  6. suc(plus(fib(suc(0)),fib(0))) w/ rule c?
  7. suc(plus(fib(suc(0)),suc(0))) w/ rule b?
  8. suc(suc(plus(fib(suc(0)),0))) w/ rule a?
  9. suc(suc(fib(suc(0)))) w/ rule
    d?
  10. suc(suc(suc(0)))

14
Conditional Rewrite RulesAbstract Syntax
Rewrite Rule Base
Rewrite Rule
  • X 0 ? Y 0 X Y ? 0

RHS

LHS
Condition

2
Term
Equation
  • Rule with matching LHS can only be fired if
    condition is also verified
  • Proving condition can be recursively done by
    rewriting it to true

15
Rewrite Rule Base Deduction ExampleIs West
Criminal?
  • Rewrite Rule Base
  • criminal(P) ? american(P) ? weapon(W) ? nation(N)
    ? hostile(N) ? sells(P,N,W)
  • sells(west,nono,W) ? owns(nono,W) ? missile(W)
  • hostile(N) ? enemy(N,america)
  • weapon(W) ? missile(W)
  • owns(nono,m1) ? missile(m1) ? american(west) ?
    nation(nono) ? enemy(nono,america) ? true
  • A ? B ? B ? A
  • A ? A ? A
  • Term
  • criminal(P)

  • american(P) ? weapon(W) ? nation(N) ? hostile(N)
    ? sells(P,N,W)
    w/ rule a
  • american(P) ? weapon(W) ? nation(N) ? hostile(N)
    ? owns(nono,W) ? missile(W) w/
    rule b
  • american(P) ? weapon(W) ? nation(N) ?
    enemy(N,america) ? owns(nono,W) ? missile(W) w/
    rule c
  • american(P) ? missile(W) ? nation(N) ?
    enemy(N,america) ? owns(nono,W) ? missile(W)
    w/ rule d
  • american(P) ? missile(W) ? nation(N) ?
    enemy(N,america) ? owns(nono,W)
    w/ rule g

  • ...

    w/ rule f
  • owns(nono,W) ? missile(W) ? american(P) ?
    nation(N) ? enemy(N,america)
    w/ rule f
  • true




    w/ rule e

16
Rewriting Systems Practical Application
  • Theorem proving
  • CASE
  • Programming language formal semantics
  • Program verification
  • Compiler design and implementation
  • Model transformation and automatic programming
  • Data integration
  • Using XSLT an XML-based language to rewrite
    XML-based data and documents
  • Web server pages and web services (also using
    XSLT)

17
Production Rules Abstract Syntax
IF (p(X,a) OR p(X,b)) AND
p(Y,Z) AND q(c) AND X ltgt Y AND X gt 3.5 THEN
Z X 12 AND addr(a,c,Z
AND deletep(Y,Z)
Arithmetic Predicate Symbol
Arithmetic Constant Symbol
18
Production System Architecture
Fact Base Management Component
Fact Base
Rule Firing Policy Component
Action Execution Component
Pattern Matching Component
Rule Base
Host Language API
Candidate Rules
19
Production Rules Operational Semantics
20
Conflict Resolution Strategies
  • Conflict resolution strategy
  • Heuristic to choose at each cycle which of the
    matching rule set to fire
  • Common strategies
  • Follow writing order of rules in rule base
  • Follow absolute priority level annotations
    associated with each rule or rule class
  • Follow relative priority level annotations
    associated with pairs of rules or rule classes
  • Prefer rules whose LHS match the most recently
    derived facts in the fact base
  • Prefer rules that have remained for the longest
    time unfired while matching a fact
  • Apply control meta-rules that declaratively
    specify arbitrarily sophisticated strategies

21
Production Rule Base ExampleIs West Criminal?
  • Production Rule Base
  • IF american(P) AND weapon(W) AND nation(N) AND
    hostile(N) AND sell(P,N,W)
  • THEN addcriminal(P)
  • IF owns(nono,W) AND missile(W) THEN
    addsells(west,nono,W)
  • IF missile(W) THEN addweapon(W)
  • IF enemy(N,america) THEN addhostile(N)
  • Initial Fact Base
  • owns(nono,m1)
  • missile(m1)
  • american(west)
  • nation(nono)
  • enemy(nono,america)
  • nation(america)

22
Production Rule Inference ExampleIs West
Criminal?
criminal(west)?
criminal(P)
american(P)
weapon(W)
nation(N)
hostile(N)
sells(P,N,W)
sells(west,nono,W)
missile(W)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
23
Production Rule Inference ExampleIs West
Criminal?
criminal(west)?
criminal(P)
american(P)
weapon(W)
nation(N)
hostile(N)
sells(P,N,W)
sells(west,nono,W)
missile(m1)
enemy(nono,america)
owns(nono,m1)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
24
Production Rule Inference ExampleIs West
Criminal?
criminal(west)?
criminal(P)
american(P)
weapon(m1)
nation(N)
hostile(N)
sells(P,N,W)
sells(west,nono,W)
missile(W)
enemy(nono,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
25
Production Rule Inference ExampleIs West
Criminal?
criminal(west)?
criminal(P)
american(P)
weapon(m1)
nation(N)
hostile(N)
sells(P,N,W)
sells(west,nono,W)
missile(m1)
enemy(nono,america)
owns(nono,m1)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
26
Production Rule Inference ExampleIs West
Criminal?
criminal(west)?
criminal(P)
american(P)
weapon(m1)
nation(N)
hostile(nono)
sells(P,N,W)
sells(west,nono,W)
missile(W)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enemy(nono,america)
owns(nono,m1)
nation(america)
27
Production Rule Inference ExampleIs West
Criminal?
criminal(west)?
criminal(P)
american(P)
weapon(m1)
nation(N)
hostile(nono)
sells(P,N,W)
sells(west,nono,W)
missile(m1)
owns(nono,m1)
missile(m1)
american(west)
nation(nono)
enemy(nono,america)
owns(nono,m1)
nation(america)
28
Production Rule Inference ExampleIs West
Criminal?
criminal(west)?
criminal(P)
american(P)
weapon(m1)
nation(N)
hostile(nono)
sells(P,N,W)
sells(west,nono,m1)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
29
Production Rule Inference ExampleIs West
Criminal?
criminal(west)?
criminal(P)
american(west)
weapon(m1)
nation(nono)
hostile(nono)
sells(west,nono,m1)
sells(west,nono,m1)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
30
Production Rule Inference ExampleIs West
Criminal?
criminal(west)?
criminal(west)
weapon(m1)
hostile(nono)
sells(west,nono,m1)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
31
Production Rule Inference ExampleIs West
Criminal?
criminal(west)? yes
criminal(west)
weapon(m1)
hostile(nono)
sells(west,nono,m1)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
32
Properties of Production Systems
  • Confluence
  • From confluent rule base, same final fact base
    is derived independently of rule firing order
  • Makes values of queries made to the system
    independent of the conflict resolution strategy
  • Termination
  • Terminating system does not enter in an infinite
    loop
  • Example of non-termination production rule base
  • Initial fact base p(0)
  • Production rule base IF p(X) THEN Y X 1 AND
    addp(Y)
  • Any production system which conflict resolution
    strategy does not prevent the same rule instance
    to be fired in two consecutive cycles is
    trivially non-terminating.

33
Production System Inference vs.Lifted Forward
Chaining
  • Common characteristics
  • Data driven reasoning
  • Requires conflict resolution strategy to choose
  • Which of several matching rules to fire
  • Which of several unifying clauses for next Modus
    Ponens inference step
  • Production System Inference
  • Sequential conjunction of actions in rule RHS
  • Non-monotonic reasoning due to delete actions
  • Matching only Datalog atoms (i.e., atoms which
    arguments are all non-functional terms)
  • Matching ground fact atoms against non-ground
    atoms in rule LHS And-Or atom
  • Neither sound nor complete inference engine
  • Lifted Forward Chaining
  • Unique conclusion in Horn Clause
  • Monotonic reasoning
  • Unifying arbitrary first-order atoms, possibly
    functional
  • Unifying two arbitrary atoms, possibly both
    non-grounds
  • Sound and refutation-complete

34
Embedded Production System Abstract Syntax
35
Generalized Production Rules ECA Rules
  • Event-Condition-Action rule extension of
    production rule with triggering event external to
    addition of facts in fact base
  • Only the rule subset which event just occurred is
    matched against the fact base
  • Events thus partition the rule base into subsets,
    each one specifying a behavior in response to a
    given events

Event Condtion Action Rule
LHS
RHS
Event
Agents Percept
HPL Boolean Operation
36
Production Rules vs. Rewriting Rules
  • Common characteristics
  • Data driven reasoning
  • Requires conflict resolution strategy to choose
  • Which of several matching rules to fire
  • Which of several rules with an LHS unifying with
    a sub-term
  • Non-monotonic reasoning due to
  • Fact deletion actions in RHS
  • Retraction of substituted sub-term
  • Tricky confluence and termination issues
  • Production System Inference
  • Fact base implicitly conjunctive
  • Matching only Datalog atoms (i.e., atoms which
    arguments are all non-functional terms)
  • Matching ground fact atoms against non-ground
    atoms in rule LHS And-Or atom
  • Term Rewriting
  • Reified logical connectives in term provide full
    first-order expressivity
  • Unifying arbitrary first-order atoms, possibly
    functional
  • Unifying two arbitrary atoms, possibly both
    non-grounds

37
Logic Programming a Versatile Metaphor
38
Logic Programming Key Ideas
Logical Theory Software Specification Declarative Programming Automated Reasoning Intelligent Databases
Logical Formula Abstract Specification Declarative Program / Data Structure Knowledge Base Database
Theorem Prover Specification Verifier Interpreter / Compiler Inference Engine Query Processor
Theorem Proof Specification Verification Program Execution Inference Query Execution
Theorem Proving Strategy Verification Algorithm Single, Fixed, Problem-Independent Control Structure Inference Search Algorithm Query Processing Algorithm
39
Logic programming vision
  • Single language with logic-based declarative
    semantics that is
  • A Turing-complete, general purpose programming
    language
  • A versatile, expressive knowledge representation
    language to support deduction and other reasoning
    services useful for intelligent agents
    (abduction, induction, constraint solving, belief
    revision, belief update, inheritance, planning)
  • Data definition, query and update language for
    databases with built-in inference capabilities
  • "One tool solves all" philosophy
  • Any computation resolution unification
    search
  • Programming declaring logical axioms (Horn
    clauses)
  • Running the program query about theorems
    provable from declared axioms
  • Algorithmic design entirely avoided (single,
    built-in control structure)
  • Same language for formal specification
    (modeling) and implementation
  • Same language for model checking and code testing

40
Prolog
  • First and still most widely used logic
    programming language
  • Falls short to fulfill the vision in many
    respect
  • Many imperative constructs with no logical
    declarative semantics
  • No commercial deductive database available
  • Most other logic programming languages both
  • Extend Prolog
  • Fulfill better one aspect of the logic
    programming vision
  • In the 80s, huge Japanese project tried to
    entirely rebuild all of computing from ground up
    using logic programming as hardware basis

41
Pure Prolog abstract syntax
arg

0..1

Pure Prolog Atom

head
body
Function-Free Term
Functional Term
functor
Variable
  • parent(al,jim)
  • ? parent(jim,joe)
  • ? anc(A,D) ? parent(A,D)
  • ? anc(A,D) ? parent(A,P) ? anc(P,D)

42
Full Prolog
arg

arg
Prolog Literal
Full Prolog Term

Functional Term
predicate
Function-Free Term
functor
Symbol
User-Defined Symbol
Built-in Symbol
Variable
Built-in Logical Symbol
Built-in Imperative Symbol
  • Semantics of full Prolog
  • Cannot be purely logic-based
  • Must integrate algorithmic ones

Meta-Programming Predicate Symbol
Numerical Symbol
I/O Predicate Symbol
Search Customization Predicate Symbol
Program Update Predicate Symbol
43
Pure Prolog program declarative formal semantics
  • Declarative, denotational, intentional
  • Clarks transformation to CFOL formula
  • First-order formula semantically equivalent to
    program
  • Declarative, denotational, extentional,
    model-theoretic
  • Least Herbrand Model
  • Intersection of all Herbrand Models
  • Conjunction of all ground formulas that are
    deductive consequences of program

44
CFOL x Prolog Semantic Assumptions
  • Classical First-Order Predicate Logic
  • No Unique Name Assumption (UNA) two distinct
    symbols can potentially be paraphrases to denote
    the same domain entity
  • Open-World Assumption (OWA) If KB ? Q but KB
    ? ?Q , the truth value of Q is considered
    unknown
  • Ex KB true ? core(ai) ? true ? core(se)
    ? core(C) ? offered(C,T) ?
    true ? offered(mda,fall)
  • Q true ? offered(mda,spring)
  • OWA necessary for monotonic, deductively sound
    reasoning If KB T then ?A, KB ? A T
  • Logic Programming
  • UNA two distinct symbols necessarily denote two
    distinct domain entities
  • Closed-World Assumption (CWA) If KB ? Q but KB
    ? ?Q , the truth value of Q is considered false
  • Ex ?- offered(mda,spring) fail
  • CWA is a logically unsound form of negatively
    abductive reasoning
  • CWA makes reasoning inherently non-monotonic as
    one can haveKB T but KB ? A ? Tif the
    proof KB T included steps assuming A false by
    CWA
  • Motivation intuitive, representational economy,
    consistent w/ databases

45
Clarks completion semantics
  • Transform Pure Prolog Program P into semantically
    equivalent CFOL formula comp(P)
  • Same answer query set derived from P
    (abductively) than from FP (deductively)
  • Example Pcore(se). core(ai).
    offered(mda,fall). offered(C,T) - core(C).
  • ?- offered(mda,spring)
  • no
  • ?-
  • Naive semantics naive(P)?C,T true ? core(ai)
    ? true ? core(se) ? true ?
    offered(mda,fall) ? core(C) ?
    offered(C,T) naive(P) ? ?offered(mda,spring)
  • Clarks completion semantics comp(P)
  • ?C,T,C1,T1
  • (core(C1) ? (C1ai ? C1se)) ?(offered(C1,T1) ?
    (C1mda ? T1fall) ? (?C,T (C1C
    ? T1T ? core(C)))) ??(aise) ? ?(aimda) ?
    ?(aifall) ? ?(sefall) ? ?(semda) ?
    ?(mdafall)Fp ?offered(mda,spring)

46
Clarks transformation
  • Axiomatizes closed-world and unique name
    assumptions in CFOL
  • Starts from naive Horn formula semantics of pure
    Prolog program
  • Partitions program in clause sets, each one
    defining one predicate (i.e., group together
    clauses with same predicate c(t1, ..., tn) as
    conclusion)
  • Replaces each such set by a logical equivalence
  • One side of this equivalence contains c(X1, ...,
    Xn) where X1, ..., Xn are fresh universally
    quantified variables
  • The other side contains a disjunction of
    conjunctions, one for each original clause
  • Each conjunction is either of the form
  • Xi ci ? ... ? Xj ci, if the original clause
    is a ground fact
  • ?Yi ... Yj Xi Yi ? ... ? Xj Yj ? p1( ...) ?
    ... ? pn( ... ) if the original clause is a rule
    with body p1( ...) ? ... ? pn( ... ) containing
    variables Yi ... Yj
  • Joins all resulting equivalences in a conjunction
  • Adds conjunction of the form ?(ci cj) for all
    possible pairs (ci,cj) of constant symbols in
    pure Prolog program

47
SLD Resolution
  • SLD resolution (Linear resolution with Selection
    function for Definite logic programs)
  • Joint use of goal-driven set of support and input
    resolution heuristics
  • Always pick last proven theorem clause with next
    untried axiom clause
  • Always questions last pick even if unrelated to
    failure that triggered backtracking
  • A form of goal-driven backward chaining of Horn
    clauses seen as deductive rules
  • Prolog uses special case of SLD resolution where
  • Axiom clauses tried in top to bottom program
    writing order
  • Atoms to unify in the two picked clauses
  • Conclusion of selected axiom clause
  • Next untried premise of last proven theorem
    clause in left to right program writing order
    (goal)
  • Unification without occur-check
  • Generates proof tree in top-down, depth-first
    manner
  • Failure triggers systematic, chronological
    backtracking
  • Try next alternative for last selection even if
    clearly unrelated to failure
  • Reprocess from scratch new occurrences of
    sub-goals previously proven true or false
  • Simple, intuitive, space-efficient,
    time-inefficient, potentially non-terminating
    (incomplete)

48
Refutation Resolution Proof Example
  • Refutation proof principle
  • To prove KB F
  • Prove logically equivalent (KB ? F) True
  • In turn logically equivalent to (KB ? ? F)
    False
  • (american(P) ? weapon(W) ?
  • nation(N) ? hostile(N) ?
  • sells(P,N,W) ? criminal(P)) //1
  • ? (T ? owns(nono,m1)) //2a
  • ? (T ? missile(m1)) //2b
  • ? (owns(nono,W) ? missile(W) ?
    sells(west,nono,W)) //3
  • ? (T ? american(west)) //4
  • ? (T ? nation(nono)) //5
  • ? (T ? enemy(nono,america)) //6
  • ? (missile(W) ? weapon(W)) //7
  • ? (enemy(N,america) ? hostile(N))
    //8
  • ? (T ? nation(america)) //9
  • ? (criminal(west) ? F) //0

1. Solve 0 w/ 1 unifying P/westamerican(west) ?
weapon(W) ? nation(N) ?hostile(N) ?
sells(west,N,W) ? F //10 2. Solve
10 w/ 4weapon(W) ? nation(N) ? hostile(N)
?sells(west,N,W) ? F
//11 3. Solve 11 w/ 7 missile(W) ? nation(N)
? hostile(N) ?sells(west,N,W) ? F
//12 4. Solve 12 w/ 2b unifying
W/m1nation(N) ? hostile(N) ? sells(west,N,m1) ?
F //13 5. Solve 13 w/ 5 unifying
N/nonohostile(nono) ? sells(west,nono,m1) ? F
//14 6. Solve 14 w/ 8 unifying
N/nonoenemy(nono,america) ? sells(west,nono,m1)
? F //15 7. Solve 15 w/ 6 sells(west,nono,m1) ?
F //16 8. Solve 16 w/ 3 unifying W/m1
owns(nono,m1) ? missile(m1) ? F
//17 9. Solve 17 with 2a missile(m1) ? F
//18 10. Solve 18 with 2b F
49
SLD resolution example
criminal(west)?
criminal(P)
american(P)
weapon(W)
nation(N)
hostile(N)
sells(P,N,W)
sells(west,nono,W)
missile(W)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
50
SLD resolution example
criminal(west)?
criminal(west)
american(P)
weapon(W)
nation(N)
hostile(N)
sells(P,N,W)
sells(west,nono,W)
missile(W)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
51
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(W)
nation(N)
hostile(N)
sells(west,N,W)
sells(west,nono,W)
missile(W)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
52
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(W)
nation(N)
hostile(N)
sells(west,N,W)
sells(west,nono,W)
missile(W)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
53
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(W)
nation(N)
hostile(N)
sells(west,N,W)
sells(west,nono,W)
missile(W)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
54
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(W)
nation(N)
hostile(N)
sells(west,N,W)
sells(west,nono,W)
missile(W)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
55
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(W)
nation(N)
hostile(N)
sells(west,N,W)
sells(west,nono,W)
missile(W)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
56
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(W)
nation(N)
hostile(N)
sells(west,N,W)
sells(west,nono,W)
missile(m1)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
57
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(N)
hostile(N)
sells(west,N,W)
sells(west,nono,W)
missile(m1)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
58
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(N)
hostile(N)
sells(west,N,m1)
sells(west,nono,W)
missile(m1)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
59
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(N)
hostile(N)
sells(west,N,m1)
sells(west,nono,W)
missile(m1)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
60
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(N)
hostile(N)
sells(west,N,m1)
sells(west,nono,W)
missile(m1)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
61
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(nono)
hostile(N)
sells(west,N,m1)
sells(west,nono,W)
missile(m1)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
62
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(nono)
hostile(nono)
sells(west,nono,m1)
sells(west,nono,W)
missile(m1)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
63
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(nono)
hostile(nono)
sells(west,nono,m1)
sells(west,nono,W)
missile(m1)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
64
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(nono)
hostile(nono)
sells(west,nono,m1)
sells(west,nono,W)
missile(m1)
enemy(nono,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
65
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(nono)
hostile(nono)
sells(west,nono,m1)
sells(west,nono,W)
missile(m1)
enemy(nono,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
66
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(nono)
hostile(nono)
sells(west,nono,m1)
sells(west,nono,W)
missile(m1)
enemy(nono,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
67
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(nono)
hostile(nono)
sells(west,nono,m1)
sells(west,nono,W)
missile(m1)
enemy(nono,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
68
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(nono)
hostile(nono)
sells(west,nono,m1)
sells(west,nono,m1)
missile(m1)
enemy(nono,america)
owns(nono,W)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
69
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(nono)
hostile(nono)
sells(west,nono,m1)
sells(west,nono,m1)
missile(m1)
enemy(nono,america)
owns(nono,m1)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
70
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(nono)
hostile(nono)
sells(west,nono,m1)
sells(west,nono,m1)
missile(m1)
enemy(nono,america)
owns(nono,m1)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
71
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(nono)
hostile(nono)
sells(west,nono,m1)
sells(west,nono,m1)
missile(m1)
enemy(nono,america)
owns(nono,m1)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
72
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(nono)
hostile(nono)
sells(west,nono,m1)
sells(west,nono,m1)
missile(m1)
enemy(nono,america)
owns(nono,m1)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
73
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(nono)
hostile(nono)
sells(west,nono,m1)
sells(west,nono,m1)
missile(m1)
enemy(nono,america)
owns(nono,m1)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
74
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(nono)
hostile(nono)
sells(west,nono,m1)
sells(west,nono,m1)
missile(m1)
enemy(nono,america)
owns(nono,m1)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
75
SLD resolution example
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(nono)
hostile(nono)
sells(west,nono,m1)
sells(west,nono,m1)
missile(m1)
enemy(nono,america)
owns(nono,m1)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
76
SLD resolution example
criminal(west)? yes
criminal(west)
american(west)
weapon(m1)
nation(nono)
hostile(nono)
sells(west,nono,m1)
sells(west,nono,m1)
missile(m1)
enemy(nono,america)
owns(nono,m1)
missile(m1)
american(west)
nation(nono)
enermy(nono,america)
owns(nono,m1)
nation(america)
77
SLD resolution example with backtracking
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(N)
hostile(N)
sells(west,N,m1)
sells(west,nono,W)
missile(m1)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(america)
enermy(nono,america)
owns(nono,m1)
nation(nono)
78
SLD resolution example with backtracking
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(N)
hostile(N)
sells(west,N,m1)
sells(west,nono,W)
missile(m1)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(america)
enermy(nono,america)
owns(nono,m1)
nation(nono)
79
SLD resolution example with backtracking
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(america)
hostile(N)
sells(west,N,m1)
sells(west,nono,W)
missile(m1)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(america)
enermy(nono,america)
owns(nono,m1)
nation(nono)
80
SLD resolution example with backtracking
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(america)
hostile(america)
sells(west,america,m1)
sells(west,nono,W)
missile(m1)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(america)
enermy(nono,america)
owns(nono,m1)
nation(nono)
81
SLD resolution example with backtracking
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(america)
hostile(america)
sells(west,america,m1)
sells(west,nono,W)
missile(m1)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(america)
enermy(nono,america)
owns(nono,m1)
nation(nono)
82
SLD resolution example with backtracking
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(america)
hostile(america)
sells(west,america,m1)
sells(west,nono,W)
missile(m1)
owns(nono,W)
enemy(america,america)
missile(m1)
american(west)
nation(america)
enermy(nono,america)
owns(nono,m1)
nation(nono)
83
SLD resolution example with backtracking
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(america)
hostile(america)
sells(west,america,m1)
sells(west,nono,W)
enemy(america,america)
missile(m1)
owns(nono,W)
fail
missile(m1)
american(west)
nation(america)
enermy(nono,america)
owns(nono,m1)
nation(nono)
84
SLD resolution example with backtracking
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(america)
hostile(america)
sells(west,america,m1)
sells(west,nono,W)
backtrack
missile(m1)
enemy(N,america)
owns(nono,W)
fail
missile(m1)
american(west)
nation(america)
enermy(nono,america)
owns(nono,m1)
nation(nono)
85
SLD resolution example with backtracking
criminal(west)?
criminal(west)
backtrack
american(west)
weapon(m1)
nation(N)
hostile(N)
sells(west,N,m1)
sells(west,nono,W)
missile(m1)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(america)
enermy(nono,america)
owns(nono,m1)
nation(nono)
86
SLD resolution example with backtracking
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(N)
hostile(N)
sells(west,N,m1)
sells(west,nono,W)
missile(m1)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(america)
enermy(nono,america)
owns(nono,m1)
nation(nono)
87
SLD resolution example with backtracking
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(nono)
hostile(N)
sells(west,N,m1)
sells(west,nono,W)
missile(m1)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(america)
enermy(nono,america)
owns(nono,m1)
nation(nono)
88
SLD resolution example with bactracking
criminal(west)?
criminal(west)
american(west)
weapon(m1)
nation(nono)
hostile(nono)
sells(west,nono,m1)
sells(west,nono,W)
missile(m1)
enemy(N,america)
owns(nono,W)
missile(m1)
american(west)
nation(america)
enermy(nono,america)
owns(nono,m1)
nation(nono)
89
Limitations of Pure Prolog and ISO Prolog
  • For programming
  • no fine-grained encapsulation
  • no code factoring (inheritance)
  • poor data structures (function symbols as only
    construct)
  • mismatch with dominant object-oriented paradigm
  • not integrated to comprehensive software
    engineering methodology
  • IDE not friendly enough
  • scarce middleware
  • very scarce reusable libraries or components (ex,
    web, graphics)
  • mono-thread
  • For declarative logic programming
  • imperative numerical computation, I/O and
    meta-programming without logical semantics
  • For knowledge representation
  • search customization
  • No declarative constructs
  • Limited support procedimental constructs (cuts)
  • no support for uncertain reasoning
  • forces unintuitive rule-based encoding of
    inherently taxonomic and procedural knowledge
  • knowledge base updates non-backtrackable and
    without logical semantics
  • ab - assert(a), b.if b fails, a remains as true

90
Limitation of SLD resolution engines
  • Unsound unification without occur-check
  • Incomplete left-recursion
  • Correct ancestor Prolog program
  • anc(A,D) - parent(A,D).
  • anc(A,D) - parent(P,D), anc(A,P).
  • Logically equivalent program (since conjunction
    is a commutative connective) that infinitely
    loops anc(A,D) - anc(A,P), parent(P,D).
    anc(A,D) - parent(A,D).
  • Inefficient
  • repeated proofs of same sub-goals
  • irrelevant chronological backtracking

91
Prologs imperative arithmetics
  • fac(0,1) - !.
  • fac(I,O) - I1 is I - 1,
  • fac(I1,O1), O is I O1.
  • ?- fac(1,X).
  • X 1
  • ?- fac(3,X).
  • X 6
  • ?- I1 is I -1
  • error
  • ?- I1 I -1
  • I1 I -1
  • ?- I 2, I1 I -1
  • I1 2 -1
  • ?- I 2, I1 is I -1
  • I1 1
  • Arithmetic functions and predicates generate
    exception if queried with non-ground terms as
    arguments
  • is requires a uninstantiated variable on the
    left and an arithmetic expression on the right
  • Relational programming property lost
  • Syntax more like assembly than functional !
  • is Prologs sole explicit variable assignment
    predicate (only for arithmetics)
  • is a bi-directional, general-purpose
    unification query predicate

92
Prologs redundant sub-goal proofs
93
Extensions of pure Prolog
Aleph
Inductive LP
Abductive LP
Preference LP
Functional LP
Pure Prolog
Constraint LP
ISO Prolog
XSB
High-Order LP
Tabled LP
Transaction LP
Flora
Frame (OO) LP
94
Constraint Logic Programming (CLP)
  • CSP libraries strengths
  • Specification level, declarative programming for
    predefined sets of constraints over given domains
  • Efficient
  • Extensive libraries cover both finite domain
    combinatorial problems and infinite numerical
    domain optimization problems
  • CSP libraries weaknesses
  • Constraint set extension can only be done
    externally through API using general-purpose
    programming language
  • Same problem for mixed constraint problems (ex,
    mixing symbolic finite domain with real
    variables)
  • Prologs strengths
  • Allows specification level, declarative
    programming of arbitrary general purpose problems
  • A constraint is just a predicate
  • New constraints easily declaratively specified
    through user predicate definitions
  • Mixed-domain constraints straightforwardly
    defined as predicate with arguments from
    different domains
  • Prologs weakness
  • Numerical programming is imperative, not
    declarative
  • Very inefficient at solving finite domain
    combinatorial problem

95
CLP
  • Integrate Prolog with constraint satisfaction and
    solving libraries in a single inference engine
  • Get the best of both worlds
  • Declarative user definition of arbitrary
    constraints
  • Declarative definition of arbitrarily mixed
    constraints
  • Declarative numerical and symbolic reasoning,
    seamlessly integrated
  • Efficient combinatorial and optimization problem
    solving
  • Single language to program constraint
    satisfaction or solving problems and the rest of
    the application

CLP Application Rule Base
CLP Engine
Prolog Engine
...
Procedural Solver for Domain D1
Procedural Solver for Domain Dk
Solver Programming Language L
Prolog/L Bridge
Write a Comment
User Comments (0)
About PowerShow.com