% An example of type annotated Prolog:

% 
% built-in types and predicates for numbers and numeric expressions
%


type num.
suptype num > float.
suptype num > int.
type int.
type nat.
suptype int > negint.
suptype int > nat.
suptype nat > posint.
suptype nat > zero.
type zero --> 0.
type posint --> {X|(integer(X),X>0)}.
type negint --> {X|(integer(X),X<0)}.

type float --> {X|float(X)}.

% built-in predicates
pred integer(int).
pred float(float).



% arithmetic
type numexpr --> numexpr + numexpr ;         % binary infix operators
                 numexpr - numexpr ;
                 numexpr * numexpr ;
                 numexpr / numexpr ;
                 + num;                      % prefix operators
                 - num.

suptype numexpr  > num.

pred num is numexpr.                         % built-in 'is'
pred numexpr =:= numexpr.
pred numexpr =\= numexpr.
pred numexpr  < numexpr.
pred numexpr =< numexpr.
pred numexpr >  numexpr.
pred numexpr > numexpr.