- Improved code for new preferred order swapping of substitutions. Also

included more comments.
This commit is contained in:
ccremers 2005-10-08 20:22:24 +00:00
parent 2e495099bb
commit 2ead7ab2ff

View File

@ -139,24 +139,22 @@ termMguTerm (Term t1, Term t2)
}
}
/* symmetrical tests for single variable */
/*
* I broke symmetry later, for the special case where both are unbound
* variables that will be connected, and I want to give one priority over the
* other for readability.
* Distinguish a special case where both are unbound variables that will be
* connected, and I want to give one priority over the other for readability.
*
* Because t1 and t2 have been deVar'd means that if they are variables, they
* are also unbound.
*/
if (realTermVariable (t2))
if (realTermVariable (t1) && realTermVariable (t2) && goodsubst (t1, t2))
{
if (termSubTerm (t1, t2) || !goodsubst (t2, t1))
return MGUFAIL;
else
{
// Symmetry break starts here
if (isTermVariable (t1))
{
// Both are variables. Decide.
// The plan: t2->subst will point to t1. Is that desired?
if (preferSubstitutionOrder (t1,t2))
/* Both are unbound variables. Decide.
*
* The plan: t1->subst will point to t2. But maybe we prefer the other
* way around?
*/
if (preferSubstitutionOrder (t2, t1))
{
Term t3;
@ -165,8 +163,22 @@ termMguTerm (Term t1, Term t2)
t1 = t2;
t2 = t3;
}
t1->subst = t2;
#ifdef DEBUG
showSubst (t1);
#endif
return termlistAdd (NULL, t1);
}
/* symmetrical tests for single variable.
*/
if (realTermVariable (t2))
{
if (termSubTerm (t1, t2) || !goodsubst (t2, t1))
return MGUFAIL;
else
{
t2->subst = t1;
#ifdef DEBUG
showSubst (t2);