package term-tools

  1. Overview
  2. Docs

Module Make.TermSource

First-order terms.

include Intf.Term_core with type prim = P.t
Sourcetype prim = P.t

The type of primitives, i.e. the symbols. Each value of type prim has a definite arity.

Sourcetype t

The type of terms

type var := int
include Intf.Hashed with type t := t
Sourceval compare : t -> t -> int

compare is a total order.

Sourceval equal : t -> t -> bool

equal s1 s2 tests whether s1 and s2 are equal.

Sourceval hash : t -> int

hash s is a hash of s.

Sourceval pp : Format.formatter -> t -> unit

Pretty-printing of terms.

Sourceval pp_sexp : Format.formatter -> t -> unit

Pretty-printing of terms in s-exp format.

Sourceval prim : prim -> t array -> t

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.

Sourceval var : var -> t

var v construcst a variable v

Sourceval destruct : (prim -> t array -> 'a) -> (var -> 'a) -> t -> 'a

destruct ifprim ifvar t performs case analysis on the term t

Sourceval destruct2 : (prim -> t array -> prim -> t array -> 'a) -> (prim -> t array -> int -> 'a) -> (int -> prim -> t array -> 'a) -> (int -> int -> 'a) -> t -> t -> 'a

destruct2 fpp fpv fvp fvv t1 t2 performs case analysis on a pair of terms t1, t2

Sourceval is_var : t -> var option

is_var t is equal to var v if equal t (var v) or None if it is not the case

Sourceval is_ground : t -> bool

is_ground t is true if and only if t does not contain any variable.

Sourceval fold : (t -> 'b -> 'b) -> t -> 'b -> 'b

fold f acc t folds f over the subterms of t

Sourcetype 'a var_map

The type of polymorphic maps indexed by variables

type var := int
Sourceval ub : t -> Int_option.t

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.

Sourceval map_variables : (int -> t) -> t -> t

map_variables f t replaces all variables var i present in t by f i.

Sourceval get_subterm : t -> int list -> 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.

Sourceval subst : term:t -> path:int list -> (t -> t) -> t

subst ~term ~path f replaces the subterm of term at path by f (get_subterm term path).

Sourceval fold_variables : (var -> 'b -> 'b) -> t -> 'b -> 'b

fold_variables f acc t folds f over the variables of t

Sourceval canon : t -> (unit -> var) -> var var_map * t

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.

Sourceval uid : t -> int

uid t returns a unique integer attached to t. It is guaranteed that if two terms have the same uid, they are equal.