Class ReferenceWorld
- java.lang.Object
-
- net.sf.tweety.commons.AbstractInterpretation<FolBeliefSet,FolFormula>
-
- net.sf.tweety.logics.rpcl.semantics.ReferenceWorld
-
- All Implemented Interfaces:
java.util.Map<Predicate,InstanceAssignment>
,Interpretation<FolBeliefSet,FolFormula>
public class ReferenceWorld extends AbstractInterpretation<FolBeliefSet,FolFormula> implements java.util.Map<Predicate,InstanceAssignment>
Instances of this class represent reference worlds, i.e. sets of instance assignment. Each reference world describes a set of Herbrand interpretations.- Author:
- Matthias Thimm
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<Predicate,InstanceAssignment>
assignments
The instance assignments of this reference worldsprivate 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.
-
Method Summary
Modifier and Type Method Description void
clear()
boolean
containsKey(java.lang.Object key)
boolean
containsValue(java.lang.Object value)
java.util.Set<java.util.Map.Entry<Predicate,InstanceAssignment>>
entrySet()
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.boolean
equals(java.lang.Object obj)
InstanceAssignment
get(java.lang.Object key)
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.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.java.lang.Integer
getMultiplicator(FolFormula f)
Returns the multiplicator of this reference world for the given formula, i.e.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.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".int
hashCode()
boolean
isEmpty()
java.util.Set<Predicate>
keySet()
InstanceAssignment
put(Predicate key, InstanceAssignment value)
void
putAll(java.util.Map<? extends Predicate,? extends InstanceAssignment> m)
InstanceAssignment
remove(java.lang.Object key)
boolean
satisfies(FolBeliefSet beliefBase)
Checks whether this interpretation satisfies the given knowledge base.boolean
satisfies(FolFormula formula)
Checks whether this interpretation satisfies the given formula.int
size()
java.lang.Integer
spanNumber()
Returns the span number of this reference world, i.e.java.lang.String
toString()
java.util.Collection<InstanceAssignment>
values()
-
Methods inherited from class net.sf.tweety.commons.AbstractInterpretation
satisfies
-
-
-
-
Field Detail
-
log
private static org.slf4j.Logger log
Logger.
-
assignments
private java.util.Map<Predicate,InstanceAssignment> assignments
The instance assignments of this reference worlds
-
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 interfaceInterpretation<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 interfaceInterpretation<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.
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Map<Predicate,InstanceAssignment>
-
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKey
in interfacejava.util.Map<Predicate,InstanceAssignment>
-
containsValue
public boolean containsValue(java.lang.Object value)
- Specified by:
containsValue
in interfacejava.util.Map<Predicate,InstanceAssignment>
-
entrySet
public java.util.Set<java.util.Map.Entry<Predicate,InstanceAssignment>> entrySet()
- Specified by:
entrySet
in interfacejava.util.Map<Predicate,InstanceAssignment>
-
get
public InstanceAssignment get(java.lang.Object key)
- Specified by:
get
in interfacejava.util.Map<Predicate,InstanceAssignment>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfacejava.util.Map<Predicate,InstanceAssignment>
-
keySet
public java.util.Set<Predicate> keySet()
- Specified by:
keySet
in interfacejava.util.Map<Predicate,InstanceAssignment>
-
put
public InstanceAssignment put(Predicate key, InstanceAssignment value)
- Specified by:
put
in interfacejava.util.Map<Predicate,InstanceAssignment>
-
putAll
public void putAll(java.util.Map<? extends Predicate,? extends InstanceAssignment> m)
- Specified by:
putAll
in interfacejava.util.Map<Predicate,InstanceAssignment>
-
remove
public InstanceAssignment remove(java.lang.Object key)
- Specified by:
remove
in interfacejava.util.Map<Predicate,InstanceAssignment>
-
size
public int size()
- Specified by:
size
in interfacejava.util.Map<Predicate,InstanceAssignment>
-
values
public java.util.Collection<InstanceAssignment> values()
- Specified by:
values
in interfacejava.util.Map<Predicate,InstanceAssignment>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfacejava.util.Map<Predicate,InstanceAssignment>
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfacejava.util.Map<Predicate,InstanceAssignment>
- Overrides:
equals
in classjava.lang.Object
-
-