Agda-stdlib: Small change to inject≤

Created on 30 Mar 2019  Â·  8Comments  Â·  Source: agda/agda-stdlib

inject≤ : ∀ {m n} → Fin m → m ℕ.≤ n → Fin n
inject≤ {n = zero} zero ()
inject≤ {n = suc n} zero le = zero
inject≤ (suc i) (s≤s le) = suc (inject≤ i le)

https://agda.github.io/agda-stdlib/Data.Fin.Base.html#3219

This way, we avoid to need to pattern match on le , which can be hard to do on a proof, we would need to abstact over le so as to pattern match.

enhancement question

Most helpful comment

Note that with 2.6.0 we should be able to leave out the impossible cases.

All 8 comments

You could also use ≤-pred in the suc i case.

Yes, it is much better now :

inject≤ : ∀ {m n} → Fin m → m ℕ.≤ n → Fin n
inject≤ {n = zero} zero ()
inject≤ {n = suc n} zero le = zero
inject≤ {n = zero} (suc i) ()
inject≤ {n = suc n} (suc i) le = suc (inject≤ i (≤-pred le))

Sounds good.

Note that with 2.6.0 we should be able to leave out the impossible cases.

The same can be done to fromℕ≤ .
I can upload the changes now, or later after 2.6.0

Probably best to wait until after 2.6.0 and I reset the CHANGELOG

I think this should wait until 2.6.0.1 is out, see https://github.com/agda/agda/issues/3692. ;)

Fixed with 1690f69

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MatthewDaggitt picture MatthewDaggitt  Â·  5Comments

langston-barrett picture langston-barrett  Â·  7Comments

masaeedu picture masaeedu  Â·  5Comments

mechvel picture mechvel  Â·  4Comments

oisdk picture oisdk  Â·  7Comments