Zulip Chat Archive

Stream: mathlib4

Topic: Ring tactic bug?


Arthur Paulino (Jan 25 2022 at 15:30):

I was playing with the latest Mathlib4 version (3a835b7) and the ring tactic output was a bit strange:

import Mathlib.Tactic.Ring

def sum : Nat  Nat
  | 0     => 0
  | n + 1 => n + 1 + sum n

theorem mulDist {a b c : Nat} : a * (b + c) = a * b + a * c := by ring

theorem twoTimesSumEqTimesSucc {n : Nat} : 2 * sum n = n * (n + 1) := by
  induction n with
    | zero => rfl
    | succ n hi =>
      simp only [sum]
      iterate rw [mulDist]
      rw [hi]
      ring -- unknown free variable '_uniq.1942'

Is this a bug or a misuse of the tactic?

Gabriel Ebner (Jan 25 2022 at 15:35):

That's a bug.

Arthur Paulino (Jan 25 2022 at 15:38):

Alright, I'm going to try and debug it

Jannis Limperg (Jan 25 2022 at 15:44):

The error message indicates that some Expr constructed by the tactic contains an FVarId that doesn't exist. Usually this means that the Expr is used in the wrong context. Maybe that helps with the debugging.

Arthur Paulino (Jan 25 2022 at 16:00):

The problem happens when calling (m {α := ty, univ := u, cs := inst }).run' {} as the return of RingM.run

Arthur Paulino (Jan 25 2022 at 16:15):

https://github.com/leanprover-community/mathlib4/issues/165

Arthur Paulino (Jan 25 2022 at 18:48):

And it's closed :open_mouth:

Kevin Buzzard (Jan 25 2022 at 23:10):

Thank you!


Last updated: Dec 20 2023 at 11:08 UTC