Skip to content

[ add ] injectivity of suc for relation m ≡ n (mod o) for {{NonZero o}}#2971

Open
jamesmckinna wants to merge 14 commits intoagda:masterfrom
jamesmckinna:jacques-lemma
Open

[ add ] injectivity of suc for relation m ≡ n (mod o) for {{NonZero o}}#2971
jamesmckinna wants to merge 14 commits intoagda:masterfrom
jamesmckinna:jacques-lemma

Conversation

@jamesmckinna
Copy link
Copy Markdown
Collaborator

@jamesmckinna jamesmckinna commented Mar 27, 2026

Taken from the discussion at https://agda.zulipchat.com/#narrow/channel/264623-stdlib/topic/suc.20injective.20under.20_.25_/with/582024092 :

  • introduces definition m ≲%[ o ] n = ∃ λ k → n ≡ m + k * o
  • characterises the relation m % o ≡ n % o in terms of (the symmetric closure of) m ≲%[ o ] n
  • gives two proofs of 'Carette's Lemma' (suc m) % o ≡ (suc n) % o → m % o ≡ n % o
    • indirect, via the characterisation, using a new lemma about SymClosure
    • direct, via a slick proof due to @alexarice

Possible TODO:

@jamesmckinna jamesmckinna added this to the v2.4 milestone Mar 27, 2026
@jamesmckinna jamesmckinna requested a review from Taneb March 27, 2026 18:24
@jamesmckinna jamesmckinna requested a review from gallais March 27, 2026 18:25
@jamesmckinna
Copy link
Copy Markdown
Collaborator Author

Last commit tidies up notations etc.
Still can't quite make the proof carettesLemma delegate via a suitable combinator to ≲%[o]⇒≡[o]% ∘ ≲%[o]-suc⁻¹ but this will have to do, I guess. Suggestions welcome!

@jamesmckinna
Copy link
Copy Markdown
Collaborator Author

Last commit tidies up notations etc. Still can't quite make the proof carettesLemma delegate via a suitable combinator to ≲%[o]⇒≡[o]% ∘ ≲%[o]-suc⁻¹ but this will have to do, I guess. Suggestions welcome!

Can now: by generalising SymClosure.gmap! Final commit closes this last niggle.

Comment on lines +510 to +512
≡[o]%⇒≅%[o] {x = m} {y = n} eq with ≤-total m n
... | inj₁ m≤n = fwd (≡[o]%⇒≲%[o] eq m≤n)
... | inj₂ n≤m = bwd (≡[o]%⇒≲%[o] (sym eq) n≤m)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This proof could be refactored in terms of Relation.Binary.Consequences.wlog, but my first attempt ended up more verbose and harder to read than this version. But perhaps eventually that combinator will be reimplemented, and with it, a suitable refactoring of this lemma.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Notwithstanding that wlog can be used, I think the above proof is easier to read.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

And now, in terms of Sum elimination, so avoiding the appeal to with.

@jamesmckinna
Copy link
Copy Markdown
Collaborator Author

@JacquesCarette hope I've addressed all your feedback
@gallais feel free to insist on the wlog proof, but I think the direct one is better!

@jamesmckinna jamesmckinna changed the title [ add ] proof of Carette's Lemma for relation m ≡ n (mod o) for {{NonZero o}} [ add ] injectivity of suc for relation m ≡ n (mod o) for {{NonZero o}} Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants