2

I am using the LogPy implementation of minikanren.

I have some facts about marriages.

from logpy import *
marriedo=Relation()
fact(marriedo,"Bob", "Jane")
fact(marriedo,"Greg", "Anne")
fact(marriedo,"Bob", "Susan")

I can find out someones wife by using the "user level" run function

wife = var()
run(1, wife, (marriedo, "Bob", wife))
>('Jane')
run(0, wife, (marriedo, "Bob", wife))
>('Jane', 'Susan')

But calling run escapes me from the logic programming world, so its not reversible.

Never the less, I thought I could detect bigamist by doing:

wives = var()
wife = var()
husband = var()
run(1, husband, arith.gt(len(run(0,wife,(marriedo, husband, wife))),1))

But that outputs something like (~_105,) the number changes each time I run it. It is not "Bob".

In Prolog, I believe the key tools in doing this would be findall/bagof/setoff.

I see some speculation about these in minikanren but nothing concrete.

Frames Catherine White
  • 27,368
  • 21
  • 87
  • 137
  • This isn't a full answer, but maybe you could do something like `run(0, (wife1, wife2), marriedo(husband, wife1), marriedo(husband, wife2))`. I'm not sure how but you could probably add something so that wife1 and wife2 were not the same wife... – Robert Hickman Sep 05 '19 at 20:45

0 Answers0