kanren icon indicating copy to clipboard operation
kanren copied to clipboard

Add a `condp` implementation

Open brandonwillard opened this issue 2 years ago • 1 comments

This PR provides an implementation of “A Surprisingly Competitive Conditional Operator”.

As I mentioned in this comment, there's an interesting avenue to explore regarding cross-cond-branch states, and I've included an example via the relation condpseq.

Currently, condpseq sequentially overwrites the state (i.e. substitutions dictionary) as it goes through the cond branches in order, and passes that state along to the branch-specific suggestion functions.

It might be better to provide the separate branch-specific states to the suggestion functions. For instance, a branch suggestion function could be given a map of branch-labels to variables reified according the the state produced by each branch. That opens up other considerations, though.

In the aforementioned scenario, how do we provide those branch-reifications across branches without evaluating every branch? Do we sequentially process and use the branch suggestions and return None for skipped branch entries in the suggestion function branch-map argument? Some sort of topo-sort on branch suggestion function requirements (e.g. evaluate the first and third branch before the second, because its suggestion function requests the latter two reifications)?

Also, it would be good to understand how cross-branch state suggestions affect relational properties, especially since it seems like condpseq could be used to implement conda and condu.

brandonwillard avatar Jun 11 '22 13:06 brandonwillard

This needs more/better tests before merging. It's still just a quick port of my old logpy PR.

brandonwillard avatar Jun 11 '22 15:06 brandonwillard