Zulip Chat Archive

Stream: new members

Topic: Use of Tactics


Alex Zhang (May 24 2021 at 03:09):

Suppose I have some goal like a+a+b <= d+c+a and I would like to change the second "a" on the LHS to "a+0", how can I make this change?

Hanting Zhang (May 24 2021 at 03:11):

nth_rewrite 2 [add_zero a]

Hanting Zhang (May 24 2021 at 03:12):

docs#nth_rewrite Nevermind that doesn't work. nth_rewrite essentially allows you to rw with more precision

Scott Morrison (May 24 2021 at 03:14):

Or use conv mode, which lets you select subexpressions to work on.

Scott Morrison (May 24 2021 at 03:14):

Maybe tactic#nth_rewrite?

Alex Zhang (May 24 2021 at 03:23):

@Hanting Zhang It seems not to work for me as add_zero is from a+0 to a, but what I want is to rewrite in the other direction.

Scott Morrison (May 24 2021 at 03:26):

Use the left arrow to rewrite backwards.

Alex Zhang (May 24 2021 at 03:28):

Do you mean`nth_rewrite←'? This gives me the error message: (small) natural number expected... :hurt:

Adam Topaz (May 24 2021 at 03:37):

nth_rewrite 2 [← add_zero a]

Adam Topaz (May 24 2021 at 03:38):

In general when you're rewriting adding a left arrow in front of the name of the lemma uses that particular lemma in reverse.

Alex Zhang (May 24 2021 at 03:47):

Thanks to all of you!


Last updated: Dec 20 2023 at 11:08 UTC