Esempio n. 1
0
def test_disj_x_never():
    x = variables("x")
    goal = disj(same("olive", x), never)
    s_inf = goal(Substitution())
    assert next(s_inf) == Substitution({x: "olive"})
    s_inf = assert_suspended(s_inf)
    s_inf = assert_suspended(s_inf)
Esempio n. 2
0
def test_disj():
    x = variables("x")
    goal = disj(same("olive", x), same("oil", x))
    assert set(goal(Substitution())) == {
        Substitution({x: "olive"}),
        Substitution({x: "oil"})
    }
Esempio n. 3
0
def test_ifte_disj():
    x, y = variables("x, y")
    goal = ifte(disj(same(True, x), same(False, x)), same(False, y),
                same(True, y))
    assert list(goal(Substitution())) == [
        Substitution({
            x: True,
            y: False
        }),
        Substitution({
            x: False,
            y: False
        })
    ]
Esempio n. 4
0
def test_reify_run_goal_inf():
    x = variables("x")
    goal = disj(same("olive", x), same("oil", x))
    results = map(reify(x), run_goal(goal))
    assert list(results) == ['olive', 'oil']
Esempio n. 5
0
def test_reify_some():
    x = variables("x")
    goal = disj(same("olive", x), same("oil", x))
    subs = take(5, goal(Substitution()))
    results = map(reify(x), subs)
    assert list(results) == ['olive', 'oil']
Esempio n. 6
0
 def teacupo(t):
     return disj(same('tea', t), same('cup', t))
Esempio n. 7
0
 def listo(l):
     return disj(nullo(l), fresh(lambda d: (cdro(l, d), listo(d))))