@ Override public ImmutableSet < ImmutableSubstitution < NonVariableTerm > > getPossibleVariableDefinitions ( IQTree leftChild , IQTree rightChild ) { ImmutableSet < ImmutableSubstitution < NonVariableTerm >> leftDefs = leftChild . getPossibleVariableDefinitions ( ) ; ImmutableSet < Variable > rightSpecificVariables = Sets . difference ( rightChild . getVariables ( ) , leftChild . getVariables ( ) ) . immutableCopy ( ) ; ImmutableSet < ImmutableSubstitution < NonVariableTerm > > rightDefs = leftChild . getPossibleVariableDefinitions ( ) . stream ( ) . map ( s -> s . reduceDomainToIntersectionWith ( rightSpecificVariables ) ) . collect ( ImmutableCollectors . toSet ( ) ) ; if ( leftDefs . isEmpty ( ) ) return rightDefs ; else if ( rightDefs . isEmpty ( ) ) return leftDefs ; else return leftDefs . stream ( ) . flatMap ( l -> rightDefs . stream ( ) . map ( r -> combine ( l , r ) ) ) . collect ( ImmutableCollectors . toSet ( ) ) ; }
Returns possible definitions for left and right - specific variables .