%% %CopyrightBegin%
%%
%% SPDX-License-Identifier: Apache-2.0
%%
%% Copyright Ericsson AB 2021-2025. All Rights Reserved.
%%
%% %CopyrightEnd%

[;1m  specification(Fun, Set1)[0m

  Returns the set containing every element of [;;4mSet1[0m for which [;;4mFun[0m
  returns [;;4mtrue[0m.

  If [;;4mFun[0m is a tuple [;;4m{external, Fun2}[0m, [;;4mFun2[0m is applied to the
  external set of each element, otherwise [;;4mFun[0m is applied to each
  element.

[;1mExamples[0m

    1> R1 = sofs:relation([{a,1},{b,2}]).
    2> R2 = sofs:relation([{x,1},{x,2},{y,3}]).
    3> S1 = sofs:from_sets([R1,R2]).
    4> S2 = sofs:specification(fun sofs:is_a_function/1, S1).
    5> sofs:to_external(S2).
    [[{a,1},{b,2}]]

  Using an external fun.

    1> S1 = sofs:set([1,2,3,4,5,6,7]).
    2> SetFun = {external,fun(E) -> E rem 2 =:= 0 end}.
    3> S2 = sofs:specification(SetFun, S1).
    4> sofs:to_external(S2).
    [2,4,6]
