(0) Obligation:

Clauses:

init_vars(E1, E2, E1init, E2init) :- ','(find_all_vars(E1, Vars1), ','(find_all_vars(E2, Vars2), ','(intersect(Vars1, Vars2, _X, Notin1, Notin2), ','(init_vars2(Notin1, E1, E1init), init_vars2(Notin2, E2, E2init))))).
find_all_vars(E, Vars) :- ','(find_all_vars2(E, Vars0), sort(Vars0, Vars)).
find_all_vars2([], []).
find_all_vars2(.(=(Vars, _Values), Es), AllVars) :- ','(append(Vars, AllVars1, AllVars), find_all_vars2(Es, AllVars1)).
init_vars2(Notin, E, Einit) :- ','(init_vars3(Notin, E, Einit0), sort(Einit0, Einit)).
init_vars3([], E, E).
init_vars3(.(Var, Vars), E, .(=(.(Var, []), .(unbound, [])), Es)) :- init_vars3(Vars, E, Es).
append([], A, A).
append(.(A, B), C, .(A, D)) :- append(B, C, D).
intersect(As, [], [], [], As) :- !.
intersect([], Bs, [], Bs, []) :- !.
intersect(.(A, As), .(B, Bs), Cs, Ds, Es) :- ;(;(->(=(A, B), ','(=(Cs, .(A, Cs2)), intersect(As, Bs, Cs2, Ds, Es))), ->(@<(A, B), ','(=(Es, .(A, Es2)), intersect(As, .(B, Bs), Cs, Ds, Es2)))), ','(=(Ds, .(B, Ds2)), intersect(.(A, As), Bs, Cs, Ds2, Es))).
get_query(E1, E2) :- ','(=(E1, .(=(X, .(a, [])), .(=(X, .(a, [])), .(=(X, .(a, [])), .(=(X, .(a, [])), []))))), ','(=(E2, .(=(Y, .(a, [])), .(=(Y, .(a, [])), .(=(Y, .(a, [])), .(=(Y, .(a, [])), []))))), ','(=(X, .(5, .(7, .(8, .(3, .(2, .(4, .(1, .(6, .(9, .(15, .(17, .(18, .(13, .(12, .(14, .(11, .(16, .(19, .(25, .(27, .(28, .(23, .(22, .(24, .(21, .(26, .(29, [])))))))))))))))))))))))))))), =(Y, .(15, .(17, .(18, .(13, .(12, .(14, .(11, .(16, .(19, .(35, .(37, .(38, .(33, .(32, .(34, .(5, .(7, .(8, .(3, .(2, .(4, .(1, .(6, .(9, .(31, .(36, .(39, []))))))))))))))))))))))))))))))).

Query: init_vars(g,g,a,a)

(1) PrologToPiTRSViaGraphTransformerProof (SOUND transformation)

Transformed Prolog program to (Pi-)TRS.

(2) Obligation:

Pi-finite rewrite system:
R is empty.
Pi is empty.

(3) RisEmptyProof (EQUIVALENT transformation)

The TRS R is empty. Hence, termination is trivially proven.

(4) YES