Class Equivalence

java.lang.Object
org.tweetyproject.logics.pl.syntax.PlFormula
org.tweetyproject.logics.pl.syntax.Equivalence
All Implemented Interfaces:
Formula, ClassicalFormula, Conjunctable, Disjunctable, Invertable, ProbabilityAware, SimpleLogicalFormula

public class Equivalence extends PlFormula
This class models equivalence of propositional logic.
Author:
Anna Gessler
  • Constructor Details

    • Equivalence

      public Equivalence(PlFormula a, PlFormula b)
      Creates a new equivalence with the given two formulas
      Parameters:
      a - a propositional formula
      b - a propositional formula
    • Equivalence

      public Equivalence(Pair<PlFormula,PlFormula> formulas)
      Creates a new equivalence with the given pair of formulas
      Parameters:
      formulas - a pair of formulas
  • Method Details

    • getFormulas

      public Pair<PlFormula,PlFormula> getFormulas()
      Returns the formulas of the equivalence.
      Returns:
      the formulas that are part of the equivalence
    • setFormulas

      public void setFormulas(Pair<PlFormula,PlFormula> formulas)
      Sets the formulas of the equivalence.
      Parameters:
      formulas - the formulas
    • setFormulas

      public void setFormulas(PlFormula formula1, PlFormula formula2)
      Sets the formulas of the equivalence.
      Parameters:
      formula1 - some formula
      formula2 - some formula
    • getAtoms

      public Set<Proposition> 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 PlFormula
      Returns:
      The set of all atoms
    • getLiterals

      public 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 class PlFormula
      Returns:
      all literals appearing in this formula.
    • 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 class PlFormula
      Returns:
      the collapsed formula.
    • getPredicates

      public Set<PlPredicate> getPredicates()
      Description copied from interface: SimpleLogicalFormula
      Processes the set of all predicates which appear in this formula
      Specified by:
      getPredicates in interface SimpleLogicalFormula
      Specified by:
      getPredicates in class PlFormula
      Returns:
      all predicates that appear in this 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.
      Specified by:
      trim in class PlFormula
      Returns:
      an equivalent formula without duplicates.
    • 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.
      Specified by:
      toNnf in class PlFormula
      Returns:
      the formula in NNF.
    • 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. The CNF generated by this method is not necessarily minimal.
      Specified by:
      toCnf in class PlFormula
      Returns:
      the formula in CNF.
    • getModels

      public Set<PossibleWorld> getModels(PlSignature sig)
      Description copied from class: PlFormula
      Returns the set of models of this formula wrt. the given signature.
      Specified by:
      getModels in class PlFormula
      Parameters:
      sig - some propositional signature
      Returns:
      the set of models of this formula wrt. the given signature.
    • 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 class PlFormula
      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.
      Specified by:
      replace in class PlFormula
      Parameters:
      p - some proposition
      f - some formula
      i - the index of the proposition
      Returns:
      a new formula with the ith instance of the proposition p replaced by f.
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface SimpleLogicalFormula
      Specified by:
      hashCode in class PlFormula
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface SimpleLogicalFormula
      Specified by:
      equals in class PlFormula
    • clone

      public Equivalence clone()
      Description copied from interface: SimpleLogicalFormula
      Creates a deep copy of this formula
      Specified by:
      clone in interface SimpleLogicalFormula
      Specified by:
      clone in class PlFormula
      Returns:
      the cloned formula
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getSignature

      public PlSignature getSignature()
      Description copied from interface: Formula
      Returns the signature of the language of this formula.
      Specified by:
      getSignature in interface Formula
      Overrides:
      getSignature in class PlFormula
      Returns:
      the signature of the language of this formula.