예제 #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;
}
예제 #2
0
LIST cond_CondFast(CLAUSE c)
/**********************************************************
  INPUT:   A clause c.
  RETURNS: A list with indexes with respect to c that can
           be deleted due to condensing.
  CAUTION: None.
***********************************************************/
{
    int    vec, i, j, k;
    LIST   indexlist;

    indexlist = list_Nil();
    vec       = vec_ActMax();

    for (i = 0; i < clause_Length(c); i++) {
        vec_Push((POINTER) i);
    }

    for (k = clause_Length(c) - 1; k >= 0; k--) {
        for (i = vec; i < vec_ActMax(); i++) {
            if ((int)vec_GetNth(i) != k) {
                cont_StartBinding();
                if (unify_Match(cont_LeftContext(),
                                clause_GetLiteralTerm(c,k),
                                clause_GetLiteralTerm(c,(int)vec_GetNth(i)))) {
                    cont_BackTrack();
                    for (j = vec; j < vec_ActMax(); j++) {
                        if (k == (int)vec_GetNth(j)) {
                            vec_Swap((vec_ActMax() -1) ,j);
                            j = vec_ActMax();
                        }
                    }

                    if (subs_IdcRes(c,vec,(vec_ActMax() -1))) {
                        indexlist = list_Cons((POINTER)k,indexlist);
                        vec_Pop();
                    }

                    i = vec_ActMax()+1;
                }
                else
                    cont_BackTrack();
            }
        }
    }

    vec_SetMax(vec);
    return indexlist;
}
예제 #3
0
BOOL res_BackSubWithLength(CLAUSE clause, st_INDEX stindex)
/**********************************************************
  INPUT:   A clauses and an index.
  RETURNS: TRUE if a clause of the index subsumes the clause clause
           and length(clause) >= length(clause of index).
  CAUTION: None.
***********************************************************/
{
  int     n,i; 
  LIST    scan,generals;
  TERM    term;
  LITERAL litres;

  n = clause_Length(clause);
  for (i = 0; i < n; i++) {
    term      = clause_GetLiteralTerm(clause,i);
    generals  = st_GetGen(cont_LeftContext(), stindex, term);
    for (scan = generals; !list_Empty(scan); scan = list_Cdr(scan)) {
      litres = (LITERAL) list_Car(scan);
      if (litres == clause_GetLiteral(clause_LiteralOwningClause(litres),0) &&
	  clause_Length(clause) >= clause_Length(clause_LiteralOwningClause(litres)) &&
	  clause_Weight(clause) >= clause_Weight(clause_LiteralOwningClause(litres)) &&
	  subs_Idc(clause_LiteralOwningClause(litres),clause)) {
	    list_Delete(generals);
	    return TRUE;
      }
    }
    list_Delete(generals);
  }
  return FALSE;
}
예제 #4
0
void res_InsertClauseIndex(CLAUSE clause, st_INDEX stindex)
/**********************************************************
  INPUT:   A st_INDEX and a clause.
  RETURNS: Inserts the clause in the st_INDEX stindex.
  CAUTION: None.
***********************************************************/
{
  int n,j;

  n = clause_Length(clause);
  for (j = 0; j < n; j++)
    st_EntryCreate(stindex,
		   clause_GetLiteral(clause,j),
		   clause_GetLiteralTerm(clause,j),
		   cont_LeftContext());
}
예제 #5
0
void res_DeleteClauseIndex(CLAUSE clause, st_INDEX stindex)
/**********************************************************
  INPUT:   A st_INDEX and a clause.
  RETURNS: Deletes the clause from the st_INDEX stindex.
  CAUTION: None.
***********************************************************/
{
  int n, j;

  n = clause_Length(clause);
  for (j = 0; j < n; j++)
    if (!st_EntryDelete(stindex,
			clause_GetLiteral(clause,j), 
			clause_GetLiteralTerm(clause,j),
			cont_LeftContext()))
      misc_DumpCore();
}