}
return;
}
final Set<ATermAppl> types = getTypes();
final DatatypeReasoner dtReasoner = abox.getDatatypeReasoner();
try {
if( hasValue ) {
if( !dtReasoner.isSatisfiable( types, value ) ) {
ArrayList<ATermAppl> primitives = new ArrayList<ATermAppl>();
for( ATermAppl t : types ) {
if( ATermUtils.TOP_LIT.equals( t ) ) {
continue;
}
else {
primitives.add( t );
}
}
final ATermAppl dt[] = primitives
.toArray( new ATermAppl[primitives.size() - 1] );
DependencySet ds = DependencySet.EMPTY;
for( int i = 0; i < dt.length; i++ ) {
ds = ds.union( getDepends( dt[i] ), abox.doExplanation() );
if (abox.doExplanation()) {
ATermAppl dtName = ATermUtils.isNot(dt[i]) ? (ATermAppl) dt[i].getArgument(0) : dt[i];
ATermAppl definition = dtReasoner.getDefinition(dtName);
if (definition != null) {
ds = ds.union(Collections.singleton(ATermUtils.makeDatatypeDefinition(dtName, definition)), true);
}
}
}
reportClash( Clash.valueDatatype( this, ds, (ATermAppl) atermValue.getArgument(0), dt[0] ) );
}
}
else {
if( dtReasoner.isSatisfiable( types ) ) {
if ( !dtReasoner.containsAtLeast( 2, types ) ) {
/*
* This literal is a variable, but given current ranges can only
* take on a single value. Merge with that value.
*/
final Object value = dtReasoner.valueIterator( types ).next();
final ATermAppl valueTerm = dtReasoner.getLiteral( value );
Literal valueLiteral = abox.getLiteral( valueTerm );
if (valueLiteral == null) {
/*
* No dependency set is used here because omitting it prevents the
* constant literal from being removed during backtrack
*/
valueLiteral = abox.addLiteral( valueTerm );
}
DependencySet mergeDs = DependencySet.INDEPENDENT;
for ( DependencySet ds : depends.values() ) {
mergeDs = mergeDs.union( ds, abox.doExplanation() );
}
merge = new NodeMerge( this, valueLiteral, mergeDs );
}
} else {
ArrayList<ATermAppl> primitives = new ArrayList<ATermAppl>();
for( ATermAppl t : types ) {
if( ATermUtils.TOP_LIT.equals( t ) ) {
continue;
}
else {
primitives.add( t );
}
}
final ATermAppl dt[] = primitives
.toArray( new ATermAppl[primitives.size() - 1] );
DependencySet ds = DependencySet.EMPTY;
for( int i = 0; i < dt.length; i++ ) {
ds = ds.union( getDepends( dt[i] ), abox.doExplanation() );
if (abox.doExplanation()) {
ATermAppl definition = dtReasoner.getDefinition(dt[i]);
if (definition != null) {
ds = ds.union(Collections.singleton(ATermUtils.makeDatatypeDefinition(dt[i], definition)), true);
}
}
}