Package net.sf.tweety.logics.pl.syntax
Class Proposition
- java.lang.Object
-
- net.sf.tweety.logics.pl.syntax.PlFormula
-
- net.sf.tweety.logics.pl.syntax.Proposition
-
- All Implemented Interfaces:
java.lang.Comparable<Proposition>
,Formula
,Atom
,ClassicalFormula
,Conjunctable
,Disjunctable
,Invertable
,ProbabilityAware
,SimpleLogicalFormula
- Direct Known Subclasses:
QueryProposition
public class Proposition extends PlFormula implements Atom, java.lang.Comparable<Proposition>
This class represents a simple proposition in propositional logic.- Author:
- Matthias Thimm, Tim Janus
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.sf.tweety.logics.commons.syntax.interfaces.Atom
Atom.AtomImpl, Atom.RETURN_SET_PREDICATE
-
-
Constructor Summary
Constructors Constructor Description Proposition()
Default-Ctor for dynamic instantiationProposition(java.lang.String name)
Creates a new proposition of the given name.Proposition(Proposition other)
-
Method Summary
Modifier and Type Method Description void
addArgument(Term<?> arg)
Adds an argument to the atom's argument listProposition
clone()
Creates a deep copy of this formulaPlFormula
collapseAssociativeFormulas()
This method collapses all associative operations appearing in this term, e.g.int
compareTo(Proposition o)
boolean
equals(java.lang.Object obj)
java.util.List<? extends Term<?>>
getArguments()
java.util.Set<Proposition>
getAtoms()
Processes the set of all atoms which appear in this formulajava.util.Set<PlFormula>
getLiterals()
Returns all literals, i.e.java.util.Set<PossibleWorld>
getModels(PlSignature sig)
Returns the set of models of this formula wrt.java.lang.String
getName()
PlPredicate
getPredicate()
java.util.Set<PlPredicate>
getPredicates()
Processes the set of all predicates which appear in this formulaPlSignature
getSignature()
Returns the signature of the language of this formula.int
hashCode()
boolean
isComplete()
boolean
isLiteral()
int
numberOfOccurrences(Proposition p)
Returns the number of occurrences of the given proposition within this formulaPlFormula
replace(Proposition p, PlFormula f, int i)
Replaces the ith instance of the proposition p by f.Atom.RETURN_SET_PREDICATE
setPredicate(Predicate predicate)
Changes the predicate of the atom.Conjunction
toCnf()
This method returns this formula in conjunctive normal form (CNF).PlFormula
toNnf()
This method returns this formula in negation normal form (NNF).java.lang.String
toString()
PlFormula
trim()
Removes duplicates (identical formulas) from conjunctions and disjunctions and removes duplicate negations.-
Methods inherited from class net.sf.tweety.logics.pl.syntax.PlFormula
combineWithAnd, combineWithOr, complement, getModels, getPredicateCls, getPrimeImplicants, getUniformProbability, isClause, isConjunctiveClause, resolvableWith, resolveWith, toBlakeCanonicalForm, toDnf
-
Methods inherited from interface net.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula
getPredicateCls
-
-
-
-
Constructor Detail
-
Proposition
public Proposition()
Default-Ctor for dynamic instantiation
-
Proposition
public Proposition(java.lang.String name)
Creates a new proposition of the given name.- Parameters:
name
- the name of the proposition.
-
Proposition
public Proposition(Proposition other)
-
-
Method Detail
-
getName
public java.lang.String getName()
-
getPredicate
public PlPredicate getPredicate()
- Specified by:
getPredicate
in interfaceAtom
- Returns:
- the predicate of the atom
-
getPredicates
public java.util.Set<PlPredicate> getPredicates()
Description copied from interface:SimpleLogicalFormula
Processes the set of all predicates which appear in this formula- Specified by:
getPredicates
in interfaceSimpleLogicalFormula
- Specified by:
getPredicates
in classPlFormula
- Returns:
- all predicates that appear in this formula
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
collapseAssociativeFormulas
public PlFormula collapseAssociativeFormulas()
Description copied from class:PlFormula
This method collapses all associative operations appearing in this term, e.g. every a||(b||c) becomes a||b||c.- Specified by:
collapseAssociativeFormulas
in classPlFormula
- Returns:
- the collapsed formula.
-
getSignature
public PlSignature getSignature()
Description copied from interface:Formula
Returns the signature of the language of this formula.- Specified by:
getSignature
in interfaceFormula
- Overrides:
getSignature
in classPlFormula
- Returns:
- the signature of the language of this formula.
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceSimpleLogicalFormula
- Specified by:
hashCode
in classPlFormula
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfaceSimpleLogicalFormula
- Specified by:
equals
in classPlFormula
-
toNnf
public PlFormula toNnf()
Description copied from class:PlFormula
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.
-
clone
public Proposition clone()
Description copied from interface:SimpleLogicalFormula
Creates a deep copy of this formula- Specified by:
clone
in interfaceSimpleLogicalFormula
- Specified by:
clone
in classPlFormula
- Returns:
- the cloned formula
-
trim
public PlFormula trim()
Description copied from class:PlFormula
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.
-
addArgument
public void addArgument(Term<?> arg)
Description copied from interface:Atom
Adds an argument to the atom's argument list- Specified by:
addArgument
in interfaceAtom
- Parameters:
arg
- The next argument
-
getArguments
public java.util.List<? extends Term<?>> getArguments()
- Specified by:
getArguments
in interfaceAtom
- Returns:
- A list containing all the arguments of this specific atom
-
isComplete
public boolean isComplete()
- Specified by:
isComplete
in interfaceAtom
- Returns:
- true if the size of the argument list is equal to the arity of the predicate
-
getAtoms
public java.util.Set<Proposition> getAtoms()
Description copied from interface:SimpleLogicalFormula
Processes the set of all atoms which appear in this formula- Specified by:
getAtoms
in interfaceSimpleLogicalFormula
- Specified by:
getAtoms
in classPlFormula
- Returns:
- The set of all atoms
-
isLiteral
public boolean isLiteral()
- Specified by:
isLiteral
in interfaceSimpleLogicalFormula
- Overrides:
isLiteral
in classPlFormula
- Returns:
- true if the formula represents a literal in the language or false otherwise
-
getLiterals
public java.util.Set<PlFormula> getLiterals()
Description copied from class:PlFormula
Returns all literals, i.e. all formulas of the form "a" or "!a" where "a" is a proposition, that appear in this formula.- Specified by:
getLiterals
in classPlFormula
- Returns:
- all literals appearing in this formula.
-
setPredicate
public Atom.RETURN_SET_PREDICATE setPredicate(Predicate predicate)
Description copied from interface:Atom
Changes the predicate of the atom. Given an old Predicate po and a new predicate pn with their list of arguments types at(po) and at(pn) and the arguments of this Atom: arg(this) this method distinguishes between three cases: 1. The predicate only differ in the names, returning RSP_SUCCESS 2. The old predicates argument types is a sub-list of the new argument types then the method returns RSP_INCOMPLETE and the atoms isComplete() method returns false 3. The new predicates argument types is a sub-list of the old argument types then the method returns RSP_TRUNCATED and the arguments of this atom are truncated too and isComplete() returns true. 4. The old and new predicates' argument types differ then the list of arguments of the atom get cleared and isComplete() returns false.- Specified by:
setPredicate
in interfaceAtom
- Parameters:
predicate
- some predicate- Returns:
- Depends on the cases described above: 1. RSP_SUCCESS 2. RSP_INCOMPLETE 3. RSP_TRUNCATED 4. RSP_CLEARED
-
compareTo
public int compareTo(Proposition o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Proposition>
-
toCnf
public Conjunction toCnf()
Description copied from class:PlFormula
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.
-
numberOfOccurrences
public int numberOfOccurrences(Proposition p)
Description copied from class:PlFormula
Returns the number of occurrences of the given proposition within this formula- Specified by:
numberOfOccurrences
in classPlFormula
- Parameters:
p
- some proposition- Returns:
- the number of occurrences of the given proposition within this formula
-
replace
public PlFormula replace(Proposition p, PlFormula f, int i)
Description copied from class:PlFormula
Replaces the ith instance of the proposition p by f.
-
getModels
public java.util.Set<PossibleWorld> getModels(PlSignature sig)
Description copied from class:PlFormula
Returns the set of models of this formula wrt. the given signature.
-
-