
:- use_module( library('clp/bounds')).
:- use_module( library(clpfd)).

couleur(1,bleu).
couleur(2,jaune).
couleur(3,rouge).

colorier :- 
	ListeVar = [C1,C2,C3,C4],
	ListeVar in 1..3,       
	label(ListeVar),       
	all_different([C1,C2]),
	all_different([C1,C3]),
	all_different([C1,C4]),
	all_different([C2,C3]),
	all_different([C3,C4]),
	affiche(ListeVar),
	fail.

colorier.

affiche([]) :- nl.
affiche([H|T]) :- couleur(H,C),write(C),tab(2),affiche(T).

trains([[1,2,0,1],[2,3,4,5],[2,3,0,1],[3,4,5,6],[3,4,2,3],[3,4,8,9]]).

itineraire(A, D, Ps) :-
	Ps = [
		[A,B,_T0,T1],
		[B,C,T2,T3],
		[C,D,T4,_T5]
	     ],
	T2 #> T1,
	T4 #> T3,
	trains(Ts),
	tuples_in(Ps,Ts).
