:- ensure_loaded(typeops).

% An example of type annotated Prolog:

%
% partially ordered sets
%


:- type_import(prolog_types).
:- type_import(lib).

%----------------------------------------------

% A partial order over some domain D has a binary relation D =< D
% where =< is reflexive, transfitive and antisymmetric.
%


type order1(T) --> T =< T.


% A partially ordered set is internally represented by a structure
abstract
type poset(T) -->
        poset( list(T),            % domain
               list(order1(T))     % order relationships
             ).



%----
% po_create(Domain,Order,PO) :-
%       PO is the internal repr. of partial order over Domain.
%
pred po_create(list(@T),list(order1(T)),poset(@T)).
%
po_create(Domain,Order,PO) :-
      % ... implementation not part of example


%----
% po_leq(PO,X,Y) :- (X =< Y) is true in PO.
%
pred po_leq(poset(@T),T,T).
%
po_leq(_PO,X,X).
po_leq(poset(_,LT),X,Y) :- member(X=<Y,LT).


%  ...