Zulip Chat Archive

Stream: mathlib4

Topic: nth_rw broken?


Michael Stoll (Oct 27 2023 at 13:21):

I think I may have seen a thread on that, but can't find it (searching for nth_rw or nth_rewrite om Zulip seems to ignore the nth_ part...).
The following certainly does not work as expected.

import Mathlib

example (x y z : ) : x^2 + y^2 = x^2 + y*y := by
  nth_rw 2 [pow_two] -- leaves `x ^ 2 + y ^ 2 = x * x + y * y`
  sorry

It seems that nth_rw n [lemma] finds the first match for the lemma (here x^2) and then rewrites the nth occurrence of that match instead of the nth occurrence of some match.
Is this a know bug (and if so, is something being done about it)?

Patrick Massot (Oct 27 2023 at 13:22):

Yes, it is known.

Patrick Massot (Oct 27 2023 at 13:24):

See https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/How.20to.20use.20nth_rewrite.20in.20NNG4.3F/near/397991051

Scott Morrison (Oct 29 2023 at 10:50):

In particular for anyone coming to this thread later, lean4#2539 is the fix.


Last updated: Dec 20 2023 at 11:08 UTC