 
 
 
| :- local struct(contents(glass, plastic, steel, wood, copper)). | 
| :- local struct(colour(red, blue, green)). | 
| :- local struct(bin(colour, capacity, contents:contents)). | 
| 
 | 
solve_bin/2 is the general predicate
that takes an amount of components packed into a contents
structure and returns the solution.
	|  | 
solve_bin/2 calls bin_setup/2 to
generate a list Bins.
It adds redundant constraints to remove symmetries (two
solutions are considered symmetrical if they are
the same, but with the bins in a different order).
Finally it labels all decision variables in the problem.
	|  | 
bin_setup/2, to generate a list of bins with appropriate
constraints, works as follows.
First it tries to match the (remaining) demand with zero,
and use no (further) bins.
If this fails, a new bin is added to the bin list;
appropriate constraints are imposed on all the new bin's
variables;
its contents are subtracted from the demand;
and the bin_setup/2 predicate calls itself recursively:|  | 
|  | 
relates/4 predicate (defined 
in section 8.6.3):
	|  | 
|  | 
|  | 
=>.
`Wood requires paper' is expressed in logic as `If the number of wood
items is greater than zero, then the number of paper items
is also greater than zero':
	|  | 
or.
`X and Y are exclusive' is expressed as `Either the number of items of
kind X is zero, or the number of items of kind Y is zero':
	|  | 
relates/4 predicate.
The number of wooden items is then constrained not to exceed the capacity:
	|  | 
|  | 
|  | 
|  | 
search/6 predicate of the ic library).
 
 
