Zulip Chat Archive

Stream: general

Topic: simplifying in `monoid_algebra`


Yury G. Kudryashov (Feb 18 2022 at 19:13):

I'm helping @Laurent Bartholdi with a Lean course. @Cedric Holle is one of the students at this course and he tries to formalize some equality in Q[GL4(Q)]\mathbb Q[GL_4(\mathbb Q)] (actually, in Q[G]\mathbb Q[G], where GG is a subgroup of GL4(Q)GL_4(\mathbb Q) but this shouldn't be too important). The equality is rather long and I hope that Cedric will copy+paste relevant definitions below.
Once we unfold the definitions, we get a linear combination of finsupp.single (some_matrix) 1 1. In order to simplify this, we need to decide whether some_matrix is equal to one or no. Can some tactic do this for us?

Kevin Buzzard (Feb 18 2022 at 19:14):

Please tell me that GL_4(G) is a typo for G :-)

Yury G. Kudryashov (Feb 18 2022 at 19:16):

Thanks! Fixed.

Kevin Buzzard (Feb 18 2022 at 19:16):

Is some_matrix literally a 4x4 matrix with explicit rational coefficients? Does norm_num work?

Yury G. Kudryashov (Feb 18 2022 at 19:17):

Yes, some_matrix is an explicit 4x4 matrix. It is obtained using arithmetic operations from matrices in ![...] notation.

Yury G. Kudryashov (Feb 18 2022 at 19:18):

The problem is to make norm_num decide whether this matrix is equal to 1 or not.

Yury G. Kudryashov (Feb 18 2022 at 19:19):

And feed the result to one of 2 lemmas about finsupp.single.

Yury G. Kudryashov (Feb 18 2022 at 19:20):

More generally, we may have finsupp.single a b c, where a = c is decidable.

Yury G. Kudryashov (Feb 18 2022 at 19:21):

I don't remember if norm_num can tell whether (1 : matrix (fin 2) (fin 2) R) = ![[1, 0], [0, 1]] or not.

Kevin Buzzard (Feb 18 2022 at 19:21):

I see, and this is why you wanted dec_trivial!

Yakov Pechersky (Feb 18 2022 at 19:21):

have : some_matrix = (1 : matrix _ _ _),
{ ext i j; fin_cases i; fin_cases j; norm_num }

Kevin Buzzard (Feb 18 2022 at 19:21):

The problem with that is that it only proves that things are equal to 1, not that they're not equal to 1

Yury G. Kudryashov (Feb 18 2022 at 19:21):

And now you have 20-30 terms of this form.

Yury G. Kudryashov (Feb 18 2022 at 19:22):

The question is how to avoid 20-30 explicitly written lemmas "this is not equal to one".

Yakov Pechersky (Feb 18 2022 at 19:23):

The best I could do for similar problems can be found in this file: https://github.com/pechersky/e222/blob/master/src/problems02.lean#L49-L58

Yury G. Kudryashov (Feb 18 2022 at 19:23):

If you write a proof for "not equal" manually, then you can just tell Lean which elements are not equal.

Yury G. Kudryashov (Feb 18 2022 at 19:27):

I guess, one can write a tactic that goes over elements of fin 4 and evaluates LHS and RHS

Yury G. Kudryashov (Feb 18 2022 at 19:27):

But I'm not good at writing tactics.

Yakov Pechersky (Feb 18 2022 at 19:28):

Is that not fin_cases?

Gabriel Ebner (Feb 18 2022 at 19:34):

I guess, one can write a tactic that goes over elements of fin 4 and evaluates LHS and RHS
But I'm not good at writing tactics.

A simple approach is to write a lemma matrix22_ext_iff : (![![a,b], ![c,d]] = ![![e,f], ![g,h]]) ↔ a=e ∧ b = f ∧ c = g ∧ d = h and then call simp [matrix22_ext_iff] (we might have such a lemma already, didn't check).

Yury G. Kudryashov (Feb 18 2022 at 19:44):

Am I right that in this case simp will simplify each equality even if one of them already says false?

Gabriel Ebner (Feb 18 2022 at 19:46):

Right.

Yury G. Kudryashov (Feb 18 2022 at 19:48):

So, a specialized tactic can be more effective but requires some meta programming skills. Let's wait for the students to come here, read the backlog, and decide what they're going to do.

Eric Wieser (Feb 18 2022 at 20:21):

Rewriting backwards by docs#matrix.one_fin_three (but for four) might put you in a place where dec_trivial is easy

Yury G. Kudryashov (Feb 18 2022 at 20:23):

dec_trivial can't solve (5 : rat) = 1

Yury G. Kudryashov (Feb 18 2022 at 20:23):

And the matrices have half-integer elements.

Yury G. Kudryashov (Feb 18 2022 at 20:23):

So, we can't just deal with matrices over int.

Kevin Buzzard (Feb 18 2022 at 21:33):

You could write an ext lemma which clears the denominators and reduces to int :-)


Last updated: Dec 20 2023 at 11:08 UTC