[SLP-Homepage]    [Source Modules]    [Manual]    [Run]    [Examples]
 

List of Literals in a Rule

This module defines a class rlits_c. The objects of this class correspond to lists of literals in a rule. These lists are used as

As usual, each object is a pair of head and tail, not really an entire list (tail is the "next"-pointer, i.e. a reference to another rlits_c-object).


Construction:

Constructor from list element:
rlits_c(rlit_t head);
This method creates a new list of literals out of a given element (a single literal). The given element will be the head of the list, the tail will be empty (NIL).
Constructor from list of input formula literals:
rlits_c(lit_t *lits, rvars_t vars, bool_t binding);
This method translates a list of input formula literals into a list of rule literals. The input formula literals are represented by an array lits of pointers to lit_c objects that is ended by a NIL pointer. The translation needs the list of variables in the rule in order to replace variables by binding frame offsets. If binding is BOOL_FALSE, any variables that are not already present in vars are stored in the list of unsafe variables (in addition to being added to vars).


Object Methods:

head:
rlit_t head(void) const;
This method returns the first literal in the list.
tail:
rlits_c* tail(void) const;
This method returns the rest of the list (all literals except the first one).
append:
void append(rlits_c* tail);
This method sets the tail of the list to the given value. It can only be called if the tail is currently NIL, i.e. if this is the last list element.
print:
void print(rvars_t vars, str_t separator) const;
This method prints the lists of terms (separated by the string passed in the argument separator). Different separators are needed since the list can be a conjunction or disjunction. Since the rarg_c objects for the argument terms of the literals contain only the variable offsets, the list of variables in the rule (vars) is needed in order to print the variable names.


Implementation:


Stefan Brass (sbrass@sis.pitt.edu), October 2, 2001.    [HTML 3.2 Checked]