#include "clause.h"

This page has information from files clause.h and clause.c.

Contents


Public Routines in File clause.c

Index

any_clausedefinite_clausemixed_clausepositive_literals
append_literalfprint_clausenegative_clauserenumber_variables
atom_numberfprint_clause_memnegative_literalsterm_to_clause
clause_lengthget_clausenew_literalunit_clause
clause_set_variablesgreatest_variable_in_clausenumber_of_literalsupward_clause_links
clause_to_termhorn_clausep_clausezap_clause
clause_to_term_xith_literalp_clause_mem
copy_clauseliteral_numberpositive_clause

Details


BOOL any_clause(Clause c);
This function is always TRUE. (It it intended to be used as an argument.)
void append_literal(Clause c, Literal lit);
This routine appends a literal to a clause.
int atom_number(Clause c, Term atom);
Given a clause and an atom, return the position of the atom (counting from 1) in the clause. The check is by pointer only. If the atom does not occur in the clause, 0 is returned.
int clause_length(Clause c);
This routine returns the length of a clause, which is the sum of the lengths of its atoms.
BOOL clause_set_variables(Clause c, int max_vars);
This routine traverses a clause and changes the constants that should be variables, into variables. On input, the clause should have no variables. The new variables are numbered 0, 1, 2 ... according the the first occurrence, reading from the left.

If there are not more than max_vars distinct variables, 1 is returned; if there are more than max_vars variables, the transformation is not completed, and 0 is returned.

The intended is use is for input clauses that are built without regard to variable/constant distinction.


Term clause_to_term(Clause c);
This routine takes a Clause and returns an entirely new Term which represents the clause. The disjunction symbol for the term is binary OR_SYM, and the negation symbols is NOT_SYM.
Term clause_to_term_x(Clause c);
This routine takes a Clause and returns its Term form. The disjunction symbol for the term is binary OR_SYM, and the negation symbols is NOT_SYM.

This version destroys the clause.


Clause copy_clause(Clause c);
This routine builds and returns a copy of a clause.
BOOL definite_clause(Clause c);
This Boolean function checks if a clause has exactly one positive literal.
void fprint_clause(FILE *fp, Clause c);
This routine prints a clause to a file.
void fprint_clause_mem(FILE *fp, BOOL heading);
This routine prints (to FILE *fp) memory usage statistics for data types associated clauses. The Boolean argument heading tells whether to print a heading on the table.
Clause get_clause(void);
This routine allocates and returns an empty clause.
int greatest_variable_in_clause(Clause c);
This routine returns the greatest variable index in a clause. If the clause is ground, -1 is returned.
BOOL horn_clause(Clause c);
This function checks if a clause has at most one positive literal.
Literal ith_literal(Clause c, int i);
Return the i-th literal of a clause, counting from 1. Return NULL if i is out of range.
int literal_number(Clause c, Literal l);
Given a clause and a literal, return the position of the literal (counting from 1) in the clause. The check is by pointer only. If the literal does not occur in the clause, 0 is returned.
BOOL mixed_clause(Clause c);
This function checks if a clause has at least one positive and at least one negative literal.
BOOL negative_clause(Clause c);
This function checks if all of the literals of a clause are negative.
int negative_literals(Clause c);
This function returns the number of negative literals in a clause.
Literal new_literal(int sign, Term atom);
This routine takes a sign (Boolean) and a Term atom, and returns a literal. The atom is not copied.
int number_of_literals(Clause c);
This function returns the number of literals in a clause.
void p_clause(Clause c);
This routine prints a clause to stdout.
void p_clause_mem();
This routine prints (to stdout) memory usage statistics for data types associated with clauses.
BOOL positive_clause(Clause c);
This function checks if all of the literals of a clause are positive.
int positive_literals(Clause c);
This function returns the number of positive literals in a clause.
BOOL renumber_variables(Clause c, int max_vars);
This routine renumbers the variables of a clause. The variables are renumbered 0, 1, 2 ... according the the first occurrence, reading from the left.

If there are not more than max_vars distinct variables, 1 is returned; if there are more than max_vars variables, the transformation is not completed, and 0 is returned.

The intended is use is for inferred clauses that may contain variable indexes greater than max_vars.


Clause term_to_clause(Term t);
This routine takes a Term t (presumably a disjunction with binary symbol OR_SYM), and constructs a Clause. The Clause is entirely new.

The main use of this routine is intended to be as follows: a Term representing a clause is parsed (using mixfix notation) from the input, then here it is copied translated into a Clause data structure.


BOOL unit_clause(Clause c);
This function checks if a clause has exactly one literal.
void upward_clause_links(Clause c);
In the given Clause c, make the "container" field of each subterm point to c.
void zap_clause(Clause c);
This routine frees a clause (but not any justification list or attributes). The caller should make sure that nothing (e.g., indexes) refer to the clause or any of its subterms.

Public Definitions in File clause.h

typedef struct literal * Literal;

struct literal {
  int      sign;
  Term     atom;
  Literal  next;
};

typedef struct clause * Clause;

struct clause {
  int              id;
  Literal          first_literal;
  Glist            justification;
  struct clist_pos *containers;
};


Introduction


These activities are projects of the Mathematics and Computer Science Division of Argonne National Laboratory.