Download presentation
Presentation is loading. Please wait.
1
Rule-Based Reasoning Jacques Robin
2
Outline Rules as a knowledge representation formalism
Common characteristics of rule-based systems Diversity of rules and rule-based reasoning Advantages and limitations Production rules and systems Abstract syntax High-level operational semantics Example rule bases Special cases Practical applications Rewrite rules and systems Comparison with production rules 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
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 perceptions and/or the fluent facts in an agent’s 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.
4
Rule-Based Agent Fact Base: Environment Rule Engine: Rule Base:
Volatile extensional knowledge specific to both application domain and particular problem instance; Data Sensors Ask Rule Engine: Application Domain Independent Only dependent on rule language Declarative code interpreter or compiler Tell Retract Rule Base: Persistant intentional knowledge, specific to application domain, but general to problem class; 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 a closed keyword set expressing logical connectives and actions classes and an open keyword set to refer to the entities and relations appearing in the agent’s 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 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 and detailed knowledge with the rule engine’s algorithm Especially serious with object-oriented rule languages that combine rule-based deduction or abduction with class-based inheritance But purely relational rule-based language do not naturally: Embed within mainstream object-oriented modeling and programming languages Represent inherently procedural knowledge Represent taxonomic knowledge
8
Rule Languages: Diversity
Production rules Event-Condition-Action rules (ECA rules) Rewrite rules Conditional rewrite rules Logic program rules Constraint handling rules (CHR) Object-oriented rules Semantic web service rules (SWS rules) Business rules Meta-rules
9
Production Rules: Abstract Syntax
* IF (p(X,a) OR p(X,b)) AND p(Y,Z) AND q(c) AND X <> Y AND X > 3.5 THEN Z = X + 12 AND add{r(a,c,Z} AND delete{p(Y,Z)} Production Rule Base Production Rule Right-Hand Side (RHS) * Action Left-Hand Side (LHS) Arithmetic Calculation Fact Base Update Operator: enum{add,delete} And-Or Formula Connective: enum{and,or} Fact Base * Fact 2..* Atom Predicate Symbol Functor args Non-Ground Atom Non-Functional Term Arithmetic Predicate Symbol Ground Atom Variable Constant Symbol Arithmetic Constant Symbol
10
Production System Architecture
Fact Base Fact Base Management Component Pattern Matching Component Action Execution Component Rule Firing Policy Component Rule Base Host Language API Candidate Rules
11
Production Rules: Operational Semantics
[Matching Instantiated Rule Set Empty] Match LHS of Rule Base against Fact Base Pick one Instantiated Rule to Fire Matching Instantiated Rule Set [Else] Rule Base Fact Base [Matching Instantiated Rule Set Singleton] Selected Instantiated Rule Execute in Sequence Actions in RHS of Selected Instantiated Rule
12
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
13
Production Rule Base Example: Is West Criminal?
IF american(P) AND weapon(W) AND nation(N) AND hostile(N) AND sell(P,N,W) THEN add{criminal(P)} IF owns(nono,W) AND missile(W) THEN add{sells(west,nono,W) IF missile(W) THEN add{weapon(W)} IF enemy(N,america) THEN add{hostile(N)} Initial Fact Base: owns(nono,m1) missile(m1) american(west) nation(nono) enemy(nono,america) nation(america)
14
Production Rule Inference Example: Is 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) american(west) missile(m1) nation(nono) enermy(nono,america) owns(nono,m1) nation(america)
15
Production Rule Inference Example: Is 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,N) owns(nono,m1) american(west) missile(m1) nation(nono) enermy(nono,america) owns(nono,m1) nation(america)
16
Production Rule Inference Example: Is 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,N) owns(nono,W) american(west) missile(m1) nation(nono) enermy(nono,america) owns(nono,m1) nation(america)
17
Production Rule Inference Example: Is 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,N) owns(nono,m1) american(west) missile(m1) nation(nono) enermy(nono,america) owns(nono,m1) nation(america)
18
Production Rule Inference Example: Is 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) american(west) missile(m1) nation(nono) enemy(nono,N) owns(nono,m1) nation(america)
19
Production Rule Inference Example: Is 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) american(west) missile(m1) nation(nono) enemy(nono,america) owns(nono,m1) nation(america)
20
Production Rule Inference Example: Is West Criminal?
criminal(west)? criminal(P) american(P) weapon(m1) nation(N) hostile(nono) sells(P,N,W) sells(west,nono,m1) american(west) missile(m1) nation(nono) enermy(nono,america) owns(nono,m1) nation(america)
21
Production Rule Inference Example: Is West Criminal?
criminal(west)? criminal(P) american(west) weapon(m1) nation(nono) hostile(nono) sells(west,nono,m1) sells(west,nono,m1) american(west) missile(m1) nation(nono) enermy(nono,america) owns(nono,m1) nation(america)
22
Production Rule Inference Example: Is West Criminal?
criminal(west)? criminal(west) weapon(m1) hostile(nono) sells(west,nono,m1) american(west) missile(m1) nation(nono) enermy(nono,america) owns(nono,m1) nation(america)
23
Production Rule Inference Example: Is West Criminal?
criminal(west)? yes criminal(west) weapon(m1) hostile(nono) sells(west,nono,m1) american(west) missile(m1) nation(nono) enermy(nono,america) owns(nono,m1) nation(america)
24
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 add{p(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.
25
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
26
Embedded Production System: Abstract Syntax
Rule Base Production Rule Right-Hand Side (RHS) Fact Base Update Operator: enum{add,delete} * * Action * Fact Base\ Left-Hand Side (LHS) Fact And-Or Formula Connective: enum{and,or} HPL Boolean Operation HPL Operation * HPL Data Structure HPL Ground Data Structure 2..* args HPL Operator HPL Boolean Operator
27
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 Event RHS Agent’s Percept HPL Boolean Operation
28
Production Systems: Practical Applications
Reactive agents Expert systems in domains without complex entity taxonomy nor uncertainty Business rules Imperative OO Program Language SQL API GUI API Classic Implementation GUI Layer Data Layer Business Logic Layer Classic 3-Tier Information System Architecture Rule-Based Implementation Imperative OO Host Language Embedded Production Rule Engine Language SQL API GUI API Rule Base Easier to reflect frequent policy changes than imperative code Generic Component Reusable in Any Application Domain
29
Semi-Natural Language Syntax for Production Rules
Associate key word or key phrase to: Each domain model constant, function and predicate symbol Each production rule syntactic construct Each host programming language construct 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 nono to W IF W is a missile THEN W is a weapon IF N is an enemy of America THEN N is hostile
30
Rewrite Rules: Abstract Syntax
Rule Base Rewrite Rule * RHS plus(X,0) X fib(suc(suc(N))) plus(fib(suc(N)),fib(N)) LHS Term args * {non-overlapping, complete} {non-overlapping, complete} Functional Term Non-Functional Term Ground Term Non-Ground Term Function Symbol Constant Symbol Variable
31
Rewrite Rules: Operational Semantics
Unify LHS of Rewrite Rule Base against sub-terms of Term : Unifying Set of Pairs: Instantiated Rule Instantiated Sub-term : Rewrite Rule Base [ Matching Pair Set Empty ] [ Matching Pair Set Singleton ] Pick one Pair Set [ Else ] : Pair Instantiated Rule R Instantiated Sub-Term S T : Term Substitute Sub-Term S in Term T by RHS of Rule R
32
Rewrite Rule Base 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)) fib(suc(suc(suc(0)))) w/ rule e plus(fib(suc(suc(0))),fib(suc(0))) w/ rule d plus(fib(suc(suc(0))),suc(0)) w/ rule b suc(plus(fib(suc(suc(0))),0)) w/ rule a suc(fib(suc(suc(0)))) w/ rule e suc(plus(fib(suc(0)),fib(0))) w/ rule c suc(plus(fib(suc(0)),suc(0))) w/ rule b suc(suc(plus(fib(suc(0)),0))) w/ rule a suc(suc(fib(suc(0)))) w/ rule c suc(suc(suc(0)))
33
Conditional Rewrite Rules: Abstract Syntax
Rule Base Rewrite Rule * RHS X = 0 Y = 0 | X + Y 0 Condition LHS * 2 Equation Term Rule with matching LHS can only be fired if condition is also verified Proving condition can be recursively done by rewriting it to true
34
Rewrite Rule Base Example: Is West Criminal?
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
35
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)
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
Constraint 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
38
{non-overlapping, complete}
CHR: Syntax Overview guard simplified head propagated head body Logical Formula 0..1 * CHR Rule 2..* And Formula CHR Base Simpagation Rule Simplification Propagation {non-overlapping, complete} Atomic Formula Built-In Constraint Rule Defined Simplification rule: sh1(X,a), sh2(b,Y) <=> g1(X,Y), g2(a,b,c) | b1(X,c), b2(Y,c). Propagation rule: ph1(X,Y), ph2(d) ==> g3(X), g4(d,Y) | b3(X,d), b4(X,Y). Simpagation rule: ph3(X), ph4(Y,Z) \ sh3(X,U), sh4(Y,V) <=> 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 <=> g, h | b, c. is equivalent to p, r, s, t <=> g, h | p, r, b, c. Head: Rule-Defined Constraints Guard: Built-In Constraints (from host language) Body: Rule-Defined and Built-In Constraints
39
CHR: Complete Abstract Syntax
body guard 0..1 CHR Rule Logical Formula 2..* CHR Base * simplified head 0..1 And Formula propagated head 0..1 {non-overlapping, complete} Constraint Domain * arg * Term Constraint Symbol Atomic Formula Simplification Rule Simpagation Rule Propagation Rule Built-In Constraint Rule Defined true false Rule Defined Constraint Symbol Built-In arg * Non-Ground Term Ground {non-overlapping, complete} Functional Term Non-Functional {non-overlapping, complete} Variable Constant Symbol Function Symbol
40
CHR: Derivation Data Structures
body guard 0..1 CHR Rule CHR Logical Formula 2..* CHR Base * simplified head 0..1 And Formula * {ordered} Rule Defined Constraint Store Built-In Used Rule Derivation State CHR propagated head 0..1 arg Atomic Formula * Simplification Rule Simpagation Rule Propagation Rule Term Built-In Constraint Rule Defined Constraint
41
CHR: Declarative Semantics in Classical First-Order Logic (CFOL)
Simplification rule: sh1, ... , shi <=> 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 ==> 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)
42
CHR: Operational Semantics
Rule Defined Constraint Store (RDCS) RDCS = Query Built-In Constraint Store (BICS) BICS = true Match RDCS w/ Heads of CHR Base Set M of Matching Triples: Rule Matched RDCS Subset Variable Equations CHR Base Set U of Used Triples: Rule Matched RDCS Subset Variable Equations Set N of New Matching Triples N = M \ U V = N \ {T N, BICS E T.R.guard |= false} Set V of New Matching Triples w/ Verified Guards RDCS = RDCS \ R.simplifiedHead RDCS = RDCS R.body.RDC U = U T card(V) = 0 BICS = BICS R.body.BIC card(V) = 1 Picked Triple T: Rule R Matched RDCS Subset C Variable Equations E card(V) 1 Pick one Triple T from N Following Priority Heuristics
43
CHR: Rule Priority Heuristics
No standard, implementation dependent 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
44
CHR Base Example: Is West Criminal
CHR 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 Rule Goal UDCS BICS criminal(P) true
45
CHR Base Example: Is West Criminal
CHR 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 Rule Goal UDCS BICS criminal(P) true
46
CHR Base Example: Is West Criminal
CHR 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 Rule Goal UDCS BICS criminal(P) true a) american(P) weapon(W) nation(N) hostile(N) sells(P,N,W)
47
CHR Base Example: Is West Criminal
CHR 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 Rule Goal UDCS BICS criminal(P) true a) american(P) weapon(W) nation(N) hostile(N) sells(P,N,W) b) american(P) weapon(W) nation(N) hostile(N) owns(N,W) missile(W) N = nono P = west
48
CHR Base Example: Is West Criminal
CHR 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 Rule Goal UDCS BICS criminal(P) true a) american(P) weapon(W) nation(N) hostile(N) sells(P,N,W) b) american(P) weapon(W) nation(N) hostile(N) owns(N,W) missile(W) N = nono P = west c) american(P) weapon(W) nation(N) enemy(N,M) owns(N,W) missile(W) N = nono P = west M = america
49
CHR Base Example: Is West Criminal
CHR 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 Rule Goal UDCS BICS criminal(P) true a) american(P) weapon(W) nation(N) hostile(N) sells(P,N,W) b) american(P) weapon(W) nation(N) hostile(N) owns(N,W) missile(W) N = nono P = west c) american(P) weapon(W) nation(N) enemy(N,M) owns(N,W) missile(W) N = nono P = west M = america d) american(P) nation(N) enemy(N,M) owns(N,W) missile(W)
50
CHR Base Example: Is West Criminal
CHR 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 Rule Goal UDCS BICS criminal(P) true a) american(P) weapon(W) nation(N) hostile(N) sells(P,N,W) b) american(P) weapon(W) nation(N) hostile(N) owns(N,W) missile(W) N = nono P = west c) american(P) weapon(W) nation(N) enemy(N,M) owns(N,W) missile(W) N = nono P = west M = america d) american(P) nation(N) enemy(N,M) owns(N,W) missile(W) e) N = nono P = west M = america W = m1
51
CHR Base Example: Is West Criminal
CHR 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 Rule Goal UDCS BICS criminal(P) true
52
CHR Base Example: Is West Criminal
CHR 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 Rule Goal UDCS BICS criminal(P) true crimimal(P)
53
CHR Base Example: Is West Criminal
CHR 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 Rule Goal UDCS BICS criminal(P) true crimimal(P) a) american(P) weapon(W) nation(N) hostile(N) sells(P,N,W) head sells(west,nono,W) unifies with constraint sells(P,N,W) but does not match it!
54
CHR Base Example: Is West Criminal
CHR 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 Rule Goal UDCS BICS criminal(P) true crimimal(P) a) american(P) weapon(W) nation(N) hostile(N) sells(P,N,W) c) american(P) weapon(W) nation(N) enemy(N,america) sells(P,N,W)
55
CHR Base Example: Is West Criminal
CHR 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 Rule Goal UDCS BICS criminal(P) true crimimal(P) a) american(P) weapon(W) nation(N) hostile(N) sells(P,N,W) c) american(P) weapon(W) nation(N) enemy(N,america) sells(P,N,W) d) american(P) missile(W) nation(N) enemy(N,america) sells(P,N,W) 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
56
CHR Base Example: Is West Criminal
CHR 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) Rule Goal UDCS BICS start true
57
CHR Base Example: Is West Criminal
CHR 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) Rule Goal UDCS BICS start true
58
CHR Base Example: Is West Criminal
CHR 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) Rule Goal UDCS BICS start true e) start owns(N,W) missile(W) american(P) nation(N) enemy(N,M) N = nono W = m1 P = west M = america
59
CHR Base Example: Is West Criminal
CHR 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) Rule Goal UDCS BICS start true e) start owns(N,W) missile(W) american(P) nation(N) enemy(N,M) N = nono W = m1 P = west M = america b) start owns(N,W) missile(W) american(P) nation(N) enemy(N,M) sells(P,N,W)
60
CHR Base Example: Is West Criminal
CHR 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) Rule Goal UDCS BICS start true e) start owns(N,W) missile(W) american(P) nation(N) enemy(N,M) N = nono W = m1 P = west M = america b) start owns(N,W) missile(W) american(P) nation(N) enemy(N,M) sells(P,N,W) c) start owns(N,W) missile(W) american(P) nation(N) enemy(N,M) sells(P,N,W) hostile(N)
61
CHR Base Example: Is West Criminal
CHR 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) Rule Goal UDCS BICS start true e) start owns(N,W) missile(W) american(P) nation(N) enemy(N,M) N = nono W = m1 P = west M = america b) start owns(N,W) missile(W) american(P) nation(N) enemy(N,M) sells(P,N,W) c) start owns(N,W) missile(W) american(P) nation(N) enemy(N,M) sells(P,N,W) hostile(N) d) start owns(N,W) missile(W) american(P) nation(N) enemy(N,M) sells(P,N,W) hostile(N) weapon(W)
62
CHR Base Example: Is West Criminal
CHR 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) Rule Goal UDCS BICS start true e) start owns(N,W) missile(W) american(P) nation(N) enemy(N,M) N = nono W = m1 P = west M = america b) start owns(N,W) missile(W) american(P) nation(N) enemy(N,M) sells(P,N,W) c) start owns(N,W) missile(W) american(P) nation(N) enemy(N,M) sells(P,N,W) hostile(N) d) start owns(N,W) missile(W) american(P) nation(N) enemy(N,M) sells(P,N,W) hostile(N) weapon(W) a) start owns(N,W) missile(W) american(P) nation(N) enemy(N,M) sells(P,N,W) hostile(N) weapon(W) ) criminal(P)
63
CHR Base Example: Is West Criminal
CHR 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) Rule Goal UDCS BICS start true
64
CHR Base Example: Is West Criminal
CHR 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) Rule Goal UDCS BICS start true
65
CHR Base Example: Is West Criminal
CHR 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) Rule Goal UDCS BICS start true e) owns(nono,m1) missile(m1) american(west) nation(nono) enemy(nono,america)
66
CHR Base Example: Is West Criminal
CHR 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) Rule Goal UDCS BICS start true e) owns(nono,m1) missile(m1) american(west) nation(nono) enemy(nono,america) b) owns(nono,m1) missile(m1) american(west) nation(nono) enemy(nono,america) sells(west,nono,m1)
67
CHR Base Example: Is West Criminal
CHR 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) Rule Goal UDCS BICS start true e) owns(nono,m1) missile(m1) american(west) nation(nono) enemy(nono,america) b) owns(nono,m1) missile(m1) american(west) nation(nono) enemy(nono,america) sells(west,nono,m1) c) owns(nono,m1) missile(m1) american(west) nation(nono) enemy(nono,america) sells(west,nono,m1) hostile(N)
68
CHR Base Example: Is West Criminal
CHR 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) Rule Goal UDCS BICS start true e) owns(nono,m1) missile(m1) american(west) nation(nono) enemy(nono,america) b) owns(nono,m1) missile(m1) american(west) nation(nono) enemy(nono,america) sells(west,nono,m1) c) owns(nono,m1) missile(m1) american(west) nation(nono) enemy(nono,america) sells(west,nono,m1) hostile(N) d) owns(nono,m1) missile(m1) american(west) nation(nono) enemy(nono,america) sells(west,nono,m1) hostile(N) weapon(m1)
69
CHR Base Example: Is West Criminal
CHR 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) Rule Goal UDCS BICS start true e) owns(nono,m1) missile(m1) american(west) nation(nono) enemy(nono,america) b) owns(nono,m1) missile(m1) american(west) nation(nono) enemy(nono,america) sells(west,nono,m1) c) owns(nono,m1) missile(m1) american(west) nation(nono) enemy(nono,america) sells(west,nono,m1) hostile(N) d) owns(nono,m1) missile(m1) american(west) nation(nono) enemy(nono,america) sells(west,nono,m1) hostile(N) weapon(m1) a) owns(nono,m1) missile(m1) american(west) nation(nono) enemy(nono,america) sells(west,nono,m1) hostile(N) weapon(m1) criminal(west)
70
connective: enum{or,and}
CHRV: Abstract Syntax body OrAnd Formula connective: enum{or,and} 2..* guard 0..1 CHR Rule And Formula CHR Base * simplified head Tried Alternative Body 0..1 propagated head 0..1 * Atomic Formula Fired Rule Simplification Rule Simpagation Rule Propagation Rule Constraint * {ordered} Derivation State CHR Derivation Rule Defined Constraint Store * Rule Defined Constraint * Built-In Constraint * Built-In Constraint Store * * true false
71
CHRV: Declarative Semantics in Classical First-Order Logic (CFOL)
Simplification rule: sh1, ... , shi <=> 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 ==> 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))
72
CHRV: 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 Bi+1 Exhaustively try all alternative bodies of all fired rules through backtracking
73
CHRV Base Example: Course Enrollment
enrolled(john,C,T) ==> T < 1994 ; T >= 1996. enrolled(S,C,T), prereq(C,C’) ==> enrolled(S,C’,T’), T’ < T. X<Y, X<Z <=> Y <gd Z | X < Y. X <Y, X >= Y <=> false. X >= X <=> true. X < Y <=> gd(X), gd(Y) | X <gd Y Rule UDCS BICS a1) enrolled(john,cs100,1996), prereq(cs100,cs50) true
74
CHRV Base Example: Course Enrollment
enrolled(john,C,T) ==> T < 1994 ; T >= 1996. enrolled(S,C,T), prereq(C,C’) ==> enrolled(S,C’,T’), T’ < T. X<Y, X<Z <=> Y <ground Z | X < Y. X <Y, X >= Y <=> false. X >= X <=> true. X < Y <=> gd(X), gd(Y) | X <gd Y Rule UDCS BICS a1) enrolled(john,cs100,1996), prereq(cs100,cs50) true b) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994
75
CHRV Base Example: Course Enrollment
enrolled(john,C,T) ==> T < 1994 ; T >= 1996. enrolled(S,C,T), prereq(C,C’) ==> enrolled(S,C’,T’), T’ < T. X<Y, X<Z <=> Y <ground Z | X < Y. X <Y, X >= Y <=> false. X >= X <=> true. X < Y <=> gd(X), gd(Y) | X <gd Y Rule UDCS BICS a1) enrolled(john,cs100,1996), prereq(cs100,cs50) true b) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994 f) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994, enrolled(john,cs50,T’), T’ < 1996
76
CHRV Base Example: Course Enrollment
enrolled(john,C,T) ==> T < 1994 ; T >= 1996. enrolled(S,C,T), prereq(C,C’) ==> enrolled(S,C’,T’), T’ < T. X<Y, X<Z <=> Y <ground Z | X < Y. X <Y, X >= Y <=> false. X >= X <=> true. X < Y <=> gd(X), gd(Y) | X <gd Y Rule UDCS BICS a1) enrolled(john,cs100,1996), prereq(cs100,cs50) true b) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994 f) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994, enrolled(john,cs50,T’), T’ < 1996 solve enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996 gd(1996), gd(1994), 1996 <gd 1994
77
CHRV Base Example: Course Enrollment
enrolled(john,C,T) ==> T < 1994 ; T >= 1996. enrolled(S,C,T), prereq(C,C’) ==> enrolled(S,C’,T’), T’ < T. X<Y, X<Z <=> Y <ground Z | X < Y. X <Y, X >= Y <=> false. X >= X <=> true. X < Y <=> gd(X), gd(Y) | X <gd Y Rule UDCS BICS a1) enrolled(john,cs100,1996), prereq(cs100,cs50) true b) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994 f) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994, enrolled(john,cs50,T’), T’ < 1996 solve enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996 gd(1996), gd(1994), 1996 <gd 1994 bt false
78
CHRV Base Example: Course Enrollment
enrolled(john,C,T) ==> T < 1994 ; T >= 1996. enrolled(S,C,T), prereq(C,C’) ==> enrolled(S,C’,T’), T’ < T. X<Y, X<Z <=> Y <ground Z | X < Y. X <Y, X >= Y <=> false. X >= X <=> true. X < Y <=> gd(X), gd(Y) | X <gd Y Rule UDCS BICS a1) enrolled(john,cs100,1996), prereq(cs100,cs50) true b) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994 f) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994, enrolled(john,cs50,T’), T’ < 1996 solve enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996 gd(1996), gd(1994), 1996 <gd 1994 bt false a2)
79
CHRV Base Example: Course Enrollment
enrolled(john,C,T) ==> T < 1994 ; T >= 1996. enrolled(S,C,T), prereq(C,C’) ==> enrolled(S,C’,T’), T’ < T. X<Y, X<Z <=> Y <ground Z | X < Y. X <Y, X >= Y <=> false. X >= X <=> true. X < Y <=> gd(X), gd(Y) | X <gd Y Rule UDCS BICS a1) enrolled(john,cs100,1996), prereq(cs100,cs50) true b) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994 f) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994, enrolled(john,cs50,T’), T’ < 1996 solve enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996 gd(1996), gd(1994), 1996 <gd 1994 bt false a2) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 >= 1996
80
CHRV Base Example: Course Enrollment
enrolled(john,C,T) ==> T < 1994 ; T >= 1996. enrolled(S,C,T), prereq(C,C’) ==> enrolled(S,C’,T’), T’ < T. X<Y, X<Z <=> Y <ground Z | X < Y. X <Y, X >= Y <=> false. X >= X <=> true. X < Y <=> gd(X), gd(Y) | X <gd Y Rule UDCS BICS a1) enrolled(john,cs100,1996), prereq(cs100,cs50) true b) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994 f) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994, enrolled(john,cs50,T’), T’ < 1996 solve enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996 gd(1996), gd(1994), 1996 <gd 1994 bt false a2) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 >= 1996 e) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 >= 1996, enrolled(john,cs50,T’), T’ < 1996
81
CHRV Base Example: Course Enrollment
enrolled(john,C,T) ==> T < 1994 ; T >= 1996. enrolled(S,C,T), prereq(C,C’) ==> enrolled(S,C’,T’), T’ < T. X<Y, X<Z <=> Y <ground Z | X < Y. X <Y, X >= Y <=> false. X >= X <=> true. X < Y <=> gd(X), gd(Y) | X <gd Y Rule UDCS BICS a1) enrolled(john,cs100,1996), prereq(cs100,cs50) true b) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994 f) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994, enrolled(john,cs50,T’), T’ < 1996 solve enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996 gd(1996), gd(1994), 1996 <gd 1994 bt false a2) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 >= 1996 e) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 >= 1996, enrolled(john,cs50,T’), T’ < 1996
82
CHRV Base Example: Course Enrollment
enrolled(john,C,T) ==> T < 1994 ; T >= 1996. enrolled(S,C,T), prereq(C,C’) ==> enrolled(S,C’,T’), T’ < T. X<Y, X<Z <=> Y <ground Z | X < Y. X <Y, X >= Y <=> false. X >= X <=> true. X < Y <=> gd(X), gd(Y) | X <gd Y Rule UDCS BICS a1) enrolled(john,cs100,1996), prereq(cs100,cs50) true b) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994 f) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994, enrolled(john,cs50,T’), T’ < 1996 solve enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996 gd(1996), gd(1994), 1996 <gd 1994 bt false a2) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 >= 1996 e) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 >= 1996, enrolled(john,cs50,T’), T’ < 1996 c) enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996, T’ < 1994
83
CHRV Base Example: Course Enrollment
enrolled(john,C,T) ==> T < 1994 ; T >= 1996. enrolled(S,C,T), prereq(C,C’) ==> enrolled(S,C’,T’), T’ < T. X<Y, X<Z <=> Y <ground Z | X < Y. X <Y, X >= Y <=> false. X >= X <=> true. X < Y <=> gd(X), gd(Y) | X <gd Y Rule UDCS BICS a1) enrolled(john,cs100,1996), prereq(cs100,cs50) true b) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994 f) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994, enrolled(john,cs50,T’), T’ < 1996 solve enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996 gd(1996), gd(1994), 1996 <gd 1994 bt false a2) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 >= 1996 e) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 >= 1996, enrolled(john,cs50,T’), T’ < 1996 c) enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996, T’ < 1994 enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1994 1994 <gd 1996
84
CHRV Base Example: Course Enrollment
enrolled(john,C,T) ==> T < 1994 ; T >= 1996. enrolled(S,C,T), prereq(C,C’) ==> enrolled(S,C’,T’), T’ < T. X<Y, X<Z <=> Y <ground Z | X < Y. X <Y, X >= Y <=> false. X >= X <=> true. X < Y <=> gd(X), gd(Y) | X <gd Y Rule UDCS BICS a1) enrolled(john,cs100,1996), prereq(cs100,cs50) true b) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994 f) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994, enrolled(john,cs50,T’), T’ < 1996 solve enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996 gd(1996), gd(1994), 1996 <gd 1994 bt false a2) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 >= 1996 e) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 >= 1996, enrolled(john,cs50,T’), T’ < 1996 c) enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996, T’ < 1994 enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1994 1994 <gd 1996
85
CHRV Base Example: Course Enrollment
enrolled(john,C,T) ==> T < 1994 ; T >= 1996. enrolled(S,C,T), prereq(C,C’) ==> enrolled(S,C’,T’), T’ < T. X<Y, X<Z <=> Y <ground Z | X < Y. X <Y, X >= Y <=> false. X >= X <=> true. X < Y <=> gd(X), gd(Y) | X <gd Y Rule UDCS BICS a1) enrolled(john,cs100,1996), prereq(cs100,cs50) true b) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994 f) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994, enrolled(john,cs50,T’), T’ < 1996 solve enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996 gd(1996), gd(1994), 1996 <gd 1994 bt false a2) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 >= 1996 e) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 >= 1996, enrolled(john,cs50,T’), T’ < 1996 c) enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996, T’ < 1994 enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1994 1994 <gd 1996 d) enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996, T' >= 1996
86
CHRV Base Example: Course Enrollment
enrolled(john,C,T) ==> T < 1994 ; T >= 1996. enrolled(S,C,T), prereq(C,C’) ==> enrolled(S,C’,T’), T’ < T. X<Y, X<Z <=> Y <ground Z | X < Y. X <Y, X >= Y <=> false. X >= X <=> true. X < Y <=> gd(X), gd(Y) | X <gd Y Rule UDCS BICS a1) enrolled(john,cs100,1996), prereq(cs100,cs50) true b) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994 f) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994, enrolled(john,cs50,T’), T’ < 1996 solve enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996 gd(1996), gd(1994), 1996 <gd 1994 bt false a2) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 >= 1996 e) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 >= 1996, enrolled(john,cs50,T’), T’ < 1996 c) enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996, T’ < 1994 enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1994 1994 <gd 1996 d) enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996, T >= 1996 enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’) true, false
87
CHRV Base Example: Course Enrollment
enrolled(john,C,T) ==> T < 1994 ; T >= 1996. enrolled(S,C,T), prereq(C,C’) ==> enrolled(S,C’,T’), T’ < T. X<Y, X<Z <=> Y <ground Z | X < Y. X <Y, X >= Y <=> false. X >= X <=> true. X < Y <=> gd(X), gd(Y) | X <gd Y Rule UDCS BICS a1) enrolled(john,cs100,1996), prereq(cs100,cs50) true b) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994 f) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 < 1994, enrolled(john,cs50,T’), T’ < 1996 solve enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996 gd(1996), gd(1994), 1996 <gd 1994 bt false a2) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 >= 1996 e) enrolled(john,cs100,1996), prereq(cs100,cs50), 1996 >= 1996, enrolled(john,cs50,T’), T’ < 1996 c) enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996, T’ < 1994 enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1994 1994 <gd 1996 d) enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’), T’ < 1996, T >= 1996 enrolled(john,cs100,1996), prereq(cs100,cs50), enrolled(john,cs50,T’) true, false
88
CHRV Base Example: Append CHRV 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 Rule UDCS BICS append([a,b],[c],R) true
89
CHRV Base Example: Append CHRV 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 Rule UDCS BICS append([a,b],[c],R) true a1) [c] [ ] [a,b] = [ ] [c] = L R = L
90
CHRV Base Example: Append CHRV 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 Rule UDCS BICS append([a,b],[c],R) true a1) [c] [ ] [a,b] = [ ] [c] = L R = L solve false
91
CHRV Base Example: Append CHRV 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 Rule UDCS BICS append([a,b],[c],R) true a1) [c] [ ] [a,b] = [ ] [c] = L R = L solve false bt append([a],[c],R) [c] [ ]
92
CHRV Base Example: Append CHRV 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 Rule UDCS BICS append([a,b],[c],R) true a1) [c] [ ] [a,b] = [ ] [c] = L R = L solve false bt [c] [ ] a2) append(L1,L2,L3) [c] [ ] [a,b] = [H | L1] [c] = L2 R = [H | L3]
93
CHRV Base Example: Append CHRV 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 Rule UDCS BICS append([a,b],[c],R) true a1) [c] [ ] [a,b] = [ ] [c] = L R = L solve false bt append([a],[c],R) [c] [ ] a2) append(L1,L2,L3) [c] [ ] [a,b] = [H | L1] [c] = L2 R = [H | L3] append([b],[c],L3) H = a L1 = [b] L2 = [c] R = [a | L3]
94
CHRV Base Example: Append CHRV 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 Rule UDCS BICS append([a,b],[c],R) true a1) [c] [ ] [a,b] = [ ] [c] = L R = L solve false bt append([a],[c],R) [c] [ ] a2) append(L1,L2,L3) [c] [ ] [a,b] = [H | L1] [c] = L2 R = [H | L3] append([b],[c],L3) H = a L1 = [b] L2 = [c] R = [a | L3] H = a L1 = [ ] L2 = [c] R = [a | L3] [c] [ ] [b] = [ ] [c] = L’ L3 = L’
95
CHRV Base Example: Append CHRV 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 Rule UDCS BICS append([a,b],[c],R) true a1) [c] [ ] [a,b] = [ ] [c] = L R = L solve false bt append([a],[c],R) [c] [ ] a2) append(L1,L2,L3) [c] [ ] [a,b] = [H | L1] [c] = L2 R = [H | L3] append([b],[c],L3) H = a L1 = [b] L2 = [c] R = [a | L3] H = a L1 = [ ] L2 = [c] R = [a | L3] [c] [ ] [b] = [ ] [c] = L’ L3 = L’
96
CHRV Base Example: Append CHRV 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 Rule UDCS BICS append([a,b],[c],R) true a1) [c] [ ] [a,b] = [ ] [c] = L R = L solve false bt append([a],[c],R) [c] [ ] a2) append(L1,L2,L3) [c] [ ] [a,b] = [H | L1] [c] = L2 R = [H | L3] append([b],[c],L3) H = a L1 = [b] L2 = [c] R = [a | L3] H = a L1 = [ ] L2 = [c] R = [a | L3] [c] [ ] [b] = [ ] [c] = L’ L3 = L’ H = a L1 = [ ] L2 = [c] R = [a | L3] [c] [ ]
97
CHRV Base Example: Append CHRV 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 Rule UDCS BICS append([a,b],[c],R) true a1) [c] [ ] [a,b] = [ ] [c] = L R = L solve false bt append([a],[c],R) [c] [ ] a2) append(L1,L2,L3) [c] [ ] [a,b] = [H | L1] [c] = L2 R = [H | L3] append([b],[c],L3) H = a L1 = [b] L2 = [c] R = [a | L3] H = a L1 = [ ] L2 = [c] R = [a | L3] [c] [ ] [b] = [ ] [c] = L’ L3 = L’ H = a L1 = [ ] L2 = [c] R = [a | L3] [c] [ ] append(L1’,L2’,L3’) H = a L1 = [ ] L2 = [c] R = [a | L3] [c] [ ] [b] = [H’ | L1’] [c] = L2’ L3 = [H’ | L3’]
98
CHRV Base Example: Append CHRV 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 Rule UDCS BICS append([a,b],[c],R) true a1) [c] [ ] [a,b] = [ ] [c] = L R = L solve false bt append([a],[c],R) [c] [ ] a2) append(L1,L2,L3) [c] [ ] [a,b] = [H | L1] [c] = L2 R = [H | L3] append([b],[c],L3) H = a L1 = [b] L2 = [c] R = [a | L3] H = a L1 = [ ] L2 = [c] R = [a | L3] [c] [ ] [b] = [ ] [c] = L’ L3 = L’ H = a L1 = [ ] L2 = [c] R = [a | L3] [c] [ ] append(L1’,L2’,L3’) H = a L1 = [ ] L2 = [c] R = [a | L3] [c] [ ] [b] = [H’ | L1’] [c] = L2’ L3 = [H’ | L3’] append([ ],[c],L3’) H = a L1 = L1’ = [ ] L2 = L2’ = [c] R = [a,b | L3’] H’= b L3 = [b | L3’]
99
CHRV Base Example: Append CHRV 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 Rule UDCS BICS append([a,b],[c],R) true a1) [c] [ ] [a,b] = [ ] [c] = L R = L solve false bt append([a],[c],R) [c] [ ] a2) append(L1,L2,L3) [c] [ ] [a,b] = [H | L1] [c] = L2 R = [H | L3] append([b],[c],L3) H = a L1 = [b] L2 = [c] R = [a | L3] H = a L1 = [ ] L2 = [c] R = [a | L3] [c] [ ] [b] = [ ] [c] = L’ L3 = L’ H = a L1 = [ ] L2 = [c] R = [a | L3] [c] [ ] append(L1’,L2’,L3’) H = a L1 = [ ] L2 = [c] R = [a | L3] [c] [ ] [b] = [H’ | L1’] [c] = L2’ L3 = [H’ | L3’] append([ ],[c],L3’) H = a L1 = L1’ = [ ] L2 = L2’ = [c] R = [a,b | L3’] H’= b L3 = [b | L3’] H = a L1 = L1’ = [ ] L2 = L2’ = [c] R = [a,b | L3’] H’= b L3 = [b | L3’] [c] [ ] [ ] = [ ] [c] = L’’ L3’ = L’’
100
CHRV Base Example: Append CHRV 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 Rule UDCS BICS append([a,b],[c],R) true a1) [c] [ ] [a,b] = [ ] [c] = L R = L solve false bt append([a],[c],R) [c] [ ] a2) append(L1,L2,L3) [c] [ ] [a,b] = [H | L1] [c] = L2 R = [H | L3] append([b],[c],L3) H = a L1 = [b] L2 = [c] R = [a | L3] H = a L1 = [ ] L2 = [c] R = [a | L3] [c] [ ] [b] = [ ] [c] = L’ L3 = L’ H = a L1 = [ ] L2 = [c] R = [a | L3] [c] [ ] append(L1’,L2’,L3’) H = a L1 = [ ] L2 = [c] R = [a | L3] [c] [ ] [b] = [H’ | L1’] [c] = L2’ L3 = [H’ | L3’] append([ ],[c],L3’) H = a L1 = L1’ = [ ] L2 = L2’ = [c] R = [a,b | L3’] H’= b L3 = [b | L3’] H = a L1 = L1’ = [ ] L2 = L2’ = [c] R = [a,b | L3’] H’= b L3 = [b | L3’] [c] [ ] [ ] = [ ] [c] = L’’ L3’ = L’’ H = a L1 = L1’ = [ ] L2 = L2’ = L’’ = L3’ = [c] R = [a,b,c] H’= b L3 = [b,c]
101
CHRV: 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
102
CHRV 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
103
CHRV 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)
104
CHRV 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 <=> 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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.