|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.udo.cs.ie.cowbots.logic.ELPRule
public class ELPRule
this class models a rule used in extended logics programs. each rule consists of two list: Hl, list of head literals, and Bl, list of body literals. if Bl is empty, we call the rule a fact. if Hl is empty, we call the rule a constraint. Hl is always a (possibly empty) list of positive literals (ELPAtom instances), and if |Hl| > 1 we call the rule (or fact) disjunctive. Hl may not contain any instances derived from ELPArithExpr. Bl is always a list of literals (ELPLiteral instances), and it may contain any meaningful negation or arithmetical expression. Summary: do what you want to do, but make sure it will never ever crash your solver. this class is not designed to catch syntactical errors while building elps.
Field Summary | |
---|---|
(package private) java.util.ArrayList<ELPLiteral> |
body
|
(package private) java.util.ArrayList<ELPLiteral> |
head
|
Constructor Summary | |
---|---|
ELPRule()
create a new elp rule |
|
ELPRule(ELPRule other)
creates new rule based on an existing on. |
|
ELPRule(int maxHead,
int maxBody)
create a rule with preallocated memory for body and head literals. |
Method Summary | |
---|---|
void |
addBody(java.util.Collection<ELPLiteral> lits)
|
void |
addBody(ELPLiteral l)
add a literal to Bl |
void |
addHead(ELPLiteral l)
add a literal to Hl |
protected java.lang.String |
dumpLitList(java.util.ArrayList<ELPLiteral> ll,
java.lang.String sep)
internal helper function to dump a list of literals |
java.util.ArrayList<ELPLiteral> |
getBody()
|
ELPLiteral |
getBody(int i)
return the i-th literal in Bl |
ELPLiteral |
getHead(int i)
returns the i-th literal in Hl |
boolean |
isConstraint()
returns true if the rule is a constraint (no head literals, and at least on body literal |
boolean |
isDisjunctive()
indicated wether there is more than one (or zero) literals in the read of the rule. |
boolean |
isFact()
returns true if the rule has at least on head, but no body literals. |
int |
nBody()
returns the size of |Bl|, including arithmetical expressions. |
int |
nHead()
returns the size of |Hl| |
java.lang.String |
toString()
converts the rule into a human readable string representing this rule in a datalog-like syntax. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
java.util.ArrayList<ELPLiteral> head
java.util.ArrayList<ELPLiteral> body
Constructor Detail |
---|
public ELPRule()
public ELPRule(int maxHead, int maxBody)
maxHead
- maxBody
- public ELPRule(ELPRule other)
other
- rule to copyMethod Detail |
---|
public boolean isFact()
public boolean isConstraint()
public boolean isDisjunctive()
public void addHead(ELPLiteral l)
l
- atom to add to Hlpublic void addBody(ELPLiteral l)
l
- public java.util.ArrayList<ELPLiteral> getBody()
public void addBody(java.util.Collection<ELPLiteral> lits)
public java.lang.String toString()
toString
in class java.lang.Object
protected java.lang.String dumpLitList(java.util.ArrayList<ELPLiteral> ll, java.lang.String sep)
ll
- list of literalssep
- literal separator
public int nHead()
public int nBody()
public ELPLiteral getHead(int i)
i
- literal index
public ELPLiteral getBody(int i)
i
- literal index
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |