Class RelationalFormula
- java.lang.Object
- 
- net.sf.tweety.logics.commons.syntax.RelationalFormula
 
- 
- All Implemented Interfaces:
- Formula,- ClassicalFormula,- ComplexLogicalFormula,- Conjunctable,- Disjunctable,- Invertable,- LogicStructure,- ProbabilityAware,- QuantifiedFormula,- SimpleLogicalFormula
 - Direct Known Subclasses:
- DefaultRule,- DelpRule,- FolFormula,- MlnFormula,- RelationalConditional
 
 public abstract class RelationalFormula extends java.lang.Object implements ClassicalFormula, QuantifiedFormula This is the abstract base class for relational formulas, i.e. formulas that are build on first-order signatures. NOTE: "RelationalFormula" and "FolFormula" differ in their meaning as follows:- A relational formula is any formula over a first-order signature, i.e. even a conditional
- A first-order formula is the actual first-order formula in the classical sense.
 - Author:
- Matthias Thimm, Tim Janus, Anna Gessler
 
- 
- 
Constructor SummaryConstructors Constructor Description RelationalFormula()
 - 
Method SummaryModifier and Type Method Description java.util.Set<RelationalFormula>allGroundInstances(java.util.Set<Constant> constants)Computes all ground instances of this relational formula wrt.java.util.Set<java.util.Map<Variable,Term<?>>>allSubstitutions(java.util.Collection<? extends Term<?>> terms)Computes all possible substitutions, i.e.abstract RelationalFormulaclone()Creates a deep copy of this formulaabstract DisjunctablecombineWithAnd(Conjunctable f)Returns a conjunction of this and the given formula.abstract ConjunctablecombineWithOr(Disjunctable f)abstract RelationalFormulacomplement()<C extends Term<?>>
 booleancontainsTermsOfType(java.lang.Class<C> cls)Checks if this logical structure contains at least one term of type C.RelationalFormulaexchange(Term<?> v, Term<?> t)Substitutes all occurrences of term "v" in this formula by term "t" and at the same time replaces all occurrences of term "t" by term "v" and eventually returns the new formula.abstract java.util.Set<? extends Atom>getAtoms()Processes the set of all atoms which appear in this formulaRelationalFormulagetFormula()abstract java.util.Set<Functor>getFunctors()java.lang.Class<? extends Predicate>getPredicateCls()doublegetSatisfactionRatio()Returns the ratio of worlds not satisfying this formula to worlds satisfying this formula.abstract ProbabilitygetUniformProbability()booleanisGround()Checks whether this formula is ground, i.e.booleanisWellFormed()Tests whether this formula is well-formed, i.e.RelationalFormulasubstitute(java.util.Map<? extends Term<?>,? extends Term<?>> map)Substitutes all occurrences of all terms "v" in map.keyset() in this formula by map.get(v) and returns the new formula.
 NOTE: variables bound to quantifiers are not substituted in their inner formulas even if they appear in the map.abstract RelationalFormulasubstitute(Term<?> v, Term<?> t)Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.abstract java.lang.StringtoString()- 
Methods inherited from class java.lang.Objectequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface net.sf.tweety.commons.FormulagetSignature
 - 
Methods inherited from interface net.sf.tweety.logics.commons.syntax.interfaces.LogicStructuregetTerms, getTerms
 - 
Methods inherited from interface net.sf.tweety.logics.commons.syntax.interfaces.QuantifiedFormulacontainsQuantifier, getQuantifierVariables, getUnboundVariables, isClosed, isClosed, isWellBound, isWellBound
 - 
Methods inherited from interface net.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormulaequals, getPredicates, hashCode, isLiteral
 
- 
 
- 
- 
- 
Method Detail- 
getFormulapublic RelationalFormula getFormula() - Specified by:
- getFormulain interface- QuantifiedFormula
- Returns:
- the relational formula
 
 - 
getAtomspublic abstract java.util.Set<? extends Atom> getAtoms() Description copied from interface:SimpleLogicalFormulaProcesses the set of all atoms which appear in this formula- Specified by:
- getAtomsin interface- SimpleLogicalFormula
- Returns:
- all atoms that appear in this formula.
 
 - 
getFunctorspublic abstract java.util.Set<Functor> getFunctors() - Returns:
- all functors that appear in this formula.
 
 - 
getPredicateClspublic java.lang.Class<? extends Predicate> getPredicateCls() - Specified by:
- getPredicateClsin interface- SimpleLogicalFormula
- Returns:
- The class description of the predicate used by this formula.
 
 - 
substitutepublic abstract RelationalFormula substitute(Term<?> v, Term<?> t) throws java.lang.IllegalArgumentException Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula. NOTE: if "v" is a variable and bound to a quantifier then "v" is not substituted in that quantifiers inner formula.- Specified by:
- substitutein interface- ComplexLogicalFormula
- 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 (NOTE: this exception is only thrown when "v" actually appears in this formula).
 
 - 
substitutepublic RelationalFormula substitute(java.util.Map<? extends Term<?>,? extends Term<?>> map) throws java.lang.IllegalArgumentException Substitutes all occurrences of all terms "v" in map.keyset() in this formula by map.get(v) and returns the new formula.
 NOTE: variables bound to quantifiers are not substituted in their inner formulas even if they appear in the map.- Specified by:
- substitutein interface- ComplexLogicalFormula
- Parameters:
- map- a mapping defining which terms to be substituted.
- Returns:
- a formula where every term in map.keyset() has been replaced by map.get(v).
- Throws:
- java.lang.IllegalArgumentException- if any term and its mapping are of different sorts (NOTE: this exception is only thrown when the variable actually appears in this formula).
 
 - 
exchangepublic RelationalFormula exchange(Term<?> v, Term<?> t) throws java.lang.IllegalArgumentException Substitutes all occurrences of term "v" in this formula by term "t" and at the same time replaces all occurrences of term "t" by term "v" and eventually returns the new formula. NOTE: if "v" is a variable and bound to a quantifier then "v" is not substituted in that quantifiers inner formula.- Specified by:
- exchangein interface- ComplexLogicalFormula
- Parameters:
- v- a term.
- t- a term.
- Returns:
- a new relational formula with both "v" and "t" exchanged.
- Throws:
- java.lang.IllegalArgumentException- if "v" and "t" are of different sorts
 
 - 
allSubstitutionspublic java.util.Set<java.util.Map<Variable,Term<?>>> allSubstitutions(java.util.Collection<? extends Term<?>> terms) throws java.lang.IllegalArgumentException Computes all possible substitutions, i.e. maps from variables to terms, of unbound variables of this formula to terms in "terms".- Parameters:
- terms- a set of terms.
- Returns:
- a set of maps from variables to terms.
- Throws:
- java.lang.IllegalArgumentException- if there is an unbound variable in this formula for which there is no term in "terms" with the same sort.
 
 - 
allGroundInstancespublic java.util.Set<RelationalFormula> allGroundInstances(java.util.Set<Constant> constants) throws java.lang.IllegalArgumentException Computes all ground instances of this relational formula wrt. the given set of constants, i.e. every formula where each occurrence of some unbound variable is replaced by some constant.- Parameters:
- constants- a set of constants
- Returns:
- a set of ground instances of this formula
- Throws:
- java.lang.IllegalArgumentException- if there is an unbound variable in this formula for which there is no constant in "constants" with the same sort.
 
 - 
getSatisfactionRatiopublic double getSatisfactionRatio() Returns the ratio of worlds not satisfying this formula to worlds satisfying this formula.- Returns:
- the ratio of worlds not satisfying this formula to worlds satisfying this formula.
 
 - 
getUniformProbabilitypublic abstract Probability getUniformProbability() - Specified by:
- getUniformProbabilityin interface- ProbabilityAware
- Returns:
- this formula's probability in the uniform distribution.
 
 - 
isGroundpublic boolean isGround() Checks whether this formula is ground, i.e. whether there appears no variable in this formula.- Specified by:
- isGroundin interface- ComplexLogicalFormula
- Returns:
- "true" if this formula is ground.
 
 - 
isWellFormedpublic boolean isWellFormed() Tests whether this formula is well-formed, i.e. whether
 - there are no two variables with the same name but different sort
 - there are no two constants with the same name but different sort
 - there are no two predicates with the same name but different arguments
 - there are no two functors with the same name but different sort or arguments
 - every atom is complete, i.e. has a complete list of arguments
 - every functional term is complete, i.e. has a complete list of arguments
 - no variable bound by a quantifier is again bound by another quantifier within the first quantifier range.
 - every functor has arity greater zero (otherwise it should be modeled by a constant- Specified by:
- isWellFormedin interface- ComplexLogicalFormula
- Returns:
- "true" if this formula is well-formed
 
 - 
containsTermsOfTypepublic <C extends Term<?>> boolean containsTermsOfType(java.lang.Class<C> cls) Description copied from interface:LogicStructureChecks if this logical structure contains at least one term of type C. This method is a shortcut for !getTerms(TermImplementation.class).isEmpty().- Specified by:
- containsTermsOfTypein interface- LogicStructure
- Type Parameters:
- C- the type of terms
- Parameters:
- cls- The class structure representing the type C of the term.
- Returns:
- True if this logical structure contains at least one term of type C or false otherwise.
 
 - 
complementpublic abstract RelationalFormula complement() - Specified by:
- complementin interface- Invertable
- Returns:
- the complement of this formula.
 
 - 
combineWithOrpublic abstract Conjunctable combineWithOr(Disjunctable f) - Specified by:
- combineWithOrin interface- Disjunctable
- Parameters:
- f- a formula to be combined with OR and this.
- Returns:
- a disjunction of this and the given formula.
 
 - 
combineWithAndpublic abstract Disjunctable combineWithAnd(Conjunctable f) Description copied from interface:ConjunctableReturns a conjunction of this and the given formula.- Specified by:
- combineWithAndin interface- Conjunctable
- Parameters:
- f- a formula to be combined with AND and this.
- Returns:
- a conjunction of this and the given formula.
 
 - 
toStringpublic abstract java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
clonepublic abstract RelationalFormula clone() Description copied from interface:SimpleLogicalFormulaCreates a deep copy of this formula- Specified by:
- clonein interface- ComplexLogicalFormula
- Specified by:
- clonein interface- SimpleLogicalFormula
- Overrides:
- clonein class- java.lang.Object
- Returns:
- the cloned formula
 
 
- 
 
-