peters-buy() :- buy(peters,_what) & _what.
buy(_broker,_prod) :- want(customer(_broker),_prod), deal(_prod,cost(_prod),benefit(_prod)).
deal(_prod,_cost,_benefit) :- >=(_benefit,_cost).
want(miller,stock1).
want(miller,stock2).
want(fuller,stock3).
customer(peters) :& miller.
customer(peters) :& fuller.
cost(stock1) :& 165.
cost(stock2) :& 130.
cost(stock3) :& 175.
benefit(stock1) :& 160.
benefit(stock2) :& 130.
benefit(stock3) :& 180.