Prove() private method

Attempts to prove the specified goal.
private Prove ( Symbol functor, object args, PrologContext context, ushort parentFrame ) : IEnumerable
functor Symbol
args object
context PrologContext
parentFrame ushort
return IEnumerable
Beispiel #1
0
 /// <summary>
 /// Resets the context (clears stack, etc.) and starts a proof of the specified goal.
 /// </summary>
 /// <param name="goal">Goal to attempt to prove</param>
 /// <returns>Enumerator for solutions</returns>
 public IEnumerable <bool> ResetStackAndProve(Structure goal)
 {
     Reset(this.This);
     foreach (var state in KnowledgeBase.Prove(goal.Functor, goal.Arguments, this, 0))
     {
         if (state == CutState.ForceFail)
         {
             yield break;
         }
         else
         {
             yield return(false);
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// Resets the context (clears stack, etc.) and starts a proof of the specified goal.
        /// </summary>
        /// <param name="goal">Goal to attempt to prove</param>
        /// <returns>Enumerator for solutions</returns>
        public IEnumerable <bool> ResetStackAndProve(object goal)
        {
            Reset(this.This);
            Structure s = Term.Structurify(goal, "Invalid goal.");

            foreach (var state in KnowledgeBase.Prove(s.Functor, s.Arguments, this, 0))
            {
                if (state == CutState.ForceFail)
                {
                    yield break;
                }
                else
                {
                    yield return(false);
                }
            }
        }
Beispiel #3
0
 private static IEnumerable<CutState> RandomizeInternal(KnowledgeBase kb, PrologContext context, Structure t)
 {
     bool savedRandomize = context.Randomize;
     context.Randomize = true;
     foreach (var state in kb.Prove(t.Functor, t.Arguments, context, context.CurrentFrame))
         if (state==CutState.ForceFail)
             yield break;
         else
             yield return state;
     context.Randomize = savedRandomize;
 }
Beispiel #4
0
        /// <summary>
        /// Proves the specified goal, throwing an exception with badGoalErrorMessage if the goal is ill-formed.
        /// </summary>
        internal IEnumerable <CutState> Prove(object goal, string badGoalErrorMessage)
        {
            Structure s = Term.Structurify(goal, badGoalErrorMessage);

            return(KnowledgeBase.Prove(s.Functor, s.Arguments, this, CurrentFrame));
        }
Beispiel #5
0
 /// <summary>
 /// Proves the goal in the specified structure.
 /// </summary>
 internal IEnumerable <CutState> Prove(Structure goal)
 {
     return(KnowledgeBase.Prove(goal.Functor, goal.Arguments, this, CurrentFrame));
 }