%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Representaiton for PC Configuration Example 
% 
%               Jessica Chen-Burger 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Description of boards available 
% 

is_a(processor,       board). 
is_a(disk_controller, board).
is_a(io,              board).
is_a(optionI,         board).
is_a(optionII,        board).
is_a(optionIII,       board).
is_a(optionIV,        board).

class(processor). 
property(processor, capability, [processor]). 
property(processor, length,     long).
property(processor, extra_power_data, extra).
property(processor, cost, 200).

class(disk_controller). 
property(disk_controller, capability, [disk_io]). 
property(disk_controller, length,     long).
property(disk_controller, extra_power_data, normal). 
property(disk_controller, cost,      50).
static_constraint([], [next_to(disk_controller, processor)]).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Definition of predicate next_to(A, B). 
next_to(A, B) :-
    next_to(A, B);
    next_to(B, A). 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

class(io). 
property(io, capability,       [other_io]). 
property(io, length,           short).
property(io, extra_power_data, normal). 
property(io, cost,             50).

class(optionI). 
property(optionI, capability, [fast_graphics]).
property(optionI, length,     long).
property(optionI, extra_power_data, extra). 
property(optionI, cost,       100).
static_constraint([], [next_to(optionI, processor)]).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% static_constratin(Pre-conditions, Conclusions). 
%% both arguments are described in conjunctive normal form.  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

class(optionII). 
property(optionII, capability, [fast_graphics, video_in]).
property(optionII, length,     short).
property(optionII, extra_power_data, extra). 
property(optionII, cost,       300).

class(optionIII). 
property(optionIII, capability,       [sound]).
property(optionIII, length,           long).
property(optionIII, extra_power_data, normal). 
property(optionIII, cost,             50).
static_constraint([], [next_to(optionIII, io)]).

class(optionIV). 
property(optionIV, capability,       [video_in]).
property(optionIV, length,           short).
property(optionIV, extra_power_data, normal). 
property(optionIV, cost,             50).
static_constraint([], [next_to(optionIV, disk_controller)]).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Description of the mother board used: 
%% note that instances are used here to indicate that 
%% a particular type of board with 6 slot instances are 
%% used. 

is_a(slot, device). 

class(slot).
instance_of(slot1, slot). 
instance_att(slot1, position, 1). 
instance_att(slot1, length, long). 
instance_att(slot1, extra_power_data, normal). 
next_to(slot1, slot2). 
 
instance_of(slot2, slot). 
instance_att(slot2, position, 2). 
instance_att(slot2, length, long). 
instance_att(slot2, extra_power_data, extra). 
next_to(slot2, slot3). 

instance_of(slot3, slot). 
instance_att(slot3, position, 3). 
instance_att(slot3, length, long). 
instance_att(slot3, extra_power_data, extra). 
next_to(slot3, slot4). 

instance_of(slot4, slot). 
instance_att(slot4, position, 4). 
instance_att(slot4, length,   short). 
instance_att(slot4, extra_power_data, extra). 
next_to(slot4, slot5). 

instance_of(slot5, slot). 
instance_att(slot5, position, 5). 
instance_att(slot5, length,   short). 
instance_att(slot5, extra_power_data, normal).  
next_to(slot5, slot6). 

instance_of(slot6, slot). 
instance_att(slot6, position, 6). 
instance_att(slot6, length,   short). 
instance_att(slot6, extra_power_data, normal).  

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% OVERALL constraint for a goal state: 
%% i.e. must have a processor, disk-controller and an io, 
%% this is independent of the customer, or the mother
%% board type. Notice that a class type has been specified
%% because we may not know if there is such a board in 
%% stock. 

static_constraint([], [class(processor), 
                       class(disk_controller),
                       class(io)]). 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Dynamic constraint: 
%% constraint that may be negociatable, 
%% e.g. less than 500 pounds, and with sound card. 

dynamic_constraint([], [ less_than(total_cost, 500),
                         property(_, _, [sound]) ]). 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% end of file 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
