This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/CHR/chr/examples/path.pl
vsc e5f4633c39 This commit was generated by cvs2svn to compensate for changes in r4,
which included commits to RCS files with non-trunk default branches.


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@5 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
2001-04-09 19:54:03 +00:00

53 lines
1.1 KiB
Prolog

% PATH CONSISTENCY, simple
% thom fruehwirth ECRC 941201, simplified version of time-pc.chr
% 980311 Thom Fruehwirth, LMU, adapted to Sicstus CHR
:- use_module(library(chr)).
handler path.
option(already_in_heads,on).
constraints con/3.
% con(X,Y,C) means that constraint C holds between variables X and Y
intersect_xy_xy @ con(X, Y, C1), con(X, Y, C2) <=>
inter(C1, C2, C3),
con(X,Y,C3).
intersect_xy_yx @ con(X, Y, C1), con(Y, X, CR) <=>
invert(CR, C2),
inter(C1, C2, C3),
con(X,Y,C3).
propagate_xy_yz @ con(X, Y, C1), con(Y, Z, C2) ==>
trans(C1, C2, C3)
|
con(X, Z, C3).
propagate_xy_xz @ con(X, Y, CR), con(X, Z, C2) ==>
invert(CR,C1),
trans(C1, C2, C3)
|
con(Y, Z, C3).
propagate_xy_zy @ con(X, Y, C1), con(Z, Y, CR) ==>
invert(CR,C2),
trans(C1, C2, C3)
|
con(X, Z, C3).
% Example ---------------------------------
% constraints are < and >
invert(<,>).
invert(>,<).
% fail if empty constraint would be produced
inter(C,C,C).
% fail if most general constraint would be produced
trans(C,C,C).
% ?- con(A,B,>),con(A,C,>),con(B,D,>),con(C,D,>).
/*--------------- eof path.pl ----------------------------------------------*/