Module Bigraph.Fun
Standard map operations
Additional functions
val inverse : t -> Rel.t
Return the inverse of a function. Note that the inverse of a function is, in the general case, a binary relation.
val to_list : t -> (int * int) list
Return the list of pairs defined by a function.
val of_list : (int * int) list -> t
Inverse of
Fun.to_list
. Note that in case of clashing pairs only the right-most is used.
val parse : int list -> t
parse l
returns a function in which the numbers from0
ton - 1
(withn
the length ofl
) are mapped to the elements ofl
, in the given order. Example:parse [0;0;3;1;2] = [(0,0);(1,0);(2,3);(3,1);(4,2)]
.
val to_string : t -> string
Return the string representation of a function. Example:
{(1, 2), (2, 3), (3, 3)}
val pp : Stdlib.Format.formatter -> t -> unit
Pretty printer.
val apply : t -> int -> int option
apply f x
returnsf(x)
.
val transform : iso_dom:Iso.t -> iso_codom:Iso.t -> t -> t
transform ~iso_dom ~iso_codom f
returns the function obtained by applyingiso_dom
andiso_codom
to the domain and codomain off
, respectively.
val is_total : int -> t -> bool
is_total n f
returnstrue
if functionf
is total over domain0,...,n-1
,false
otherwise.
val is_surj : int -> t -> bool
is_surj n f
returnstrue
if functionf
is surjective over codomain0,...,n-1
,false
otherwise.
val is_id : t -> bool
is_id f
returnstrue
iff(i) = i
for eachi
,false
otherwise.
val check_codom : int -> t -> bool
check_codom n f
returnstrue
if the codomain off
is in the range[0, n-1]
.