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

[ new ] Quantity for proof in with-clauses #3415

Merged
merged 5 commits into from
Dec 18, 2024

Conversation

spcfox
Copy link
Contributor

@spcfox spcfox commented Nov 18, 2024

Description

Currently the quantity of proof in with-clause is the same as the quantity of expression. But often proofs are needed only at compile time. Example:

filterSquared : (p : a -> Bool) -> (xs : List a) ->
                filter p (filter p xs) === filter p xs
filterSquared p [] = Refl
filterSquared p (x :: xs) with (p x) proof 0 eq
  filterSquared p (x :: xs) | False = filterSquared p xs
  filterSquared p (x :: xs) | True
    = rewrite eq in cong (x ::) (filterSquared p xs)

So I suggest adding the ability to separately specify quantities for proofs.

Note that prf is currently erased in the following code, but in this version it will now be unrestricted, as will all variables for which multiplicity is not explicitly specified. This may affect existing code and probably requires discussion.

foo x with 0 (x) proof prf

Should this change go in the CHANGELOG?

  • If this is a fix, user-facing change, a compiler change, or a new paper
    implementation, I have updated CHANGELOG_NEXT.md (and potentially also
    CONTRIBUTORS.md).

@spcfox spcfox force-pushed the with-proof-multiplicity branch from c407589 to ba57b5b Compare November 18, 2024 13:18
src/Idris/REPL.idr Outdated Show resolved Hide resolved
@spcfox
Copy link
Contributor Author

spcfox commented Dec 9, 2024

This PR is ready to review.
I made a PR stefan-hoeck/idris2-elab-util#79 in elab-util to fix a build issue. pack and lsp build without problems, but I also made a PR idris-community/idris2-lsp#234 in lsp that fixes pretty printing.

@spcfox spcfox force-pushed the with-proof-multiplicity branch from 8731e10 to eda38fc Compare December 9, 2024 12:37
@gallais
Copy link
Member

gallais commented Dec 17, 2024

Happy to merge once the build is successful.

@buzden
Copy link
Contributor

buzden commented Dec 17, 2024

We can merge both downstream PRs, but this pack job is harder, since we need newer elab-util AND this PR to be merged in order to have new successfully building pack collection for that. I propose this PR #3446 in order to not to require this. After that PR we can merge downstreams and then all three failing CI jobs from this PR should pass.

buzden pushed a commit to idris-community/idris2-lsp that referenced this pull request Dec 18, 2024
buzden pushed a commit to stefan-hoeck/idris2-elab-util that referenced this pull request Dec 18, 2024
@spcfox spcfox force-pushed the with-proof-multiplicity branch from eda38fc to afea968 Compare December 18, 2024 11:47
@gallais gallais merged commit 457ca7c into idris-lang:main Dec 18, 2024
22 checks passed
andrevidela pushed a commit to andrevidela/Idris2 that referenced this pull request Dec 29, 2024
* [ new ] Quantity for proof in with-clauses

* [ test ] Add failing tests for quantities of proofs

* [ cleanup ] Match on pairs

* [ test ] Add test for 0 proof in elaborator script

* [ cleanup ] Use `So` and `All` from base in tests
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.

3 participants