--------------------------------------------------------------------
--------------------------------------------------------------------
-- Function auxiliary operations
--------------------------------------------------------------------
--------------------------------------------------------------------
-- Function is a set {(x1, y1),...,(xn, yn)}
-- Transforms a singleton set into the element itself
pick({x}) = x
-- Returns the function return
-- Raises error if z is not in the domain of the function
apply(<(x,y)>^rs,z) =
if x==z then y else apply(rs,z)
-- domain antirestriction
ddres(f,xs) = <(n,v) | (n,v) <- f, not member(n,xs)>
-- domain restriction
dres(f,xs) = <(n,v) | (n,v) <- f, member(n,xs)>
-- Overwrites the fuction
over(<>,n,v) = <>
over(<(x,y)>^rs,n,v) =
if x==n then <(x,v)>^rs else <(x,y)>^over(rs,n,v)
-- Returns the domain of a relation
dom(f) = set(<n | (n,v) <- f>)
-- Returns the domain of a relation
ran(f) = set(<v | (n,v) <- f>)
-- Subset or equals
subseteq(S,T) = diff(S,T) == {}