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

Lift complex expression that don't use the lambda-bound variables out of the lambdas #3028

Open
lukaszcz opened this issue Sep 13, 2024 · 0 comments · May be fixed by #3195
Open

Lift complex expression that don't use the lambda-bound variables out of the lambdas #3028

lukaszcz opened this issue Sep 13, 2024 · 0 comments · May be fixed by #3195
Assignees
Labels
core Related to JuvixCore enhancement New feature or request optimization pending-review
Milestone

Comments

@lukaszcz
Copy link
Collaborator

lukaszcz commented Sep 13, 2024

I've noticed that people often write things like

all (x in X) {f x (doSomethingComplex Y)}

Instead of trying to convince people that they should always lift the complex computation on Y out of the loop, it's not so difficult to do it automatically.

This would need to be an optimization performed before lambda-lifiting. It would identify maximial non-immediate subexpressions in the lambda-body which don't contain the lambda-bound variables and lift them out.

Since the above is syntactic sugar for:

all \{x := f x (doSomethingComplex Y)} X

the transformation would optimize it to

all (let y := doSomethingComplex Y in \{x := f x y}) X

In the optimized version, doSomethingComplex is performed only once before passing the lambda-function to all.

@lukaszcz lukaszcz added enhancement New feature or request pending-review core Related to JuvixCore optimization labels Sep 13, 2024
@lukaszcz lukaszcz added this to the 0.6.7 milestone Sep 13, 2024
@lukaszcz lukaszcz self-assigned this Sep 13, 2024
@lukaszcz lukaszcz changed the title Lift complex expression that don't use the lambda-bound variable out of the lambdas Lift complex expression that don't use the lambda-bound variables out of the lambdas Sep 13, 2024
@lukaszcz lukaszcz modified the milestones: 0.6.7, 0.6.8 Sep 17, 2024
@paulcadman paulcadman modified the milestones: 0.6.8, 0.6.9 Nov 11, 2024
@lukaszcz lukaszcz linked a pull request Nov 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to JuvixCore enhancement New feature or request optimization pending-review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants