Class MlnFormula
java.lang.Object
org.tweetyproject.logics.commons.syntax.RelationalFormula
org.tweetyproject.logics.mln.syntax.MlnFormula
- All Implemented Interfaces:
Formula,ClassicalFormula,ComplexLogicalFormula,Conjunctable,Disjunctable,Invertable,LogicStructure,ProbabilityAware,QuantifiedFormula,SimpleLogicalFormula
Instances of this class represent first-order formulas with a weight.
- Author:
- Matthias Thimm, Tim Janus
-
Constructor Summary
ConstructorsConstructorDescriptionMlnFormula(FolFormula formula) Creates a new strict MLN formula with the given formula.MlnFormula(FolFormula formula, Double weight) Creates a new MLN formula with the given formula and weight.MlnFormula(FolFormula formula, Probability p) Creates a new MLN formula and estimates its weight w by the given probability p using the formula w = log(p/(1-p)*f) where "f" is the ratio of the number of worlds not satisfying the formula and the worlds satisfying the formula. -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates a deep copy of this formulaReturns a conjunction of this and the given formula.booleanChecks whether this formula contains any quantification.getAtoms()Processes the set of all atoms which appear in this formulaReturns the inner formula.Processes the set of all predicates which appear in this formulaReturns the signature of the language of this formula.getTerms()Processes the set containing all terms of type C.Returns the weight.booleanisClosed()Checks whether this formula is closed, i.e.booleanChecks whether this formula is closed, i.e.booleanbooleanisStrict()Returns "true" iff this formula is strict.booleanChecks whether this formula is well-bound, i.e.booleanisWellBound(Set<Variable> boundVariables) Checks whether this formula is well-bound, i.e.substitute(Term<?> v, Term<?> t) Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.toString()Methods inherited from class org.tweetyproject.logics.commons.syntax.RelationalFormula
allGroundInstances, allSubstitutions, containsTermsOfType, exchange, getPredicateCls, getSatisfactionRatio, isGround, isWellFormed, substituteMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.tweetyproject.logics.commons.syntax.interfaces.SimpleLogicalFormula
equals, hashCode
-
Constructor Details
-
MlnFormula
Creates a new strict MLN formula with the given formula.- Parameters:
formula- the first-order formula.
-
MlnFormula
Creates a new MLN formula with the given formula and weight.- Parameters:
formula- the first-order formula.weight- the weight of the formula (null means that the formula is strict).
-
MlnFormula
Creates a new MLN formula and estimates its weight w by the given probability p using the formula w = log(p/(1-p)*f) where "f" is the ratio of the number of worlds not satisfying the formula and the worlds satisfying the formula.- Parameters:
formula- the first-order formula.p- the intended probability of the formula.
-
-
Method Details
-
combineWithAnd
Description copied from interface:ConjunctableReturns a conjunction of this and the given formula.- Specified by:
combineWithAndin interfaceConjunctable- Specified by:
combineWithAndin classRelationalFormula- Parameters:
f- a formula to be combined with AND and this.- Returns:
- a conjunction of this and the given formula.
-
combineWithOr
- Specified by:
combineWithOrin interfaceDisjunctable- Specified by:
combineWithOrin classRelationalFormula- Parameters:
f- a formula to be combined with OR and this.- Returns:
- a disjunction of this and the given formula.
-
complement
- Specified by:
complementin interfaceInvertable- Specified by:
complementin classRelationalFormula- Returns:
- the complement of this formula.
-
getPredicates
Description copied from interface:SimpleLogicalFormulaProcesses the set of all predicates which appear in this formula- Returns:
- all predicates that appear in this formula
-
getAtoms
Description copied from interface:SimpleLogicalFormulaProcesses the set of all atoms which appear in this formula- Specified by:
getAtomsin interfaceSimpleLogicalFormula- Specified by:
getAtomsin classRelationalFormula- Returns:
- all atoms that appear in this formula.
-
containsQuantifier
public boolean containsQuantifier()Description copied from interface:QuantifiedFormulaChecks whether this formula contains any quantification.- Returns:
- "true" if this formula contains a quantification.
-
substitute
Description copied from class:RelationalFormulaSubstitutes 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 interfaceComplexLogicalFormula- Specified by:
substitutein classRelationalFormula- 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 (NOTE: this exception is only thrown when "v" actually appears in this formula).
-
getUnboundVariables
-
isClosed
public boolean isClosed()Description copied from interface:QuantifiedFormulaChecks whether this formula is closed, i.e. whether every variables occurring in the formula is bound by a quantifier.- Returns:
- "true" if this formula is closed, "false" otherwise.
-
isClosed
Description copied from interface:QuantifiedFormulaChecks whether this formula is closed, i.e. whether every variables occurring in the formula is bound by a quantifier. Every variable in "boundVariables" is already assumed to be bound.- Parameters:
boundVariables- the variables assumed to be bound.- Returns:
- "true" if this formula is closed wrt. "boundVariables", "false" otherwise.
-
isWellBound
public boolean isWellBound()Description copied from interface:QuantifiedFormulaChecks whether this formula is well-bound, i.e. whether no variable bound by a quantifier is again bound by another quantifier within the first quantifier's range.- Returns:
- "true" if this formula is well-bound, "false" otherwise.
-
isWellBound
Description copied from interface:QuantifiedFormulaChecks whether this formula is well-bound, i.e. whether no variable bound by a quantifier is again bound by another quantifier within the first quantifier range. Every variable in "boundVariables" is assumed to be bound already.- Parameters:
boundVariables- the variables assumed to be bound.- Returns:
- "true" if this formula is well-bound, "false" otherwise.
-
toString
- Specified by:
toStringin classRelationalFormula
-
getFunctors
- Specified by:
getFunctorsin classRelationalFormula- Returns:
- all functors that appear in this formula.
-
getFormula
Returns the inner formula.- Specified by:
getFormulain interfaceQuantifiedFormula- Overrides:
getFormulain classRelationalFormula- Returns:
- the inner formula.
-
getWeight
-
isStrict
public boolean isStrict()Returns "true" iff this formula is strict.- Returns:
- "true" iff this formula is strict.
-
getUniformProbability
- Specified by:
getUniformProbabilityin interfaceProbabilityAware- Specified by:
getUniformProbabilityin classRelationalFormula- Returns:
- this formula's probability in the uniform distribution.
-
isLiteral
public boolean isLiteral()- Returns:
- true if the formula represents a literal in the language or false otherwise
-
getTerms
-
getTerms
Description copied from interface:LogicStructureProcesses the set containing all terms of type C. This method uses the equals method of the given Class and therefore does not add terms which are sub classes of type C to the set.- Type Parameters:
C- the type of terms- Parameters:
cls- The Class structure containing type information about the searched term- Returns:
- A set containing all terms of type C of this logical structure
-
getQuantifierVariables
-
clone
Description copied from interface:SimpleLogicalFormulaCreates a deep copy of this formula- Specified by:
clonein interfaceComplexLogicalFormula- Specified by:
clonein interfaceSimpleLogicalFormula- Specified by:
clonein classRelationalFormula- Returns:
- the cloned formula
-
getSignature
Description copied from interface:FormulaReturns the signature of the language of this formula.- Returns:
- the signature of the language of this formula.
-