leanprover-community / lean4game

Server to host lean games.
https://adam.math.hhu.de
GNU General Public License v3.0
198 stars 35 forks source link

I guess I don't understand nth_rewrite #141

Closed rwv37 closed 1 year ago

rwv37 commented 1 year ago

I've been fighting against nth_rewrite for quite some time, and I don't understand what I'm doing wrong. For example, in the "Power World", level 7/10 (i.e. proving mul_pow), I currently have:

(a * b) ^ succ c = a ^ succ c * b ^ succ c

I would expect that applying nth_rewrite 1 [pow_succ] to this would result in (a * b) ^ c * (a * b) = a ^ succ c * b ^ succ c, and in fact it does.

I would furthermore expect that applying nth_rewrite 2 [pow_succ] to the same original line would result in (a * b) ^ succ c = (a ^ c * a) * b ^ succ c, and that applying nth_rewrite 3 [pow_succ] would result in (a * b) ^ succ c = a ^ succ c * (b ^ c * b). But neither of these do what I expect; instead they throw errors. For example:

image

To be clear, I've been having this sort of problem with nth_rewrite frequently, not just in the case of this particular example. Am I doing something incorrectly? If so, what? Thanks in advance.

abentkamp commented 1 year ago

You are completely correct, but the nth_rewrite tactic is currently broken. A PR to lean4 is under review: https://github.com/leanprover/lean4/pull/2539

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