New empty cells are allocated for any unbound variable in the original:
?- G=f(X),duplicate_term(G,H),X=2. G = f(2), X = 2, H = f(_6402).
Can deal with cyclic structures:
?- A=[1,K,3|A],B=[a,b|A],cyclic_term(A), duplicate_term(B,BB),nth0(3,BB,foo). A = [1, K, 3|A], B = [a, b|A], % B = [a,b,1,K,3,1,K,3,1,K,3,....] BB = [a, b|_S1], % where % BB as B but with the copy of K bound to 'foo' _S1 = [1, foo, 3|_S1].