Welcome! Please see the About page for a little more info on how this works.

0 votes
in core.logic by
retagged by

Example:

user> (def tmp {\a 1})
{\a 1}
user> (logic/run* [q] (logic/featurec tmp {\a q}))
(1)
user> (logic/run* [q] (logic/fresh [x] (logic/== x \a) (logic/featurec tmp {x q})))
()

The first logic search is as-expected. The second should return the same results as the first, but it instead fails.

There are tests in core.logic that cover the other mode of featurec under fresh, ie: (logic/featurec {x q} tmp). But this mode, on the other hand, appears to not universally work.

It was recommended I post this here as I am unable to create an account with access to the Jira to file this bug.

2 Answers

0 votes
by
0 votes
by
edited by

featurec cannot have logic variables (ground or not) as keys

as a perquisite for logically dealing with maps with keys that are lvars, you have to be able to deal with sets that contain lvars (not just handling a set data structure, but understanding the logic of sets) and core.logic doesn't have code for that, so it both cannot handle logic on sets (https://clojure.atlassian.net/browse/LOGIC-56 was "fixed" by removing the nascent support core.logic had for sets because it wasn't logically correct) and cannot handle lvars as map keys.

Handling sets is a prereq for handling map keys because keys in a map are a set.

by
This seems to have some confusion with the docs for featurec, which state:

> fs must be partially instantiated - that is,
> it may contain values which are logic variables to support
> feature extraction.

I see the docs explicitly state values. They should probably also state that *keys* cannot be logic variables, to prevent confusion.
by
the docs are not great, and expect you to be very familiar with terms of art around minikanran and logic programming.

if you look at these docs https://cs.union.edu/~striegnk/courses/nlp-with-prolog/html/node84.html#l11.sec.fs.prolog around "feature structure unification" in prolog, you can see they talk about things in terms of improper lists, cons cells where the car is a ground term and the cdr is some logic variable which can be seen as a kind of map if you build an association list of those structures, and that kind of map would have keys that are not lvars but the values can be, which is how you get to core.logic's featurec

I am not super up on logic programming terminology, have not read the reasoned schemer, and do not know the real origin story of core.logic's featurec, but I have spent sometime fiddling with trying to add reasoning over sets to core.logic, so I know for sure it doesn't have it, and I know it is a requirement for general unification over map keys.
...