Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a condp implementation #48

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

brandonwillard
Copy link
Member

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 brandonwillard added enhancement New feature or request stream processing Operations related to (goal) stream processing new goal This issue implies the creation of a new goal (constructor) labels Jun 11, 2022
@brandonwillard brandonwillard self-assigned this Jun 11, 2022
@brandonwillard
Copy link
Member Author

brandonwillard commented Jun 11, 2022

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

@brandonwillard brandonwillard mentioned this pull request Jun 11, 2022
kanren/condp.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new goal This issue implies the creation of a new goal (constructor) stream processing Operations related to (goal) stream processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants