コード例 #1
0
        private static InstantiationPath ExtendPathUpwardsWithInstantiations(InstantiationPath path, IEnumerable <Tuple <Quantifier, Term> > instantiations, Node node)
        {
            if (!instantiations.Any())
            {
                return(path);
            }
            var instantiation = instantiations.First();
            var nodeInst      = (Instantiation)node.UserData;

            if (instantiation.Item1 != nodeInst.Quant || instantiation.Item2 != nodeInst.bindingInfo.fullPattern)
            {
                return(path);
            }
            var extendedPath = new InstantiationPath(path);

            extendedPath.prepend(nodeInst);
            var bestPath = extendedPath;
            var remainingInstantiations = instantiations.Skip(1);

            foreach (var predecessor in node.InEdges)
            {
                var candidatePath = ExtendPathUpwardsWithInstantiations(extendedPath, remainingInstantiations, predecessor.SourceNode);
                if (candidatePath.Length() > bestPath.Length())
                {
                    bestPath = candidatePath;
                }
            }
            return(bestPath);
        }
コード例 #2
0
 private static IEnumerable <InstantiationPath> AllUpPaths(InstantiationPath basePath, Node node, int nodesToGo)
 {
     if (nodesToGo <= 0 || !node.InEdges.Any())
     {
         return(Enumerable.Repeat(basePath, 1));
     }
     return(node.InEdges.SelectMany(e => {
         var copy = new InstantiationPath(basePath);
         copy.prepend((Instantiation)e.SourceNode.UserData);
         return AllUpPaths(copy, e.SourceNode, nodesToGo - 1);
     }));
 }