Skip to content

Make orderings on Nat and Int definitional propositions#597

Open
TOTBWF wants to merge 27 commits intomainfrom
nat-order
Open

Make orderings on Nat and Int definitional propositions#597
TOTBWF wants to merge 27 commits intomainfrom
nat-order

Conversation

@TOTBWF
Copy link
Collaborator

@TOTBWF TOTBWF commented Feb 26, 2026

Description

This PR replaces the inductive definitions of _≤_ and _<_ on Nat and Int with So applied to a decision procedure, and makes the single field of So irrelevant. When taken together, these changes make the orderings definitional propositions, which allows us to remove the Irr wrapper on Fin.

Checklist

Before submitting a merge request, please check the items below:

  • I've read the contributing guidelines.
  • The imports of new modules have been sorted with support/sort-imports.hs (or nix run --experimental-features nix-command -f . sort-imports).
  • All new code blocks have "agda" as their language.

If your change affects many files without adding substantial content, and
you don't want your name to appear on those pages (for example, treewide
refactorings or reformattings), start the commit message and PR title with chore:.

This makes a lot of inductive arguments easier
Now that lower < n is a definitional proposition,
we don't need to worry about irrelevance here
This file typechecks, but I suspect that there is an Agda bug lurking
in the shaddows. If you try to typecheck Homotopy.Truncation, a call
to elim! throws the following error:

> Projection  _≤_.is-leq  is irrelevant.
> Turn on option --irrelevant-projections to use it (unsafe)
> when checking that the expression ._≤_.is-leq (Leq-refl {n}) has
> type Data.Bool.Base.is-true (suc (suc n) ≤? suc (suc n))

This seems to trigger when resolving the 'Inductive' instance using
Inductive-n-Tr, which has the type

> Inductive-n-Tr
>   : ∀ {ℓ ℓ' ℓm} {A : Type ℓ} {n} {P : n-Tr A (suc n) → Type ℓ'} ⦃ i : Inductive (∀ x → P (inc x)) ℓm ⦄
>   → ⦃ _ : ∀ {x} → H-Level (P x) (suc n) ⦄
>   → Inductive (∀ x → P x) ℓm

Moreover, the problematic elim! is eliminating into the universe of
n-Types, which require us to use a hlevel-projection, so I think that
some sequence of events is causing the proof Leq-refl {n} to get
η-expanded to a (bogus) irrelevant projection, which then gets
re-checked by reflection, which then (rightfully) complains.
This seems to solve the issues with Homotopy.Truncation
@TOTBWF TOTBWF requested a review from plt-amy February 26, 2026 19:24
@Lavenza
Copy link
Member

Lavenza commented Feb 26, 2026

Pull request preview

Changed pages

@TOTBWF
Copy link
Collaborator Author

TOTBWF commented Feb 26, 2026

Hmmm, looks like we can't remove irrelevancy annotations on some Positive instances: we should probably re-work this code so that it's a bit less janky.

Copy link
Member

@plt-amy plt-amy left a comment

Choose a reason for hiding this comment

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

bwah i do not want to write a review go away

Co-authored-by: Amélia Liao <me@amelia.how>
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