Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file intf.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429(** Hashable, totally ordered, printable types *)moduletypeHashed=sigtypet(** [compare] is a total order. *)valcompare:t->t->int(** [equal s1 s2] tests whether [s1] and [s2] are equal. *)valequal:t->t->bool(** [hash s] is a hash of [s]. *)valhash:t->int(** [pp fmt s] prints a representation of [s] to the formatter [fmt]. *)valpp:Format.formatter->t->unitend(** The type of signatures of first-order terms. *)moduletypeSignature=sigincludeHashed(** [arity s] is the arity of [s], i.e. a term with head [s] must have exactly [arity s] sub-terms. *)valarity:t->intend(** The module type of finite maps. *)moduletypeMap=sig(** The type of keys. *)typekey(** The type of maps polymorphic in their values. *)type'at(** [empty ()] is the empty map. *)valempty:unit->'at(** [is_empty m] is true if and only if [m] is empty. *)valis_empty:'at->bool(** [find_opt k m] is [Some v] if [k] is bound to [v] in [m], and [None] otherwise. *)valfind_opt:key->'at->'aoption(** [add k v m] is the map that binds [k] to [v] in [m]. If [k] is already bound, the previous binding is shadowed. *)valadd:key->'a->'at->'at(** [equal eq m1 m2] is true if and only if [m1] and [m2] are equal according to [eq]. *)valequal:('a->'a->bool)->'at->'at->bool(** [union m1 m2] is the union of [m1] and [m2].
Raises [Invalid_argument] if [m1] and [m2] have overlapping domains.
*)valunion:'at->'at->'at(** [to_seq m] produces the {b persistent} sequence of elements of [m] in
increasing key order. *)valto_seq:'at->(key*'a)Seq.t(** [of_seq_keys m] is the sequence of keys of [m] *)valto_seq_keys:'at->keySeq.t(** [of_seq s] constructs a map from the elements of [s]. *)valof_seq:(key*'a)Seq.t->'atend(** The module type of patterns. *)moduletypePattern=sig(** The type of primitives, i.e. the symbols. Each value of type [prim] has a definite arity. *)typeprimtype'awith_state(** The type of zippers over terms. *)typezipper(** The type of patterns. *)typet(** The type of matchings. A matching is a disjunction of patterns. *)typematching=tlist(** The type of patterns on lists of terms. *)typeplist(** The type of terms. *)typeterm(** [pattern_matches patt t] checks whether the pattern [patt] matches the term [t] *)valpattern_matches:t->term->bool(** [all_matches t matching] returns all zippers at which there is a subterm satisfying [matching] *)valall_matches:matching->termwith_state->zipperlist(** [first_match t matching] returns the first zippers, if any, where there is a subterm satisfying [matching].
If the matched pattern does not specify focused subterms, the result is at most a singleton list.
If the matched pattern specifies focused subterms, the result is a list of zippers, one for each focused subterm.
*)valfirst_match:matching->termwith_state->zipperlist(** [refine_focused patt zippers] returns the refinements of [zippers] that correspond to focused subterms of [patt].
If [patt] is does not specify focii, the result is the empty list.
*)valrefine_focused:t->zipper->zipperlist(** [prim p plist] is a pattern matching a term with head bearing a primitive [p] and subterms matching the list pattern [plist]. *)valprim:prim->plist->t(** [prim_pred pred plist] is a pattern matching a term with primitive [p] such that [pred p] is [true], and subterms
matching the list pattern [plist]. *)valprim_pred:(prim->bool)->plist->t(** [any_var] is a pattern matching any variable. *)valany_var:t(** [var i] is a pattern matching a variable [i]. *)valvar:int->t(** [any] is a pattern matching any term. *)valany:t(** [focus patt] returns a pattern equivalent to [patt] except that a focus mark is added
on all terms matched by [patt].
Raises [Invalid_pattern] if [t] is already a focus. *)valfocus:t->t(** [list_any] is a list pattern matching any list of terms. *)vallist_any:plist(** [list_empty] is a list pattern matching the empty list of terms. *)vallist_empty:plist(** [list_cons hd tl] is a list pattern matching a list with head matching the pattern [hd] and tail
matching the list pattern [tl]. *)vallist_cons:t->plist->plist(** An alias for {!list_cons} *)val(@.):t->plist->plist(** Pattern pretty-printing *)valpp:Format.formatter->t->unit(** [uid p] returns a unique integer attached to [p]. It is guaranteed that if two patterns
have the same [uid], they are equal. *)valuid:t->intend(** [Term_core] specifies the core types and operations related to first-order terms. *)moduletypeTerm_core=sig(** The type of primitives, i.e. the symbols. Each value of type [prim] has a definite arity. *)typeprim(** The type of terms *)typettypevar:=intincludeHashedwithtypet:=t(** Pretty-printing of terms. *)valpp:Format.formatter->t->unit(** Pretty-printing of terms in s-exp format. *)valpp_sexp:Format.formatter->t->unit(** [prim p ts] constructs a term with head equal to [p] and subterms equal to [ts]
Raises [Invalid_argument] if the length of [ts] does not match the arity of [p]. *)valprim:prim->tarray->t(** [var v] construcst a variable [v] *)valvar:var->t(** [destruct ifprim ifvar t] performs case analysis on the term [t] *)valdestruct:(prim->tarray->'a)->(var->'a)->t->'a(** [destruct2 fpp fpv fvp fvv t1 t2] performs case analysis on a pair of terms [t1], [t2] *)valdestruct2:(prim->tarray->prim->tarray->'a)->(prim->tarray->int->'a)->(int->prim->tarray->'a)->(int->int->'a)->t->t->'a(** [is_var t] is equal to [var v] if [equal t (var v)] or [None] if it is not the case *)valis_var:t->varoption(** [is_ground t] is true if and only if [t] does not contain any variable. *)valis_ground:t->bool(** [get_subterm t fpth] is the subterm of [t] at position defined by the forward path
[fpth].
Raises [Get_subterm_oob] if the path is out of bounds.
*)valget_subterm:t->intlist->t(** [fold f acc t] folds [f] over the subterms of [t] *)valfold:(t->'b->'b)->t->'b->'b(**/**)valto_tree:t->PrintBox.t(**/**)end(** The module type of first-order terms *)moduletypeTerm=sigincludeTerm_core(** The type of polymorphic maps indexed by variables *)type'avar_maptypevar:=int(** [ub t] is an upper bound on the absolute value of variables contained in [t].
Equal to {!Int_option.none} if [t] does not contain variables. *)valub:t->Int_option.t(** [map_variables f t] replaces all variables [var i] present in [t] by [f i]. *)valmap_variables:(int->t)->t->t(** [get_subterm t pth] is the subterm of [t] at position defined by the path [pth].
Raise [Get_subterm_oob] if the path is out of bounds. *)valget_subterm:t->intlist->t(** [subst ~term ~path f] replaces the subterm of [term] at [path]
by [f (get_subterm term path)]. *)valsubst:term:t->path:intlist->(t->t)->t(** [fold_variables f acc t] folds [f] over the variables of [t] *)valfold_variables:(var->'b->'b)->t->'b->'b(** [canon t gen] canonicalizes the term [t] using the variable generator [gen].
Returns the canonicalized term as well as a map from old to canonicalized variables. *)valcanon:t->(unit->var)->varvar_map*t(** [uid t] returns a unique integer attached to [t]. It is guaranteed that if two terms
have the same [uid], they are equal. *)valuid:t->intend(** The module type of read-only states *)(** The module type of substitutions *)moduletypeSubst=sig(** The type of terms *)typetermtypevar:=int(** The type of substitutions *)typetvalof_seq:(var*term)Seq.t->tvalto_seq:t->(var*term)Seq.tvalto_seq_keys:t->varSeq.tvalpp:Format.formatter->t->unit(** [empty ()] is the empty substitution. *)valempty:unit->t(** [is_empty subst] checks whether [equal subst empty] *)valis_empty:t->bool(** [equal s1 s2] checks equality of substitutions. *)valequal:t->t->bool(** [get k state] returns [Some v] if the key [k] is associated to the value [v] in [state], or [None] otherwise. *)valget:var->t->termoption(** [add v t subst] adds a mapping from [v] to [t] in [subst].
If [v] is already in the domain of [subst], the previous mapping is replaced.
Raises [Invalid_argument] if [t] is a variable equal to [v] *)valadd:var->term->t->t(** [unsafe_add] does as {!add} but doen't check for validity of the mapping. *)valunsafe_add:var->term->t->t(** [lift subst term] applies the substitution [subst] to [term].
Note that [lift] does not perform an occur check: do not use with
substitutions that are not well-founded. *)vallift:t->term->term(** [union s1 s2] computes the union of [s1] and [s2].
Raises [Invalid_argument] if [s1] and [s2] have overlapping domains. *)valunion:t->t->tend(** [Unification] contains facilities to solve unification problems on first-order terms *)moduletypeUnification=sig(** The type of terms *)typeterm(** The type of substitutions *)typesubst(** [state] is the type of unification state. *)typestate(** [Cannot_unify] is raised by {!unify} when a unifier cannot be found. *)exceptionCannot_unify(** [empty ()] is an empty unification state. *)valempty:unit->state(** [unify t1 t2 state] unifies terms [t1] and [t2] in state [state] and returns
an updated {!state}. *)valunify:term->term->state->stateoption(** [unify_exn t1 t2 state] unifies terms [t1] and [t2] in state [state] and returns
an updated {!state}.
Raises [Cannot_unify] if no solution was found. *)valunify_exn:term->term->state->state(** [unify_subst s state] unifies [s] with substitution state [state]
and returns an updated {!state}. *)valunify_subst:subst->state->stateoption(** [unify_subst s1 s2 state] unifies [s1] with [s2] in state [state]
and returns an updated {!state}. *)valunify_subst_exn:subst->state->state(** [generalizes t1 t2] checks that there exists a substitution [subst]
such that [lift t1 subst = t2]. *)valgeneralizes:term->term->bool(** [subst state] returns the substitution underlying the unification state. *)valsubst:state->subst(** [Occurs_check] is raised by {!unfold} when the solution contains a cycle. *)exceptionOccurs_check(** [unfold state term] returns [term] with variables substituted for their representative terms.
Raises [Occurs_check] if the solution contains a cycle. *)valunfold:state->term->termend(** The module type of zippers. *)moduletypeZipper=sig(** This module implements zippers over first-order terms.
For advanced users: as an extension over plain zippers, the module also allows to edit a term lazily applied
to a substitution. In plain words, the variables contained in terms may point to other terms, specified
by a substitution provided at zipper creation time. One can then navigate and edit the induced graph in a
purely applicative fashion. *)(** The type of terms. *)typeterm(** The type of zippers. *)typet(** For plain zippers, ['a with_state = 'a]. When doing term graph edition, this type encapsulates the underlying
substitution. *)type'awith_state(** Pretty-printing zippers. *)valpp:tFmt.t(** [compare] is a total order. *)valcompare:t->t->int(** [equal z1 z2] tests whether [z1] and [z2] are equal. *)valequal:t->t->bool(** [cursor z] is the term under focus of [z]. *)valcursor:t->term(** [path z] is the path from the root to the term under focus of [z]. *)valpath:t->intlist(** [of_term t] is the zipper of the term [t]. *)valof_term:termwith_state->t(** [to_term z] is the term represented by the zipper [z]. *)valto_term:t->termwith_state(** [move_up z] is the zipper obtained by moving up in the zipper [z]. *)valmove_up:t->toption(** For experienced users only. [deref z] is
{ul
{- [None] when [cursor z] is not a variable}
{- If [cursor z] is a variable [k] and [k] is not bound in the underlying substitution, [deref z] is also [None] }
{- Otherwise, [deref z] is [Some z'] where [z'] is a zipper located at the term associated to [k]. } }
*)valderef:t->toption(** [move_at z i] is the zipper obtained by moving at the index [i].
For experienced users/experimental: when doing term graph edition, in the case where [cursor z] is a variable
in the domain of the underlying substitution, [move_at z i] will silently perform a {!deref}
before moving at the index [i] of the obtained term. *)valmove_at:t->int->toption(** [move_at_exn z i] is the exception-raising vaeriant of {!move_at}.
Raises [Invalid_argument] if [i] is out of bounds. *)valmove_at_exn:t->int->t(** [replace t z] is the zipper obtained by replacing the term at the focus of [z] by [t]. *)valreplace:term->t->t(** [fold f acc z] folds a zipper over the subterms of [cursor z] (including [cursor z]).
[fold] does not follow the links given by the substitution underlying [z], if any.
*)valfold:(t->'a->'a)->t->'a->'atypevar:=int(** [fold_variables f acc z] folds a zipper over the subterms of [cursor z] which are variables.
[fold_variables] does not follow the links given by the substitution underlying [z], if any.
*)valfold_variables:(var->t->'a->'a)->t->'a->'aend