Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

non-idempotence of ring (when following zify) #3326

Closed
robertylewis opened this issue Jul 8, 2020 · 3 comments
Closed

non-idempotence of ring (when following zify) #3326

robertylewis opened this issue Jul 8, 2020 · 3 comments
Labels
bug t-meta Tactics, attributes or user commands

Comments

@robertylewis
Copy link
Member

import tactic.ring tactic.zify

open tactic 

example (a b c : ℕ) (h : b + a < c + a) : b < c :=
begin 
  zify at h,
  rw ← sub_lt_sub_iff_right (a : ℤ) at h,
  ring at h, -- this line succeeds, but doesn't cancel the `a`s
  ring at h, -- this also succeeds and cancels the `a`s
end 

I assumed at first this was another uninstantiated mvar bug, but surprisingly, it doesn't seem to be. The first ring changes some type class instances but doesn't go any further.

I couldn't replicate it without zify and the rw. In particular, manually inserting casts at the beginning makes the problem go away.

@digama0 any instinct here? Maybe zify is bringing in some non-canonical type class instances somehow, but I'm still not sure how/where this interferes with ring.

@eric-wieser
Copy link
Member

@bryangingechen bryangingechen added t-meta Tactics, attributes or user commands bug labels Jul 19, 2020
@bryangingechen
Copy link
Collaborator

bryangingechen commented Jan 19, 2021

Here's another example where ring is non-idempotent:

import analysis.special_functions.pow
example : 3 * real.pi = (1 : ℤ) * (2 * real.pi) + real.pi := 
-- by norm_cast; ring
begin
  ring,
  -- ⊢ 3 * real.pi = 2 * real.pi * ↑1 + real.pi
  ring,
  -- ⊢ 3 * real.pi = (2 * ↑1 + 1) * real.pi
  ring,
  -- ⊢ 3 * real.pi = 2 * real.pi * ↑1 + real.pi
  ring,
  -- ⊢ 3 * real.pi = (2 * ↑1 + 1) * real.pi
end

Edit: This is expected since this kind of goal is out-of-scope for ring: see Zulip.

@robertylewis
Copy link
Member Author

This seems to have solved itself:

import tactic.ring tactic.zify

open tactic 

example (a b c : ℕ) (h : b + a < c + a) : b < c :=
begin 
  zify at h,
  rw ← sub_lt_sub_iff_right (a : ℤ) at h,
  ring_nf at h,
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug t-meta Tactics, attributes or user commands
Projects
None yet
Development

No branches or pull requests

3 participants