Module Functional.GenericRelationalValued

Functional union find

This is functional and immutable

Parameters

module Value : Parameters.GENERIC_VALUE with type ('a, 'b) relation = ('a, 'b) Relation.t

Signature

Set of 'a Term.t

type t

Type of the union-find structure

val pretty : Stdlib.Format.formatter -> t -> unit

Prints equivalence classes

val pretty_debug : Stdlib.Format.formatter -> t -> unit

Prints whole data structure

val equal : t -> t -> bool
val subseteq : t -> t -> bool
val empty : t

Existential wrappers for the return type of find operations

type 'a term_through_relation =
  1. | TermThroughRel : 'b Term.t * ('a, 'b) Relation.t -> 'a term_through_relation
type 'a value_through_relation =
  1. | ValueThroughRelation : 'b Value.t option * ('a, 'b) Relation.t -> 'a value_through_relation
type 'a all_through_relation =
  1. | AllThroughRelation : 'b Term.t * 'b Value.t option * TermSet.t * ('a, 'b) Relation.t -> 'a all_through_relation

Find operations

val find_representative : t -> 'a Term.t -> 'a term_through_relation

Returns the representative of the given terms, along with the relation between the given term and its representative. O(1) complexity

val find_class : t -> 'a Term.t -> TermSet.t

Returns the class of the given term, O(1) complexity

val find_value : t -> 'a Term.t -> 'a value_through_relation

Returns the value of the given term's representative (None for top), along with the relation between the given term and its representative. O(1) complexity

val find : t -> 'a Term.t -> 'a all_through_relation

Returns the given term's representative, associated value (None for top), along with the relation between the given term and its representative. O(1) complexity

check_related uf a b returns the relation between a and b if they are in the same class.

val add_value : t -> 'a Term.t -> 'a Value.t -> t

add_value uf a v is uf with the value v added to a (Or more precisely, the value is added to the representative of a, via the relation between a and its representative). Intersects with previous value via Value.meet if one is present

Union and join

val union : t -> 'a Term.t -> 'b Term.t -> ('a, 'b) Relation.t -> t

union uf a b r adds the r a b relation in uf. Does nothing if a and b are already related

val join : t -> t -> t

join a b joins the two union find-structures:

  • The new classes are the intersection of the old classes
  • The new values are the Value.join of the old values