Projection and Redundancy Elimination

Once a derivation succeeds, the Prolog system presents the bindings for the variables in the query. In a CLP system, the set of answer constraints is presented in analogy. A complication in the CLP context are variables and associated constraints that were not mentioned in the query. A motivating example is the familiar mortgage relation:

             
% library('clpqr/examples/mg')
mg(P,T,I,B,MP):- { T = 1, B + MP = P * (1 + I) }. mg(P,T,I,B,MP):- { T > 1, P1 = P * (1 + I) - MP, T1 = T - 1 }, mg(P1, T1, I, B, MP).
A sample query yields:
     clp(r) ?- use_module(library('clpqr/examples/mg')).
     clp(r) ?- mg(P,12,0.01,B,Mp).
     
     {B=1.1268250301319698*P-12.682503013196973*Mp}
     
Without projection of the answer constraints onto the query variables we would observe the following interaction:
     clp(r) ?- mg(P,12,0.01,B,Mp).
     
     {B=12.682503013196973*_A-11.682503013196971*P},
     {Mp= -(_A)+1.01*P},
     {_B=2.01*_A-1.01*P},
     {_C=3.0301*_A-2.0301*P},
     {_D=4.060401000000001*_A-3.0604009999999997*P},
     {_E=5.101005010000001*_A-4.10100501*P},
     {_F=6.152015060100001*_A-5.152015060099999*P},
     {_G=7.213535210701001*_A-6.213535210700999*P},
     {_H=8.285670562808011*_A-7.285670562808009*P},
     {_I=9.368527268436091*_A-8.36852726843609*P},
     {_J=10.462212541120453*_A-9.46221254112045*P},
     {_K=11.566834666531657*_A-10.566834666531655*P}
     
The variables _A ... _K are not part of the query, they originate from the mortgage program proper. Although the latter answer is equivalent to the former in terms of linear algebra, most users would prefer the former.