Skip to content

Commit

Permalink
Some recursive Fin functions (#1077)
Browse files Browse the repository at this point in the history
Found myself needing these when using these as variables in well-scoped
lambda terms.
  • Loading branch information
dolio authored Nov 9, 2023
1 parent f8d6fcf commit 4de6b69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Cubical/Data/Fin/Recursive/Base.agda
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ elim
(fn : Fin k) P fn
elim {k = suc k} P fz fs zero = fz
elim {k = suc k} P fz fs (suc x) = fs x (elim P fz fs x)

toℕ : Fin k
toℕ {suc k} zero = zero
toℕ {suc k} (suc n) = suc (toℕ n)
4 changes: 4 additions & 0 deletions Cubical/Data/Fin/Recursive/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ toFin : (n : ℕ) → Fin (suc n)
toFin zero = zero
toFin (suc n) = suc (toFin n)

toFin< : (m : ℕ) m < n Fin n
toFin< {suc n} zero 0<sn = zero
toFin< {suc n} (suc m) m<n = suc (toFin< m m<n)

inject<#toFin : (i : Fin n) inject< (≤-refl (suc n)) i # toFin n
inject<#toFin {suc n} zero = _
inject<#toFin {suc n} (suc i) = inject<#toFin {n} i
Expand Down

0 comments on commit 4de6b69

Please sign in to comment.