org.semanticweb.kaon2.api.rules
Interface Rule

All Superinterfaces:
Axiom

public interface Rule
extends Axiom

Represents a rule in the program. A rule consists of a positive head literal and of a conjunction of several body literals. A rule must be range-restricted (also called safe or allowed), which means that each variable from the head must occur in some positive literal in the body.


Nested Class Summary
static class Rule.SubsumptionResult
          Returns the result of a subsumption check.
static class Rule.SubsumptionType
          The enumeration of the types of subsumption relationships.
 
Method Summary
 int getBodyLength()
          Returns the number of body literals.
 Literal getBodyLiteral(int bodyLiteralIndex)
          Returns the body literal with given index.
 Literal[] getBodyLiterals()
          Returns the array of body literals.
 Rule getDLSafeVersion()
          Returns the DL-safe version of this rule.
 int getHeadLength()
          Returns the number of head literals.
 Literal getHeadLiteral()
          Returns the head literal.
 Literal getHeadLiteral(int headLiteralIndex)
          Returns the head literal with given index.
 Literal[] getHeadLiterals()
          Returns the array of head literals.
 boolean isHorn()
          Returns true if this is a Horn rule with one head literal.
 boolean isRangeRestricted()
          Checks whether the rule is range-restricted.
 boolean isTautology()
          Checks if this rule is a tautology.
 Rule normalize()
          Normalizes this rule by eliminating certain surplus literals.
 Rule.SubsumptionResult subsumes(Rule rule)
          Checks whether this rule subsumes another rule.
 
Methods inherited from interface org.semanticweb.kaon2.api.Axiom
accept, toString
 

Method Detail

getHeadLiterals

Literal[] getHeadLiterals()
Returns the array of head literals. The returned object is not owned by this rule and can be freely changed without affecting the rule.

Returns:
the head literals

getHeadLiteral

Literal getHeadLiteral()
                       throws java.lang.IllegalStateException
Returns the head literal. This method can be called only for Horn rules, otherwise it throws an exception.

Returns:
the head literal
Throws:
java.lang.IllegalStateException - thrown if this is a Horn rule

getHeadLength

int getHeadLength()
Returns the number of head literals.

Returns:
the number of head literals

getHeadLiteral

Literal getHeadLiteral(int headLiteralIndex)
Returns the head literal with given index.

Parameters:
headLiteralIndex - the index of the head literal
Returns:
the head literal with given index

getBodyLiterals

Literal[] getBodyLiterals()
Returns the array of body literals. The returned object is not owned by this rule and can be freely changed without affecting the rule.

Returns:
the body literals

getBodyLength

int getBodyLength()
Returns the number of body literals.

Returns:
the number of body literals

getBodyLiteral

Literal getBodyLiteral(int bodyLiteralIndex)
Returns the body literal with given index.

Parameters:
bodyLiteralIndex - the index of the body literal
Returns:
the literal with given index

isHorn

boolean isHorn()
Returns true if this is a Horn rule with one head literal.

Returns:
true if this is a Horn rule with one head literal

isRangeRestricted

boolean isRangeRestricted()
Checks whether the rule is range-restricted. A rule is range-restricted if each variable in a rule occurs in a positive body literal.

Returns:
true if the rule is range-restricted

normalize

Rule normalize()
Normalizes this rule by eliminating certain surplus literals. It may turn out that the normalized rule is tautological; in that case null is returned.

Returns:
the normalized rule (or null if the rule is a tautology)

getDLSafeVersion

Rule getDLSafeVersion()
Returns the DL-safe version of this rule.

Returns:
the DL-safe version of this rule

subsumes

Rule.SubsumptionResult subsumes(Rule rule)
Checks whether this rule subsumes another rule.

Parameters:
rule - the other rule
Returns:
true if this rule subsumes the given rule

isTautology

boolean isTautology()
Checks if this rule is a tautology. This is the case if the same literal occurs in the body and in the head.

Returns:
true if the rule is a tautology