i'm trying to write a simple meta-interpreter for the unification in prolog, this is what i got so far
unify(A,B):-var(A),A=B.
unify(A,B):-nonvar(A),var(B),B=A.
unify(A,B):-compound(A),compound(B),A=..[F|ArgsA],B=..[F|ArgsB],unify_args(ArgsA,ArgsB).
unify_args([A|TA],[B|TB]):-unify(A,B),unify_args(TA,TB).
unify_args([],[]).
meta(true).
meta((A,B)):- meta(A),meta(B).
meta(C):-clause(H,B), unify(H,C), meta(B).
the problem that i'm getting is that when i try to unify two variables e.g
meta((A,B)).
i get the correct result
A = B, B = true .
but when i try to unify anything else for example
meta((a,a)).
or even a compund i get the following error:
ERROR: Arguments are not sufficiently instantiated
ERROR: In:
ERROR: [12] clause(_4306,_4308)
ERROR: [11] meta(a) at path_redacted/unify1.pl:22
ERROR: [10] meta((a,a)) at path_redacted/unify1.pl:21
ERROR: [9] <user>
i can't understand why clause/2 would need instantiated argouments in this particular case, or maybe i'm missing something else?
Thank you for any help