Class ReferenceWorld

    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map<Predicate,​InstanceAssignment> assignments
      The instance assignments of this reference worlds
      private java.util.Collection<? extends java.util.Collection<? extends Constant>> equivalenceClasses
      The equivalence classes this reference world bases on.
      private static org.slf4j.Logger log
      Logger.
      private java.util.Map<FolFormula,​java.lang.Integer> multiplicators
      Multiplicators for formulas; saved for efficiency.
      private java.util.Collection<Predicate> predicates
      The set of predicates this reference world bases on.
      private java.lang.Integer spanNumber
      The span number of this reference world; saved for efficiency.
    • Constructor Summary

      Constructors 
      Constructor Description
      ReferenceWorld​(java.util.Collection<? extends java.util.Collection<? extends Constant>> equivalenceClasses, java.util.Collection<Predicate> predicates)
      Creates a new reference world for the given equivalence classes.
    • Field Detail

      • log

        private static org.slf4j.Logger log
        Logger.
      • equivalenceClasses

        private java.util.Collection<? extends java.util.Collection<? extends Constant>> equivalenceClasses
        The equivalence classes this reference world bases on.
      • predicates

        private java.util.Collection<Predicate> predicates
        The set of predicates this reference world bases on.
      • spanNumber

        private java.lang.Integer spanNumber
        The span number of this reference world; saved for efficiency.
      • multiplicators

        private java.util.Map<FolFormula,​java.lang.Integer> multiplicators
        Multiplicators for formulas; saved for efficiency.
    • Constructor Detail

      • ReferenceWorld

        public ReferenceWorld​(java.util.Collection<? extends java.util.Collection<? extends Constant>> equivalenceClasses,
                              java.util.Collection<Predicate> predicates)
        Creates a new reference world for the given equivalence classes.
        Parameters:
        equivalenceClasses - a set of set of constants.
        predicates - a set of predicates
    • Method Detail

      • get

        public java.lang.Integer get​(Predicate predicate,
                                     java.util.Collection<? extends Constant> constants)
        Retrieves the number of true instances assigned for the given predicate and the given equivalence class of constants.
        Parameters:
        predicate - a predicate.
        constants - a set of constants.
        Returns:
        the number of true instances.
      • spanNumber

        public java.lang.Integer spanNumber()
        Returns the span number of this reference world, i.e. the number of Herbrand interpretations this world refers to.
        Returns:
        the span number of this reference world.
      • getMultiplicator

        public java.lang.Integer getMultiplicator​(FolFormula f)
        Returns the multiplicator of this reference world for the given formula, i.e. the number of interpretations that map to this world and satisfy the formula.
        Parameters:
        f - a fol formula.
        Returns:
        the multiplicator of this reference world for the given formula.
      • getMultiplicatorForConjunction

        private java.lang.Integer getMultiplicatorForConjunction​(FolFormula f)
        Returns the multiplicator of this reference world for the given formula (which is a conjunction of literals or a single literal), i.e. the number of interpretations that map to this world and satisfy the formula.
        Parameters:
        f - a fol formula (either a conjunction of literals or a single literal).
        Returns:
        the multiplicator of this reference world for the given formula.
      • getNumberOfOccurences

        private java.lang.Integer getNumberOfOccurences​(FolFormula f,
                                                        Predicate p,
                                                        java.util.Collection<? extends Constant> constants,
                                                        boolean positive)
        Determines the number of occurrences of instances of predicate "p" with a constant in "constants". The boolean positive determines whether this instance is positive (or negative) and "f" is to be assumed either a single literal or a conjunction of literals. Furthermore "p" is assumed to be unary.
        Parameters:
        f - a fol formula.
        p - a predicate.
        constants - a set of constants.
        positive - whether the instances are to be positive.
        Returns:
        an integer describing the number of occurrences of instances of predicate "p" with a constant in "constants".
      • getMapping

        public static ReferenceWorld getMapping​(HerbrandInterpretation i,
                                                java.util.Set<Predicate> predicates,
                                                java.util.Set<java.util.Set<Constant>> constants)
        Determines the reference world of the given interpretation wrt. the given set of equivalence classes and the given set of predicates..
        Parameters:
        i - a Herbrand interpretation.
        constants - the set of equivalence classes.
        predicates - a set of predicates.
        Returns:
        a reference world.
      • enumerateReferenceWorlds

        public static java.util.Set<ReferenceWorld> enumerateReferenceWorlds​(java.util.Set<Predicate> predicates,
                                                                             java.util.Set<java.util.Set<Constant>> constants)
        Determines the set of all reference worlds wrt. the given set of predicates and equivalence classes.
        Parameters:
        predicates - a set of predicates.
        constants - a set of set of constants.
        Returns:
        a set of reference worlds.
      • satisfies

        public boolean satisfies​(FolFormula formula)
                          throws java.lang.IllegalArgumentException
        Description copied from interface: Interpretation
        Checks whether this interpretation satisfies the given formula.
        Specified by:
        satisfies in interface Interpretation<FolBeliefSet,​FolFormula>
        Parameters:
        formula - a formula .
        Returns:
        "true" if this interpretation satisfies the given formula.
        Throws:
        java.lang.IllegalArgumentException - if the formula does not correspond to the expected language.
      • satisfies

        public boolean satisfies​(FolBeliefSet beliefBase)
                          throws java.lang.IllegalArgumentException
        Description copied from interface: Interpretation
        Checks whether this interpretation satisfies the given knowledge base.
        Specified by:
        satisfies in interface Interpretation<FolBeliefSet,​FolFormula>
        Parameters:
        beliefBase - a knowledge base.
        Returns:
        "true" if this interpretation satisfies the given knowledge base.
        Throws:
        java.lang.IllegalArgumentException - IllegalArgumentException if the knowledgebase does not correspond to the expected language.
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Specified by:
        containsKey in interface java.util.Map<Predicate,​InstanceAssignment>
      • containsValue

        public boolean containsValue​(java.lang.Object value)
        Specified by:
        containsValue in interface java.util.Map<Predicate,​InstanceAssignment>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Map<Predicate,​InstanceAssignment>
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Specified by:
        equals in interface java.util.Map<Predicate,​InstanceAssignment>
        Overrides:
        equals in class java.lang.Object