
  -spec substitution(SetFun, Set1) -> Set2
                        when
                            SetFun :: set_fun(),
                            Set1 :: a_set(),
                            Set2 :: a_set().

  Returns a function, the domain of which is Set1. The value of an
  element of the domain is the result of applying SetFun to the
  element.

    1> L = [{a,1},{b,2}].
    [{a,1},{b,2}]
    2> sofs:to_external(sofs:projection(1,sofs:relation(L))).
    [a,b]
    3> sofs:to_external(sofs:substitution(1,sofs:relation(L))).
    [{{a,1},a},{{b,2},b}]
    4> SetFun = {external, fun({A,_}=E) -> {E,A} end},
    sofs:to_external(sofs:projection(SetFun,sofs:relation(L))).
    [{{a,1},a},{{b,2},b}]

  The relation of equality between the elements of {a,b,c}:

    1> I = sofs:substitution(fun(A) -> A end, sofs:set([a,b,c])),
    sofs:to_external(I).
    [{a,a},{b,b},{c,c}]

  Let SetOfSets be a set of sets and BinRel a binary relation.
  The function that maps each element Set of SetOfSets onto the 
  image of Set under BinRel is returned by the following
  function:

    images(SetOfSets, BinRel) ->
       Fun = fun(Set) -> sofs:image(BinRel, Set) end,
       sofs:substitution(Fun, SetOfSets).

  External unordered sets are represented as sorted lists. So,
  creating the image of a set under a relation R can traverse all
  elements of R (to that comes the sorting of results, the image).
  In image/2, BinRel is traversed once for each element of 
  SetOfSets, which can take too long. The following efficient
  function can be used instead under the assumption that the image
  of each element of SetOfSets under BinRel is non-empty:

    images2(SetOfSets, BinRel) ->
       CR = sofs:canonical_relation(SetOfSets),
       R = sofs:relative_product1(CR, BinRel),
       sofs:relation_to_family(R).
