2.6 Program Collection

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% V1,...,V6 in {1,...,6}
%%% V1<V2, ... , V5<V6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
declare 
N=6
fun {Tail _|L} L end 
proc {GenerateAndTest L}
   L={MakeList N}
   L ::: 1#N
   {FD.distribute naive L}
   for 
      X in L
      Y in {Tail L}
   do 
      (X<Y)=true 
   end 
end 
proc {TestAndGenerate L}
   L={MakeList N}
   L ::: 1#N
   for 
      X in L
      Y in {Tail L}
   do 
      thread (X<Y)=true end 
   end 
   {FD.distribute naive L}
end 
proc {PropagateAndDistribute L}
   L={MakeList N}
   L ::: 1#N
   for 
      X in L
      Y in {Tail L}
   do 
      X<:Y
   end 
   {FD.distribute naive L}
end 
 
{ExploreAll GenerateAndTest}
{ExploreAll TestAndGenerate}
{ExploreAll PropagateAndDistribute}
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% X,Y,Y,U,V,W in {1,...,7}
%%% X+Y = 3*Z
%%% X-Y = Z
%%% U+W = 2*Z
%%% V+W = U+V
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
%%% propagate and distribute
declare 
proc {Equations Sol}
   X Y Z U V W  
in 
   Sol = solution(x:X y:Y z:Z u:U v:V w:W)
   [X Y Z U V W] ::: 1#7
% Propagate
   X + Y =: 3*Z  
   X - Y =: Z  
   U + W =: 2*Z  
   V + W =: U+V  
% Distribute
   {FD.distribute naive [X Y Z U V W]}
end 
 
{Explorer.all Equations}
 
%%% test and generate
declare 
proc {Equations Sol}
   X Y Z U V W  
in 
   Sol = solution(x:X y:Y z:Z u:U v:V w:W)
   [X Y Z U V W] ::: 1#7
% Test
   thread X + Y = 3*end 
   thread X - Y = Z   end 
   thread U + W = 2*end 
   thread V + W = U+end 
% Distribute
   {FD.distribute naive [X Y Z U V W]}
end 
 
{Explorer.all Equations}
 
%%% generate and test
declare 
proc {Equations Sol}
   X Y Z U V W  
in 
   Sol = solution(x:X y:Y z:Z u:U v:V w:W)
   [X Y Z U V W] ::: 1#7
% Distribute
   {FD.distribute naive [X Y Z U V W]}
% Test
   X + Y = 3*Z  
   X - Y = Z  
   U + W = 2*Z  
   V + W = U+V  
end 
 
{Explorer.all Equations}


Denys Duchier, Claire Gardent and Joachim Niehren
Version 1.3.99 (20050412)