Zulip Chat Archive

Stream: general

Topic: ring_exp with integer powers


Yury G. Kudryashov (Sep 09 2021 at 23:07):

Here is an #mwe:

import tactic.ring_exp

example {k : Type*} [field k] {x : k} (hx : x  0) (m : ) : x ^ m * x ^ m = x ^ (2 * m) :=
by ring_exp -- fails

Yury G. Kudryashov (Sep 09 2021 at 23:09):

Do I understand correctly that ring_exp only works with natural powers? Is it hard to make it work for integer powers?

Yury G. Kudryashov (Sep 09 2021 at 23:10):

Of course, the actual expression where I wanted to use ring_exp is much longer.

Eric Rodriguez (Sep 09 2021 at 23:21):

docs#ring_exp mentions that it is; from a glance through the code, I think it'd just be a looot of special casing but I'm not too sure

Yury G. Kudryashov (Sep 09 2021 at 23:29):

I see a few problems with supporting fpow (without looking at the code):

  • we have two different lemmas, e.g., for x ^ (m + n) = x ^ m * x ^ n, see docs#gpow_add and docs#fpow_add;
  • for the fpow case we need to prove x ≠ 0 here and there;
  • need to deal with, e.g., x ^ m * x ^ n, where m : int, n : nat.

Yakov Pechersky (Sep 09 2021 at 23:35):

Can one case on m as nonneg and neg, and use field_simp first?

Yury G. Kudryashov (Sep 09 2021 at 23:36):

field_simp won't deal with x ^ m * x ^n

Yury G. Kudryashov (Sep 09 2021 at 23:36):

And you can have many ms and ns

Yury G. Kudryashov (Sep 09 2021 at 23:37):

I don't want the proof to be exponentially large (and exponentially slow) in the number of exponents in the formula.

Yakov Pechersky (Sep 09 2021 at 23:38):

Of course. The forcing to nat via a case is just a possible stopgap for a two exponents. It's the "brute force" tactic that you can use as the baseline for comparing performance :-)


Last updated: Dec 20 2023 at 11:08 UTC