Package net.sf.tweety.lp.nlp.syntax
Class NLPRule
- java.lang.Object
-
- net.sf.tweety.logics.commons.syntax.ComplexLogicalFormulaAdapter
-
- net.sf.tweety.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
-
-
Field Summary
Fields Modifier and Type Field Description (package private) FolFormula
conclusion
(package private) java.util.Set<FolFormula>
premise
-
Constructor Summary
Constructors Constructor Description NLPRule()
NLPRule(FolFormula conclusion)
NLPRule(FolFormula conclusion, java.util.Collection<FolFormula> premise)
NLPRule(FolFormula conclusion, FolFormula premise)
NLPRule(NLPRule other)
-
Method Summary
Modifier and Type Method Description void
addPremise(FolFormula premise)
void
addPremises(java.util.Collection<? extends FolFormula> premises)
private void
checkFormula(FolFormula formula)
Helper methods checks if the given FOL formula is supported by the nested logic program language, that means it checks if it contains quantifiers and if that is the case it throws a LanguageExceptionNLPRule
clone()
Creates a deep copy of this formulaboolean
equals(java.lang.Object other)
java.util.Set<FolAtom>
getAtoms()
Processes the set of all atoms which appear in this formulaFolFormula
getConclusion()
Returns the conclusion of this rule.java.lang.Class<? extends Predicate>
getPredicateCls()
java.util.Set<Predicate>
getPredicates()
Processes the set of all predicates which appear in this formulajava.util.Collection<FolFormula>
getPremise()
Returns the premise of this rule.FolSignature
getSignature()
Returns the signature of the language of this formula.java.util.Set<Term<?>>
getTerms()
int
hashCode()
boolean
isConstraint()
boolean
isFact()
void
setConclusion(FolFormula conclusion)
NLPRule
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 net.sf.tweety.logics.commons.syntax.ComplexLogicalFormulaAdapter
containsTermsOfType, exchange, getTerms, isGround, isLiteral, isWellFormed, substitute
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.tweety.logics.commons.syntax.interfaces.ComplexLogicalFormula
exchange, isGround, isWellFormed, substitute
-
Methods inherited from interface net.sf.tweety.logics.commons.syntax.interfaces.LogicStructure
containsTermsOfType, getTerms
-
Methods inherited from interface net.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula
isLiteral
-
-
-
-
Field Detail
-
conclusion
FolFormula conclusion
-
premise
java.util.Set<FolFormula> premise
-
-
Constructor Detail
-
NLPRule
public NLPRule()
-
NLPRule
public NLPRule(NLPRule other)
-
NLPRule
public NLPRule(FolFormula conclusion)
-
NLPRule
public NLPRule(FolFormula conclusion, FolFormula premise)
-
NLPRule
public NLPRule(FolFormula conclusion, java.util.Collection<FolFormula> premise)
-
-
Method Detail
-
addPremise
public void addPremise(FolFormula premise) throws LanguageException
- Specified by:
addPremise
in interfaceRule<FolFormula,FolFormula>
- Throws:
LanguageException
-
addPremises
public void addPremises(java.util.Collection<? extends FolFormula> premises)
- Specified by:
addPremises
in interfaceRule<FolFormula,FolFormula>
-
setConclusion
public void setConclusion(FolFormula conclusion) throws LanguageException
- Specified by:
setConclusion
in interfaceRule<FolFormula,FolFormula>
- Throws:
LanguageException
-
checkFormula
private void checkFormula(FolFormula formula) throws LanguageException
Helper methods checks if the given FOL formula is supported by the nested logic program language, that means it checks if it contains quantifiers and if that is the case it throws a LanguageException- Parameters:
formula
- The formula which gets checked- Throws:
LanguageException
- if there is an issue with the language
-
getPremise
public java.util.Collection<FolFormula> 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
public FolFormula 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
public FolSignature 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()
- Specified by:
isFact
in interfaceRule<FolFormula,FolFormula>
-
isConstraint
public boolean isConstraint()
- Specified by:
isConstraint
in interfaceRule<FolFormula,FolFormula>
-
getAtoms
public java.util.Set<FolAtom> 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
public java.util.Set<Predicate> 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
public java.lang.Class<? extends Predicate> getPredicateCls()
- Specified by:
getPredicateCls
in interfaceSimpleLogicalFormula
- Returns:
- The class description of the predicate used by this formula.
-
getTerms
public java.util.Set<Term<?>> getTerms()
- Specified by:
getTerms
in interfaceLogicStructure
- Returns:
- a set containing all terms of this logical structure
-
substitute
public NLPRule substitute(Term<?> v, Term<?> t) throws java.lang.IllegalArgumentException
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:
java.lang.IllegalArgumentException
- if "v" and "t" are of different sorts
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceSimpleLogicalFormula
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Specified by:
equals
in interfaceSimpleLogicalFormula
- Overrides:
equals
in classjava.lang.Object
-
clone
public NLPRule 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
-
-