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) FolFormulaconclusion(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 voidaddPremise(FolFormula premise)voidaddPremises(java.util.Collection<? extends FolFormula> premises)private voidcheckFormula(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 LanguageExceptionNLPRuleclone()Creates a deep copy of this formulabooleanequals(java.lang.Object other)java.util.Set<FolAtom>getAtoms()Processes the set of all atoms which appear in this formulaFolFormulagetConclusion()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.FolSignaturegetSignature()Returns the signature of the language of this formula.java.util.Set<Term<?>>getTerms()inthashCode()booleanisConstraint()booleanisFact()voidsetConclusion(FolFormula conclusion)NLPRulesubstitute(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:
addPremisein interfaceRule<FolFormula,FolFormula>- Throws:
LanguageException
-
addPremises
public void addPremises(java.util.Collection<? extends FolFormula> premises)
- Specified by:
addPremisesin interfaceRule<FolFormula,FolFormula>
-
setConclusion
public void setConclusion(FolFormula conclusion) throws LanguageException
- Specified by:
setConclusionin 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:RuleReturns the premise of this rule.- Specified by:
getPremisein interfaceRule<FolFormula,FolFormula>- Returns:
- the premise of this rule.
-
getConclusion
public FolFormula getConclusion()
Description copied from interface:RuleReturns the conclusion of this rule.- Specified by:
getConclusionin interfaceRule<FolFormula,FolFormula>- Returns:
- the conclusion of this rule.
-
getSignature
public FolSignature getSignature()
Description copied from interface:FormulaReturns the signature of the language of this formula.- Specified by:
getSignaturein interfaceFormula- Specified by:
getSignaturein interfaceRule<FolFormula,FolFormula>- Returns:
- the signature of the language of this formula.
-
isFact
public boolean isFact()
- Specified by:
isFactin interfaceRule<FolFormula,FolFormula>
-
isConstraint
public boolean isConstraint()
- Specified by:
isConstraintin interfaceRule<FolFormula,FolFormula>
-
getAtoms
public java.util.Set<FolAtom> getAtoms()
Description copied from interface:SimpleLogicalFormulaProcesses the set of all atoms which appear in this formula- Specified by:
getAtomsin interfaceSimpleLogicalFormula- Returns:
- The set of all atoms
-
getPredicates
public java.util.Set<Predicate> getPredicates()
Description copied from interface:SimpleLogicalFormulaProcesses the set of all predicates which appear in this formula- Specified by:
getPredicatesin interfaceSimpleLogicalFormula- Returns:
- all predicates that appear in this formula
-
getPredicateCls
public java.lang.Class<? extends Predicate> getPredicateCls()
- Specified by:
getPredicateClsin interfaceSimpleLogicalFormula- Returns:
- The class description of the predicate used by this formula.
-
getTerms
public java.util.Set<Term<?>> getTerms()
- Specified by:
getTermsin 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:ComplexLogicalFormulaSubstitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.- Specified by:
substitutein 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:
hashCodein interfaceSimpleLogicalFormula- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Specified by:
equalsin interfaceSimpleLogicalFormula- Overrides:
equalsin classjava.lang.Object
-
clone
public NLPRule clone()
Description copied from interface:SimpleLogicalFormulaCreates a deep copy of this formula- Specified by:
clonein interfaceComplexLogicalFormula- Specified by:
clonein interfaceSimpleLogicalFormula- Specified by:
clonein classComplexLogicalFormulaAdapter- Returns:
- the cloned formula
-
-