org.semanticweb.HermiT.tableau
Class DatatypeManager

java.lang.Object
  extended by org.semanticweb.HermiT.tableau.DatatypeManager

public class DatatypeManager
extends java.lang.Object


Nested Class Summary
protected static class DatatypeManager.SetLengthComparator
          used to sort data ranges based on the number of possible assignments
 
Field Summary
protected  UnionDependencySet dependencySetTwoCauses
           
protected  ExtensionManager extensionManager
           
protected  ExtensionTable.Retrieval pairsDeltaOld
           
protected  ExtensionTable.Retrieval pairsFirstBoundRetr
           
protected  TableauMonitor tableauMonitor
           
protected  ExtensionTable.Retrieval triplesFirstBoundRetr
           
protected  ExtensionTable.Retrieval triplesSecondBoundRetr
           
protected  ExtensionTable.Retrieval triplesZeroBoundRetr
           
 
Constructor Summary
DatatypeManager(Tableau tableau)
           
 
Method Summary
protected  java.util.Map<Node,CanonicalDataRange> buildCanonicalRanges(java.util.Map<Node,java.util.Set<DataRange>> nodeToDRs)
          Given a map from nodes to a set of data ranges, construct a map from nodes to data ranges such that each constructed data range captures all restrictions of the data ranges in the set for the node in the given map.
protected  java.util.Set<java.util.Map<CanonicalDataRange,Node>> buildPartitions(java.util.Map<Node,CanonicalDataRange> nodeToCanonicalDR, java.util.Map<Node,java.util.Set<Node>> inequalities, java.util.Map<Node,java.util.Set<Node>> inequalitiesSym)
          Partition the set of nodes and their canonical data ranges together with their inequalities into mutally disjoint non-empty subsets P1, ..., Pn such that no Pi and Pj with i neq j have variables in common.
protected  boolean checkDatatypeAssertionFor(java.util.Map<Node,java.util.Set<DataRange>> nodeToDRs)
          Given a map with nodes and data range assertions for the nodes, check whether there is an assignment for all the data ranges that is consistent with the restrictions on the data ranges and the inequalities
 boolean checkDatatypeConstraints()
          Checks if in the last iteration a new data range assertion has been added and if so, whether the restrictions on this newly added node and its data range siblings are satisfiable given the asserted inequalities.
protected  boolean fetchInequalities(java.util.Set<Node> nodes, java.util.Map<Node,java.util.Set<Node>> inequalities, java.util.Map<Node,java.util.Set<Node>> inequalitiesSym)
          Given a set of nodes for which there are data range assertions in the tableau, collect all inequalities for the nodes.
protected  java.util.Map<Node,java.util.Set<DataRange>> fetchRelevantAssertions(Node initialNode)
          Given a node that has a data range assertion in the extension table, look up its predecessor node in the tableau (unique for data range nodes) and collect all successors of the fond predecessor that have data range assertions.
protected  CanonicalDataRange getCanonicalDataRange(java.util.Set<DataRange> ranges)
          Given a set of data ranges, construct a data range that captures all the restrictions of the given ranges.
protected  boolean hasAssignment(java.util.Map<CanonicalDataRange,Node> partition, java.util.Map<Node,java.util.Set<Node>> inequalities, java.util.Map<Node,java.util.Set<Node>> inequalitiesSym, java.util.Map<Node,java.util.Set<DataRange>> originalNodeToDRs)
          Given a map from data ranges to nodes and inequalities between the nodes, check whether there is a suitable assignment of values for the nodes that complies with the given datatype restrictions and inequalities.
protected  void removeUnderRestrictedRanges(java.util.Map<Node,CanonicalDataRange> nodeToCanonicalDR, java.util.Map<Node,java.util.Set<Node>> inequalities, java.util.Map<Node,java.util.Set<Node>> inequalitiesSym)
          Remove those nodes and data ranges that have more than enough values to cover the inequalities.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tableauMonitor

protected final TableauMonitor tableauMonitor

extensionManager

protected final ExtensionManager extensionManager

pairsDeltaOld

protected final ExtensionTable.Retrieval pairsDeltaOld

triplesFirstBoundRetr

protected final ExtensionTable.Retrieval triplesFirstBoundRetr

triplesSecondBoundRetr

protected final ExtensionTable.Retrieval triplesSecondBoundRetr

pairsFirstBoundRetr

protected final ExtensionTable.Retrieval pairsFirstBoundRetr

triplesZeroBoundRetr

protected final ExtensionTable.Retrieval triplesZeroBoundRetr

dependencySetTwoCauses

protected final UnionDependencySet dependencySetTwoCauses
Constructor Detail

DatatypeManager

public DatatypeManager(Tableau tableau)
Method Detail

checkDatatypeConstraints

public boolean checkDatatypeConstraints()
Checks if in the last iteration a new data range assertion has been added and if so, whether the restrictions on this newly added node and its data range siblings are satisfiable given the asserted inequalities.

Returns:
true if the data range assertions are satisfiable and false otherwise

fetchRelevantAssertions

protected java.util.Map<Node,java.util.Set<DataRange>> fetchRelevantAssertions(Node initialNode)
Given a node that has a data range assertion in the extension table, look up its predecessor node in the tableau (unique for data range nodes) and collect all successors of the fond predecessor that have data range assertions.

Parameters:
initialNode - a node that has a data range assertion in the extension table
Returns:
A map that contains as keys the given node and its siblings from the tableau that also have data range assertions. For each key n1 that mapping contains all data range assertion for n1 from the extension table.

