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

Added Z mod n as Fin #2073

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ Additions to existing modules
pred-cancel-≡ : pred m ≡ pred n → ((m ≡ 0 × n ≡ 1) ⊎ (m ≡ 1 × n ≡ 0)) ⊎ m ≡ n
```

* In `Data.Fin.Properties`:
* In `Data.Fin.Base`:
```agda
zeroFromNonZero : .⦃ NonZero n ⦄ → Fin n
zero⁺ : .⦃ NonZero n ⦄ → Fin n
jamesmckinna marked this conversation as resolved.
Show resolved Hide resolved
```

* In `Data.Fin.Mod`:
Expand Down
5 changes: 5 additions & 0 deletions src/Data/Fin/Base.agda
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ data Fin : ℕ → Set where
zero : Fin (suc n)
suc : (i : Fin n) → Fin (suc n)

-- Homogeneous Constructors

zero⁺ : .⦃ _ : ℕ.NonZero n ⦄ → Fin n
zero⁺ {n = suc _} = zero

-- A conversion: toℕ "i" = i.

toℕ : Fin n → ℕ
Expand Down
4 changes: 2 additions & 2 deletions src/Data/Fin/Mod/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ sucMod-predMod (suc i) = sucMod-inject₁ i
------------------------------------------------------------------------
-- _+_

+-identityˡ : .{{ _ : NonZero n }} → LeftIdentity zeroFromNonZero _+_
+-identityˡ : .{{ _ : NonZero n }} → LeftIdentity zero⁺ _+_
+-identityˡ {suc n} i rewrite +ℕ-identityʳ {m = toℕ i} {n} _ = fromℕ<-toℕ _ (toℕ≤pred[n] _)

+-identityʳ : .{{ _ : NonZero n }} → RightIdentity zeroFromNonZero _+_
+-identityʳ : .{{ _ : NonZero n }} → RightIdentity zero⁺ _+_
+-identityʳ {suc _} _ = refl
3 changes: 0 additions & 3 deletions src/Data/Fin/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ private
nonZeroIndex : Fin n → ℕ.NonZero n
nonZeroIndex {n = suc _} _ = _

zeroFromNonZero : .⦃ _ : ℕ.NonZero n ⦄ → Fin n
zeroFromNonZero {n = suc _} = zero

------------------------------------------------------------------------
-- Bundles

Expand Down