Skip to content

apply-reduction-relation* insensitive to alpha-equivalence #96

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

Closed
howell opened this issue May 9, 2017 · 13 comments
Closed

apply-reduction-relation* insensitive to alpha-equivalence #96

howell opened this issue May 9, 2017 · 13 comments

Comments

@howell
Copy link
Contributor

howell commented May 9, 2017

I'm working on a model that makes use of Redex's binding forms support (which has been great). However, I ran into something unexpected today: apply-reduction-relation* returned a list of 16 terms, all of which were alpha-equivalent? to one another.

This was even more surprising given that I had looked at the traces output for reducing the term in question which had merged alpha-equivalent terms.

Using this previous commit as a template, I was able to get apply-reduction-relation* behaving the way I expected for my language by using the equivalence and hash constructs from binding-forms.rkt (see here).

(It has occurred to me that maybe this is the desired behavior for apply-reduction-relation*, though I'm not sure why that would be; I would be interested to hear)

@howell
Copy link
Contributor Author

howell commented May 23, 2017

any thoughts on this?

I don't think I made this clear in my initial report, but I patched my local version of Redex to consider alpha-equivalence in apply-reduction-relation* (see here) which I'd be happy to submit as a PR if that is indeed the desired behavior.

@paulstansifer
Copy link
Collaborator

paulstansifer commented May 23, 2017 via email

@rfindler
Copy link
Member

rfindler commented May 23, 2017 via email

@paulstansifer
Copy link
Collaborator

paulstansifer commented May 23, 2017 via email

@howell
Copy link
Contributor Author

howell commented May 24, 2017

There is make-α-hash in binding-forms.rkt which I missed on my first go around. I can update my patch to use make-α-hash (as well as the code that I copied went off of implementing the same functionality for traces).

I have one bit of uncertainty with making this change, though. The loop inside traverse-reduction-graph uses a path variable for an immutable hash that needs to use alpha-equivalence. I can either convert it to a mutable hash using make-α-hash, or add a make-immutable-α-hash function and use that instead.

I'm uncertain about which way to go because there is a comment suggesting this path variable has been the subject of performance tuning and I want to be careful where I tread in that regard!

@rfindler
Copy link
Member

I think we need a make-immutable-α-hash function. Thanks for helping out with this!

howell added a commit to howell/redex that referenced this issue May 25, 2017
Also add an immutable alpha hash constructor and update hashes in
the gui to use the form provided by binding-forms.rkt

Fixes racket#96
@wilbowma
Copy link
Collaborator

Are this and #102 closed by 24f0c5c?

@rfindler
Copy link
Member

Oh, rats! I totally forgot about this and just changed only one part of the problem! I'm sorry about that.

So, no, they aren't closed, because I changed only the one for that specific bug.

Looking at the diff, I think that the fixes to traces and stepper are still needed. But test cases are also needed.

Shall I do that?

And where do we stand with the performance issues? I am guessing that there is not much to be helped there. We knew that alpha stuff would slow various things down, but I can try to investigate if there is a specific file that's problematically slower.

@wilbowma
Copy link
Collaborator

For apply-reduction-relation*, it actually improves performance in my experience. So I don't see any reason to not merge #102, other than the minor issue of using the depricated interface.

#103 is my attempt to make similar changes to judgment forms and metafunctions, but it really hurts performance.

@rfindler
Copy link
Member

rfindler commented Aug 9, 2018

@howell do you have the example (or one like it) that returned too many things so I can add it to the test suites?

@howell
Copy link
Contributor Author

howell commented Aug 24, 2018

I wasn't able to reproduce the errors I was getting in the model I was working on at the time. I had to remove some binding directives to be able to run the model, which may be related.

The directive

(facet X A ([D S #:refers-to (shadow D X)] ...))

now produces an error message

define-language: found the same binder, X, at different depths, 1 and 0

Redex used to accept this directive, and as far as I could tell interpreted it the way I intended.

@wilbowma
Copy link
Collaborator

Think this should have been closed by #102

@rfindler
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants