public void Process(IProgramKnowledgeBase pkb, BindingsManager bindingsManager) { if (LeftArgs.GetSize() < RightArgs.GetSize()) { IEntityList rightBounds = ImplementationFactory.CreateEntityList(); for (int i = 0; i < LeftArgs.GetSize(); i++) { IEntity arg = LeftArgs[i]; IEntityList result = ProcessLeftSide(pkb, arg); if (LeftRef is PqlSynonym && RightRef is PqlSynonym) { bindingsManager.CreateMultipleBindings(arg, result, LeftArgs, RightArgs); } rightBounds.Sum(result); } RightArgs.Intersection(rightBounds, bindingsManager); IEntityList leftBounds = ImplementationFactory.CreateEntityList(); for (int i = 0; i < RightArgs.GetSize(); i++) { IEntity arg = RightArgs[i]; IEntityList result = ProcessRightSide(pkb, arg); leftBounds.Sum(result); } LeftArgs.Intersection(leftBounds, bindingsManager); } else { IEntityList leftBounds = ImplementationFactory.CreateEntityList(); for (int i = 0; i < RightArgs.GetSize(); i++) { IEntity arg = RightArgs[i]; IEntityList result = ProcessRightSide(pkb, arg); leftBounds.Sum(result); } LeftArgs.Intersection(leftBounds, bindingsManager); IEntityList rightBounds = ImplementationFactory.CreateEntityList(); for (int i = 0; i < LeftArgs.GetSize(); i++) { IEntity arg = LeftArgs[i]; IEntityList result = ProcessLeftSide(pkb, arg); if (LeftRef is PqlSynonym && RightRef is PqlSynonym) { bindingsManager.CreateMultipleBindings(arg, result, LeftArgs, RightArgs); } rightBounds.Sum(result); } RightArgs.Intersection(rightBounds, bindingsManager); } if (LeftArgs == RightArgs) { List <IEntity> toRemove = new List <IEntity>(); for (int i = 0; i < LeftArgs.GetSize(); i++) { if (!CheckFull(pkb, LeftArgs[i], LeftArgs[i])) { toRemove.Add(LeftArgs[i]); } } foreach (IEntity arg in toRemove) { bindingsManager.RemoveBoundEntity(arg, LeftArgs); } } }