/// <summary>
        /// Processes conditional (when) effects.
        /// </summary>
        /// <param name="relativeState">>Relative state to be processed.</param>
        /// <returns>Modified relative states.</returns>
        private IEnumerable <IRelativeState> ProcessWhenEffects(IRelativeState relativeState)
        {
            if (Effects.WhenEffects.Count == 0)
            {
                yield return(relativeState);

                yield break;
            }

            // Collect the relevant when effects, first
            List <WhenEffect> relevantWhenEffects = GetRelevantWhenEffectsForConditions(relativeState);

            // Each of the relevant when effect is either used or not (dynamic programming approach to get all combinations of when effects usage)
            List <IRelativeState> applicationResults = new List <IRelativeState> {
                relativeState
            };

            foreach (var whenEffect in relevantWhenEffects)
            {
                Conditions whenCondition = new Conditions(whenEffect.Expression, EvaluationManager);
                EffectsBackwardsRelativeStateApplier innerApplier = new EffectsBackwardsRelativeStateApplier(whenCondition, new List <IEffect>(whenEffect.Effects), EvaluationManager);

                List <IRelativeState> currentEffectApplications = new List <IRelativeState>();
                foreach (var currentRelativeState in applicationResults)
                {
                    foreach (var resultRelativeState in innerApplier.ApplyBackwards(currentRelativeState, new Substitution()))
                    {
                        currentEffectApplications.Add((IRelativeState)resultRelativeState);
                    }
                }

                applicationResults.AddRange(currentEffectApplications);
            }

            foreach (var resultRelativeState in applicationResults)
            {
                yield return(resultRelativeState);
            }
        }
        /// <summary>
        /// Processes forall effects.
        /// </summary>
        /// <param name="relativeState">Relative state to be modified.</param>
        /// <returns>Possibly modified relative state.</returns>
        private IRelativeState ProcessForallEffects(IRelativeState relativeState)
        {
            if (Effects.ForallEffects.Count == 0)
            {
                return(relativeState);
            }

            foreach (var forallEffect in Effects.ForallEffects)
            {
                EffectsBackwardsRelativeStateApplier innerApplier = new EffectsBackwardsRelativeStateApplier(null, forallEffect.Effects, EvaluationManager);

                IEnumerable <ISubstitution> localSubstitutions = GroundingManager.GenerateAllLocalSubstitutions(forallEffect.Parameters);
                foreach (var localSubstitution in localSubstitutions)
                {
                    OperatorSubstitution.AddLocalSubstitution(localSubstitution);
                    relativeState = (IRelativeState)innerApplier.ApplyBackwards(relativeState, OperatorSubstitution).First();
                    OperatorSubstitution.RemoveLocalSubstitution(localSubstitution);
                }
            }

            return(relativeState);
        }