%
% for all board allocated in a slot,
% if the board's length is long,
% then the slot's length must be long
%

%
% FBPML-alike
%
static_constraint(
%
% other info. to stuff
%
% variable quantification:
%
%	forall(B),
%	forall(S),
%	forall(Bl),
%	forall(Sl),
%
% type info. of variables:
%
%	instance_of(B,board),
%	instance_of(S,slot),
%	string(Bl),
%	string(Sl)
%
% misc/optional info.:
%
%	variable(B),
%	variable(S),
%	variable(Bl),
%	variable(Sl),
%
	[	allocate(B,S),
		instance_att((B,board),length,Bl),		%type info. redundant
		instance_att((S,slot),length,Sl),		%type info. redundant
		Bl='long'
	],
	[	Sl='long'
	]
	).


%
% XCIF (allocate as an attribute of board)
%
restrict_subquery(
	all(var(b),var(s),var(bl),var(sl)),
	[	generate(board,var(b)),					%var(b) is a board
		generate(slot,var(s)),					%var(s) is a slot
		generate(allocate,[board],[var(b)],slot,var(s)),	%the slot where this board is allocated
		generate(length,[board],[var(b)],string,var(bl)),	%board length
		generate(length,[slot],[var(s)],string,var(sl)),	%slot length
		expression([var(bl)],[],expr(=,var(bl),'long'))		%board length is "long"
	],
	[	expression([var(sl)],[],expr(=,var(sl),'long'))		%slot length must be "long"
	]
).


%
% constraint in XCIF
%
% allocation is modelled as a entity class "allocate_board_slot" that relates a board to a slot
% property "allocate_board" & "allocate_slot" of an "allocate" instance point to the "board" & "slot"
% instances respectively
%

restrict_subquery(
	all([var(b),var(s),var(a),var(bl),var(sl),]),
	[	generate(board,var(b)),							%var(b) is a board
		generate(slot,var(s)),							%var(s) is a slot
		generate(allocate_board_slot,var(a)),					%var(a) is an allocation instance
		generate(allocate_board,[allocate_board_slot],[var(a)],board,var(b)),	
                %board assosicated w/ this allocation instance

		generate(allocate_slot,[allocate_board_slot],[var(a)],slot,var(s)),	
                %slot assosicated w/ this allocation instance
		generate(length,[board],[var(b)],string,var(bl)),			%length of board
		generate(length,[slot],[var(s)],string,var(sl)),			%length of slot
		expression([var(bl)],[],expr(=,var(bl),'long'))				%board length is "long"
	],
	[	expression([var(sl)],[],expr(=,var(sl),'long'))				%slot length must be "long"
	]
).











