Package org.tweetyproject.lp.nlp.syntax
Class NLPRule
java.lang.Object
org.tweetyproject.logics.commons.syntax.ComplexLogicalFormulaAdapter
org.tweetyproject.lp.nlp.syntax.NLPRule
- All Implemented Interfaces:
Formula
,Rule<FolFormula,
,FolFormula> ComplexLogicalFormula
,LogicStructure
,SimpleLogicalFormula
public class NLPRule
extends ComplexLogicalFormulaAdapter
implements ComplexLogicalFormula, Rule<FolFormula,FolFormula>
A rule of a nested logic program. A nested logic program contains not quantified
first order formulas.
- Author:
- Tim Janus
-
Constructor Summary
ConstructorDescriptionNLPRule()
Default constructor that creates an empty `NLPRule`.NLPRule
(FolFormula conclusion) Constructor that creates a `NLPRule` with a specified conclusion.NLPRule
(FolFormula conclusion, Collection<FolFormula> premise) Constructor that creates a `NLPRule` with a specified conclusion and a collection of premises.NLPRule
(FolFormula conclusion, FolFormula premise) Constructor that creates a `NLPRule` with a specified conclusion and a single premise.Copy constructor that creates a new `NLPRule` by copying an existing rule. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPremise
(FolFormula premise) Add the given premise to this rule.void
addPremises
(Collection<? extends FolFormula> premises) Add the given premises to this rule.clone()
Creates a deep copy of this formulaboolean
getAtoms()
Processes the set of all atoms which appear in this formulaReturns the conclusion of this rule.Processes the set of all predicates which appear in this formulaReturns the premise of this rule.Returns the signature of the language of this formula.getTerms()
int
hashCode()
boolean
isConstraintboolean
isFact()
isFactvoid
setConclusion
(FolFormula conclusion) Set the conclusion of this rule.substitute
(Term<?> v, Term<?> t) Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.Methods inherited from class org.tweetyproject.logics.commons.syntax.ComplexLogicalFormulaAdapter
containsTermsOfType, exchange, getTerms, isGround, isLiteral, isWellFormed, substitute
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.tweetyproject.logics.commons.syntax.interfaces.ComplexLogicalFormula
exchange, isGround, isWellFormed, substitute
Methods inherited from interface org.tweetyproject.logics.commons.syntax.interfaces.LogicStructure
containsTermsOfType, getTerms
Methods inherited from interface org.tweetyproject.logics.commons.syntax.interfaces.SimpleLogicalFormula
isLiteral
-
Constructor Details
-
NLPRule
public NLPRule()Default constructor that creates an empty `NLPRule`. -
NLPRule
Copy constructor that creates a new `NLPRule` by copying an existing rule.The new rule is created by cloning the conclusion and premises of the provided `NLPRule` object. This ensures that the original rule and the copied rule do not share references to the same formula objects.
- Parameters:
other
- the `NLPRule` to be copied.
-
NLPRule
Constructor that creates a `NLPRule` with a specified conclusion.This constructor initializes the rule with a given conclusion formula, without any premises.
- Parameters:
conclusion
- the `FolFormula` that serves as the conclusion of the rule.
-
NLPRule
Constructor that creates a `NLPRule` with a specified conclusion and a single premise.This constructor initializes the rule with a given conclusion formula and a single premise formula.
- Parameters:
conclusion
- the `FolFormula` that serves as the conclusion of the rule.premise
- the `FolFormula` that serves as the premise of the rule.
-
NLPRule
Constructor that creates a `NLPRule` with a specified conclusion and a collection of premises.This constructor initializes the rule with a given conclusion formula and a collection of premise formulas.
- Parameters:
conclusion
- the `FolFormula` that serves as the conclusion of the rule.premise
- a collection of `FolFormula` objects that serve as the premises of the rule.
-
-
Method Details
-
addPremise
Description copied from interface:Rule
Add the given premise to this rule.- Specified by:
addPremise
in interfaceRule<FolFormula,
FolFormula> - Parameters:
premise
- some formula- Throws:
LanguageException
-
addPremises
Description copied from interface:Rule
Add the given premises to this rule.- Specified by:
addPremises
in interfaceRule<FolFormula,
FolFormula> - Parameters:
premises
- some formulas
-
setConclusion
Description copied from interface:Rule
Set the conclusion of this rule.- Specified by:
setConclusion
in interfaceRule<FolFormula,
FolFormula> - Parameters:
conclusion
- some formula- Throws:
LanguageException
-
getPremise
Description copied from interface:Rule
Returns the premise of this rule.- Specified by:
getPremise
in interfaceRule<FolFormula,
FolFormula> - Returns:
- the premise of this rule.
-
getConclusion
Description copied from interface:Rule
Returns the conclusion of this rule.- Specified by:
getConclusion
in interfaceRule<FolFormula,
FolFormula> - Returns:
- the conclusion of this rule.
-
getSignature
Description copied from interface:Formula
Returns the signature of the language of this formula.- Specified by:
getSignature
in interfaceFormula
- Specified by:
getSignature
in interfaceRule<FolFormula,
FolFormula> - Returns:
- the signature of the language of this formula.
-
isFact
public boolean isFact()Description copied from interface:Rule
isFact- Specified by:
isFact
in interfaceRule<FolFormula,
FolFormula> - Returns:
- whether the rule is a fact
-
isConstraint
public boolean isConstraint()Description copied from interface:Rule
isConstraint- Specified by:
isConstraint
in interfaceRule<FolFormula,
FolFormula> - Returns:
- whether the rule is a constraint
-
getAtoms
Description copied from interface:SimpleLogicalFormula
Processes the set of all atoms which appear in this formula- Specified by:
getAtoms
in interfaceSimpleLogicalFormula
- Returns:
- The set of all atoms
-
getPredicates
Description copied from interface:SimpleLogicalFormula
Processes the set of all predicates which appear in this formula- Specified by:
getPredicates
in interfaceSimpleLogicalFormula
- Returns:
- all predicates that appear in this formula
-
getPredicateCls
- Specified by:
getPredicateCls
in interfaceSimpleLogicalFormula
- Returns:
- The class description of the predicate used by this formula.
-
getTerms
- Specified by:
getTerms
in interfaceLogicStructure
- Returns:
- a set containing all terms of this logical structure
-
substitute
Description copied from interface:ComplexLogicalFormula
Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.- Specified by:
substitute
in interfaceComplexLogicalFormula
- Parameters:
v
- the term to be substituted.t
- the term to substitute.- Returns:
- a formula where every occurrence of "v" is replaced by "t".
- Throws:
IllegalArgumentException
- if "v" and "t" are of different sorts
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceSimpleLogicalFormula
- Overrides:
hashCode
in classObject
-
equals
- Specified by:
equals
in interfaceSimpleLogicalFormula
- Overrides:
equals
in classObject
-
clone
Description copied from interface:SimpleLogicalFormula
Creates a deep copy of this formula- Specified by:
clone
in interfaceComplexLogicalFormula
- Specified by:
clone
in interfaceSimpleLogicalFormula
- Specified by:
clone
in classComplexLogicalFormulaAdapter
- Returns:
- the cloned formula
-