title: How bootstrap setarg_with_occurs_check/3 in Prolog?
body: <p>How would one go about and bootstrap <code>setarg_with_occurs_check/3</code> in<br />
  Prolog. It seems Prolog has two ways to create cyclic data structures.<br />
  Not only unification can do that, but also setarg/3:</p>
  <pre><code>/* SWI-Prolog 8.3.26 */
  ?- X = f(X).
  X = f(X).
  
  ?- X = f(0), setarg(1,X,X).
  X = f(X).
  </code></pre>
  <p>Lets say I want the analogue of <code>unify_with_occurs_check/2</code> for<br />
  <code>setarg/3</code>. How would one go about and implement the same?</p>
  <p>(BTW In some Prolog systems setarg/3 sometimes goes by the<br />
  name change_arg/3, and some even don't have it at all)</p>