Constraint Handling Rules: Difference between revisions

Content deleted Content added
No edit summary
m linking
Line 21:
A CHR program, then, consists of rules that manipulate a multi-set of these terms, called the ''constraint store''. Rules come in three types:<ref name="timegoesby"/>
 
* Simplification rules have the form <math>h_1, \dots, h_n \Longleftrightarrow g_1, \dots, g_m \,|\, b_1, \dots, b_o</math>. When they match the ''heads'' <math>h_1, \dots, h_n</math> and the ''[[Guard_(computer_science)|guards]]'' <math>g_1, \dots, g_m</math> hold, simplification rules may rewrite the heads into the ''body'' <math>b_1, \dots, b_o</math>.
* Propagation rules have the form <math>h_1, \dots, h_n \Longrightarrow g_1, \dots, g_m \,|\, b_1, \dots, b_o</math>. These rules add the constraints in the body to the store, without removing the heads.
* ''Simpagation'' rules combine simplification and propagation. They are written <math>h_1, \dots, h_\ell \,\backslash\, h_{\ell+1}, \dots, h_n \Longleftrightarrow g_1, \dots, g_m \,|\, b_1, \dots, b_o</math>. For a simpagation rule to fire, the constraint store must match all the rules in the head and the guards must hold true. The <math>\ell</math> constraints before the <math>\backslash</math> are kept, as a in a propagation rule; the remaining <math>n - \ell</math> constraints are removed.