private IQTree projectAwayUnnecessaryVariables ( IQTree child , IQProperties currentIQProperties ) { if ( child . getRootNode ( ) instanceof ConstructionNode ) { ConstructionNode constructionNode = ( ConstructionNode ) child . getRootNode ( ) ; AscendingSubstitutionNormalization normalization = normalizeAscendingSubstitution ( constructionNode . getSubstitution ( ) , projectedVariables ) ; Optional < ConstructionNode > proposedConstructionNode = normalization . generateTopConstructionNode ( ) ; if ( proposedConstructionNode . filter ( c -> c . isSyntacticallyEquivalentTo ( constructionNode ) ) . isPresent ( ) ) return child ; IQTree grandChild = normalization . normalizeChild ( ( ( UnaryIQTree ) child ) . getChild ( ) ) ; return proposedConstructionNode . map ( c -> ( IQTree ) iqFactory . createUnaryIQTree ( c , grandChild , currentIQProperties . declareLifted ( ) ) ) . orElse ( grandChild ) ; } else return child ; }
Projects away variables only for child construction nodes