Recently I have read some papers about CHR(Constraint Handling Rules). It is indeed a very powerful language (especially for expressing algorithm’s intent) and in most cases the refined operational semantics is sufficient.
However, I am not satisfied. I want more (I’m greedy, sorry).
Is there a CHR package that supports Constraint Handling Rules with dynamic rule priorities in swi-prolog (or other prolog systems I could try)?
For example, Dijkstra’s Shortest Path can be written in 3 lines if it supports dynamic rule priorities.
d1 @ source(V) ==> dist(V,0) pragma priority(1).
d2 @ dist(V,D1) \ dist(V,D2) <=> D1 < D2 | true pragma priority(1).
d3 @ dist(V,D), e(V,C,U) ==> dist(U,D+C) pragma priority(D+2).
The pragma priority(D+2)
schedules the rule applications first that deal with shorter distances, which saves us from having to manually maintain a priority queue (e.g. heap).
I am extremely looking forward to try this language in swi-prolog.
Thanks.