[ add ] injectivity of suc for relation m ≡ n (mod o) for {{NonZero o}}#2971
[ add ] injectivity of suc for relation m ≡ n (mod o) for {{NonZero o}}#2971jamesmckinna wants to merge 11 commits intoagda:masterfrom
suc for relation m ≡ n (mod o) for {{NonZero o}}#2971Conversation
|
Last commit tidies up notations etc. |
src/Data/Nat/DivMod.agda
Outdated
| _≲%[_]_ _≡%[_]_ : ∀ m o n → Set _ | ||
|
|
||
| m ≲%[ o ] n = ∃ λ k → n ≡ m + k * o | ||
| m ≡%[ o ] n = SymClosure _≲%[ o ]_ m n |
There was a problem hiding this comment.
I'm unsure if it would actually make anything easier, but an alternative definition here is:
| m ≡%[ o ] n = SymClosure _≲%[ o ]_ m n | |
| m ≡%[ o ] n = ∃ λ k → ∃ λ k' → m + k * o ≡ n + k' * o |
There was a problem hiding this comment.
Nice observation!
(Give relation R, the (relational) composition of R with flip R is automatically symmetric, moreover transitive if flip R . R is contained in the identity , ie R is functional, as in this instance... and then R + flip R being equivalent to flip R . R is a further stronger invariant... but does this help in proving @JacquesCarette 's lemma?)
Can now: by generalising |
src/Data/Nat/DivMod.agda
Outdated
| m ≡%[ o ] n = SymClosure _≲%[ o ]_ m n | ||
|
|
||
| infix 4 _≡[_]%_ | ||
| _≡[_]%_ : ∀ m o .{{_ : NonZero o}} n → Set _ |
There was a problem hiding this comment.
What's the mnemonic for the placement of the % sign in this notation vs.
the previous one. I don't think I could predict where it's supposed to go.
Should we have a theory of
_≡[_]_ : ∀ (m : A) (A -> B) (n : A) → Set _
m ≡[ f ] n = (_≡_ on f) m n
and then be this just be _≡[ (_% o) ]_?
There was a problem hiding this comment.
Re: naming.
No, you're absolutely correct that these names are suboptimal! Thank supernatural realms for the review process... and on a more human plane, for your intervention here.
I think I'll try instead
_≡%[_]_form ≡%[ o ] n = m % o ≡ n % o_≅%[_]_form ≅%[ o ] n = SymClosure _≲%[ o ]_ m n
on the basis that
≅seems like a plausible symbol for the symmetrisation of of a given≲- both relations now get
%preceding the actual moduluso
Is that any better?
There was a problem hiding this comment.
As for the more general 'quotient by f' equivalence relation, I'm more hesitant to pursue that, for two reasons:
_%isn't the generalfyou seek, because of the usual... weirdness aboutNonZero owitnesses- @Taneb 's Add ideals and quotient rings #2855 introduces different notation for the quotient relation, and (eventually?) we might see a suitable reconciliation, but I didn't want to prematurely commit to any eventual resolution of those decisions...?
src/Data/Nat/DivMod.agda
Outdated
| ≡[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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Notwithstanding that wlog can be used, I think the above proof is easier to read.
src/Data/Nat/DivMod.agda
Outdated
| where k = n / o ∸ m / o | ||
|
|
||
| ≡[o]%⇒≅%[o] : _≡%[ o ]_ ⇒ _≅%[ o ]_ | ||
| ≡[o]%⇒≅%[o] {x = m} {y = n} eq with ≤-total m n |
There was a problem hiding this comment.
This feels like wlog even more so because _≅%[_]_ is freely symmetric and so it should be (for once!) easy to invoke!
There was a problem hiding this comment.
Well, indeed. But see above... will see what I can do.
There was a problem hiding this comment.
Have done so, but it's a horrible proof, so verbose!
I would really claim it's not an improvement.
|
@JacquesCarette hope I've addressed all your feedback |
m ≡ n (mod o) for {{NonZero o}}suc for relation m ≡ n (mod o) for {{NonZero o}}
Taken from the discussion at https://agda.zulipchat.com/#narrow/channel/264623-stdlib/topic/suc.20injective.20under.20_.25_/with/582024092 :
m ≲%[ o ] n = ∃ λ k → n ≡ m + k * om % o ≡ n % oin terms of (the symmetric closure of)m ≲%[ o ] n(suc m) % o ≡ (suc n) % o → m % o ≡ n % oSymClosurePossible TODO:
_≲%[ o ]_satisfiesIsPreorder _≡_, indeedIsPartialOrder _≡_etc. (decidable, ...)