Skip to content

Modular arithmetic in terms of ideals #2729

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

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

Taneb
Copy link
Member

@Taneb Taneb commented Jun 7, 2025

Opening this PR to share my WIP. I've got a messy proof of the Chinese remainder theorem for arbitrary rings, but in porting it from my standalone library to this I've somehow made some parameters not infer properly

@Taneb Taneb force-pushed the modular-arithmetic branch from 8617e07 to 94cefa6 Compare June 8, 2025 11:04
Copy link
Contributor

@JacquesCarette JacquesCarette left a comment

Choose a reason for hiding this comment

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

The new Kernel file looks nice.

@JacquesCarette
Copy link
Contributor

Would you want some help to get this further along?

@Taneb
Copy link
Member Author

Taneb commented Jul 30, 2025

Yes, actually. I've been working on a module for the special case of ideals of the ring of integers, and I've been struggling to prove that (for a non-zero modulus) it's finite, which I think it important for the "yes this is modular arithmetic as you know it" feel. I'll post a WIP commit shortly

@JacquesCarette
Copy link
Contributor

Ok, once my students make further progress on the ones they are currently working on, I'll get them to look at this.

@jamesmckinna
Copy link
Contributor

And, ... having murdered my darlings #2257 #2292 I should turn my attention to helping with this!

@jamesmckinna
Copy link
Contributor

jamesmckinna commented Aug 3, 2025

Some errors thrown up by checking with agda-v2.8.0 (beyond the failing tests above):

  • Data.Fin.Properties on this branch still has the now-erroneous --warn=noUserWarning which should be fixed after a rebase/merge with the current master?
  • Data.Integer.Properties now triggers a warning about a null rewrite step on L1417 (which I hadn't seen caught anywhere else? but the offending line doesn't appear any more on master, so...)

@Taneb
Copy link
Member Author

Taneb commented Aug 3, 2025

@jamesmckinna I've merged in master, are those two errors fixed now?

ι : RawGroup.Carrier N → Carrier
ι-monomorphism : IsGroupMonomorphism N rawGroup ι
-- every element of N commutes in G
normal : ∀ n g → ∃[ n′ ] g ∙ ι n ∙ g ⁻¹ ≈ ι n′
Copy link
Contributor

Choose a reason for hiding this comment

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

So... I was a bit surprised that this was an 'easier' formulation than

Suggested change
normal : n g ∃[ n′ ] g ∙ ι n ∙ g ⁻¹ ≈ ι n′
normal : n g ∃[ n′ ] g ∙ ι n ≈ ι n′ ∙ g

which I wondered as to whether

  • it would be easier/smoother to show gives rise to an equivalence relation on the quotient
  • it would generalise (better) to Loop, Quasigroup or even Magma/Semigroup?

Cf. comments elsewhere from @JacquesCarette about defining 'ideal' via 'sink'...

Comment on lines +49 to +52
x * r * a ≈⟨ *-assoc x r a ⟩
x * (r * a) ≈⟨ *-congˡ (*-comm r a) ⟩
x * (a * r) ≈⟨ *-assoc x a r ⟨
x * a * r ∎
Copy link
Contributor

Choose a reason for hiding this comment

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

This kind of argument occurs in Algebra.Properties.CommutativeSemigroup, and might usefully be re-used here?

x * a * r ∎
}
}
; injective = λ p → p
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
; injective = λ p p
; injective = id

???

infix 0 _by_

data _≋_ (x y : Carrier) : Set (c ⊔ ℓ ⊔ c′) where
_by_ : ∀ g → x // y ≈ ι g → x ≋ y
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly to the type of NormalSubgroup.normal, is it 'easier' to write

Suggested change
_by_ : g x // y ≈ ι g x ≋ y
_by_ : g x ≈ ι g ∙ y x ≋ y

???

Comment on lines +50 to +54
x // z ≈⟨ ∙-congʳ (identityʳ x) ⟨
x ∙ ε // z ≈⟨ ∙-congʳ (∙-congˡ (inverseˡ y)) ⟨
x ∙ (y \\ y) // z ≈⟨ ∙-congʳ (assoc x (y ⁻¹) y) ⟨
(x // y) ∙ y // z ≈⟨ assoc (x // y) y (z ⁻¹) ⟩
(x // y) ∙ (y // z) ≈⟨ ∙-cong x//y≈ιg y//z≈ιh ⟩
Copy link
Contributor

Choose a reason for hiding this comment

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

Already covered by Algebra.Properties.Loop...? And if not, could/should be added?

module _ .{{_ : NonZero m}} where

from-% : ∀ {x y} → x % m ≡ y % m → x ≋ y
from-% {x} {y} x%m≡y%m = x / m - y / m by begin
Copy link
Contributor

Choose a reason for hiding this comment

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

How much of this argument recapitulates concretely reasoning steps already used abstractly in CRT?

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