I want to write a predicate rename_term_variables/3, which takes a term and a list of certain variables in the term as input and should output a new term where the variables in the list are renamed.
The following example illustrates the desired output of the predicate:
?- rename_term_variables(a(X, b(X, Y, Z)), [X,Z], New_Term).
New_Term = a(_7448, b(_7448, Y, _7450)).
Not quite sure what you’re asking, but you might be interested in the variable_names option of read_term/2 and write_term/2. Also the numbervars/1 predicate and the numbervars options of write_term/2.