Class MlnFormula

• All Implemented Interfaces:
`Formula`, `ClassicalFormula`, `ComplexLogicalFormula`, `Conjunctable`, `Disjunctable`, `Invertable`, `LogicStructure`, `ProbabilityAware`, `QuantifiedFormula`, `SimpleLogicalFormula`

```public class MlnFormula
extends RelationalFormula```
Instances of this class represent first-order formulas with a weight.
Author:
Matthias Thimm, Tim Janus
• Constructor Summary

Constructors
Constructor Description
`MlnFormula​(FolFormula formula)`
Creates a new strict MLN formula with the given formula.
```MlnFormula​(FolFormula formula, java.lang.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 Type Method Description
`RelationalFormula` `clone()`
Creates a deep copy of this formula
`Conjunction` `combineWithAnd​(Conjunctable f)`
Returns a conjunction of this and the given formula.
`Disjunction` `combineWithOr​(Disjunctable f)`
`RelationalFormula` `complement()`
`boolean` `containsQuantifier()`
Checks whether this formula contains any quantification.
`java.util.Set<FolAtom>` `getAtoms()`
Processes the set of all atoms which appear in this formula
`FolFormula` `getFormula()`
Returns the inner formula.
`java.util.Set<Functor>` `getFunctors()`
`java.util.Set<? extends Predicate>` `getPredicates()`
Processes the set of all predicates which appear in this formula
`java.util.Set<Variable>` `getQuantifierVariables()`
`FolSignature` `getSignature()`
Returns the signature of the language of this formula.
`java.util.Set<Term<?>>` `getTerms()`
`<C extends Term<?>>java.util.Set<C>` `getTerms​(java.lang.Class<C> cls)`
Processes the set containing all terms of type C.
`java.util.Set<Variable>` `getUnboundVariables()`
`Probability` `getUniformProbability()`
`java.lang.Double` `getWeight()`
Returns the weight.
`boolean` `isClosed()`
Checks whether this formula is closed, i.e.
`boolean` `isClosed​(java.util.Set<Variable> boundVariables)`
Checks whether this formula is closed, i.e.
`boolean` `isLiteral()`
`boolean` `isStrict()`
Returns "true" iff this formula is strict.
`boolean` `isWellBound()`
Checks whether this formula is well-bound, i.e.
`boolean` `isWellBound​(java.util.Set<Variable> boundVariables)`
Checks whether this formula is well-bound, i.e.
`RelationalFormula` ```substitute​(Term<?> v, Term<?> t)```
Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.
`java.lang.String` `toString()`
• Methods inherited from class net.sf.tweety.logics.commons.syntax.RelationalFormula

`allGroundInstances, allSubstitutions, containsTermsOfType, exchange, getPredicateCls, getSatisfactionRatio, isGround, isWellFormed, substitute`
• Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`
• Methods inherited from interface net.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula

`equals, hashCode`
• Constructor Detail

• MlnFormula

`public MlnFormula​(FolFormula formula)`
Creates a new strict MLN formula with the given formula.
Parameters:
`formula` - the first-order formula.
• MlnFormula

```public MlnFormula​(FolFormula formula,
java.lang.Double weight)```
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

```public 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.
Parameters:
`formula` - the first-order formula.
`p` - the intended probability of the formula.
• Method Detail

• combineWithAnd

`public Conjunction combineWithAnd​(Conjunctable f)`
Description copied from interface: `Conjunctable`
Returns a conjunction of this and the given formula.
Specified by:
`combineWithAnd` in interface `Conjunctable`
Specified by:
`combineWithAnd` in class `RelationalFormula`
Parameters:
`f` - a formula to be combined with AND and this.
Returns:
a conjunction of this and the given formula.
• combineWithOr

`public Disjunction combineWithOr​(Disjunctable f)`
Specified by:
`combineWithOr` in interface `Disjunctable`
Specified by:
`combineWithOr` in class `RelationalFormula`
Parameters:
`f` - a formula to be combined with OR and this.
Returns:
a disjunction of this and the given formula.
• complement

`public RelationalFormula complement()`
Specified by:
`complement` in interface `Invertable`
Specified by:
`complement` in class `RelationalFormula`
Returns:
the complement of this formula.
• getPredicates

`public java.util.Set<? extends Predicate> getPredicates()`
Description copied from interface: `SimpleLogicalFormula`
Processes the set of all predicates which appear in this formula
Returns:
all predicates that appear in this formula
• 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 interface `SimpleLogicalFormula`
Specified by:
`getAtoms` in class `RelationalFormula`
Returns:
all atoms that appear in this formula.
• containsQuantifier

`public boolean containsQuantifier()`
Description copied from interface: `QuantifiedFormula`
Checks whether this formula contains any quantification.
Returns:
"true" if this formula contains a quantification.
• substitute

```public RelationalFormula substitute​(Term<?> v,
Term<?> t)
throws java.lang.IllegalArgumentException```
Description copied from class: `RelationalFormula`
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:
`substitute` in interface `ComplexLogicalFormula`
Specified by:
`substitute` in class `RelationalFormula`
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).
• getUnboundVariables

`public java.util.Set<Variable> getUnboundVariables()`
Returns:
a set of of unbound variables
• isClosed

`public boolean isClosed()`
Description copied from interface: `QuantifiedFormula`
Checks 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

`public boolean isClosed​(java.util.Set<Variable> boundVariables)`
Description copied from interface: `QuantifiedFormula`
Checks 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: `QuantifiedFormula`
Checks 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

`public boolean isWellBound​(java.util.Set<Variable> boundVariables)`
Description copied from interface: `QuantifiedFormula`
Checks 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

`public java.lang.String toString()`
Specified by:
`toString` in class `RelationalFormula`
• getFunctors

`public java.util.Set<Functor> getFunctors()`
Specified by:
`getFunctors` in class `RelationalFormula`
Returns:
all functors that appear in this formula.
• getFormula

`public FolFormula getFormula()`
Returns the inner formula.
Specified by:
`getFormula` in interface `QuantifiedFormula`
Overrides:
`getFormula` in class `RelationalFormula`
Returns:
the inner formula.
• getWeight

`public java.lang.Double getWeight()`
Returns the weight.
Returns:
the weight.
• isStrict

`public boolean isStrict()`
Returns "true" iff this formula is strict.
Returns:
"true" iff this formula is strict.
• getUniformProbability

`public Probability getUniformProbability()`
Specified by:
`getUniformProbability` in interface `ProbabilityAware`
Specified by:
`getUniformProbability` in class `RelationalFormula`
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

`public java.util.Set<Term<?>> getTerms()`
Returns:
a set containing all terms of this logical structure
• getTerms

`public <C extends Term<?>> java.util.Set<C> getTerms​(java.lang.Class<C> cls)`
Description copied from interface: `LogicStructure`
Processes 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

`public java.util.Set<Variable> getQuantifierVariables()`
Returns:
a set containing all quantified variables
• clone

`public RelationalFormula clone()`
Description copied from interface: `SimpleLogicalFormula`
Creates a deep copy of this formula
Specified by:
`clone` in interface `ComplexLogicalFormula`
Specified by:
`clone` in interface `SimpleLogicalFormula`
Specified by:
`clone` in class `RelationalFormula`
Returns:
the cloned formula
• getSignature

`public FolSignature getSignature()`
Description copied from interface: `Formula`
Returns the signature of the language of this formula.
Returns:
the signature of the language of this formula.