checkDatatypeAssertionFor

protected boolean checkDatatypeAssertionFor(java.util.Map<Node,java.util.Set<DataRange>> nodeToDRs)
Given a map with nodes and data range assertions for the nodes, check whether there is an assignment for all the data ranges that is consistent with the restrictions on the data ranges and the inequalities

Parameters:
nodeToDRs - a mapping from nodes to their asserted data ranges
Returns:
true if a consistent assignment exists, false otherwise

fetchInequalities

protected boolean fetchInequalities(java.util.Set<Node> nodes,
                                    java.util.Map<Node,java.util.Set<Node>> inequalities,
                                    java.util.Map<Node,java.util.Set<Node>> inequalitiesSym)
Given a set of nodes for which there are data range assertions in the tableau, collect all inequalities for the nodes. If a self inequality is found (neq node node) a clash is raised and the method return true.

Parameters:
nodes - the set of nodes for which inequalities are collected
inequalities - is a map that is initially assumed to be empty. After running the method, it contains as keys all nodes n1 from the given set nodes for which there is an inequality assertion of the form neq n1 n2 in the extension table; the set of values for each key n1 consist of all those nodes n2 for which neq n1 n2 is in the extension table.
inequalitiesSym - is a map that is initially assumed to be empty. After running the method, it contains the symmetric counterpart of inequalities. I.e., it contains as keys all nodes n1 from the given set nodes for which there is an inequality assertion of the form neq n2 n1 in the extension table; the set of values for each key n1 consist of all those nodes n2 for which neq n2 n1 is in the extension table.
Returns:
true if a tuple neq n1 n1 is found while fetching the inequalities from the extension table and false otherwise

buildCanonicalRanges

protected java.util.Map<Node,CanonicalDataRange> buildCanonicalRanges(java.util.Map<Node,java.util.Set<DataRange>> nodeToDRs)
Given a map from nodes to a set of data ranges, construct a map from nodes to data ranges such that each constructed data range captures all restrictions of the data ranges in the set for the node in the given map. If any constructed canonical data range is equal to bottom, a clash is raised and null is returned. The canonical ranges have either oneOf values or facets (possibly empty) and notOneOfs, which are constants unsuitable for assignment (possibly empty).

Parameters:
nodeToDRs - a map from nodes to sets of data ranges n -> {dr_1, ..., dr_n}
Returns:
a map from nodes to data ranges n -> dr such that dr captures the restrictions of {dr_1, ..., dr_n} or null if conjoining the ranges lead to a clash (constructed range is bottom)

getCanonicalDataRange

protected CanonicalDataRange getCanonicalDataRange(java.util.Set<DataRange> ranges)
Given a set of data ranges, construct a data range that captures all the restrictions of the given ranges.

Parameters:
ranges - a set of data ranges
Returns:
a data range that captures all restrictions from the data ranges in the given set ranges or null this is not possible due to different data types or contradiction oneOf values in the given ranges

removeUnderRestrictedRanges

protected void removeUnderRestrictedRanges(java.util.Map<Node,CanonicalDataRange> nodeToCanonicalDR,
                                           java.util.Map<Node,java.util.Set<Node>> inequalities,
                                           java.util.Map<Node,java.util.Set<Node>> inequalitiesSym)
Remove those nodes and data ranges that have more than enough values to cover the inequalities.

Parameters:
nodeToCanonicalDR - a map from nodes to canonical data ranges
inequalities - inequalities between nodes
inequalitiesSym - symmetric counterpart for the above relation

buildPartitions

protected java.util.Set<java.util.Map<CanonicalDataRange,Node>> buildPartitions(java.util.Map<Node,CanonicalDataRange> nodeToCanonicalDR,
                                                                                java.util.Map<Node,java.util.Set<Node>> inequalities,
                                                                                java.util.Map<Node,java.util.Set<Node>> inequalitiesSym)
Partition the set of nodes and their canonical data ranges together with their inequalities into mutally disjoint non-empty subsets P1, ..., Pn such that no Pi and Pj with i neq j have variables in common.

Parameters:
nodeToCanonicalDR - a map from nodes to canonical data ranges
inequalities - a map from nodes to the nodes for which an inequality is known
inequalitiesSym - the symmetric counterpart toinequalitiesSym
Returns:
a set of partitions such that the nodes and their data ranges in each partition have inequalities between them

hasAssignment

protected boolean hasAssignment(java.util.Map<CanonicalDataRange,Node> partition,
                                java.util.Map<Node,java.util.Set<Node>> inequalities,
                                java.util.Map<Node,java.util.Set<Node>> inequalitiesSym,
                                java.util.Map<Node,java.util.Set<DataRange>> originalNodeToDRs)
Given a map from data ranges to nodes and inequalities between the nodes, check whether there is a suitable assignment of values for the nodes that complies with the given datatype restrictions and inequalities.

Parameters:
partition - A map from data ranges to nodes such that the inequalities given in the next two parameters link the variables in the partition.
inequalities - A map from nodes to sets of nodes for which there are inequalities in the extension table.
inequalitiesSym - The symmetric counter part to the above map.
originalNodeToDRs - A map from nodes to data ranges such that for each node and data range in the map, there is a corresponding entry in the extension table.
Returns:
true if an assignment from values to nodes exists such that the datatype restrictions and the inequalities are satisfied and false otherwise.