Skip to content

[ refactor ] make n≢i : n ≢ toℕ i argument to lower₁ irrelevant #2783

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jamesmckinna
Copy link
Contributor

@jamesmckinna jamesmckinna commented Jul 25, 2025

PRs #2725 / #2748 made me rethink whether Data.Fin.Base.lower₁ is fit-for-purpose (as an inverse to inject₁), or could instead be deprecated in favour of the new Data.Fin.Base.lower...

This PR doesn't entirely solve that issue, but does prove the two definitions extensionally equal on their domains, as a consequence, perhaps more importantly, of weakening the type of lower₁ so that its precondition is made irrelevant.

Two (possibly more downstream) knock-on consequences:

  • lemma lower₁-¬0≢0 : ∀ {ℓ} {A : Set ℓ} → .(0 ≢ 0) → A encapsulates a repeated pattern of (¬-recompute) reasoning, which ideally would be made private, but is needed in both Base and Properties... so, reluctantly, has been added; avoided in favour of [ refactor ] weaken type of Relation.Nullary.Negation.Core.contradiction-irr #2785 on which this PR is now blocked.
  • many of the proofs about lower₁ could/should be simplified by delegation to those for lower...?
  • Data.Fin.Base.punchOut and its properties could similarly be weakened by making its i≢j : i ≢ j argument irrelevant! What else might be susceptible to this kind of refactoring?

NB. As observed/observable in README.Data.Fin.Relation.Unary.Top, we can actually avoid having any uses of lower₁ in the library, so deprecation seems possible/desirable?

@@ -561,6 +561,17 @@ lower-injective {n = suc n} zero zero eq = refl
lower-injective {n = suc n} (suc i) (suc j) eq =
cong suc (lower-injective i j (suc-injective eq))

lower₁≗lower : (i : Fin (suc n)) .(n≢i : n ≢ toℕ i)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lemmas feel odd: basically saying lower₁ is the same as lower with 2nd argument an utter mess. Can't that argument be replaced with something much more generic, i.e. because here too we shouldn't care exactly what proof we get of that fact?

Copy link
Contributor Author

@jamesmckinna jamesmckinna Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but we want something that will typecheck with toℕ i < n in a context where all we know is n≢i : n ≢ toℕ i... the fact that the actual form is irrelevant is part of the reason to want dotted hypotheses, but we still have to be able to instantiate them!

Is this an argument in favour of irrelevant instances instead? A more drastic change in the type signature, though...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a way, the two lemmas are really the justification for subsequent deprecation of lower₁, but I held off doing so for now. Happy to be nudged towards that path, though!?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these lemmas are, in a sense, meta-theorems that justify something else, but not really important / useful on their own, then I'd erase them from the library and put them only in the github-level comments for the PR that deprecates lower₁

@jamesmckinna jamesmckinna added the status: blocked-by-issue Progress on this issue or PR is blocked by another issue. label Jul 26, 2025
@jamesmckinna jamesmckinna added this to the v2.4 milestone Jul 26, 2025
Copy link
Contributor

@JacquesCarette JacquesCarette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modulo my comment on whether we even need those extra 2 lemmas, I'm now happy with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: blocked-by-issue Progress on this issue or PR is blocked by another issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants