public static Goal Membero(this KRunner k, object x, object l) { var d = k.Fresh(); return(k.Any( k.Lhso(l, x), k.All( k.Rhso(l, d), k.Recurse(() => Membero(k, x, d))))); }
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 Goal Lhso(this KRunner k, object l, object a) { var d = k.Fresh(); return(k.Eq(k.Pair(a, d), l)); }