public static void Print (Goal goal, System.Text.StringBuilder sb) { sb.Append (goal.Definition.Predicate.Name); sb.Append ("("); sb.Append (string.Join(", ", goal.Arguments.Select (new ArgumentPrinter().Print))); sb.Append (")"); }
public Frame (Goal [] goals, Goal parent, BoundVariableSet boundVariables, Dictionary <string, Variable> variables) { this.goals = goals; this.boundVariables = boundVariables; this.HeadGoal = parent; this.variables = new Variables(variables); foreach (var goal in goals) { goal.Frame = this; } }
private void RaiseFailed (Goal goal) { if (Failed != null) { Failed (goal); } }
private void RaiseUnified (Goal goal) { if (Unified != null) { Unified (goal); } }
static bool AreEqual(Goal goal1, Goal goal2) { return(goal1.Definition.Predicate == goal2.Definition.Predicate && goal1.Arguments.Zip(goal2.Arguments, AreEqual).All(x => x)); }
static bool AreEqual (Goal goal1, Goal goal2) { return goal1.Definition.Predicate == goal2.Definition.Predicate && goal1.Arguments.Zip (goal2.Arguments, AreEqual).All(x => x); }
static bool IsEmptyDcgGoal (Goal goal) { var arguments = goal.Arguments; return arguments.Length >= 2 && arguments [arguments.Length-1] is List && arguments [arguments.Length-2] is List; }
static bool AlreadyOnTheStack (Goal goal) { int count = goal.Frame.ParentFrames .Where (f => f.GoalsProven < f.Goals.Length) .Select (f => f.Goals [f.GoalsProven]) .Count (g => AreEqual (g, goal)); bool alreadyOnTheStack = count > 0; if (alreadyOnTheStack) { } return alreadyOnTheStack; }
private void PrintGoal (string eventName, Goal goal) { sb.Append (eventName); sb.Append (new string (' ', goal.Level * 4)); SolutionTreePrinter.Print (goal, sb); sb.AppendLine (); }