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 alpha equivalence #12

Merged
merged 39 commits into from
Jun 19, 2024
Merged

Add alpha equivalence #12

merged 39 commits into from
Jun 19, 2024

Conversation

fizruk
Copy link
Owner

@fizruk fizruk commented Jun 18, 2024

This PR contributes two flavours of $\alpha$-equivalence for foil terms:

  1. (alphaEquivRefreshed) First approach is to compare terms after normalizing the binders by renaming each binder to the minimum possible one in the current scope (note that non-minimal binders may occur during substitution).
  2. (alphaEquiv) Second approach is to compare terms directly and only rename binders when they disagree. Moreover, renaming only happens for one of the terms (the one with a bigger binder). This relies on a new function added to the foil, called unifyNameBinders, as well as liftRM, a relative analogue of liftM, instead of using substitute.

The second approach is the cleaned up (yet at the moment less efficient due to liftRM) version of unsafeAeq that we have used in the benchmarks: https://github.com/KarinaTyulebaeva/lambda-n-ways/blob/09a995f9644f6bf29db1803eef004ddd382b823d/lib/FreeScoped/Foil.hs#L336-L401

What remains in this PR:

  • Implement and use alpha equivalence in Language.LambdaPi.Impl.Foil.
  • Derive and use alpha equivalence with TH or GHC.Generics in Language.LambdaPi.Impl.FoilTH.
  • Use alpha equivalence in Language.LambdaPi.Impl.FreeFoil.
  • Add tests for correctness of both approaches.

@fizruk fizruk merged commit 28c20d9 into main Jun 19, 2024
4 checks passed
@fizruk fizruk deleted the alpha-equiv branch June 19, 2024 15:50
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

Successfully merging this pull request may close these issues.

1 participant