Zulip Chat Archive

Stream: new members

Topic: swapping things in a lemma


Lawrence Lin (Nov 16 2022 at 20:51):

in an earlier thread i wrote,

import tactic
import geom_sum

example (a : ) (m n : ) : (int.gcd (a^m - 1) (a^n - 1) : ) = a^(nat.gcd m n) - 1 :=
begin
  rw mul_geom_sum a m,
end

but it spits out the error

rewrite tactic failed, did not find instance of the pattern in the target expression
  (a - 1) * geom_sum a m

would this be because in the docs we have

theorem mul_geom_sum {α : Type u} [ring α] (x : α) (n : ) :
(x - 1) * (finset.range n).sum (λ (i : ), x ^ i) = x ^ n - 1

and lean can't handle x^n - 1 turning into the other thing?

Michael Stoll (Nov 16 2022 at 21:00):

You can rewrite in the reverse direction via rw ← ... (type "\l" to get the arrow).

Lawrence Lin (Nov 16 2022 at 21:19):

thank you!


Last updated: Dec 20 2023 at 11:08 UTC