Zulip Chat Archive

Stream: maths

Topic: division_monoid and is_unit


Alexander Bentkamp (Aug 17 2022 at 15:15):

There are a couple of lemmas about is_unit that depend on division_monoid such as docs#is_unit.inv_mul_eq_iff_eq_mul. Unfortunately, I can't use these lemmas when working with square matrices because a division_monoid requires x⁻¹⁻¹ = x, even for non-invertible x. Would removing that requirement from division_monoid be an option? Or should I reprove these lemmas specifically for matrices? Or do we need two finer-grained type-classes here?

Jireh Loreaux (Aug 17 2022 at 15:48):

(deleted)

Jireh Loreaux (Aug 17 2022 at 15:48):

(deleted)

Jireh Loreaux (Aug 17 2022 at 15:49):

Nevermind, I misread your question.

Moritz Doll (Aug 17 2022 at 15:59):

Isn't the problem that the matrix multiplication is only a has_mul.mul if the matrices are square? and similarly the inverse of a : A has to have type A. I have the same problem with defining the resolvent and I was about to define my own version of inverse and unit, but if that problem occurs several times, then we might want to find a better solution.

Junyan Xu (Aug 17 2022 at 16:20):

It seems we lack a lemma saying if h : is_unit x then x⁻¹ = ↑(h.unit⁻¹) for a matrix x. After rewriting by that, what you want is defeq to docs#units.inv_mul_eq_iff_eq_mul.

Alexander Bentkamp (Aug 17 2022 at 16:24):

@Moritz Doll That's yet another problem, but I would already be happy with a solution that works for square matrices.

Moritz Doll (Aug 17 2022 at 16:33):

ah for non-invertible matrices the inverse is defined as zero and not as the matrix itself

Moritz Doll (Aug 17 2022 at 16:34):

and I also misread your question, I am sorry.

Alexander Bentkamp (Aug 17 2022 at 16:38):

Yes, the inverse of a noninvertible matrix would be the matrix itself, that would also work. Then we could use division_monoid directly. On the other hand, the definition of the inverse as ring.inverse A.det • A.adjugate is currenlty quite elegant.

Moritz Doll (Aug 17 2022 at 16:40):

the issue goes down to ring.inverse, but changing it there seems like a dangerous thing

Moritz Doll (Aug 17 2022 at 16:40):

I would guess that there a quite a few things that rely on the inverse being zero if the element is non-invertible

Alexander Bentkamp (Aug 17 2022 at 16:41):

Right, it would probably be easier to modify division_monoid, although I am not sure how much depends on it.

Alexander Bentkamp (Aug 17 2022 at 16:42):

@Junyan Xu Yes, that would be a nice way to transfer the lemmas from units to matrix. But it would still require us to create matrix-specific copies of the lemmas about units. I was wondering if we could use type class inference instead of copies.

Jireh Loreaux (Aug 17 2022 at 16:46):

@Yaël Dillies who put some serious thought into the creation of division_monoid

Yaël Dillies (Aug 17 2022 at 16:48):

Currently, matrices are not a division monoid because they do not respect docs#inv_inv.

Yaël Dillies (Aug 17 2022 at 16:49):

Removing this field to docs#division_monoid would make ~50 lemmas not true for them (out of ~300 division_monoid lemmas) iirc.

Yaël Dillies (Aug 17 2022 at 16:51):

What I suggested back then was to redefine inversion of matrices so as to make this axiom true, but @Yakov Pechersky says thus is too hard to ensure. I don't know whether I believe it but I also don't know much about matrices.

Moritz Doll (Aug 17 2022 at 16:54):

it feels a bit like the last three fields in division_monoid almost force the inverse to be a real inverse and I wonder whether the lemma Alexander was first mentioning is true without the is_unit assumption

Yaël Dillies (Aug 17 2022 at 16:57):

No, that lemma is wrong if you do not assume is_unit.

Moritz Doll (Aug 17 2022 at 16:57):

but there more serious question would be whether it is possible to prove it with something less than division_monoid

Yaël Dillies (Aug 17 2022 at 16:58):

Yes you can

Yaël Dillies (Aug 17 2022 at 16:59):

Its proof doesn't mention inv_inv.

Yaël Dillies (Aug 17 2022 at 17:13):

The easy way out is to write the typeclass division_monoid - inv_inv, but I was trying not to overengineer the hierarchy. The solution I would like to see is making inv_inv true for matrix.

Jireh Loreaux (Aug 17 2022 at 17:15):

Does this not work for div_inv_monoid?

Yaël Dillies (Aug 17 2022 at 17:24):

No, div_inv_monoid just states the definition of division in terms of inversion.

Moritz Doll (Aug 17 2022 at 17:33):

yeah, one would need a typeclass for having a⁻¹ = ↑(ha.unit)⁻¹, where ha : is_unit a, but I don't know whether that is worth it (probably not)

Jireh Loreaux (Aug 17 2022 at 17:39):

If it's just matrices for now, I think adding a standalone lemma for those is okay.

Yakov Pechersky (Aug 17 2022 at 17:40):

inv_inv_inv is true for matrices as it right now

Yakov Pechersky (Aug 17 2022 at 17:44):

If a matrix is not invertible, then currently inv sends it to 0. so A\inv\inv = 0 even when A \ne 0.

Yakov Pechersky (Aug 17 2022 at 17:44):

Let's say A\inv = A when A is not invertible. Then inv_inv is true. But then a lot of nice lemmas about the distribution of inv over mul, or zpow don't work.

Eric Rodriguez (Aug 17 2022 at 18:55):

I mean, I'd rather have lemmas applying sometimes under more conditions (e.g. requiring invertibility) instead of having to rewrite lemmas, but I'm not sure of the exact details of this situation. We can also prove lemmas about the adjugate+determinant combo separately, and leave the inv lemmas to another inv so that the typeclass system functions better.

Yakov Pechersky (Aug 17 2022 at 18:56):

There is also docs#ring.inverse

Yakov Pechersky (Aug 17 2022 at 18:56):

That's re Moritz Doll's suggestion

Yakov Pechersky (Aug 17 2022 at 18:58):

Sorry, I see that Alexander already mentioned it via the matrix.inv definition


Last updated: Dec 20 2023 at 11:08 UTC