public DependencyStructure compose2(DependencyStructure other,final List<UnlabelledDependency> newResolvedDependencies){
  other=other.standardizeApart(coindexation.getMaxID() + 1);
  final UnifyingSubstitution substitution=UnifyingSubstitution.make(coindexation.right,other.coindexation.left.left,false);
  final Set<UnresolvedDependency> newUnresolvedDependencies=new HashSet<>();
  updateResolvedDependencies(other,substitution,newUnresolvedDependencies,newResolvedDependencies);
  final Set<UnresolvedDependency> normalizedUnresolvedDependencies=new HashSet<>(newUnresolvedDependencies.size());
  final Coindexation normalizedCoindexation;
  if (coindexation.isModifier()) {
    normalizedCoindexation=normalize(substitution.applyTo(other.coindexation),newUnresolvedDependencies,normalizedUnresolvedDependencies,newResolvedDependencies,1);
  }
 else {
    final Coindexation leftWithSubstitution=substitution.applyTo(coindexation);
    final Coindexation rightWithSubstitution=substitution.applyTo(other.coindexation);
    normalizedCoindexation=normalize(new Coindexation(new Coindexation(leftWithSubstitution.left,rightWithSubstitution.left.right,leftWithSubstitution.idOrHead),rightWithSubstitution.right,leftWithSubstitution.idOrHead),newUnresolvedDependencies,normalizedUnresolvedDependencies,newResolvedDependencies,1);
  }
  return new DependencyStructure(normalizedCoindexation,normalizedUnresolvedDependencies);
}

public DependencyStructure compose2 ( DependencyStructure other , final List < UnlabelledDependency > newResolvedDependencies ) { other = other . standardizeApart ( coindexation . getMaxID ( ) + 1 ) ; final UnifyingSubstitution substitution = UnifyingSubstitution . make ( coindexation . right , other . coindexation . left . left , false ) ; final Set < UnresolvedDependency > newUnresolvedDependencies = new HashSet < > ( ) ; updateResolvedDependencies ( other , substitution , newUnresolvedDependencies , newResolvedDependencies ) ; final Set < UnresolvedDependency > normalizedUnresolvedDependencies = new HashSet < > ( newUnresolvedDependencies . size ( ) ) ; final Coindexation normalizedCoindexation ; if ( coindexation . isModifier ( ) ) { normalizedCoindexation = normalize ( substitution . applyTo ( other . coindexation ) , newUnresolvedDependencies , normalizedUnresolvedDependencies , newResolvedDependencies , 1 ) ; } else { final Coindexation leftWithSubstitution = substitution . applyTo ( coindexation ) ; final Coindexation rightWithSubstitution = substitution . applyTo ( other . coindexation ) ; normalizedCoindexation = normalize ( new Coindexation ( new Coindexation ( leftWithSubstitution . left , rightWithSubstitution . left . right , leftWithSubstitution . idOrHead ) , rightWithSubstitution . right , leftWithSubstitution . idOrHead ) , newUnresolvedDependencies , normalizedUnresolvedDependencies , newResolvedDependencies , 1 ) ; } return new DependencyStructure ( normalizedCoindexation , normalizedUnresolvedDependencies ) ; }
generalized forward composition ( to degree 2 )
