Availability:built-in
[ISO]copy_term(+In, 
-Out)Create a version of In with renamed (fresh) variables and 
unify it to Out. Attributed variables (see section 
8.1) have their attributes copied. The implementation of copy_term/2 
can deal with infinite trees (cyclic terms). As pure Prolog cannot 
distinguish a ground term from another ground term with exactly the same 
structure, ground sub-terms are shared between In 
and Out. Sharing ground terms does affect setarg/3. 
SWI-Prolog provides
duplicate_term/2 
to create a true copy of a term.