racklog fails to unify two hash tables
(%which (d) (%= (hash 1 1) (hash 1 d)))
returns '((d . 1)). However,
(%which (d) (%= (hash 1 1) (hash d 1)))
returns #f.
I'll explain why it works this way and we can figure out how to change it.
Hash table unification --- https://github.com/racket/racklog/blob/master/unify.rkt#L492-L504 --- assumes that the only unifiable things are the values, not the keys. That's why the first example works and the second doesn't.
Unifying the keys is hard because if you have something like (%= (hash a b c d) (hash u v x y)) then we have to try (%or (%and (%= a u) (%= c x) ....) (%and (%= a x) (%= c u) ....). I think the correct thing to do would be implement something like:
(%= (? hash? x) (? hash? y) :=
(try-all-permutations (hash->list x)
(lambda (xl)
(try-all-permutations (hash->list y)
(lambda (yl) (%= xl yl)))))
This will be very expensive though, so maybe should only be used if a key is found to be a logic variable.
What do you think?