# Racklog find duplicates

Racklog it's driving me crazy. I don't know why, but it keeps finding duplicate values. I'm not sure if that library even works, since "%not" procedure does some weird stuff sometimes, or it is me who just can't use it properly.

I have a tree, where each node has an unique integer value from 1 to 9. I'm trying to find Lowest Common Ancestor of x and y, where value(x) < value(y).

By the way, I'm trying to avoid using "%or" and "%and", because in my previous codes they seemed to create duplicates. That is why I made some probably unnecessary predicates.

```
#lang racket
(require racklog)
(define %parent
(%rel ()
[('1 '2)]
[('1 '4)]
[('1 '8)]
[('2 '3)]
[('2 '9)]
[('3 '5)]
[('5 '6)]
[('5 '7)]))
(define %ancestor
(%rel (x y z)
[(x y) (%parent x y)]
[(x z) (%parent x y) (%ancestor y z)]))
(define %ancestororme
(%rel (x y z)
[(x x)]
[(x y) (%parent x y)]
[(x z) (%parent x y) (%ancestororme y z)]))
(define %sibling
(%rel (x y z)
[(x y)
(%parent z x)
(%parent z y)
(%/== x y)]))
(define %notancestor
(%rel (x y z z2)
[(x y) (%ancestororme z x)
(%ancestororme z2 y)
(%sibling z z2)]))
(define %LCA ;;LCA - Lowest Common Ancestor, LCA(x, y) =/= x and LCA(x, y) =/= y, x < y
(%rel (x y slca0 slca1 lca)
[(x y lca)
(%notancestor x y) ;;LCA(x, y) =/= x
(%notancestor y x) ;;LCA(x, y) =/= y
(%< x y)
(%parent lca slca0)
(%parent lca slca1)
(%/== slca0 slca1)
(%ancestororme slca0 x)
(%ancestororme slca1 y)]))
(map (lambda (x) (list (cdr (first x)) (cdr (second x)) (cdr (third x)))) (%find-all (x y z) (%LCA x y z)))
```

So, the result is kinda correct, for each returned triple (a b c) LCA(a, b) = c. There is only one possibility of LCA(x, y), and since x < y it can't choose same x and y more than once. Yet, it still returns duplicates (eg. (2, 4, 1) appears four times).

Obviously I can use delete-duplicates function, but I don't think it should behave that way.