Zulip Chat Archive

Stream: general

Topic: proving (g⁻¹ * h) * (h⁻¹ * g) = 1 using simp


Bernd Losert (Dec 25 2021 at 17:24):

MWE:

import tactic
open option

example {G : Type} [group G] :  g h : G, (g⁻¹ * h) * (h⁻¹ * g) = 1 := by simp

Maybe I can't use simp andI have to reassociate things and apply mul_left_inv a bunch of times?

Yury G. Kudryashov (Dec 25 2021 at 17:28):

by simp [mul_assoc] solves this goal.

Bernd Losert (Dec 25 2021 at 17:30):

Nice.

Adam Topaz (Dec 25 2021 at 17:32):

https://leanprover-community.github.io/extras/simp.html

Adam Topaz (Dec 25 2021 at 17:33):

Learning to effectively use the simplifier is one of the most important things you can do when starting off with lean

Yury G. Kudryashov (Dec 25 2021 at 17:45):

You can also use assoc_rw here.

Bernd Losert (Dec 25 2021 at 19:28):

Say I have x * y and I want to insert a 1 in between and expand the 1 into (g⁻¹ * h) * (h⁻¹ * g). This is like the opposite of simp.

Bernd Losert (Dec 25 2021 at 19:29):

Is this easy to do, or do I have to carefully apply rw?

Adam Topaz (Dec 25 2021 at 19:38):

Do you know about the rw (show ..., by ...) trick? If not, I can explain a bit later (Christmas is busy around here...)

Bernd Losert (Dec 25 2021 at 19:42):

I don't think I've seen that. Is it discussed in "Theorem proving in Lean"?

Bernd Losert (Dec 25 2021 at 19:42):

Hmm.. don't see it there.

Yaël Dillies (Dec 25 2021 at 19:43):

It's a type-ascription. rw (proof_term : type) will do the same.

Ruben Van de Velde (Dec 25 2021 at 19:45):

It might be easier to write something like

have : x * y = x * (g⁻¹ * h) * (h⁻¹ * g) * y, { simp },
rw this

Alex J. Best (Dec 25 2021 at 19:54):

There is also tactic#group btw, under the hood it does something very similar to simp [mul_assoc] but is a nice idiomatic way to solve such goals.

Yury G. Kudryashov (Dec 25 2021 at 19:55):

You can also use calc mode.

Adam Topaz (Dec 25 2021 at 20:06):

@Bernd Losert what I had in mind is this:

import algebra
import tactic

example {G : Type*} [group G] (x y z : G) (h : x * y = x * y) : true :=
begin
  rw (show x * y = (x * z) * (z⁻¹ * y), by group) at h,
  sorry,
end

But all the other choices that were mentioned above would work as well.

Bernd Losert (Dec 25 2021 at 20:17):

I have been using calc mode actually for all this stuff.

Bernd Losert (Dec 25 2021 at 20:18):

Anyways, thanks a lot for the pointers.


Last updated: Dec 20 2023 at 11:08 UTC