Example #1
0

def unary(cls):
    ret = []
    for i in cls.nf().set:
        if len(i.seq) == 1:
            ret.append(i)
    return yes.ClauseSet(tuple(ret))

def cl_as_cut(_, n, m):
    if _ is None:
        _ = [None] * (2*m)
    if n == 0:
        return take(axiom("A"), [_[0], _[2*m-1]])
    else:
        left = _.copy()
        left.insert(0, left.pop(m-1))
        left.insert(m, left.pop(-1))
        right = left.copy()
        left[-1], right[0] = new_C()
        return plus(cl_as_cut(left, n-1, m), cl_as_cut(right, n-1, m))

if __name__ == "__main__":
    import sys

    for i in range(1, 5):
        # print(cl_as_cut([None, "X ", None, None, None], i).nf())
        a = (cl_as_cut(None, i, 2))
        print(a)
        print(yes.resolve3(a.nf()))
Example #2
0
    """
    if n == 0:
        return Resolution.fromString("(.)")
    else:
        return Resolution(Resolution(head(n-1), Resolution.fromString("o"*(n+1)+"(.)")), Resolution.fromString("eo"))


if __name__ == "__main__":
    import sys

    one = yes.clpsi([None, None, None], 1)
    nf = one.nf()
    res1 = yes.Resolve(nf)
    print(res1.coord)
    print(one[res1.coord])
    res2 = yes.resolve3(yes.clpsi([None, None, None], 1).nf())
    res3 = yes.resolve3(yes.clpsi([None, None, None], 2).nf())
    for i in res2.set:
        print(i)
    for i in res3.set:
        print(i)
    print("OK1")

    for n in range(50):
        sys.stdout.write(str(n) + " ")
        sys.stdout.flush()
        cl = yes.clpsi([None, None, None], n)
        cl.nf()
        assert not cl[res(n)].seq
    print("\nOK")