#include "clause.h"

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

Contents


Public Routines in File clause.c

Index

any_clausefirst_negative_literalnegative_clauserenumber_variables
append_literalfprint_clausenegative_literalstautology
atom_numberfprint_clause_memnew_atom_nodesterm_renumber_variables
clause_lengthfree_literalnew_atomsterm_to_clause
clause_set_variablesfunction_symbols_in_clausenew_literaltrue_term
clause_to_termget_clausenumber_of_literalsunit_clause
clause_to_term_xgreatest_variable_in_clausep_clauseupward_clause_links
constants_in_clausehorn_clausep_clause_memzap_clause
copy_clauseinherit_attributespositive_clausezap_literals
copy_clause_with_flagith_literalpositive_literals
definite_clauseliteral_numberrelation_symbols_in_clause
false_termmixed_clauseremove_null_literals

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.
void 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.

A fatal error occurs if there are more than max_vars variables.

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.


Plist constants_in_clause(Clause c);
Given a clause, return the set of constants therein.
Clause copy_clause(Clause c);
This routine builds and returns a copy of a clause.
Clause copy_clause_with_flag(Clause c, int flag);
This routine builds and returns a copy of a clause. The given termflag is copied for all subterms (including atoms, excluding variables).
BOOL definite_clause(Clause c);
This Boolean function checks if a clause has exactly one positive literal.
BOOL false_term(Term t);

Literal first_negative_literal(Clause c);

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.
void free_literal(Literal p);

Ilist function_symbols_in_clause(Clause c, Ilist g);

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.
void inherit_attributes(Clause parent1, Context subst1,
			Clause parent2, Context subst2,
			Clause child);
This takes two parent clauses and their associated substitutions, and a child clause. All answer attributes on the parents are instantiated and appended to the child's attributes.
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.
void new_atom_nodes(Clause c);
Replace the atom nodes in a clause. The new atom nodes have the property that they are greater in the FPA ordering than any other terms currently in use.
void new_atoms(Clause c);
Replace the atoms and all subterms in a clause. The new terms have the property that they are greater in the FPA ordering than any other terms currently in use. Also, all of the new subterms are contiguous in memory.
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.
Ilist relation_symbols_in_clause(Clause c, Ilist g);

Literal remove_null_literals(Literal l);

void 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 more than max_vars distinct variables, a fatal error occurs.

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


BOOL tautology(Clause c);
This routine returns TRUE if the clause has complementary literals or if it has any literals of the form $T, -$F.
void term_renumber_variables(Term t, int max_vars);
This routine renumbers the variables of a term. The variables are renumbered 0, 1, 2 ... according the the first occurrence, reading from the left.

If there are more than max_vars distinct variables, a fatal error occurs.

Do not use this to renumber variables of a clause (see renumber_variables).


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 true_term(Term t);

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.
void zap_literals(Literal l);
This routine frees a list of literals.

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;
  int              weight;
  Literal          literals;
  Attribute        attributes;
  struct just      *justification;
  struct clist_pos *containers;
};


Introduction


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