Ejemplo n.º 1
0
        /// <summary>
        /// Adds a fact to the proof tree.
        /// </summary>
        public static void AddToProofTree(Facts.Fact f)
        {
            // Fact should be added if it is a regular rule that is
            // not already on the tree (to avoid repeats), or if it
            // is an input rule.
            bool addIt = true;
            foreach (ProofTreeNode n in ProofTree)
            {
                Facts.Fact f2 = n.TheFact;
                if (f.Relationship == f2.Relationship && Util.AreEqual(f.Arg1, f2.Arg1) && Util.AreEqual(f.Arg2, f2.Arg2) && Util.AreEqual(f.Arg3, f2.Arg3))
                {
                    addIt = false;
                }
            }

            // Approximates Akkadian function depth
            int depth = new StackTrace().FrameCount;

            // Sometimes the stack trace overestimates the function depth
            // (for example, in Switch() statements).  The following code
            // compensates for this by de-indenting facts so they're not
            // more than one level deeper than their parent level.
            //            int depthOfLastFact = 0;
            //            if (ProofTree.Count > 0) depthOfLastFact = ProofTree[ProofTree.Count-1].Depth;
            //            depth = Math.Min(depth, depthOfLastFact+1);

            if (addIt)
            // TODO: Filter out repeats, etc.
            ProofTree.Add(new ProofTreeNode(f, depth));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// General response constructor.
 /// </summary>
 public Response(bool done, Facts.Fact next, int percent, List<Facts.Fact> goals)
 {
     InvestigationComplete = done;
     NextFact = next;
     PercentComplete = percent;
     Goals = goals;
 }
Ejemplo n.º 3
0
 public ProofTreeNode(Facts.Fact fact, int depth)
 {
     TheFact = fact;
     Depth = depth;
 }