コード例 #1
0
 IEnumerable <CutState> Prover(Structure goal)
 {
     if (goal == null)
     {
         return(CutStateSequencer.Succeed());
     }
     return(context.Prove(goal));
 }
コード例 #2
0
 /// <summary>
 /// Attempts to prove all woken goals, in the order they were woken.
 ///
 /// </summary>
 internal IEnumerable <CutState> ProveAllWokenGoals()
 {
     if (this.wokenStack == null || this.wokenStack.Count == 0)
     {
         return(CutStateSequencer.Succeed());
     }
     WokenGoal[] goals = wokenStack.ToArray();
     wokenStack.Clear();
     return(ProveWokenGoalsInternal(goals, 0));
 }
コード例 #3
0
ファイル: ELProlog.cs プロジェクト: mantoun/MKULTRA
 internal static System.Collections.Generic.IEnumerable<CutState> Retract(object term, PrologContext context)
 {
     ELNode foundNode;
     ELNodeEnumerator enumerator;
     if (!TryQuery(term, context, out foundNode, out enumerator))
         return CutStateSequencer.Fail();
     if (foundNode != null)
     {
         foundNode.DeleteSelf();
         return CutStateSequencer.Succeed();
     }
     return DeleteSuccessive(enumerator);
 }
コード例 #4
0
ファイル: ELProlog.cs プロジェクト: rzubek/UnityProlog
        internal static IEnumerable <CutState> Retract(object term, PrologContext context)
        {
            ELNode           foundNode;
            ELNodeEnumerator enumerator;

            if (!TryQuery(term, context, out foundNode, out enumerator))
            {
                return(CutStateSequencer.Fail());
            }
            if (foundNode != null)
            {
                foundNode.DeleteSelf();
                return(CutStateSequencer.Succeed());
            }
            return(DeleteSuccessive(enumerator));
        }
コード例 #5
0
        internal static IEnumerable <CutState> SetImplementation(object[] args, PrologContext context)
        {
            if (args.Length != 2)
            {
                throw new ArgumentCountException("set", args, new object[] { "Variable", "NewValue" });
            }

            object value = Term.CopyInstantiation(args[1]);

            if (value is LogicVariable)
            {
                throw new UninstantiatedVariableException((LogicVariable)args[1], "Value argument should be a data object, not an uninstantiated (unbound) variable.");
            }
            var functor = Term.Deref(args[0]) as Symbol;

            if (functor == null)
            {
                throw new ArgumentTypeException("set", "functor", args[0], typeof(Symbol));
            }

            List <KnowledgeBaseEntry> entries = context.KnowledgeBase.EntryListForStoring(new PredicateIndicator(functor, 1));

            switch (entries.Count)
            {
            case 0:
                entries.Add(new KnowledgeBaseVariable(value));
                return(CutStateSequencer.Succeed());

            case 1:
                var v = entries[0] as KnowledgeBaseVariable;
                if (v == null)
                {
                    throw new ArgumentException("Functor is not a variable; it has another entry defined for it.");
                }
                v.CurrentValue = value;
                return(CutStateSequencer.Succeed());

            default:
                throw new ArgumentException("Functor is not a variable; it has multiple entries defined for it.");
            }
        }