I have the following code in Clojure (with core.logic):
(db-rel parent x y)
(db-rel go-to-school x y)
(def schools
(db
[parent 'Adam 'Ana]
[parent 'Adam 'Andre]
[parent 'Adam 'Alan]
[parent 'Bernard 'Bia]
[parent 'Bernard 'Beatrice]
[parent 'Carl 'Carlos]
[parent 'Carl 'Connie]
[go-to-school 'School1 'Ana]
[go-to-school 'School1 'Andre]
[go-to-school 'School2 'Alan]
[go-to-school 'School2 'Bia]
[go-to-school 'School2 'Beatrice]
[go-to-school 'School1 'Carlos]
[go-to-school 'School2 'Connie]))
What I want is to find all parents where all the children go to the same school. So, running on the above list, my expected return would be ('Bernard)
, because his two daughters go the "school2", where every other parent have at least one child that will not go to the same school of others.
Is this possible with core.logic? If so, how can I do that?