if( !node.isRoot() ) {
EdgeList preds = node.getInEdges();
boolean validPred = preds.size() == 1 || (preds.size() == 2 && preds.hasEdgeFrom( node ));
if( !validPred ) {
throw new InternalReasonerException( "Invalid blockable node: " + node + " "
+ node.getInEdges() );
}
}
else if( node.isNominal() ) {
ATermAppl nominal = ATermUtils.makeValue( node.getName() );
if( !ATermUtils.isAnonNominal( node.getName() ) && !node.hasType( nominal ) ) {
throw new InternalReasonerException( "Invalid nominal node: " + node + " "
+ node.getTypes() );
}
}
for( Iterator<ATermAppl> i = node.getDepends().keySet().iterator(); i.hasNext(); ) {
ATermAppl c = i.next();
DependencySet ds = node.getDepends( c );
if( ds.max() > branch || (!PelletOptions.USE_SMART_RESTORE && ds.getBranch() > branch) ) {
throw new InternalReasonerException( "Invalid ds found: " + node + " " + c + " "
+ ds + " " + branch );
// if( c.getAFun().equals( ATermUtils.VALUEFUN ) ) {
// if( !PelletOptions.USE_PSEUDO_NOMINALS ) {
// Individual z = getIndividual(c.getArgument(0));
// if(z == null)
// throw new InternalReasonerException("Nominal to non-existing
// node: " + node + " " + c + " " + ds + " " + branch);
// }
// }
}
}
for( Iterator<Node> i = node.getDifferents().iterator(); i.hasNext(); ) {
Node ind = i.next();
DependencySet ds = node.getDifferenceDependency( ind );
if( ds.max() > branch || ds.getBranch() > branch ) {
throw new InternalReasonerException( "Invalid ds: " + node + " != " + ind + " "
+ ds );
}
if( ind.getDifferenceDependency( node ) == null ) {
throw new InternalReasonerException( "Invalid difference: " + node + " != " + ind
+ " " + ds );
}
}
EdgeList edges = node.getOutEdges();
for( int e = 0; e < edges.size(); e++ ) {
Edge edge = edges.edgeAt( e );
Node succ = edge.getTo();
if( nodes.get( succ.getName() ) != succ ) {
throw new InternalReasonerException( "Invalid edge to a non-existing node: " + edge
+ " " + nodes.get( succ.getName() ) + "("
+ nodes.get( succ.getName() ).hashCode() + ")" + succ + "("
+ succ.hashCode() + ")" );
}
if( !succ.getInEdges().hasEdge( edge ) ) {
throw new InternalReasonerException( "Invalid edge: " + edge );
}
if( succ.isMerged() ) {
throw new InternalReasonerException( "Invalid edge to a removed node: " + edge
+ " " + succ.isMerged() );
}
DependencySet ds = edge.getDepends();
if( ds.max() > branch || ds.getBranch() > branch ) {
throw new InternalReasonerException( "Invalid ds: " + edge + " " + ds );
}
EdgeList allEdges = node.getEdgesTo( succ );
if( allEdges.getRoles().size() != allEdges.size() ) {
throw new InternalReasonerException( "Duplicate edges: " + allEdges );
}
}
edges = node.getInEdges();
for( int e = 0; e < edges.size(); e++ ) {
Edge edge = edges.edgeAt( e );
DependencySet ds = edge.getDepends();
if( ds.max() > branch || ds.getBranch() > branch ) {
throw new InternalReasonerException( "Invalid ds: " + edge + " " + ds );
}
}
}