Attempting to use Logic to solve the following in python:
from kanren import run, eq, membero, var, conde
from kanren.constraints import neq, isinstanceo
rules = (eq, (var(), var(), var(), var()), people),
(membero, (4, x, ('Steve' , var() , 'blue' , var() ), people)),
(membero, (4, x, ( var() , 'cat' , var() , 'Canada' ), people)),
(membero, (4, x, ('Matthew', var() , var() , 'USA' ), people)),
(membero, (4, x, ( var() , var() , 'black', 'Australia'), people)),
(membero, (4, x, ('Jack' , 'cat' , var() , var() ), people)),
(membero, (4, x, ('Alfred' , var() , var() , 'Australia'), people)),
(membero, (4, x, ( var() , 'dog' , var() , 'France' ), people)),
(membero, (4, x, ( var() , 'rabbit', var() , var() ), people))
results in:
(<function kanren.goals.membero(x, ls)>,
(4, ~_2, (~_2422, 'rabbit', ~_2423, ~_2424), ~_809))
which keeps me from running
solutions = run(0, people, rules)
Can you help me with a solution?
Thank you.
Not sure what version of
kanrenyou were using but it sure doesn't work that way under the latest one. This seemed to produce the result:It results in many solutions, but I think they're just permutations of each other. Maybe it can be made tighter like this:
This still resulted in two solutions, both of which look identical to me.
Of course, only mentioning three animals and two colors, that's all you're gonna get.
I can see where you might have gotten the syntax in the original question: was it perhaps here? I wish I could get that puzzle going, but nothing I do works for it...
Update
Had a very helpful exchange with the developers at
kanren. Check it out