%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Representation of PC Configuration Example % Definition of The Domain % % Shared Information for All Sites % % Jessica Chen-Burger % % In this document, we will adopt a convention that words starting % with a capital letter stand for variables, whereas words starting % with a lower case letter stand for constants. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % use list library ! :- use_module(library(lists)). :- multifile property/3, def_predicate/2, axiom/2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % (1) def_predicate(Predicate, A_list_of_definition_for_predicate) % % The def_predicate/2 defines other predicates. % % The content in the Definition_for_predicate defines the Predicate, % where the "," symbol denotes conjunction, "or" denotes disjunction, % and predicate not/1 denotes negation. % % The predicate exist/1 denotes the existential quantification, % predicate forall/1 denotes the universal quantification. When no % quantification predicates are used, all variables are universally % quantified. The predicate imply/0 denotes the one directional % implicaiton ->. The predicate double_imply/0 denotes bi-directional % or tautology, <->. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % class_rel(Relationship, Sub_class, Super_class) def_predicate(class(X), [atomic(X)]). def_predicate(class_rel(is_a, X, Y), [class(X), class(Y)]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % (2) axiom(Conclusion, Hypothesis) % % The axiom/2 defines other predicates. % % The content stores in the Hypothesis implies the Conclusion. % Rules for describing the Hypothesis is the same as it is described % in the A_list_of_definition_for_predicate in predicate % def_predicate/2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % The is_a/2 predicate is transitive axiom(class_rel(is_a, X, Z), [class_rel(is_a, X, Y), class_rel(is_a, Y, Z)]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Property name of a class is normally a string which is represented % here as an atom, i.e. constants connected by under scores. def_predicate(string(X), [atom(X)]). def_predicate(property_name(X), [string(X)]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Property value is either an atom, number or a compounded % term def_predicate(constant(X), [atomic(X)]). def_predicate(property_value(X), [or([atomic(X),compound(X)])]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % att_domain(Class, Attribute_name, Attribute_value) % % Defining the attributes for instances and the domain for the % attribute value. def_predicate(att_domain(X, Y, Z), [class(X), attribute_name(Y), value_domain(Z)] ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % property(Class, Property_name, Property_value) def_predicate(property(X, Y, Z), [class(X), property_name(Y), property_value(Z)]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def_predicate(instance(X), [atomic(X)]). def_predicate(instance_of(X, Y), [instance(X), class(Y) ]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Description of boards %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% class(board). class(processor). class_rel(is_a, processor, board). class(disk_controller). class_rel(is_a, disk_controller, board). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def_predicate(allocate(X, Y), [instance_of(X, board), instance_of(Y, slot) ]). def_predicate(next_to(X,Y), [instance_of(X, slot), instance_of(Y, slot) ]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Definition of predicate: % allocate(Board, Slot): % A Board (type) has been allocated to a Slot. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% class(io). class_rel(is_a, io, board). class(optionI). class_rel(is_a, optionI, board). class(optionII). class_rel(is_a, optionII, board). class(optionIII). class_rel(is_a, optionIII, board). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% class(optionIV). class_rel(is_a, optionIV, board). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def_predicate(has(X, Y), [instance(X), instance(Y) ]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def_predicate(attribute_name(Y), [string(Y)]). def_predicate(attribute_value(X), [ or( [atomic(X), compound(X)] )]). def_predicate(instance_att(X, Y, Z), [instance(X), attribute_name(Y), attribute_value(Z) ]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% 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. class(mother_board). class_rel(is_a, mother_board, device). class(slot). class_rel(is_a, slot, device). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def_predicate(total_cost(X), [cost_domain(X)] ). def_predicate(less_than(X, Y), [cost_domain(X), cost_domain(Y) ] ). axiom(less_than(X, Y), [X =< Y] ). % note that exactly what is the domain for cost, is defined % in the edinburgh.txt - i.e. it is defined by edinburgh site. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def_predicate(special_req(X, Y, Z), [property(X, Y, _), property_value(Z)]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def_predicate(solution(Customer, Requirement, Old_sol, New_sol, Difference), [person(Customer), requirement(Requirement), solution(Old_sol), solution(New_sol), difference(Difference) ] ). def_predicate(init_solution(Customer, Requirement, Old_sol, New_sol, Difference), [person(Customer), requirement(Requirement), solution(Old_sol), solution(New_sol), difference(Difference) ] ). def_predicate(person(X), [ or([atom(X),compound(X)])]). % use list library ! def_predicate(requirement(X), [is_list(X)]). def_predicate(solution(X), [is_list(X) ]). def_predicate(difference(X), [is_list(X) ]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% static_constratint(Typing, Pre_conditions, Conclusions). %% static_constratint(Typing, Conclusions). % %% Arguments are described in conjunction normal form. %% %% 1. static_constraint/3: when all variables are universally %% quantified. %% 2. static_constraint/2: when variables are existentially %% quantified. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% OVERALL constraint for an eventually 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. %% %% This constraint is always true for all solutions. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % existential quantified static_constraint([slot(Slot1), slot(Slot2), slot(Slot3), cost(Cost), instance_of(X, processor), instance_of(Y, disk_controller), instance_of(Z, io) ], [allocate(X, Slot1), allocate(Y, Slot2), allocate(Z, Slot3), total_cost(Cost)] ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % end of file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%