Title: RuleBased Reasoning
1Rule-Based Reasoning
2Outline
- Rules as a knowledge representation formalism
- Common characteristics of rule-based systems
- Diversity of rules and rule-based reasoning
- Advantages and limitations
- History of rule-based systems
- Constraint Handling Rules (CHR)
- Abstract syntax
- Declarative logical semantics
- High-level operational semantics
- Example rule bases
- Comparison with rewrite and production rules
- Extension CHRV
- Practical applications
3Rules 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 perceptions and/or the fluent
facts in an agents Knowledge Base (KB), - that represents 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, - on directly on its environment (through
actuators) or on its fluent facts. - 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.
4Rule-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
5Rule 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.
6Rule 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
7Rule 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 knowledge,
taxonomic and uncertain knowledge - Current research challenge
- User-friendly reasoning engine for probabilistic
object-oriented rules
8Roadmap of Rule-Based Languages
9Constraint Handling Rules (CHR)Key Ideas
- Originally a logical rule-based language to
declaratively program specialized constraint
solvers on top of a host programming language
(Prolog, Haskell, Java) - Since evolved in a general purpose first-order
knowledge representation language and
Turing-complete programming language - Fact base contains both extensional and
intentional knowledge in the form of a
conjunction of constraints - Rule base integrates and generalizes
- Event-Condition-Action rules (themselves
generalizing production rules) for constraint
propagation - Conditional rewrite rules for constraint
simplification - Relies on forward chaining and rule LHS matching
- Extended variant CHRV adds backtracking search
and thus generalizes Prolog rules as well
10CHR Syntax Overview
CHR Base
- Simplification rule sh1(X,a), sh2(b,Y)
ltgt g1(X,Y),
g2(a,b,c) b1(X,c), b2(Y,c). - Propagation rule ph1(X,Y), ph2(d)
gt g3(X), g4(d,Y)
b3(X,d), b4(X,Y). - Simpagation rule ph3(X), ph4(Y,Z) \
sh3(X,U), sh4(Y,V) ltgt g5(X,Z), g6(Z,Y)
b5(X), b6(Y,Z). - Simplification rules are conditional rewrite
rules (condition is the guard) - Propagation rules are event-condition-action
rules (event is the guard) - Simpagation rules heads are hybrid syntactic
sugar, each can be replaced by a semantically
equivalent simplification rule, ex, p, r \ s, t
ltgt g, h b, c. is equivalent to p, r, s, t ltgt
g, h p, r, b, c.
Body Rule-Defined and Built-In Constraints
Guard Built-In Constraints (from host
language)
Head Rule-Defined Constraints
11CHR Complete Abstract Syntax
body
guard
0..1
Logical Formula
CHR Rule
2..
simplified head
CHR Base
0..1
And Formula
propagated head
0..1
non-overlapping, complete
Atomic Formula
Simpagation Rule
Simplification Rule
Propagation Rule
12CHR Derivation Data Structures
body
guard
0..1
CHR Logical Formula
CHR Rule
2..
simplified head
CHR Base
0..1
And Formula
propagated head
0..1
arg
Atomic Formula
Simpagation Rule
Simplification Rule
Propagation Rule
Term
Built-In Constraint
Rule Defined Constraint
13CHR Declarative Semantics inClassical
First-Order Logic (CFOL)
- Simplification rule sh1, ... , shi ltgt g1, ...,
gj b1, ..., bk. - where X1, ..., Xn vars(sh1 ? ... ? shi ? g1
? ... ? gj) and Y1, ... , Ym vars(b1 ? ... ?
bk) \ X1, ..., Xn?X1, ..., Xn g1 ? ... ? gj
? (sh1 ? ... ? shi ? ?Y1, ... , Ym b1 ? ... ? bk) - Propagation rule ph1, ... , phi gt g1, ..., gj
b1, ..., bk. - where X1, ..., Xn vars(ph1 ? ... ? phi ? g1
? ... ? gj) and Y1, ... , Ym vars(b1 ? ... ?
bk) \ X1, ..., Xn?X1, ..., Xn g1 ? ... ? gj
? (ph1 ? ... ? phi ? ?Y1, ... , Ym b1 ? ... ? bk)
14CHR Operational Semantics
15CHR Rule Priority Heuristics
- No standard, implementation dependent
- Generally
- Simplification before simpagation before
propagation - Rule whose head matches the highest number of
RDCS constraints first - Rule matching yet untried for the longest time
first - Writing order
16CHR Base Example Is West Criminal?Goal-Directed
Version with Rewrite Rules
- criminal(P) ? american(P) ? weapon(W) ? nation(N)
? hostile(N) ? sells(P,N,W) - sells(P,N,W) ? N nono ? P west owns(N,W) ?
missile(W) - hostile(N) ? M america enemy(N,M)
- weapon(W) ? missile(W)
- owns(N,W) ? missile(W) ? american(P) ? nation(N)
? enemy(N,M) ? N nono ? W m1 ? P west ? M
america true
17CHR Base Example Is West Criminal?Goal-Directed
Version with Rewrite Rules
- criminal(P) ? american(P) ? weapon(W) ? nation(N)
? hostile(N) ? sells(P,N,W) - sells(P,N,W) ? N nono ? P west owns(N,W) ?
missile(W) - hostile(N) ? M america enemy(N,M)
- weapon(W) ? missile(W)
- owns(N,W) ? missile(W) ? american(P) ? nation(N)
? enemy(N,M) ? N nono ? W m1 ? P west ? M
america true
18CHR Base Example Is West Criminal?Goal-Directed
Version with Rewrite Rules
- criminal(P) ? american(P) ? weapon(W) ? nation(N)
? hostile(N) ? sells(P,N,W) - sells(P,N,W) ? N nono ? P west owns(N,W) ?
missile(W) - hostile(N) ? M america enemy(N,M)
- weapon(W) ? missile(W)
- owns(N,W) ? missile(W) ? american(P) ? nation(N)
? enemy(N,M) ? N nono ? W m1 ? P west ? M
america true
19CHR Base Example Is West Criminal?Goal-Directed
Version with Rewrite Rules
- criminal(P) ? american(P) ? weapon(W) ? nation(N)
? hostile(N) ? sells(P,N,W) - sells(P,N,W) ? N nono ? P west owns(N,W) ?
missile(W) - hostile(N) ? M america enemy(N,M)
- weapon(W) ? missile(W)
- owns(N,W) ? missile(W) ? american(P) ? nation(N)
? enemy(N,M) ? N nono ? W m1 ? P west ? M
america true
20CHR Base Example Is West Criminal?Goal-Directed
Version with Rewrite Rules
- criminal(P) ? american(P) ? weapon(W) ? nation(N)
? hostile(N) ? sells(P,N,W) - sells(P,N,W) ? N nono ? P west owns(N,W) ?
missile(W) - hostile(N) ? M america enemy(N,M)
- weapon(W) ? missile(W)
- owns(N,W) ? missile(W) ? american(P) ? nation(N)
? enemy(N,M) ? N nono ? W m1 ? P west ? M
america true
21CHR Base Example Is West Criminal?Goal-Directed
Version with Rewrite Rules
- criminal(P) ? american(P) ? weapon(W) ? nation(N)
? hostile(N) ? sells(P,N,W) - sells(P,N,W) ? N nono ? P west owns(N,W) ?
missile(W) - hostile(N) ? M america enemy(N,M)
- weapon(W) ? missile(W)
- owns(N,W) ? missile(W) ? american(P) ? nation(N)
? enemy(N,M) ? N nono ? W m1 ? P west ? M
america true
22CHR Base Example Is West Criminal?Goal-Directed
Version with Rewrite Rules
- criminal(P) ? american(P) ? weapon(W) ? nation(N)
? hostile(N) ? sells(P,N,W) - sells(P,N,W) ? N nono ? P west owns(N,W) ?
missile(W) - hostile(N) ? M america enemy(N,M)
- weapon(W) ? missile(W)
- owns(N,W) ? missile(W) ? american(P) ? nation(N)
? enemy(N,M) ? N nono ? W m1 ? P west ? M
america true
23CHR Base Example Is West Criminal?CHR are
matched not unified with constraint store
- 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
24CHR Base Example Is West Criminal?CHR are
matched not unified with constraint store
- 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
25CHR Base Example Is West Criminal?CHR are
matched not unified with constraint store
- 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
head sells(west,nono,W) unifies with constraint
sells(P,N,W) but does not match it!
26CHR Base Example Is West Criminal?CHR are
matched not unified with constraint store
- 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
27CHR Base Example Is West Criminal?CHR are
matched not unified with constraint store
- 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
- No new rule applies
- Neither positive nor negative conclusion can be
reached about the goal to prove - Like CFOL and unlike Prolog and production
systems, CHR makes open-world assumption - Thus, lack of proof for the goal does not result
in negative conclusion
28CHR Base Example Is West Criminal?Data-Driven
Version with Production Rules
- american(P) ? weapon(W) ? nation(N) ? hostile(N)
? sells(P,N,W) ? criminal(P) - owns(N,W) ? missile(W) ? N nono ? P west
sells(P,N,W) - enemy(N,M) ? M america hostile(N)
- missile(W) ? weapon(W)
- start ? N nono ? W m1 ? P west ? M
america owns(N,W) ? missile(W) ?
american(P) ? nation(N) ? enemy(N,M)
29CHR Base Example Is West Criminal?Data-Driven
Version with Production Rules
- american(P) ? weapon(W) ? nation(N) ? hostile(N)
? sells(P,N,W) ? criminal(P) - owns(N,W) ? missile(W) ? N nono ? P west
sells(P,N,W) - enemy(N,M) ? M america hostile(N)
- missile(W) ? weapon(W)
- start ? N nono ? W m1 ? P west ? M
america owns(N,W) ? missile(W) ?
american(P) ? nation(N) ? enemy(N,M)
30CHR Base Example Is West Criminal?Data-Driven
Version with Production Rules
- american(P) ? weapon(W) ? nation(N) ? hostile(N)
? sells(P,N,W) ? criminal(P) - owns(N,W) ? missile(W) ? N nono ? P west
sells(P,N,W) - enemy(N,M) ? M america hostile(N)
- missile(W) ? weapon(W)
- start ? N nono ? W m1 ? P west ? M
america owns(N,W) ? missile(W) ?
american(P) ? nation(N) ? enemy(N,M)
31CHR Base Example Is West Criminal?Data-Driven
Version with Production Rules
- american(P) ? weapon(W) ? nation(N) ? hostile(N)
? sells(P,N,W) ? criminal(P) - owns(N,W) ? missile(W) ? N nono ? P west
sells(P,N,W) - enemy(N,M) ? M america hostile(N)
- missile(W) ? weapon(W)
- start ? N nono ? W m1 ? P west ? M
america owns(N,W) ? missile(W) ?
american(P) ? nation(N) ? enemy(N,M)
32CHR Base Example Is West Criminal?Data-Driven
Version with Production Rules
- american(P) ? weapon(W) ? nation(N) ? hostile(N)
? sells(P,N,W) ? criminal(P) - owns(N,W) ? missile(W) ? N nono ? P west
sells(P,N,W) - enemy(N,M) ? M america hostile(N)
- missile(W) ? weapon(W)
- start ? N nono ? W m1 ? P west ? M
america owns(N,W) ? missile(W) ?
american(P) ? nation(N) ? enemy(N,M)
33CHR Base Example Is West Criminal?Data-Driven
Version with Production Rules
- american(P) ? weapon(W) ? nation(N) ? hostile(N)
? sells(P,N,W) ? criminal(P) - owns(N,W) ? missile(W) ? N nono ? P west
sells(P,N,W) - enemy(N,M) ? M america hostile(N)
- missile(W) ? weapon(W)
- start ? N nono ? W m1 ? P west ? M
america owns(N,W) ? missile(W) ?
american(P) ? nation(N) ? enemy(N,M)
34CHR Base Example Is West Criminal?Data-Driven
Version with Production Rules
- american(P) ? weapon(W) ? nation(N) ? hostile(N)
? sells(P,N,W) ? criminal(P) - owns(N,W) ? missile(W) ? N nono ? P west
sells(P,N,W) - enemy(N,M) ? M america hostile(N)
- missile(W) ? weapon(W)
- start ? N nono ? W m1 ? P west ? M
america owns(N,W) ? missile(W) ?
american(P) ? nation(N) ? enemy(N,M)
35CHR Base Example Is West Criminal?Data Driven
Version with Partially Instantiated Heads
- american(P) ? weapon(W) ? nation(N) ? hostile(N)
? sells(P,N,W) ? criminal(P) - owns(nono,W) ? missile(W) ? sells(west,nono,W)
- enemy(N,america) ? hostile(N)
- missile(W) ? weapon(W)
- start ? owns(nono,m1) ? missile(m1) ?
american(west) ? nation(nono) ?
enemy(nono,america)
36CHR Base Example Is West Criminal?Data Driven
Version with Partially Instantiated Heads
- american(P) ? weapon(W) ? nation(N) ? hostile(N)
? sells(P,N,W) ? criminal(P) - owns(nono,W) ? missile(W) ? sells(west,nono,W)
- enemy(N,america) ? hostile(N)
- missile(W) ? weapon(W)
- start ? owns(nono,m1) ? missile(m1) ?
american(west) ? nation(nono) ?
enemy(nono,america)
37CHR Base Example Is West Criminal?Data Driven
Version w/ Partially Instantiated Heads
- american(P) ? weapon(W) ? nation(N) ? hostile(N)
? sells(P,N,W) ? criminal(P) - owns(nono,W) ? missile(W) ? sells(west,nono,W)
- enemy(N,america) ? hostile(N)
- missile(W) ? weapon(W)
- start ? owns(nono,m1) ? missile(m1) ?
american(west) ? nation(nono) ?
enemy(nono,america)
38CHR Base Example Is West Criminal?Data Driven
Version w/ Partially Instantiated Heads
- american(P) ? weapon(W) ? nation(N) ? hostile(N)
? sells(P,N,W) ? criminal(P) - owns(nono,W) ? missile(W) ? sells(west,nono,W)
- enemy(N,america) ? hostile(N)
- missile(W) ? weapon(W)
- start ? owns(nono,m1) ? missile(m1) ?
american(west) ? nation(nono) ?
enemy(nono,america)
39CHR Base Example Is West Criminal?Data Driven
Version w/ Partially Instantiated Heads
- american(P) ? weapon(W) ? nation(N) ? hostile(N)
? sells(P,N,W) ? criminal(P) - owns(nono,W) ? missile(W) ? sells(west,nono,W)
- enemy(N,america) ? hostile(N)
- missile(W) ? weapon(W)
- start ? owns(nono,m1) ? missile(m1) ?
american(west) ? nation(nono) ?
enemy(nono,america)
40CHR Base Example Is West Criminal?Data Driven
Version w/ Partially Instantiated Heads
- american(P) ? weapon(W) ? nation(N) ? hostile(N)
? sells(P,N,W) ? criminal(P) - owns(nono,W) ? missile(W) ? sells(west,nono,W)
- enemy(N,america) ? hostile(N)
- missile(W) ? weapon(W)
- start ? owns(nono,m1) ? missile(m1) ?
american(west) ? nation(nono) ?
enemy(nono,america)
41CHR Base Example Is West Criminal?Data Driven
Version w/ Partially Instantiated Heads
- american(P) ? weapon(W) ? nation(N) ? hostile(N)
? sells(P,N,W) ? criminal(P) - owns(nono,W) ? missile(W) ? sells(west,nono,W)
- enemy(N,america) ? hostile(N)
- missile(W) ? weapon(W)
- start ? owns(nono,m1) ? missile(m1) ?
american(west) ? nation(nono) ?
enemy(nono,america)
42CHRV Abstract Syntax
2..
body
guard
0..1
CHR Rule
And Formula
Tried Alternative Body
simplified head
CHR Base
0..1
propagated head
0..1
Atomic Formula
Fired Rule
Simpagation Rule
Simplification Rule
Propagation Rule
Constraint
ordered
Built-In Constraint
Rule Defined Constraint
Built-In Constraint Store
Rule Defined Constraint Store
Derivation State
CHR Derivation
true
false
43CHRV Declarative Semantics inClassical
First-Order Logic (CFOL)
- Simplification rule sh1, ... , shi ltgt g1, ...,
gj b11, ..., bkp ... b11, ..., blq. - where X1, ..., Xn vars(sh1 ? ... ? shi ? g1
? ... ? gj) and Y1, ... , Ym vars(b1 ? ... ?
bk) \ X1, ..., Xn?X1, ..., Xn g1 ? ... ? gj
? (sh1 ? ... ? shi ?
?Y1, ... , Ym ((b11 ? ... ?
bkp) ? ... ? (b11 ? ... ? bkq)) - Propagation rule ph1, ... , phi gt g1, ..., gj
b11, ..., bkp ... b11, ..., blq. - where X1, ..., Xn vars(ph1 ? ... ? phi
? g1 ? ... ? gj) and Y1, ... , Ym vars(b1 ?
... ? bk) \ X1, ..., Xn?X1, ..., Xn g1 ? ...
? gj ? (ph1 ? ... ? phi ?
?Y1, ... , Ym ((b11 ? ...
? bkp) ? ... ? (b11 ? ... ? bkq))
44CHRV Operational Semantics
- When rule R with disjunctive body B1 ... Bk
is fired - Update both constraint stores using B1
- Start next matching-updating cycle
- When BICS false or when no rule matches the
RDCS - Backtrack to last alternative body Bi
- Restore both constraint stores to their states
prior to their update with Bi - Update both constraint stores using Bi1
- Start next matching-updating cycle
- Exhaustively try all alternative bodies of all
fired rules through backtracking
45CHRV Base Example Course Enrollment
- enrolled(john,C,T) gt T lt 1994 T gt 1996.
- enrolled(S,C,T), prereq(C,C) gt
enrolled(S,C,T), T lt T. - XltY, XltZ ltgt Y ltgd Z X lt Y.
- X ltY, X gt Y ltgt false.
- X gt X ltgt true.
- X lt Y ltgt gd(X), gd(Y) X ltgd Y
46CHRV Base Example Course Enrollment
- enrolled(john,C,T) gt T lt 1994 T gt 1996.
- enrolled(S,C,T), prereq(C,C) gt
enrolled(S,C,T), T lt T. - XltY, XltZ ltgt Y ltground Z X lt Y.
- X ltY, X gt Y ltgt false.
- X gt X ltgt true.
- X lt Y ltgt gd(X), gd(Y) X ltgd Y
47CHRV Base Example Course Enrollment
- enrolled(john,C,T) gt T lt 1994 T gt 1996.
- enrolled(S,C,T), prereq(C,C) gt
enrolled(S,C,T), T lt T. - XltY, XltZ ltgt Y ltground Z X lt Y.
- X ltY, X gt Y ltgt false.
- X gt X ltgt true.
- X lt Y ltgt gd(X), gd(Y) X ltgd Y
48CHRV Base Example Course Enrollment
- enrolled(john,C,T) gt T lt 1994 T gt 1996.
- enrolled(S,C,T), prereq(C,C) gt
enrolled(S,C,T), T lt T. - XltY, XltZ ltgt Y ltground Z X lt Y.
- X ltY, X gt Y ltgt false.
- X gt X ltgt true.
- X lt Y ltgt gd(X), gd(Y) X ltgd Y
49CHRV Base Example Course Enrollment
- enrolled(john,C,T) gt T lt 1994 T gt 1996.
- enrolled(S,C,T), prereq(C,C) gt
enrolled(S,C,T), T lt T. - XltY, XltZ ltgt Y ltground Z X lt Y.
- X ltY, X gt Y ltgt false.
- X gt X ltgt true.
- X lt Y ltgt gd(X), gd(Y) X ltgd Y
50CHRV Base Example Course Enrollment
- enrolled(john,C,T) gt T lt 1994 T gt 1996.
- enrolled(S,C,T), prereq(C,C) gt
enrolled(S,C,T), T lt T. - XltY, XltZ ltgt Y ltground Z X lt Y.
- X ltY, X gt Y ltgt false.
- X gt X ltgt true.
- X lt Y ltgt gd(X), gd(Y) X ltgd Y
51CHRV Base Example Course Enrollment
- enrolled(john,C,T) gt T lt 1994 T gt 1996.
- enrolled(S,C,T), prereq(C,C) gt
enrolled(S,C,T), T lt T. - XltY, XltZ ltgt Y ltground Z X lt Y.
- X ltY, X gt Y ltgt false.
- X gt X ltgt true.
- X lt Y ltgt gd(X), gd(Y) X ltgd Y
52CHRV Base Example Course Enrollment
- enrolled(john,C,T) gt T lt 1994 T gt 1996.
- enrolled(S,C,T), prereq(C,C) gt
enrolled(S,C,T), T lt T. - XltY, XltZ ltgt Y ltground Z X lt Y.
- X ltY, X gt Y ltgt false.
- X gt X ltgt true.
- X lt Y ltgt gd(X), gd(Y) X ltgd Y
53CHRV Base Example Course Enrollment
- enrolled(john,C,T) gt T lt 1994 T gt 1996.
- enrolled(S,C,T), prereq(C,C) gt
enrolled(S,C,T), T lt T. - XltY, XltZ ltgt Y ltground Z X lt Y.
- X ltY, X gt Y ltgt false.
- X gt X ltgt true.
- X lt Y ltgt gd(X), gd(Y) X ltgd Y
54CHRV Base Example Course Enrollment
- enrolled(john,C,T) gt T lt 1994 T gt 1996.
- enrolled(S,C,T), prereq(C,C) gt
enrolled(S,C,T), T lt T. - XltY, XltZ ltgt Y ltground Z X lt Y.
- X ltY, X gt Y ltgt false.
- X gt X ltgt true.
- X lt Y ltgt gd(X), gd(Y) X ltgd Y
55CHRV Base Example Course Enrollment
- enrolled(john,C,T) gt T lt 1994 T gt 1996.
- enrolled(S,C,T), prereq(C,C) gt
enrolled(S,C,T), T lt T. - XltY, XltZ ltgt Y ltground Z X lt Y.
- X ltY, X gt Y ltgt false.
- X gt X ltgt true.
- X lt Y ltgt gd(X), gd(Y) X ltgd Y
56CHRV Base Example Course Enrollment
- enrolled(john,C,T) gt T lt 1994 T gt 1996.
- enrolled(S,C,T), prereq(C,C) gt
enrolled(S,C,T), T lt T. - XltY, XltZ ltgt Y ltground Z X lt Y.
- X ltY, X gt Y ltgt false.
- X gt X ltgt true.
- X lt Y ltgt gd(X), gd(Y) X ltgd Y
57CHRV Base Example Course Enrollment
- enrolled(john,C,T) gt T lt 1994 T gt 1996.
- enrolled(S,C,T), prereq(C,C) gt
enrolled(S,C,T), T lt T. - XltY, XltZ ltgt Y ltground Z X lt Y.
- X ltY, X gt Y ltgt false.
- X gt X ltgt true.
- X lt Y ltgt gd(X), gd(Y) X ltgd Y
58CHRV Base Example Course Enrollment
- enrolled(john,C,T) gt T lt 1994 T gt 1996.
- enrolled(S,C,T), prereq(C,C) gt
enrolled(S,C,T), T lt T. - XltY, XltZ ltgt Y ltground Z X lt Y.
- X ltY, X gt Y ltgt false.
- X gt X ltgt true.
- X lt Y ltgt gd(X), gd(Y) X ltgd Y
59CHRV Base Example Course Enrollment
- enrolled(john,C,T) gt T lt 1994 T gt 1996.
- enrolled(S,C,T), prereq(C,C) gt
enrolled(S,C,T), T lt T. - XltY, XltZ ltgt Y ltground Z X lt Y.
- X ltY, X gt Y ltgt false.
- X gt X ltgt true.
- X lt Y ltgt gd(X), gd(Y) X ltgd Y
60CHRV Base Example AppendCHRV as a Logic
Programming Platform
- a) append(X,Y,Z) ? Y ? ( X ? Y L ?
Z L ) ? ( X H L1 ? Y L2 ? Z H L3
? append(L1,L2,L3)) - b) append(X, ,Z) ? X Z
61CHRV Base Example AppendCHRV as a Logic
Programming Platform
- a) append(X,Y,Z) ? Y ? ( X ? Y L ?
Z L ) ? ( X H L1 ? Y L2 ? Z H L3
? append(L1,L2,L3)) - b) append(X, ,Z) ? X Z
62CHRV Base Example AppendCHRV as a Logic
Programming Platform
- a) append(X,Y,Z) ? Y ? ( X ? Y L ?
Z L ) ? ( X H L1 ? Y L2 ? Z H L3
? append(L1,L2,L3)) - b) append(X, ,Z) ? X Z
63CHRV Base Example AppendCHRV as a Logic
Programming Platform
- a) append(X,Y,Z) ? Y ? ( X ? Y L ?
Z L ) ? ( X H L1 ? Y L2 ? Z H L3
? append(L1,L2,L3)) - b) append(X, ,Z) ? X Z
64CHRV Base Example AppendCHRV as a Logic
Programming Platform
- a) append(X,Y,Z) ? Y ? ( X ? Y L ?
Z L ) ? ( X H L1 ? Y L2 ? Z H L3
? append(L1,L2,L3)) - b) append(X, ,Z) ? X Z
65CHRV Base Example AppendCHRV as a Logic
Programming Platform
- a) append(X,Y,Z) ? Y ? ( X ? Y L ?
Z L ) ? ( X H L1 ? Y L2 ? Z H L3
? append(L1,L2,L3)) - b) append(X, ,Z) ? X Z
66CHRV Base Example AppendCHRV as a Logic
Programming Platform
- a) append(X,Y,Z) ? Y ? ( X ? Y L ?
Z L ) ? ( X H L1 ? Y L2 ? Z H L3
? append(L1,L2,L3)) - b) append(X, ,Z) ? X Z
67CHRV Base Example AppendCHRV as a Logic
Programming Platform
- a) append(X,Y,Z) ? Y ? ( X ? Y L ?
Z L ) ? ( X H L1 ? Y L2 ? Z H L3
? append(L1,L2,L3)) - b) append(X, ,Z) ? X Z
68CHRV Base Example AppendCHRV as a Logic
Programming Platform
- a) append(X,Y,Z) ? Y ? ( X ? Y L ?
Z L ) ? ( X H L1 ? Y L2 ? Z H L3
? append(L1,L2,L3)) - b) append(X, ,Z) ? X Z
69CHRV Base Example AppendCHRV as a Logic
Programming Platform
- a) append(X,Y,Z) ? Y ? ( X ? Y L ?
Z L ) ? ( X H L1 ? Y L2 ? Z H L3
? append(L1,L2,L3)) - b) append(X, ,Z) ? X Z
70CHRV Base Example AppendCHRV as a Logic
Programming Platform
- a) append(X,Y,Z) ? Y ? ( X ? Y L ?
Z L ) ? ( X H L1 ? Y L2 ? Z H L3
? append(L1,L2,L3)) - b) append(X, ,Z) ? X Z
71CHRV Base Example AppendCHRV as a Logic
Programming Platform
- a) append(X,Y,Z) ? Y ? ( X ? Y L ?
Z L ) ? ( X H L1 ? Y L2 ? Z H L3
? append(L1,L2,L3)) - b) append(X, ,Z) ? X Z
72CHRV Base Example AppendCHRV as a Logic
Programming Platform
- a) append(X,Y,Z) ? Y ? ( X ? Y L ?
Z L ) ? ( X H L1 ? Y L2 ? Z H L3
? append(L1,L2,L3)) - b) append(X, ,Z) ? X Z
73CHRV Practical Applications
- Declarative, easy to extend and compose
constraint solvers and all their applications - Scheduling, allocation, planning, optimization,
recommendation, configuration - Deductive theorem proving (propositional and
first-order) and all its applications - CASE tools, declarative programs analysis,
formal methods in hardware and software design, - Hypothetical adbuctive reasoning and all its
applications - Diagnosis and repair, observation explanation,
sensor data integration - Multi-agent reasoning
- Spatio-temporal reasoning and robotics
- Hybrid reasoning integrating
- Deduction, belief revision, abduction,
constraint solving and optimization - with open and closed world assumption
- Heterogeneous knowledge integration
- Semantic web services
- Natural language processing
74CHRV vs. Production Systems
- Common characteristics
- Forward chains rules
- Requires conflict resolution strategy to choose
- Which of several matching rules to fire
- Non-monotonic reasoning due to
- Constraint retraction in Rule-Defined Constraint
Store - Fact retraction in the RHS
- Tricky confluence and termination issues
- CHRV
- Constraint store contains arbitrary atoms
including functional, non-ground atoms - Simplification rules allow straightforward
modeling for goal-driven reasoning, with
rewriting simulating Prolog-like backward
chaining - Disjunctive bodies
- Built-in backtracking search
- Production Systems
- Fact base only contains ground Datalog atoms
- Cumbersome modeling to implement goal-driven
reasoning - No disjunctions in RHS
- No built-in search
75CHRV vs. Rewriting Systems
- Common characteristics
- Forward chains rules
- Requires conflict resolution strategy to choose
- Which of several matching rules to fire
- Non-monotonic reasoning due to
- Constraint retraction in Rule-Defined Constraint
Store - Retraction of substituted sub-term
- Tricky confluence and termination issues
- CHRV
- Matching applied to atomic formula conjunctions
- Rule head is matched with constraint store
sub-set, which requires head to be more general
than sub-set - Propagation rules provide further simplification
opportunities
- Rewriting Systems
- Unification of LHS is applied recursively down to
sub-terms - Rule LHS is unified with sub-term which can thus
be more general than LHS - All reasoning done through rewriting (no
propagation rules)
76CHRV vs. Prolog
- CFOL semantics of CHRV guardless, single head
simplification rule, equivalent to CFOL semantics
of pure Prolog clause set sharing same conclusion
(Clark's completion) - Simplification rule sh ltgt true b11, ..., bkp
... b11, ..., blq. - where X1, ..., Xn vars(shi), and Y1,
... , Ym vars(b1 ? ... ? bk) \ X1, ..., Xn
?X1, ..., Xn true ? (sh ? ?Y1, ... , Ym ((b11 ?
... ? bkp) ? ... ? (b11 ? ... ? bkq)) - Equivalent Prolog clauses sh - b11, ..., bkp.
, ... , sh - b11, ..., blq. - Thus, using Clark's completion, any Prolog
program can be reformulated into a semantically
equivalent CHRV program - CHRV extends Prolog with
- Conjunctions in the heads
- Guards
- Non-ground numerical constraints heads, guards
and bodies - Propagation rules