AIMA.Core.Logic.FOL.Inference.FOLBCAsk.compose C# (CSharp) Метод

compose() приватный Метод

private compose ( FOLKnowledgeBase KB, Term>.Dictionary theta1, Term>.Dictionary theta2 ) : Term>.Dictionary
KB AIMA.Core.Logic.FOL.KB.FOLKnowledgeBase
theta1 Term>.Dictionary
theta2 Term>.Dictionary
Результат Term>.Dictionary
        private Dictionary<Variable, Term> compose(FOLKnowledgeBase KB,
                Dictionary<Variable, Term> theta1, Dictionary<Variable, Term> theta2)
        {
            Dictionary<Variable, Term> composed = new Dictionary<Variable, Term>();

            // So that it behaves like:
            // SUBST(theta2, SUBST(theta1, p))
            // There are two steps involved here.
            // See: http://logic.stanford.edu/classes/cs157/2008/notes/chap09.pdf
            // for a detailed discussion:

            // 1. Apply theta2 to the range of theta1.
            foreach (Variable v in theta1.Keys)
            {
                composed.Add(v, KB.subst(theta2, theta1[v]));
            }

            // 2. Adjoin to delta all pairs from tau with different
            // domain variables.
            foreach (Variable v in theta2.Keys)
            {
                if (!theta1.ContainsKey(v))
                {
                    composed.Add(v, theta2[v]);
                }
            }

            return cascadeSubstitutions(KB, composed);
        }