Zulip Chat Archive
Stream: general
Topic: implicit arguments, and `ring`
Scott Morrison (Sep 29 2018 at 11:13):
Hi @Mario Carneiro, I noticed an unfortunate feature of ring.
Scott Morrison (Sep 29 2018 at 11:13):
I'd got stuck doing this:
example (x y : ℕ) (h : x ^ 2 + 3 * y ^ 2 = 4) : false := begin ring at h, simp at h, ring at h, simp at h, -- ... end
Scott Morrison (Sep 29 2018 at 11:14):
where it looks like the goal isn't changing.
Scott Morrison (Sep 29 2018 at 11:14):
It just says
x y : ℕ, h : x ^ 2 + 3 * y ^ 2 = 4 ⊢ false
Scott Morrison (Sep 29 2018 at 11:14):
but with pp.all true, you can see if flipping back and forth:
Mario Carneiro (Sep 29 2018 at 11:14):
You shouldn't use ring nonterminally
Mario Carneiro (Sep 29 2018 at 11:14):
at least not automatically (i.e. in tidy)
Mario Carneiro (Sep 29 2018 at 11:15):
if it doesn't close the goal, assume it failed
Scott Morrison (Sep 29 2018 at 11:15):
Yes, I know, but I want to for a moment anyway. :-)
Scott Morrison (Sep 29 2018 at 11:15):
Ah, okay. :-)
Scott Morrison (Sep 29 2018 at 11:15):
But that takes all the fun out of it.
Mario Carneiro (Sep 29 2018 at 11:15):
ring rewrites the goal into sum-of-products form for ease of reading when it fails
Scott Morrison (Sep 29 2018 at 11:15):
Because sometimes ring at *, exfalso, linarith can get stuff done.
Mario Carneiro (Sep 29 2018 at 11:15):
this form disagrees with simp normal form in some places
Scott Morrison (Sep 29 2018 at 11:16):
The problem I was having here is actually just in the implicit arguments flipping back and forth.
Scott Morrison (Sep 29 2018 at 11:16):
The expression "itself" is not being changed by either simp or ring.
Mario Carneiro (Sep 29 2018 at 11:16):
wait, maybe I don't understand then
Mario Carneiro (Sep 29 2018 at 11:16):
what is changing?
Scott Morrison (Sep 29 2018 at 11:17):
With usual pretty printing, neither simp nor ring do anything, and the goal just looks like
x y : ℕ, h : x ^ 2 + 3 * y ^ 2 = 4 ⊢ false
Scott Morrison (Sep 29 2018 at 11:17):
but with pp.all we get:
Scott Morrison (Sep 29 2018 at 11:17):
x y : nat,
h :
@eq.{1} nat
(@has_add.add.{0} nat nat.has_add
(@has_pow.pow.{0 0} nat nat nat.has_pow x (@bit0.{0} nat nat.has_add (@has_one.one.{0} nat nat.has_one)))
(@has_mul.mul.{0} nat
(@mul_zero_class.to_has_mul.{0} nat
(@semiring.to_mul_zero_class.{0} nat
(@comm_semiring.to_semiring.{0} nat
(@canonically_ordered_comm_semiring.to_comm_semiring.{0} nat
nat.canonically_ordered_comm_semiring))))
(@bit1.{0} nat nat.has_one nat.has_add (@has_one.one.{0} nat nat.has_one))
(@has_pow.pow.{0 0} nat nat nat.has_pow y (@bit0.{0} nat nat.has_add (@has_one.one.{0} nat nat.has_one)))))
(@bit0.{0} nat nat.has_add (@bit0.{0} nat nat.has_add (@has_one.one.{0} nat nat.has_one)))
⊢ false
Scott Morrison (Sep 29 2018 at 11:17):
after the simp
Mario Carneiro (Sep 29 2018 at 11:17):
oh, it's nat.pow isn't it
Scott Morrison (Sep 29 2018 at 11:17):
and then
Scott Morrison (Sep 29 2018 at 11:17):
x y : nat,
h :
@eq.{1} nat
(@has_add.add.{0} nat nat.has_add
(@has_pow.pow.{0 0} nat nat
(@monoid.has_pow.{0} nat
(@semiring.to_monoid.{0} nat
(@comm_semiring.to_semiring.{0} nat
(@canonically_ordered_comm_semiring.to_comm_semiring.{0} nat
nat.canonically_ordered_comm_semiring))))
x
(@bit0.{0} nat nat.has_add (@has_one.one.{0} nat nat.has_one)))
(@has_mul.mul.{0} nat
(@mul_zero_class.to_has_mul.{0} nat
(@semiring.to_mul_zero_class.{0} nat
(@comm_semiring.to_semiring.{0} nat
(@canonically_ordered_comm_semiring.to_comm_semiring.{0} nat
nat.canonically_ordered_comm_semiring))))
(@bit1.{0} nat nat.has_one nat.has_add (@has_one.one.{0} nat nat.has_one))
(@has_pow.pow.{0 0} nat nat
(@monoid.has_pow.{0} nat
(@semiring.to_monoid.{0} nat
(@comm_semiring.to_semiring.{0} nat
(@canonically_ordered_comm_semiring.to_comm_semiring.{0} nat
nat.canonically_ordered_comm_semiring))))
y
(@bit0.{0} nat nat.has_add (@has_one.one.{0} nat nat.has_one)))))
(@bit0.{0} nat nat.has_add (@bit0.{0} nat nat.has_add (@has_one.one.{0} nat nat.has_one)))
⊢ false
Scott Morrison (Sep 29 2018 at 11:17):
after the ring
Mario Carneiro (Sep 29 2018 at 11:18):
right, ring prefers monoid powers but that's not simp normal form
Scott Morrison (Sep 29 2018 at 11:18):
Okay, I see.
Scott Morrison (Sep 29 2018 at 11:18):
Nothing to be done, then!
Mario Carneiro (Sep 29 2018 at 11:19):
ring doesn't make any attempt to be in simp normal form; if you need that you should just call ring, simp
Mario Carneiro (Sep 29 2018 at 11:20):
but even better is to just ignore the pretty failure mode
Kenny Lau (Sep 29 2018 at 11:26):
it's a feature!
Last updated: May 02 2025 at 03:31 UTC