If term_variables/2 works in a time linear with the size of its first argument, this might work:
varset_intersection(As, Bs, As_cap_Bs):- term_variables([As, Bs], As_and_Bs), term_variables(As, SetAs), append(SetAs, OnlyBs, As_and_Bs), term_variables([OnlyBs, Bs], SetBs), append(OnlyBs, As_cap_Bs, SetBs).
Each common variable appears only once in the list of results, no matter how many times it appears in two lists.
?- varset_intersection2([A,_C,A,A,A], [A,_B,A,A,A], L). L = [A].
In addition, it can give strange results, as in this case:
?- varset_intersection([A,_X,B,C], [B,C,_Y,A], [C, A, B]). A = B, B = C.
( permutation/2 may help here).