Title: Constraint Handling Rules (CHR): Rule-Based Constraint Solving and Deduction
1Constraint Handling Rules (CHR)Rule-Based
Constraint Solving and Deduction
2Outline
- Constraint Handling Rules (CHR)
- Key ideas
- Introductory example
- CHR constraint solver over real variables
- CHR with disjunction (CHR?)
- CHR constraint solver over finite domain
variables - General purpose rule-based reasoning with CHR?
- A taxonomy of rule-based languages
- Production rules and ECA rules in CHR?
- Conditional term rewrite rules in CHR?
- Prolog and CLP rules in CHR?
- Deduction with CHR?
- Propositional deduction as Boolean constraint
solving in CHR? - First-order Horn Logic forward chaining with
CHR? - First-order Horn Logic backward chaining with
CHR? - First-order logic refutation and resolution based
entailment with CHR? - Description logic reasoning with CHR?
3Constraint 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
Left-Hand-Side (LHS) matching - Extended variant CHRV adds backtracking search
and thus generalizes Prolog rules as well
4CHR by ExampleRule Base Defining ? in Terms of
- reflexivity_at_ X ? Y ltgt X Y true.
- asymmetry_at_ X ? Y, Y ? X ltgt XY.
- Constraint simplification (or rewriting) rules
- Syntax ltruleNamegt_at_ ltsimplifiedHeadgt ltgt
ltguardgt ltbodygt - Logically ?X?vars(head ? guard)
- ltguardgt ? (ltheadgt ?
?Y?vars(body - (head ? guard)) ltbodygt) - Operationally substitute in constraint store
(knowledge base) constraints that match - the rule simplified head by those in rule body
with their variables instantiated from - the match
- transitivity_at_ X ? Y , Y ? Z gt X ? Z.
- Constraint propagation (or production) rule (in
this case, unguarded) - Syntax ltruleNamegt_at_ ltpropagatedHeadgt gt guard
ltbodygt - Logically ?X?vars(head ? guard)
- ltguardgt ? (ltheadgt ?
?Y?vars(body - (head ? guard)) ltbodygt) - Operationally if constraint store (knowledge
base) contains constraints that match - the rule propagated head then add those in rule
body to the store with their variables - instantiated from the match
5CHR by Example Rule Base Defining ? in Terms of
- idempotence_at_ X ? Y \ X ? Y ltgt true.
- Constraint simpagation rule (in this case,
unguarded) - Syntax ltruleNamegt_at_ ltpropagatedHeadgt \
ltsimplifiedHeadgt ltgt guard ltbodygt - Logically ?X?vars((head ? guard) ltguardgt ?
(ltpropagatedheadgt ? ltsimplifiedHeadgt
? ?Y?vars(body - (head ? guard)) ltbodygt ?
ltpropagatedheadgt) - Operationally if constraint store (knowledge
base) contains constraints that match - the rule simplified head and the rule
propagated head, then substitute in the store
those matching the simplified head by the rule
body with their variables instantiated from the
match - query1 A ? B, C ? A, B ? C, A 2 Initial
constraint store a constraint conjunction - answer1 A 2, B 2, C 2, Final
constraint store initial constraint store
simplified through repeated rule application
until no rule neither simplifies nor propagates
any new constraint - query2 A ? B, B ? C, C ? A
- answer2 A B, B C
6CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
A ? B, C ? A, B ? C A 2
Matching Equations ? Guard
Built-In Constraint Store
Rule-Defined Constraint Store
7CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Condition for firing a rule
- Rule head matches active constraint in RDCS
- Generates set of equations between variables and
constants from the head and the constraint
(inserted to MEG) - Every other head from the rule matches against
some other (partner) constraint in the RDCS - Generates another set of equations (inserted to
MEG) - Rule r fires iff?X1,...,Xi ? vars(MEG ? BICS -
r) BICS ? ?Y1,...,Yj ? vars(r) MEG
Rule RDCS BICS MEG
r? A ? B, C ? A, B ? C A 2 X' A, Y' B, X' Y'
Active Constraint
8CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
r? A ? B, C ? A, B ? C A 2 X' A Y' B
Normalizing Simplification
Active Constraint
9CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true. ?(?A,B A 2 ?
?X',Y' X' A Y' B), eg, B 3 ? 2 A - a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
r? A ? B, C ? A, B ? C A 2 X' A Y' B
Active Constraint
10CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Rule firing order depends on 3 heuristics, with
the following priority - Rule-defined constraint ordering to become active
- Rule ordering to try matching and entailment
check with active constraint - Rule-defined constraint ordering to become
partner constraints - Engine first tries matching and entailment check
- All rules with current active constraint, before
trying any rule with the next constraint in the
RDCS - For all elements of the RDCS as partner for the
first multi-headed rule that matches the active
constraint, before trying the next rule that
matches the active constraint
Rule RDCS BICS MEG
a? A ? B, C ? A, B ? C A 2 X' A, Y' B, Y' C, X' A
Active Constraint
Partner Constraint
11CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY ?( ?A,B,C A 2 ?
?X',Y' X' A ? Y' B C), eg, B 3 ? 4 C - t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
a? A ? B, C ? A, B ? C A 2 X' A, Y' B C
Active Constraint
Partner Constraint
12CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
a? A ? B, C ? A, B ? C A 2 X' C, Y' A, Y' A, X' B
Active Constraint
Partner Constraint
13CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY ?(?A,B,C A 2
? ?X',Y' X' B C ? Y' A), eg, B 3 ? 4 C - t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
a? A ? B, C ? A, B ? C A 2 X' B C, Y' A
Active Constraint
Partner Constraint
14CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
a? A ? B, C ? A, B ? C A 2 X' A, Y' B, Y' B, X' C
Active Constraint
Partner Constraint
15CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY ?(?A,B,C A 2 ?
?X',Y' X' A C ? Y' B), eg, C 3 ? 2 A - t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
a? A ? B, C ? A, B ? C A 2 X' A C, Y' B
Active Constraint
Partner Constraint
16CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
a? A ? B, C ? A, B ? C A 2 X' B, Y' C, Y' A, X' B
Active Constraint
Partner Constraint
17CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY ?(?A,B,C A 2 ?
?X',Y' X' B ? Y' A C), eg, C 3 ? 2 A - t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
a? A ? B, C ? A, B ? C A 2 X' B, Y' A C
Active Constraint
Partner Constraint
18CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t? A ? B, C ? A, B ? C A 2 X' A, Y' B, Y' C, Z' A
Active Constraint
Partner Constraint
19CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z. ?(?A,B,C A 2 ?
?X',Y', Z' X' Z' A ? Y' B C), eg, B 3
? 4 C - i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t? A ? B, C ? A, B ? C A 2 X' Z' A, Y' B C
Active Constraint
Partner Constraint
20CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
t? A ? B, C ? A, B ? C A 2 X' C, Y' A, Y' A, Z' B
Active Constraint
Partner Constraint
21CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z. ?A,B,C A 2 ?
?X',Y',Z' X' C ? Y' A ? Z' B, e.g.,
X'C,Y'2,Z'B - i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
t? A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
Active Constraint
Partner Constraint
22CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
A ? B, C ? A, B ? C, C ? B A 2
23CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- For a given active constraint
- a matching multi-headed propagation rule is
reapplied with all matching partner constraints,
before any other rule is tried - in contrast, a matching multi-headed
simplification or simpagation rule is applied
only once with the first matching partner
constraint, and then engine moves on to the next
rule
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t? A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Y' B, Z' C
Active Constraint
Partner Constraint
24CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z. ?A,B,C A 2
? ?X',Y',Z' X' A ? Y' B ? Z' B, e.g.,
X'A,Y'B, Z'C - i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t? A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
Active Constraint
Partner Constraint
25CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
A ? B, C ? A, B ? C, C ? B, A ? C A 2
26CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Attempt to reapply same propagation rule matching
same pair of active and partner constraints with
same head pair but swapped assignments - Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
t? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' B, Y' C, Y' A, Z' B
Active Constraint
Partner Constraint
27CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z. ?(?A,B,C A 2 ?
?X',Y', Z' X' Z' B ? Y' A C), eg, A 2
? 4 C - i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
t? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' Z' B, Y' A C
Active Constraint
Partner Constraint
28CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
t? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' A, Y' B, Y' C, Z' B
Active Constraint
Partner Constraint
29CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z. ?(?A,B,C A 2
? ?X',Y', Z' X' A ? Y' Z' B C), eg, B
3 ? 4 C - i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
t? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' A, Y' Z' B C
Active Constraint
Partner Constraint
30CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
t? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B, Y' A, Z' B
Active Constraint
Partner Constraint
31CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z. ?(?A,B,C A
2 ? ?X',Y', Z' X' C ? Y' Z' A B), eg, A
2 ? 3 B - i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
t? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' Z' A B
Active Constraint
Partner Constraint
32CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
t? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' A, Y' B, Y' A, Z' C
Active Constraint
Partner Constraint
33CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z. ?(?A,B,C A
2 ? ?X',Y', Z' X' Y' A B ? Z' C ), eg, A
2 ? 3 B - i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
t? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' Y' A B, Z' C
Active Constraint
Partner Constraint
34CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
t? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' A, Y' C, Y' A, Z' B
Active Constraint
Partner Constraint
35CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z. ?(?A,B,C A 2
? ?X',Y', Z' X' Y' A C ? Z' B ), eg, A
2 ? 4 C - i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
t? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' Y' A C, Z' B
Active Constraint
Partner Constraint
36CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
i? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' A, Y' B, X' C, Y' A
Active Constraint
Partner Constraint
37CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true. ?(?A,B,C A 2 ?
?X',Y', Z' X' Y' Z' A B C ), eg, A 2
? 4 C
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
i? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' Y' A B C
Active Constraint
Partner Constraint
38CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
i? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' A, X' A, Y' B
Active Constraint
Partner Constraint
39CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true. ?(?A,B,C A 2 ?
?X',Y', Z' X' Y' Z' A B C ), eg, A 2
? 4 C - Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
i? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' Y' A B C
Active Constraint
Partner Constraint
40CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
i? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' A, Y B, X B, Y C
Active Constraint
Partner Constraint
41CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true. ?(?A,B,C A 2
? ?X',Y X' Y' A B C ), eg, A 2 ? 4 C
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
i? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' A B Y C
Active Constraint
Partner Constraint
42CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
i? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' B, Y' C, X A, Y B
Active Constraint
Partner Constraint
43CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true. ?(?A,B,C A 2 ?
?X',Y' X' Y' A B C ), eg, A 2 ? 4 C - Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
i? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' Y' A B C
Active Constraint
Partner Constraint
44CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
i? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' A, Y B, X C, Y B
Active Constraint
Partner Constraint
45CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true. ?(?A,B,C A 2
? ?X',Y X' A C, Y B), eg, A 2 ? 4 C
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
i? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' A C, Y B
Active Constraint
Partner Constraint
46CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
i? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B, X A, Y B
Active Constraint
Partner Constraint
47CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true. ?(?A,B,C A 2 ?
?X',Y' X' A C,Y B ), eg, A 2 ? 4 C - Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
i? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' A C, Y' B
Active Constraint
Partner Constraint
48CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
i? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' A, Y B, X A, Y C
Active Constraint
Partner Constraint
49CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true. ?(?A,B,C A 2
? ?X',Y X' A, Y B C), eg, B 3 ? 4 C
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
i? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' A, Y B C
Active Constraint
Partner Constraint
50CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
i? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' A, Y' C, X A, Y B
Active Constraint
Partner Constraint
51CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true. ?(?A,B,C A 2 ?
?X',Y' X' A, Y B C), eg, B 3 ? 4 C - Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
i? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' A, Y' B C
Active Constraint
Partner Constraint
52CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Heuristic to choose next active constraint after
processing of active constraint A added to the
store constraints N1, ... Nn - N1, ... , Nn in order
- Constraints O1, ... , Om present in the store
before processing A
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
r? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B, X' Y'
Active Constraint
53CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true. ?(?A,B,C A
2 ? ?X',Y' X' Y' B C ), eg, B 3 ? 4 C - a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
r? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' Y' B C
Active Constraint
54CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
a? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B, Y' A, X' B,
Partner Constraint
Active Constraint
55CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY ?(?A,B,C A
2 ? ?X',Y' X' Y' A B C), eg, B 3 ? 4
C - t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
a? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' Y' A C B
Partner Constraint
Active Constraint
56CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
-
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
a? A ? B, C ? A, B ? C, C ? B, A ? C A 2 Y' C, X' B, X' A, Y' B
Partner Constraint
Active Constraint
57CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY ?(?A,B,C A
2 ? ?X',Y' X' A C ? Y' B), eg, A 2 ? 4
C - t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
a? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' A C, Y' B
Partner Constraint
Active Constraint
58CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
a? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B, Y C, X A
Partner Constraint
Active Constraint
59CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY ?(?A,B,C A 2 ?
?X',Y' X' Y' A B C), eg, A 2 ? 4 C - t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
a? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' Y A, B C
Partner Constraint
Active Constraint
60CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
-
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
a? A ? B, C ? A, B ? C, C ? B, A ? C A 2 Y C, X B, X C, Y A
Partner Constraint
Active Constraint
61CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY ?(?A,B,C A 2 ?
?X',Y X' Y' A B C), eg, A 2 ? 4 C - t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
a? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X Y A B C
Partner Constraint
Active Constraint
62CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
a? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B, Y B, X C
Partner Constraint
Active Constraint
63CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY ?A,B,C A 2
? ?X',Y' X' C ? Y B), eg, A 2, X C,
Y B - t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
a? A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B
Partner Constraint
Active Constraint
64CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY ?A,B,C A 2
? ?X',Y' X' C ? Y B), eg, A 2, X C,
Y B - t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
a! A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B
A ? B, C ? A, A ? C A 2, B C
65CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
r! A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B
r? A ? B, C ? A, A ? C A 2, B C X A, Y C, X Y
Active Constraint
66CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true. ?(?A,B,C A
2, B C ? ?X',Y X' Y' A B C), eg, A 2
? 4 C - a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
r! A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B
r? A ? B, C ? A, A ? C A 2, B C X Y A C
Active Constraint
67CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
r! A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B
a? A ? B, C ? A, A ? C A 2, B C X A, Y C, Y A, X B
Active Constraint
Partner Constraint
68CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY ?(?A,B,C A 2, B
C ? ?X',Y X' Y' A B C), eg, A 2 ? 4
C - t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
r! A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B
a? A ? B, C ? A, A ? C A 2, B C X Y A B C
Active Constraint
Partner Constraint
69CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
- Alternate matching combination
- Active constraint matched against rightmost head
- Partner constraint matched against leftmost head
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
r! A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B
a? A ? B, C ? A, A ? C A 2, B C Y A, X C, X A, Y B
Active Constraint
Partner Constraint
70CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY ?(?A,B,C A 2, B
C ? ?X',Y X' Y' A B C), eg, A 2 ? 4
C - t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
r! A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B
a? A ? B, C ? A, A ? C A 2, B C X Y A B C
Active Constraint
Partner Constraint
71CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
r! A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B
a? A ? B, C ? A, A ? C A 2, B C X A, Y C, Y C, X A
Active Constraint
Partner Constraint
72CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY ?A,B,C A 2, B
C ? ?X',Y X' A ? Y C), eg, X 2, Y C
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
r! A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B
a? A ? B, C ? A, A ? C A 2, B C X Y A C
Active Constraint
Partner Constraint
73CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY ?A,B,C A 2, B
C ? ?X',Y X' A ? Y C), eg, X 2, Y C
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
r! A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B
a! A ? B, C ? A, A ? C A 2, B C X Y A C
A ? B A 2, B C, A C
74CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true.
- a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
r! A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B
a! A ? B, C ? A, A ? C A 2, B C X Y A C
r? A ? B A B C 2 X A, Y B, X Y
Active Constraint
75CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true. ?A,B,C
A B C 2 ? ?X',Y X' Y A B), eg, X
2, Y 2 - a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
r! A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B
a! A ? B, C ? A, A ? C A 2, B C X Y A C
r? A ? B A B C 2 X Y A B
Active Constraint
76CHR by Example Rule Base Defining ? in Terms of
- r_at_ X ? Y ltgt X Y true. ?A,B,C
A B C 2 ? ?X',Y X' Y A B), eg, X
2, Y 2 - a_at_ X ? Y, Y ? X ltgt XY
- t_at_ X ? Y, Y ? Z gt X ? Z.
- i_at_ X ? Y \ X ? Y ltgt true.
Rule RDCS BICS MEG
t! A ? B, C ? A, B ? C A 2 X' C, Y' A, Z' B
t! A ? B, C ? A, B ? C, C ? B A 2 X' A, Y' B, Z' C
r! A ? B, C ? A, B ? C, C ? B, A ? C A 2 X' C, Y' B
a! A ? B, C ? A, A ? C A 2, B C X Y A C
r! A ? B A B C 2 X Y A B
A B C 2
Constraints Simplified
Final Normalized Solved Form
77CHR 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
78CHR 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
79CHR 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
80CHR 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)
81CHR Constraint and RulePriority Heuristics
- No standard, implementation dependent
- Active constraint priority heuristics
- Preferring constraints most recently inserted in
store - Left-to-right writing order in query
- Rule priority heuristics
- Preferring simplification rules over simpagation
rules and simpagation over propagation rules - Preferring simplification and simpagation rules
with highest number of heads - Preferring propagation rules with lowest number
of heads - Preferring rules whose head constraint have
never be matched yet - Top to bottom writing order
- Partner constraint priority heuristics
- Preferring constraints most recently inserted in
store - Left-to-right writing order in query
82CHR Base Example Defining min in Terms of ?, ?
and
- r1_at_ min(X,Y,Z) ltgt X ? Y Z X
- r2_at_ min(X,Y,Z) ltgt Y ? X Z Y.
- r3_at_ min(X,Y,Z) ltgt Z lt X Y Z.
- r4_at_ min(X,Y,Z) ltgt Z lt Y X Z.
- r5_at_ min(X,Y,Z) gt Z ? X, Z ? Y.
Rule RDCS BICS MEG
min(1,2,M)
83CHR Base Example Defining min in Terms of ?, ?
and
- r1_at_ min(X,Y,Z) ltgt X ? Y Z X
?M true ?X'1,Y'2,Z'M X' 1, Y' 2, Z'
M, 1 ? 2 - r2_at_ min(X,Y,Z) ltgt Y ? X Z Y.
- r3_at_ min(X,Y,Z) ltgt Z lt X Y Z.
- r4_at_ min(X,Y,Z) ltgt Z lt Y Y Z.
- r5_at_ min(X,Y,Z) gt Z ? X, Z ? Y.
Rule RDCS BICS MEG
r? min(1,2,M) true X' 1, Y' 2, Z' M, X' ? Y'
84CHR Base Example Defining min in Terms of ?, ?
and
- r1_at_ min(X,Y,Z) ltgt X ? Y Z X
?M true ?X'1,Y'2,Z'M X' 1, Y' 2, Z'
M, X' 1 ? 2 Y' - r2_at_ min(X,Y,Z) ltgt Y ? X Z Y.
- r3_at_ min(X,Y,Z) ltgt Z lt X Y Z.
- r4_at_ min(X,Y,Z) ltgt Z lt Y Y Z.
- r5_at_ min(X,Y,Z) gt Z ? X, Z ? Y.
Rule RDCS BICS MEG
r! min(1,2,M) true X' 1, Y' 2, Z' M, X' ? Y'
true M Z' X' 1
85CHR Base Example Defining min in Terms of ?, ?
and
- r1_at_ min(X,Y,Z) ltgt X ? Y Z X
?M true ?X'1,Y'2,Z'M X' 1, Y' 2, Z'
M, X' 1 ? 2 Y' - r2_at_ min(X,Y,Z) ltgt Y ? X Z Y.
- r3_at_ min(X,Y,Z) ltgt Z lt X Y Z.
- r4_at_ min(X,Y,Z) ltgt Z lt Y Y Z.
- r5_at_ min(X,Y,Z) gt Z ? X, Z ? Y.
Rule RDCS BICS MEG
r! min(1,2,M) true X' 1, Y' 2, Z' M, X' ? Y'
true M 1
Projection(CS,vars(Query))
86CHR Base Example Defining min in Terms of ?, ?
and
- r1_at_ min(X,Y,Z) ltgt X ? Y Z X
- r2_at_ min(X,Y,Z) ltgt Y ? X Z Y.
- r3_at_ min(X,Y,Z) ltgt Z lt X Y Z.
- r4_at_ min(X,Y,Z) ltgt Z lt Y Y Z.
- r5_at_ min(X,Y,Z) gt Z ? X, Z ? Y.
Rule RDCS BICS MEG
min(A,B,M) A ? B
87CHR Base Example Defining min in Terms of ?, ?
and
- r1_at_ min(X,Y,Z) ltgt X ? Y Z X ?A,B,M A ?
B ?X'A,Y'B,Z'M X' A, Y' B, Z' M, X'
A ? B Y' - r2_at_ min(X,Y,Z) ltgt Y ? X Z Y.
- r3_at_ min(X,Y,Z) ltgt Z lt X Y Z.
- r4_at_ min(X,Y,Z) ltgt Z lt Y Y Z.
- r5_at_ min(X,Y,Z) gt Z ? X, Z ? Y.
Rule RDCS BICS MEG
r1? min(A,B,M) A ? B X' A, Y' B, Z' M, X' ? Y'
88CHR Base Example Defining min in Terms of ?, ?
and
- r1_at_ min(X,Y,Z) ltgt X ? Y Z X ?A,B,M A ?
B ?X'A,Y'B,Z'M X' A, Y' B, Z' M, X'
A ? B Y' - r2_at_ min(X,Y,Z) ltgt Y ? X Z Y.
- r3_at_ min(X,Y,Z) ltgt Z lt X Y Z.
- r4_at_ min(X,Y,Z) ltgt Z lt Y Y Z.
- r5_at_ min(X,Y,Z) gt Z ? X, Z ? Y.
Rule RDCS BICS MEG
r1! min(A,B,M) A ? B X' A, Y' B, Z' M, X' ? Y'
true M Z' X' A, A ? B
89CHR Base Example Defining min in Terms of ?, ?
and
- r1_at_ min(X,Y,Z) ltgt X ? Y Z X ?A,B,M A ?
B ?X'A,Y'B,Z'M X' A, Y' B, Z' M, X'
A ? B Y' - r2_at_ min(X,Y,Z) ltgt Y ? X Z Y.
- r3_at_ min(X,Y,Z) ltgt Z lt X Y Z.
- r4_at_ min(X,Y,Z) ltgt Z lt Y Y Z.
- r5_at_ min(X,Y,Z) gt Z ? X, Z ? Y.
Rule RDCS BICS MEG
r1! min(A,B,M) A ? B X' A, Y' B, Z' M, X' ? Y'
true M A, A ? B
Projection(CS,vars(Query))
90CHR Bases as Component
- Several solvers, each one implemented by a
pair(CHR base, CHR engine) - can be assembled in a component-based
architecture, - with server solvers' CHR bases defining in their
rule heads - the constraints used as built-ins by client
solvers' CHR bases
91Example CHR Base Component Assembly
92CHR Base Example Restricted Formof Real Linear
Equations Solver
- r1_at_ ?P C ltgt P C.
- r2_at_ ?P ?Q C ltgt ?Q.number, R C - ?Q ?P
R. - r3_at_ ?P ?Q C ltgt ?P.number, R C - ?P ?Q
R. - r4_at_ ?P ?Q C \ ?P - ?Q D ltgt R (C D)
/ 2 ?P R. -
- Notation
- ?P Constraint Domain Variable and CHR
Variable - C Constraint Domain Constant and CHR
Variable - Constraint Domain Equality Predicate
- CHR Equality Predicate
- 0,1,2, ... CHR and Host Programming Language
Constants - Host Programming Language Variable
Assignment Predicate, always
returns true, performs arithmetic computation as
side-effect - , -, / Host Programming Language
Arithmetic Function
Rule RDCS BICS MEG
?Y 2, ?X ?Y 3, ?U - ?V 2, ?U ?V 0 true
93CHR Base Example Restricted Formof Real Linear
Equations Solver
- r1_at_ ?P C ltgt P C
??Y, true
??P?Y,C2 ?P ?Y, C 2 - r2_at_ ?P ?Q C ltgt ?Q.number, R C - ?Q ?P
R. - r3_at_ ?P ?Q C ltgt ?P.number, R C - ?P ?Q
R. - r4_at_ ?P ?Q C \ ?P - ?Q D ltgt R (C D)
/ 2 ?P R.
Rule RDCS BICS MEG
r1? ?Y 2, ?X ?Y 3, ?U - ?V 2, ?U ?V 0 true ?P ?Y, C 2
94CHR Base Example Restricted Formof Real Linear
Equations Solver
- r1_at_ ?P C ltgt P C
- r2_at_ ?P ?Q C ltgt ?Q.number, R C - ?Q ?P
R. - r3_at_ ?P ?Q C ltgt ?P.number, R C - ?P ?Q
R. - r4_at_ ?P ?Q C \ ?P - ?Q D ltgt R (C D)
/ 2 ?P R.
Rule RDCS BICS MEG
r1! ?Y 2, ?X ?Y 3, ?U - ?V 2, ?U ?V 0 true ?P ?Y, C 2
?X ?Y 3, ?U - ?V 2, ?U ?V 0 ?Y 2
95CHR Base Example Restricted Formof Real Linear
Equations Solver
- r1_at_ ?P C ltgt P C
- r2_at_ ?P ?Q C ltgt ?Q.number, R C - ?Q ?P
R. - r3_at_ ?P ?Q C ltgt ?P.number, R C - ?P ?Q
R. - r4_at_ ?P ?Q C \ ?P - ?Q D ltgt R (C D)
/ 2 ?P R.
Rule RDCS BICS MEG
r1! ?Y 2, ?X ?Y 3, ?U - ?V 2, ?U ?V 0 true ?P ?Y, C 2
r1? ?X ?Y 3, ?U - ?V 2, ?U ?V 0 ?Y 2
Why r1 does not apply?
96CHR Base Example Restricted Formof Real Linear
Equations Solver
- r1_at_ ?P C ltgt P C
- r2_at_ ?P ?Q C ltgt ?Q.number, R C - ?Q ?P
R. - ??X,?Y,?U,?V ?Y 2 ?lt?P,?Q,C,Rgt lt?X,2,3,1gt
?P ?X, ?Q ?Y, C 3, ?Q.number, R 1 - r3_at_ ?P ?Q C ltgt ?P.number, R C - ?P ?Q
R. - r4_at_ ?P ?Q C \ ?P - ?Q D ltgt R (C D)
/ 2 ?P R.
Rule RDCS BICS MEG
r1! ?Y 2, ?X ?Y 3, ?U - ?V 2, ?U ?V 0 true ?P ?Y, C 2
r2? ?X ?Y 3, ?U - ?V 2, ?U ?V 0 ?Y 2 ?P ?X, ?Q ?Y, C 3, ?Q.number, R 1
97CHR Base Example Restricted Formof Real Linear
Equations Solver
- r1_at_ ?P C ltgt P C
- r2_at_ ?P ?Q C ltgt ?Q.number, R C - ?Q ?P
R. - ??X,?Y ?Y 2 ?lt?P,?Q,C,Rgt lt?X,2,3,1gt ?P
?X, ?Q ?Y, C 3, ?Q.number, R 1 - r3_at_ ?P ?Q C ltgt ?P.number, R C - ?P ?Q
R. - r4_at_ ?P ?Q C \ ?P - ?Q D ltgt R (C D)
/ 2 ?P R.
Rule RDCS BICS MEG
r1! ?Y 2, ?X ?Y 3, ?U - ?V 2, ?U ?V 0 true ?P ?Y, C 2
r2! ?X ?Y 3, ?U - ?V 2, ?U ?V 0 ?Y 2 ?P ?X, ?Q ?Y, C 3, ?Q.number, R 1
?Y 2, ?X 1
98CHR Base Example Restricted Formof Real Linear
Equations Solver
- r1_at_ ?P C ltgt P C
- r2_at_ ?P ?Q C ltgt ?Q.number, R C - ?Q ?P
R. - r3_at_ ?P ?Q C ltgt ?P.number, R C - ?P ?Q
R. - r4_at_ ?P ?Q C \ ?P - ?Q D ltgt R (C D)
/ 2 ?P R.
Rule RDCS BICS MEG
r1! ?Y 2, ?X ?Y 3, ?U - ?V 2, ?U ?V 0 true ?P ?Y, C 2
r2! ?X ?Y 3, ?U - ?V 2, ?U ?V 0 ?Y 2 ?P ?X, ?Q ?Y, C 3, ?Q.number, R 1
r1? ?U - ?V 2, ?U ?V 0 ?Y 2, ?X 1
99CHR Base Example Restricted Formof Real Linear
Equations Solver
- r1_at_ ?P C ltgt P C
- r2_at_ ?P ?Q C ltgt ?Q.number, R C - ?Q ?P
R - r3_at_ ?P ?Q C ltgt ?P.number, R C - ?P ?Q
R. - r4_at_ ?P ?Q C \ ?P - ?Q D ltgt R (C D)
/ 2 ?P R.
Rule RDCS BICS MEG
r1! ?Y 2, ?X ?Y 3, ?U - ?V 2, ?U ?V 0 true ?P ?Y, C 2
r2! ?X ?Y 3, ?U - ?V 2, ?U ?V 0 ?Y 2 ?P ?X, ?Q ?Y, C 3, ?Q.number, R 1
r2? ?U - ?V 2, ?U ?V 0 ?Y 2, ?X 1 ?P ?U, ?Q ?V, C 2, ?Q.number
100CHR Base Example Restricted Formof Real Linear
Equations Solver
- r1_at_ ?P C ltgt P C
- r2_at_ ?P ?Q C ltgt ?Q.number, R C - ?Q ?P
R - r3_at_ ?P ?Q C ltgt ?P.number, R C - ?P ?Q
R. - r4_at_ ?P ?Q C \ ?P - ?Q D ltgt R (C D)
/ 2 ?P R.
Rule RDCS BICS MEG
r1! ?Y 2, ?X ?Y 3, ?U - ?V 2, ?U ?V 0 true ?P ?Y, C 2
r2! ?X ?Y 3, ?U - ?V 2, ?U ?V 0 ?Y 2 ?P ?X, ?Q ?Y, C 3, ?Q.number, R 1
r3? ?U - ?V 2, ?U ?V 0 ?Y 2, ?X 1 ?P ?U, ?Q ?V, C 2, ?P.number
101CHR Base Example Restricted Formof Real Linear
Equations Solver
- r1_at_ ?P C ltgt P C
- r2_at_ ?P ?Q C ltgt ?Q.number, R C - ?Q ?P
R - r3_at_ ?P ?Q C ltgt ?P.number, R C - ?P ?Q
R. - r4_at_ ?P ?Q C \ ?P - ?Q D ltgt R (C D)
/ 2 ?P R.
Rule RDCS BICS MEG
r1! ?Y 2, ?X ?Y 3, ?U - ?V 2, ?U ?V 0 true ?P ?Y, C 2
r2! ?X ?Y 3, ?U - ?V 2, ?U ?V 0 ?Y 2 ?P ?X, ?Q ?Y, C 3, ?Q.number, R 1
r4? ?U - ?V 2, ?U ?V 0 ?Y 2, ?X 1 ?P ?U, ?Q ?V, C 0, ?P ?U, ?Q ?V, D 2, R 1
102CHR Base Example Restricted Formof Real Linear
Equations Solver
- r1_at_ ?P C ltgt P C
- r2_at_ ?P ?Q C ltgt ?Q.number, R C - ?Q ?P
R - r3_at_ ?P ?Q C ltgt ?P.number, R C - ?P ?Q
R. - r4_at_ ?P ?Q C \ ?P - ?Q D ltgt R (C D)
/ 2 ?P R - ??X,?Y,?U,?V ?X 1, ?Y 2 ?lt?P,?Q,C,D,Rgt
lt?U,?V,0,2,1gt ?P ?U, ?Q ?V, C 0, D 2, R
1
Rule RDCS BICS MEG
r1! ?Y 2, ?X ?Y 3, ?U - ?V 2, ?U ?V 0 true ?P