% This LaTeX document was generated using the LaTeX backend of PlDoc, % The SWI-Prolog documentation system \section{library(varnumbers): Utilities for numbered terms} \label{sec:varnumbers} \begin{tags} \tag{See also} \predref{numbervars}{4}, \predref{\Sstructeq}{2} (\predref{variant}{2}). \tag{Compatibility} This library was introduced by Quintus and available in many related implementations, although not with exactly the same set of predicates. \end{tags} This library provides the inverse functionality of the built-in \predref{numbervars}{3}. Note that this library suffers from the known issues that '\$VAR'(X) is a normal Prolog term and, -unlike the built-in numbervars-, the inverse predicates do \textit{not} process cyclic terms. The following predicate is true for any acyclic term that contains no '\$VAR'(X), \verb$integer(X)$ terms and no constraint variables: \begin{code} always_true(X) :- copy_term(X, X2), numbervars(X), varnumbers(X, Copy), Copy =@= X2. \end{code} \vspace{0.7cm} \begin{description} \predicate[det]{numbervars}{1}{+Term} Number variables in \arg{Term} using \$VAR(N). Equivalent to \verb$numbervars(Term, 0, _)$. \begin{tags} \tag{See also} \predref{numbervars}{3}, \predref{numbervars}{4} \end{tags} \predicate[det]{varnumbers}{2}{+Term, -Copy} Inverse of \predref{numbervars}{1}. Equivalent to \verb$varnumbers(Term, 0, Copy)$. \predicate[det]{varnumbers}{3}{+Term, +Start, -Copy} Inverse of \predref{numbervars}{3}. True when \arg{Copy} is a copy of \arg{Term} with all variables numbered \Sge{} \arg{Start} consistently replaced by fresh variables. Variables in \arg{Term} are \textit{shared} with \arg{Copy} rather than replaced by fresh variables. \begin{tags} \tag{Errors} \verb$domain_error(acyclic_term, Term)$ if \arg{Term} is cyclic. \tag{Compatibility} Quintus, SICStus. Not in YAP version of this library \end{tags} \predicate[det]{max_var_number}{3}{+Term, +Start, -Max} True when \arg{Max} is the max of \arg{Start} and the highest numbered \$VAR(N) term. \begin{tags} \tag{author} Vitor Santos Costa \tag{Compatibility} YAP \end{tags} \predicate[det]{varnumbers_names}{3}{+Term, -Copy, -VariableNames} If \arg{Term} is a term with numbered and named variables using the reserved term '\$VAR'(X), \arg{Copy} is a copy of \arg{Term} where each '\$VAR'(X) is consistently replaced by a fresh variable and Bindings is a list \verb$X = Var$, relating the \arg{X} terms with the variable it is mapped to. \begin{tags} \tag{See also} \predref{numbervars}{3}, \predref{varnumbers}{3}, \predref{read_term}{3} using the \verb$variable_names$ option. \end{tags} \end{description}