package term-indexing

  1. Overview
  2. Docs
include Intf.Term_core with type prim = P.t with type t = P.t Term.term
type prim = P.t

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

type t = P.t Term.term

The type of terms

type var := int
val pp_sexp : Format.formatter -> t -> unit

Pretty-printing of terms in s-exp format.

val 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.

val var : var -> t

var v construcst a variable v

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

destruct t ifprim ifvar performs case analysis on the term t

val 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

val fold : (t -> Path.t -> 'b -> 'b) -> 'b -> t -> 'b

fold f acc term folds f over the subterms of t

val get_subterm_fwd : t -> Path.forward -> t

get_subterm_fwd 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.

type 'a var_map

The type of polymorphic maps indexed by variables

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

compare is a total order.

val equal : t -> t -> bool

equal s1 s2 tests whether s1 and s2 are equal.

val hash : t -> int

hash s is a hash of s.

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

pp fmt s prints a representation of s to the formatter fmt.

type var := int
val 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.

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

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

val get_subterm : t -> Path.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.

val subst : term:t -> path:Path.t -> (t -> t) -> t

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

val fold_variables : (var -> Path.t -> 'b -> 'b) -> 'b -> t -> 'b

fold_variables f acc t folds f over the variables of t

val 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.

val 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.

OCaml

Innovation. Community. Security.