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

Modular arithmetic based on Data.Nat.Bounded #2257 #2292

Draft
wants to merge 31 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1054d17
sketch of arithmetic mod n, based on `Data.Nat.Bounded`
jamesmckinna Jan 25, 2024
96d851e
`RawRing`, not only `RawSemiring`
jamesmckinna Jan 25, 2024
edfe817
tweaks
jamesmckinna Jan 25, 2024
5808442
streamline the quotient map
jamesmckinna Feb 1, 2024
7fbcb46
start of proving the `IsRing` property
jamesmckinna Feb 1, 2024
a019dbe
rename projections
jamesmckinna Feb 4, 2024
aa7b2bf
more properties
jamesmckinna Feb 5, 2024
9d855cb
progress
jamesmckinna Feb 5, 2024
0c9eed6
shim for `Data.Nat.Bounded`
jamesmckinna Feb 9, 2024
d5bed3a
local change to `Bounded` shim
jamesmckinna Feb 9, 2024
0f9ec78
incremental progress
jamesmckinna Feb 9, 2024
532e3ed
revised to reflect improvements to `ℕ<`
jamesmckinna Feb 10, 2024
e3bf662
remove shim dependency
jamesmckinna Feb 10, 2024
b299856
remove shim dependency
jamesmckinna Feb 10, 2024
8caf9ac
further revised to reflect improvements to `ℕ<`
jamesmckinna Feb 11, 2024
d7447d0
committed `Data.Nat.Bounded.*` against subsequent PR
jamesmckinna Feb 12, 2024
508249f
tweak syntax to distinguish from `Data.Integer.Modulo`
jamesmckinna Feb 12, 2024
cccf3a8
tweaks
jamesmckinna Feb 12, 2024
b51bc24
refactoring `Data.Integer.Modulo.Properties` via revised `Data.Nat.Bo…
jamesmckinna Feb 12, 2024
e235c9a
`nonZeroModulus`
jamesmckinna Feb 12, 2024
4e9921a
using `nonZeroModulus`
jamesmckinna Feb 12, 2024
fbcec66
refactoring
jamesmckinna Feb 12, 2024
6d7e7ac
refactoring lemmas
jamesmckinna Feb 12, 2024
e3d3243
arithmetic `mod n` lemmas
jamesmckinna Feb 12, 2024
692e847
additional arithmetic
jamesmckinna Feb 12, 2024
0f6f0ce
integers `mod n` form a `Ring`
jamesmckinna Feb 12, 2024
8cf05cb
moved `Modulo` to `Modulo.Base`
jamesmckinna Feb 12, 2024
b78f407
knock-on from moving `Modulo` to `Modulo.Base`; `CHANGELOG`
jamesmckinna Feb 12, 2024
aa22e03
Merge branch 'master' into modular-arithmetic
jamesmckinna Feb 12, 2024
4ab04f1
'rebasing' against revised /updated #2257
jamesmckinna Feb 13, 2024
7672022
Merge branch 'agda:master' into modular-arithmetic
jamesmckinna Dec 9, 2024
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
Prev Previous commit
Next Next commit
tweaks
jamesmckinna committed Jan 25, 2024
commit edfe8173b48fad2db556922469d9802b4320d9d1
10 changes: 5 additions & 5 deletions src/Data/Integer/Modulo.agda
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ module Data.Integer.Modulo (n : ℕ) .{{_ : NonTrivial n}} where
open import Algebra.Bundles.Raw
using (RawMagma; RawMonoid; RawNearSemiring; RawSemiring; RawRing)
open import Data.Integer.Base as ℤ using (ℤ; _◂_; signAbs)
open import Data.Nat.Bounded as Bounded hiding (π; module Literals)
open import Data.Nat.Bounded as ℕ< hiding (π; module Literals)
open import Data.Nat.DivMod as ℕ using (_%_)
open import Data.Nat.Properties as ℕ
import Data.Sign.Base as Sign
@@ -51,16 +51,16 @@ infixl 6 _+_

-- Addition
_+_ : ℤmod → ℤmod → ℤmod
i + j = Bounded.π (⟦ i ⟧ ℕ.+ ⟦ j ⟧)
i + j = ℕ<.π (⟦ i ⟧ ℕ.+ ⟦ j ⟧)

-- Multiplication
_*_ : ℤmod → ℤmod → ℤmod
i * j = Bounded.π (⟦ i ⟧ ℕ.* ⟦ j ⟧)
i * j = ℕ<.π (⟦ i ⟧ ℕ.* ⟦ j ⟧)

------------------------------------------------------------------------
-- Projection from ℤ
π : ℤ → ℤmod
π i with s ◂ ∣i∣ ← signAbs i with j ← Bounded.π ∣i∣ | s
π i with s ◂ ∣i∣ ← signAbs i with j ← ℕ<.π ∣i∣ | s
... | Sign.+ = j
... | Sign.- = - j

@@ -100,5 +100,5 @@ module Literals where
Constraint _ = ⊤

fromNat : ∀ m → {{Constraint m}} → ℤmod
fromNat m = Bounded.π m
fromNat m = ℕ<.π m