public static Goal AllOne(this KRunner k, object lst) { var d = k.Fresh(); return(k.Any( k.Eq(lst, null), k.All( k.Eq(lst, k.Pair(1, d)), k.Recurse(() => k.AllOne(d))))); }
public static Goal Noto(this KRunner k, params Goal[] gs) { if (gs.Length == 0) { return(k.Succeed); } if (gs.Length == 1) { return(k.If(gs[0], k.Fail, k.Succeed)); } return(k.All(gs.Select(g => k.Noto(g)).ToArray())); }
public static Goal Distincto(this KRunner k, params object[] vs) { if (vs.Length < 2) { return(k.Succeed); } if (vs.Length == 2) { return(k.Noto(k.Eq(vs[0], vs[1]))); } var gs = Enumerable.Empty <Goal>().ToList(); for (var i = 0; i < vs.Length; ++i) { for (var j = i + 1; j < vs.Length; ++j) { gs.Add(k.Noto(k.Eq(vs[i], vs[j]))); } } return(k.All(gs.ToArray())); }