Ejemplo n.º 1
0
        private static void VisitOr(Disjunction or, GdlVisitor visitor)
        {
            visitor.VisitOr(or);

            var expressions = or.GetDisjuncts().ToList();
            for (int i = 0; i < expressions.Count(); i++)
                VisitAll(expressions[i], visitor);
        }
Ejemplo n.º 2
0
        private static Substitution Mgu(Disjunction dis1, Disjunction dis2)
        {
            List<Expression> contents1 = dis1.GetDisjuncts().ToList();
            List<Expression> contents2 = dis2.GetDisjuncts().ToList();
            if (contents1.Count != contents2.Count)
                return null;

            var subs = new Substitution();

            return contents1.Where((t, i) => Mgu(t, contents2[i], subs) == false).Any() ? null : subs;
        }
Ejemplo n.º 3
0
 private Disjunction RenameOr(Disjunction or, Dictionary<TermVariable, TermVariable> renamings)
 {
     return or.VariablesOrEmpty.Any()
         ? new Disjunction(or.Constituents.Select(t => RenameLiteral(t, renamings)).ToArray())
         : or;
 }
Ejemplo n.º 4
0
 private static Disjunction SubstituteOr(Disjunction or, Substitution theta)
 {
     return or.VariablesOrEmpty.Any()
         ? new Disjunction(or.Constituents.Select(t => SubstituteLiteral(t, theta)).ToArray())
         : or;
 }
Ejemplo n.º 5
0
        private void AskOr(Disjunction or, LinkedList<Expression> goals, KnowledgeBase context, Substitution theta, 
            ProverCache cache, VariableRenamer renamer, bool askOne, HashSet<Substitution> results, HashSet<Fact> alreadyAsking)
        {
            foreach (Expression expression in or.Constituents)
            {
                goals.AddFirst(expression);
                Ask(goals, context, theta, cache, renamer, askOne, results, alreadyAsking);
                goals.RemoveFirst();

                if (askOne && (results.Any()))
                    break;
            }
        }