module MultiEquation:sig..end
typevariable =descriptor UnionFind.point
The unifier relies on a union/find algorithm. A variable is
represented as a point of the union/find algorithm. An
equivalence class of points corresponds, roughly speaking, to
what is called a ``standard multi-equation'' in the book. Every
multi-equation carries a descriptor.
type descriptor = {
|
mutable structure : |
|
mutable rank : |
|
mutable mark : |
|
mutable kind : |
|
mutable name : |
|
mutable pos : |
|
mutable var : |
If the structure field is None, then the multi-equation only
has variable members. If it is Some t, then the multi-equation
contains a non-variable member, namely the term t. Note that
t is a term whose head symbol belongs to the algebra and whose
parameters are again variables. Thus, the unifier works with
so-called ``small terms'' only.
The rank field contains the rank currently attached to the
multi-equation. As far as the unifier is concerned, ranks have
no meaning. The unifier only knows that ranks are totally
ordered. When two multi-equations are fused, the smaller rank is
kept.
The mark field is transient, and may be used by the unifier's
client for any purpose.
typestructure =variable CoreAlgebra.term
type variable_kind =
| |
Rigid |
| |
Flexible |
| |
Constant |
Flexible variable can be
unified with other variables or terms. A Rigid variable cannot.type tname =
| |
TName of |
tname is the type of type identifiers.typecrterm =variable CoreAlgebra.arterm
val is_structured : variable -> boolis_structured v tests if v is related to a term.val are_equivalent : variable -> variable -> boolare_equivalent v1 v2 tests if v1 and v2 are in the same
multi-equation.val variable_name : variable -> tname optionvariable_name v returns the name of v if it exists.val variable_structure : variable -> structure optionvariable_structure v returns the structure of v if it exists.val explode : crterm -> variable CoreAlgebra.termexplode t converts an arbitrary depth tree into a 1-depth one using
variables.val variable : variable_kind ->
?name:tname ->
?structure:crterm ->
?pos:Positions.position -> unit -> variablevariable() returns a new variable.val variable_list : variable_kind ->
'a list -> variable list * ('a * crterm) listvariable_list xs allocates a fresh variable for every element in the
list xs, and returns both a list of these variables and an association
list that maps elements to variables, viewed as types.val variable_list_from_names : (tname ->
variable_kind * tname option) ->
tname list ->
variable list *
(tname * crterm) listvariable_list_from_strings f xs allocates a fresh variable for every
string in the list xs, and returns both a list of these variables
and an association list that maps elements to variables, viewed as types.
The kind is determined using the provided function f.val variable_set : (tname ->
variable_kind * tname option) ->
Misc.StringSet.t ->
variable list *
(crterm * Positions.position) Misc.StringMap.tvariable_set xs allocates a fresh variable for every element in the
set xs, and returns both a list of these variables and a map of
elements to variables.val is_rigid : variable -> boolis_rigid v returns true if v is a constant or rigid variable.val is_flexible : variable -> boolis_flexible v returns true if v is a flexible variable.type pool
pool is an abstract type denoting a set of type variables related
to a variable binding location.val inhabitants : pool -> variable listinhabitants p returns the type variables of a pool.val number : pool -> intnumber p returns the rank of a p.val new_pool : pool -> poolnew_pool p introduces a new pool with a rank equals to the one of
p + 1.val init : unit -> poolinit () returns a fresh pool.val register : pool -> variable -> unitregister p v adds v into the pool p without modifying the
rank of v.val introduce : pool -> variable -> unitintroduce p v registers v into p and updates its rank
accordingly.val instance : pool -> variable -> variableinstance p v returns a valid instance of v.val chop : pool -> crterm -> variablechop p t introduces t into p by registering a variable into p
for each node of its tree maintaining its structure using links between
these variables.val chopi : IntRank.t -> crterm -> variablechopi rank term chops a term. Any freshly created variables
receive rank rank, but are not added to any pool.