Example #1
0
BOOL res_HasTautology(CLAUSE clause)
/**********************************************************
  INPUT:   A clauses.
  RETURNS: TRUE if the clause contains a complementary 
           literal pair and FALSE otherwise. 
  CAUTION: None.
***********************************************************/
{
  BOOL found;
  TERM literal1;
  int  i, j, n;

  found = FALSE;
  n     = clause_Length(clause);
  
  for (i = 0; i < n && !found; i++) {
    literal1 = fol_ComplementaryTerm(clause_GetLiteralTerm(clause,i));
    for (j = 0; j < n && !found; j++)
      if (j != i && term_Equal(literal1, clause_GetLiteralTerm(clause,j)))
	found = TRUE;

    term_Delete(literal1);
  }
  return found;
}
Example #2
0
static ord_RESULT kbo_CompareStruc(TERM Term1, TERM Term2, int WeightDiff)
/**************************************************************
  INPUT:   Two terms where the kbo-variable condition for <Term1> and
           <Term2> is satisfied and <WeightDiff> is the kbo weight difference
	   between <Term1> and <Term2>
  RETURNS: ord_UNCOMPARABLE, if Term1 and Term2 are uncomparable
	   ord_EQUAL,        if Term1 and Term2 are equal
	   ord_GREATER_THAN, if Term1 is greater than Term2
  CAUTION: The precedence from the order module is used to determine
           the precedence of symbols!
***************************************************************/
{
    LIST   Scan1,Scan2;
    SYMBOL Top1,Top2;

    Top1       = term_TopSymbol(Term1);
    Top2       = term_TopSymbol(Term2);

    if (WeightDiff > 0)
        return ord_GREATER_THAN;
    else if (WeightDiff == 0) {
        if (symbol_IsStandardVariable(Top1)) {
            if (symbol_IsStandardVariable(Top2))
                return ord_EQUAL;
            else
                return ord_UNCOMPARABLE;
        }
        else if (symbol_IsStandardVariable(Top2) ||
                 symbol_PrecedenceGreater(ord_PRECEDENCE, Top1, Top2))
            return ord_GREATER_THAN;
        else if (Top1 == Top2) {
            int    RecWeightDiff;
            BOOL   T1VarCond, T2VarCond;
            TERM   RecTerm1,RecTerm2;
            Scan1 = term_ArgumentList(Term1);
            Scan2 = term_ArgumentList(Term2);
            if (symbol_HasProperty(Top1,ORDRIGHT)) {
                int i;
                for (i = symbol_Arity(Top1);
                        i > 0 && term_Equal(list_NthElement(Scan1,i),list_NthElement(Scan2,i));
                        i--);
                if (i > 0) {
                    RecTerm1 = (TERM)list_NthElement(Scan1,i);
                    RecTerm2 = (TERM)list_NthElement(Scan2,i);
                }
                else
                    return ord_EQUAL;
            }
            else {
                while (!list_Empty(Scan1) && term_Equal(list_Car(Scan1),list_Car(Scan2))) {
                    Scan1 = list_Cdr(Scan1);
                    Scan2 = list_Cdr(Scan2);
                }
                if (list_Empty(Scan1)) /* Implies that list_Empty(Scan2)  */
                    return ord_EQUAL;
                else {
                    RecTerm1 = (TERM)list_Car(Scan1);
                    RecTerm2 = (TERM)list_Car(Scan2);
                }
            }
            RecWeightDiff =  kbo_CompVarCondAndWeight(RecTerm1,&T1VarCond,RecTerm2,&T2VarCond);
            if (RecWeightDiff >= 0 && T1VarCond)
                return kbo_CompareStruc(RecTerm1, RecTerm2, RecWeightDiff);
            else
                return ord_UNCOMPARABLE;
        }
        else
            return ord_UNCOMPARABLE;
    }
    else
        return ord_UNCOMPARABLE;

    return ord_UNCOMPARABLE;
}