Package net.sf.tweety.logics.pl.syntax
Class PlFormula
- java.lang.Object
-
- net.sf.tweety.logics.pl.syntax.PlFormula
-
- All Implemented Interfaces:
net.sf.tweety.commons.Formula,net.sf.tweety.logics.commons.syntax.interfaces.ClassicalFormula,net.sf.tweety.logics.commons.syntax.interfaces.Conjunctable,net.sf.tweety.logics.commons.syntax.interfaces.Disjunctable,net.sf.tweety.logics.commons.syntax.interfaces.Invertable,net.sf.tweety.logics.commons.syntax.interfaces.ProbabilityAware,net.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula
- Direct Known Subclasses:
AssociativePlFormula,Equivalence,Implication,Negation,Proposition,SpecialFormula
public abstract class PlFormula extends Object implements net.sf.tweety.logics.commons.syntax.interfaces.ClassicalFormula
This class represents the common ancestor for propositional formulae.- Author:
- Matthias Thimm, Tim Janus
-
-
Constructor Summary
Constructors Constructor Description PlFormula()
-
Method Summary
Modifier and Type Method Description abstract PlFormulaclone()abstract PlFormulacollapseAssociativeFormulas()This method collapses all associative operations appearing in this term, e.g.ConjunctioncombineWithAnd(net.sf.tweety.logics.commons.syntax.interfaces.Conjunctable f)DisjunctioncombineWithOr(net.sf.tweety.logics.commons.syntax.interfaces.Disjunctable f)net.sf.tweety.logics.commons.syntax.interfaces.ClassicalFormulacomplement()abstract booleanequals(Object other)abstract Set<Proposition>getAtoms()abstract Set<PlFormula>getLiterals()Returns all literals, i.e.Set<PossibleWorld>getModels()Returns the set of models of this formula wrt.abstract Set<PossibleWorld>getModels(PlSignature sig)Returns the set of models of this formula wrt.Class<PlPredicate>getPredicateCls()abstract Set<PlPredicate>getPredicates()Collection<PlFormula>getPrimeImplicants()Returns the set of prime implicants of this formula.PlSignaturegetSignature()net.sf.tweety.math.probability.ProbabilitygetUniformProbability()Returns this formula's probability in the uniform distribution.abstract inthashCode()booleanisClause()Checks whether this formula is a clause, i.e.booleanisConjunctiveClause()Checks whether this formula is a conjunctive clause, i.e.booleanisLiteral()abstract intnumberOfOccurrences(Proposition p)Returns the number of occurrences of the given proposition within this formulaabstract PlFormulareplace(Proposition p, PlFormula f, int i)Replaces the ith instance of the proposition p by f.booleanresolvableWith(PlFormula other)Checks whether this formula (which must be a conjunction of literals) is resolvable with the given formulas (which is also a conjunction of literals, i.e.ConjunctionresolveWith(PlFormula other)Resolves this formula with the given one (both have to be conjunctive clauses) and returns some resolvent.PlFormulatoBlakeCanonicalForm()This method returns this formula in Blake canonical form.abstract ConjunctiontoCnf()This method returns this formula in conjunctive normal form (CNF).PlFormulatoDnf()This method returns this formula in disjunctive normal form (DNF).abstract PlFormulatoNnf()This method returns this formula in negation normal form (NNF).abstract PlFormulatrim()Removes duplicates (identical formulas) from conjunctions and disjunctions and removes duplicate negations.
-
-
-
Method Detail
-
getPredicateCls
public Class<PlPredicate> getPredicateCls()
- Specified by:
getPredicateClsin interfacenet.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula
-
getSignature
public PlSignature getSignature()
- Specified by:
getSignaturein interfacenet.sf.tweety.commons.Formula
-
getAtoms
public abstract Set<Proposition> getAtoms()
- Specified by:
getAtomsin interfacenet.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula
-
getLiterals
public abstract Set<PlFormula> getLiterals()
Returns all literals, i.e. all formulas of the form "a" or "!a" where "a" is a proposition, that appear in this formula.- Returns:
- all literals appearing in this formula.
-
combineWithAnd
public Conjunction combineWithAnd(net.sf.tweety.logics.commons.syntax.interfaces.Conjunctable f)
- Specified by:
combineWithAndin interfacenet.sf.tweety.logics.commons.syntax.interfaces.Conjunctable
-
combineWithOr
public Disjunction combineWithOr(net.sf.tweety.logics.commons.syntax.interfaces.Disjunctable f)
- Specified by:
combineWithOrin interfacenet.sf.tweety.logics.commons.syntax.interfaces.Disjunctable
-
collapseAssociativeFormulas
public abstract PlFormula collapseAssociativeFormulas()
This method collapses all associative operations appearing in this term, e.g. every a||(b||c) becomes a||b||c.- Returns:
- the collapsed formula.
-
getPredicates
public abstract Set<PlPredicate> getPredicates()
- Specified by:
getPredicatesin interfacenet.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula
-
trim
public abstract PlFormula trim()
Removes duplicates (identical formulas) from conjunctions and disjunctions and removes duplicate negations. Simplifies equivalences and implications with equivalent formulas (A=>A, A<=>A) to tautologies.- Returns:
- an equivalent formula without duplicates.
-
getUniformProbability
public net.sf.tweety.math.probability.Probability getUniformProbability()
Returns this formula's probability in the uniform distribution.- Specified by:
getUniformProbabilityin interfacenet.sf.tweety.logics.commons.syntax.interfaces.ProbabilityAware- Returns:
- this formula's probability in the uniform distribution.
-
toNnf
public abstract PlFormula toNnf()
This method returns this formula in negation normal form (NNF). A formula is in NNF iff negations occur only directly in front of a proposition.- Returns:
- the formula in NNF.
-
toCnf
public abstract Conjunction toCnf()
This method returns this formula in conjunctive normal form (CNF). A formula is in CNF iff it is a conjunction of disjunctions and in NNF.- Returns:
- the formula in CNF.
-
toDnf
public PlFormula toDnf()
This method returns this formula in disjunctive normal form (DNF). A formula is in DNF iff it is a disjunction of conjunctive clauses.- Returns:
- the formula in DNF.
-
resolvableWith
public boolean resolvableWith(PlFormula other)
Checks whether this formula (which must be a conjunction of literals) is resolvable with the given formulas (which is also a conjunction of literals, i.e. whether they contains exactly one complementary literal.- Parameters:
other- a conjunction of literals- Returns:
- "true" iff this formula is resolvable with the other formula.
-
resolveWith
public Conjunction resolveWith(PlFormula other)
Resolves this formula with the given one (both have to be conjunctive clauses) and returns some resolvent.- Parameters:
other- a conjunction of formulas- Returns:
- some resolvent.
-
toBlakeCanonicalForm
public PlFormula toBlakeCanonicalForm()
This method returns this formula in Blake canonical form. A formula is in Blake canonical form iff it is the disjunction of its prime implicants.- Returns:
- the formula in Blake canonical form
-
getPrimeImplicants
public Collection<PlFormula> getPrimeImplicants()
Returns the set of prime implicants of this formula.- Returns:
- the set of prime implicants of this formula.
-
getModels
public Set<PossibleWorld> getModels()
Returns the set of models of this formula wrt. a signature that only contains the propositions appearing in this formula.- Returns:
- the set of models of this formula wrt. a signature that only contains the propositions appearing in this formula.
-
getModels
public abstract Set<PossibleWorld> getModels(PlSignature sig)
Returns the set of models of this formula wrt. the given signature.- Parameters:
sig- some propositional signature- Returns:
- the set of models of this formula wrt. the given signature.
-
complement
public net.sf.tweety.logics.commons.syntax.interfaces.ClassicalFormula complement()
- Specified by:
complementin interfacenet.sf.tweety.logics.commons.syntax.interfaces.Invertable
-
isClause
public boolean isClause()
Checks whether this formula is a clause, i.e. whether it is a disjunction of literals.- Returns:
- "true" iff this formula is a clause.
-
isConjunctiveClause
public boolean isConjunctiveClause()
Checks whether this formula is a conjunctive clause, i.e. whether it is a conjunction of literals.- Returns:
- "true" iff this formula is a conjunctive clause.
-
numberOfOccurrences
public abstract int numberOfOccurrences(Proposition p)
Returns the number of occurrences of the given proposition within this formula- Parameters:
p- some proposition- Returns:
- the number of occurrences of the given proposition within this formula
-
replace
public abstract PlFormula replace(Proposition p, PlFormula f, int i)
Replaces the ith instance of the proposition p by f.- Parameters:
p- some propositionf- some formulai- the index of the proposition- Returns:
- a new formula with the ith instance of the proposition p replaced by f.
-
isLiteral
public boolean isLiteral()
- Specified by:
isLiteralin interfacenet.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula
-
equals
public abstract boolean equals(Object other)
-
hashCode
public abstract int hashCode()
-
-