Module Iso

module Iso: sig .. end
This module provides an implementation of isomorphisms on integers.
Author(s): Michele Sevegnani

type +'a t 
Type of isomorphisms on integers.
exception NOT_BIJECTIVE
Isomorphisms are bijective functions. For example, pairs

"{(1, 2), (3, 2)}"

are not allowed because value 2 in the co-domain is the mapping of both 1 and 3. This exception is raised when an invalid isomorphism is generated.


Standard map operations



These functions are described in the standard library.
val empty : int t
val is_empty : int t -> bool
val mem : int -> int t -> bool
val iter : (int -> int -> unit) -> int t -> unit
val fold : (int -> int -> 'b -> 'b) -> int t -> 'b -> 'b
val cardinal : int t -> int

Additional functions


val dom : int t -> int list
Return the domain of an isomorphism.
val codom : int t -> int list
Return the co-domain of an isomorphism.
val inverse : int t -> int t
Return the inverse of an isomorphism.
val to_list : int t -> (int * int) list
Return the list of pairs defined by an isomorphism.
val of_list_exn : (int * int) list -> int t
of_list l returns an isomorphism with the elements in list l. In case of conflicting pairs, the right-most is added to the isomorphism.
Raises NOT_BIJECTIVE if l is not a valid isomorphism.
val to_string : int t -> string
Return the string representation of an isomorphism. Example:

"{(1, 1), (2, 3), (5, 2) }".

val add_exn : int -> int -> int t -> int t
add_exn i j iso adds a new pair (i, j) to isomorphism iso. If i was already bound in iso, its previous binding disappears.
Raises NOT_BIJECTIVE when j is already in the co-domain of iso.
val equal : int t -> int t -> bool
Equality between isomorphisms.
val compare : int t -> int t -> int
Comparison between isomorphisms.
val apply_exn : int t -> int -> int
apply_exn iso i returns the value associated to i by isomorphism iso.
Raises Not_found if iso is undefined for i.
val apply : int t -> int -> int option
Same as Iso.apply_exn but with error-aware return type.
val transform_exn : int t -> int t -> int t -> int t
transform_exn i iso_d iso_c returns the isomorphism obtained by applying iso_d and iso_c to the domain and co-domain of i, respectively.
Raises Not_found if the isomorphisms are undefined.
val gen_isos_exn : int t -> int t list -> int t list
gen_isos_exn iso autos generates the symmetric isomorphisms of iso by using autos, a list of automorphisms over the domain of iso. This is the same as iterating Iso.transform_exn over auto, use each automorphism as domain isomorphism and the identity as co-domain isomorphism.
Raises Not_found if some automorphism is undefined.
val is_id : int t -> bool
Returns true if an isomorphism is an identity, false otherwise.