A The SWI-Prolog library
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • The SWI-Prolog library
        • library(aggregate): Aggregation operators on backtrackable predicates
        • library(ansi_term): Print decorated text to ANSI consoles
        • library(apply): Apply predicates on a list
        • library(assoc): Association lists
        • library(broadcast): Broadcast and receive event notifications
        • library(charsio): I/O on Lists of Character Codes
        • library(check): Consistency checking
        • library(clpb): CLP(B): Constraint Logic Programming over Boolean Variables
        • library(clpfd): CLP(FD): Constraint Logic Programming over Finite Domains
        • library(clpqr): Constraint Logic Programming over Rationals and Reals
        • library(csv): Process CSV (Comma-Separated Values) data
        • library(dcg/basics): Various general DCG utilities
        • library(dcg/high_order): High order grammar operations
        • library(debug): Print debug messages and test assertions
        • library(dicts): Dict utilities
        • library(error): Error generating support
        • library(gensym): Generate unique identifiers
        • library(iostream): Utilities to deal with streams
        • library(lists): List Manipulation
        • library(main): Provide entry point for scripts
        • library(nb_set): Non-backtrackable set
        • library(www_browser): Activating your Web-browser
        • library(occurs): Finding and counting sub-terms
        • library(option): Option list processing
        • library(optparse): command line parsing
        • library(ordsets): Ordered set manipulation
        • library(pairs): Operations on key-value lists
        • library(persistency): Provide persistent dynamic predicates
        • library(pio): Pure I/O
        • library(predicate_options): Declare option-processing of predicates
        • library(prolog_pack): A package manager for Prolog
        • library(prolog_xref): Cross-reference data collection library
        • library(quasi_quotations): Define Quasi Quotation syntax
        • library(random): Random numbers
        • library(readutil): Reading lines, streams and files
        • library(record): Access named fields in a term
        • library(registry): Manipulating the Windows registry
        • library(settings): Setting management
        • library(simplex): Solve linear programming problems
        • library(solution_sequences): Modify solution sequences
        • library(thread_pool): Resource bounded thread management
        • library(ugraphs): Unweighted Graphs
        • library(url): Analysing and constructing URL
        • library(varnumbers): Utilities for numbered terms
          • numbervars/1
          • varnumbers/2
          • varnumbers/3
          • max_var_number/3
          • varnumbers_names/3
        • library(yall): Lambda expressions
    • Packages

A.44 library(varnumbers): Utilities for numbered terms

See also
numbervars/4, =@=/2 (variant/2).
Compatibility
This library was introduced by Quintus and available in many related implementations, although not with exactly the same set of predicates.

This library provides the inverse functionality of the built-in 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 not process cyclic terms. The following predicate is true for any acyclic term that contains no '$VAR'(X), integer(X) terms and no constraint variables:

always_true(X) :-
      copy_term(X, X2),
      numbervars(X),
      varnumbers(X, Copy),
      Copy =@= X2.
[det]numbervars(+Term)
Number variables in Term using $VAR(N). Equivalent to numbervars(Term, 0, _).
See also
numbervars/3, numbervars/4
[det]varnumbers(+Term, -Copy)
Inverse of numbervars/1. Equivalent to varnumbers(Term, 0, Copy).
[det]varnumbers(+Term, +Start, -Copy)
Inverse of numbervars/3. True when Copy is a copy of Term with all variables numbered >= Start consistently replaced by fresh variables. Variables in Term are shared with Copy rather than replaced by fresh variables.
Errors
domain_error(acyclic_term, Term) if Term is cyclic.
Compatibility
Quintus, SICStus. Not in YAP version of this library
[det]max_var_number(+Term, +Start, -Max)
True when Max is the max of Start and the highest numbered $VAR(N) term.
author
Vitor Santos Costa
Compatibility
YAP
[det]varnumbers_names(+Term, -Copy, -VariableNames)
If Term is a term with numbered and named variables using the reserved term '$VAR'(X), Copy is a copy of Term where each '$VAR'(X) is consistently replaced by a fresh variable and Bindings is a list X = Var, relating the X terms with the variable it is mapped to.
See also
numbervars/3, varnumbers/3, read_term/3 using the variable_names option.