private static Stream MakeStream(Substitution curr, DelayedStream getRest) { return(new Stream() { Curr = curr, GetRest = getRest }); }
public static IList <object> Run(int?n, Func <KRunner, FreshVariable, Goal> body) { var k = new KRunner(); // 定义待求解的未知量q var q = k.Fresh(); // 执行body,得到最终目标g var g = body(k, q); // 初始上下文是一个空替换,应用到g,得到包含可行替换的Stream s var s = g(Substitution.Empty()); // 从s中取出前n个(n==null则取所有)替换,查找各个替换下q的解,并给自由变量换个好看的符号。 return(s.MapAndTake(n, sub => Renumber(sub.Walk(q)))); }
public static Stream Unit(Substitution sub) { return(MakeStream(sub, () => Empty())); }
private Substitution(Substitution p, FreshVariable var, object val) { parent = p; Var = var; Val = val; }