Zulip Chat Archive

Stream: Berkeley Lean Seminar

Topic: tactic at a target


Zachary Stier (May 26 2020 at 20:25):

In Multiplication World level 9, we prove a*(b*c)=b*(a*c). I wanted to do rw mul_comm, rw mul_assoc, rw mul_comm, with the final rewrite applied to the parenthesized multiplication on the LHS (since beforehand we have b*(c*a)). Is this possible? I managed to prove it using induction but this seemed unnecessary.

Kyle Miller (May 26 2020 at 20:26):

You should be able to do rw mul_comm b c

Patrick Lutz (May 26 2020 at 20:27):

I think there's also a way to enter only the left hand side of a goal and use rewrites there, but I can't remember how to do it

Zachary Stier (May 26 2020 at 20:28):

Kyle Miller said:

You should be able to do rw mul_comm b c

Yes, this works, thanks!

Kyle Miller (May 26 2020 at 20:45):

My understanding is that mul_comm is a two-argument function, and giving it b and c causes it to be a concrete instance of commutativity. rw mul_comm b might have worked, too, since it partially applies the function with b.

Jalex Stark (May 26 2020 at 22:32):

Patrick Lutz said:

I think there's also a way to enter only the left hand side of a goal and use rewrites there, but I can't remember how to do it

I think conv and maybe conv_lhs are relevant keywords

Jalex Stark (May 26 2020 at 22:37):

Yes, the example on this docs page about conv is almost exactly the example zach brought up:
https://leanprover-community.github.io/extras/conv.html

Jalex Stark (May 26 2020 at 22:39):

example (a b c : ) : a * (b * c) = a * (c * b) :=
begin
conv in (b*c) {rw mul_comm,},
end

Zachary Stier (May 27 2020 at 17:13):

Jalex Stark said:

Yes, the example on this docs page about conv is almost exactly the example zach brought up:
https://leanprover-community.github.io/extras/conv.html

Oh awesome, thanks! This looks like a very useful/general way to resolve these kinds of proofs.

Jalex Stark (May 27 2020 at 17:19):

once you take off the training wheels of the natural number game, the right way to deal with chaining commutativity and associativity is to apply the ring tactic

Jalex Stark (May 27 2020 at 17:19):

ring at h will do something like "apply commutativity, associativity, and distributivity until the expression is in normal form"

Jalex Stark (May 27 2020 at 17:20):

(also, hi! nice to see you here :slight_smile: )


Last updated: Dec 20 2023 at 11:08 UTC