Zulip Chat Archive
Stream: general
Topic: ring not idempotent
Kevin Buzzard (Mar 19 2021 at 19:30):
import tactic
-- set_option pp.all true
example (n : ℤ) (hn : 25 * n = n) : n = 0 :=
begin
have h := sub_eq_zero.mpr hn, -- internally an awkward `0`
-- h : 25 * n - n = 0
ring at *, -- `h` now has a better `0`
-- h : 25 * n - n = 0
ring at *,
-- h : 24 * n = 0
linarith
end
Riccardo Brasca (Mar 19 2021 at 19:40):
Something similar happened recently in one of my PR, here https://github.com/leanprover-community/mathlib/blob/1e2d820fb10b2a008e346e4f689f9be40c85cf32/src/geometry/euclidean/basic.lean#L200-L201
Riccardo Brasca (Mar 19 2021 at 19:40):
ring,
ring
works, but ring
alone doesn't.
Bryan Gin-ge Chen (Mar 19 2021 at 19:40):
#3326 has a few other examples
Riccardo Brasca (Mar 19 2021 at 19:41):
(and moreover I don't what happened, I modified normed_group
and this stopped working)
Mario Carneiro (Mar 19 2021 at 21:54):
Anyone have examples of this happening on terminal ring
calls?
Mario Carneiro (Mar 19 2021 at 21:56):
ring at h
is actually a completely different tactic under the hood, it's more like simp_to_SOP
Junyan Xu (Mar 20 2021 at 05:01):
Mario Carneiro said:
Anyone have examples of this happening on terminal
ring
calls?
https://github.com/alreadydone/formalising-mathematics/commit/6439475f106653b8eafbb1bf477e9c7d30e10e8b#diff-c9570b5dd291456377e1056063c7c8d2876960e4c2ae01f618661f4c2ea73da6R475
All that the first ring
does is a dsimp
.
(edit: and Bryan's example in #3326)
Mario Carneiro (Mar 20 2021 at 11:45):
a #mwe
Mario Carneiro (Mar 20 2021 at 11:46):
Bryan's version is also not terminal, that's not a goal ring
can solve
Mario Carneiro (Mar 20 2021 at 11:49):
Put another way, ring
proves theorems in the language of commutative rings. When given non-theorems, it instead does some debug-only heuristic rewriting for the purpose of showing the user why the goal is failing that is not necessarily idempotent and should not be used in robust proofs
Scott Morrison (Mar 20 2021 at 23:24):
I wonder if we should split it out into a separate tactic, perhaps ring_nf
or ring_normal_form
. Then ring
could still call ring_nf
when it fails, but it would _also_ print a Try this: ring_nf
message, to make clear that ring
itself is failing.
Mario Carneiro (Mar 20 2021 at 23:57):
I think that's a good idea. It's pretty easy to get confused about the two functions
Riccardo Brasca (Mar 26 2021 at 08:42):
Here
ring_nf
is not idempotent. Is using it twice OK or should I prove it by hand (it just a bunch of rw
)?
Ruben Van de Velde (Mar 26 2021 at 08:48):
Potentially related: https://github.com/leanprover-community/mathlib/issues/3326
Mario Carneiro (Mar 26 2021 at 13:55):
As my comment above indicates, I don't think you should be using ring_nf
at all, certainly not if you are just trying to close a goal. That's what ring
is for
Mario Carneiro (Mar 26 2021 at 13:57):
In the commit that adds ring_nf
, I didn't make any attempt to eliminate the existing uses in order to keep the refactor manageable, but arguably every new use of ring_nf
should be examined to see whether it isn't supposed to be a proof by congr, ring
or something
Last updated: Dec 20 2023 at 11:08 UTC