Zulip Chat Archive

Stream: mathlib4

Topic: Non-defeq SuccOrder instances


David Loeffler (Dec 24 2024 at 16:27):

I'm getting a weird error in some code I'm writing which uses the notion of a docs#SuccOrder (an ordered set with a "successor" function); it doesn't work as expected if I apply it to the natural numbers.

I think the problem is that Mathlib has two distinct ways of synthesizing an instance of SuccOrder on :

The two are propositionally equal but not definitionally equal:

import Mathlib.Data.Nat.SuccPred
import Mathlib.Order.SuccPred.LinearLocallyFinite
import Mathlib.Order.Interval.Finset.Nat

example : False := by
  let o1 : SuccOrder  := LinearLocallyFiniteOrder.instSuccOrderOfLocallyFiniteOrder
  let o2 : SuccOrder   := SuccAddOrder.toSuccOrder
  have : o1 = o2 := by rfl --fails

What's the best solution to this? Maybe LinearLocallyFiniteOrder.instSuccOrderOfLocallyFiniteOrder shouldn't be an instance?

(Tagging @Rémy Degenne, who seems to have been the author of LinearLocallyFiniteOrder.instSuccOrderOfLocallyFiniteOrder)

Rémy Degenne (Dec 24 2024 at 17:50):

I don't remember why I added that instance. Presumably it got me another instance on some type. If I worked on succ orders, it has to be as a tool for something else, not for themselves. If the instance is problematic and removing it does not break too much things, feel free to do it (or fix it in another way).

Yury G. Kudryashov (Dec 24 2024 at 20:33):

This should not be an instance.

Yury G. Kudryashov (Dec 24 2024 at 20:33):

Because it creates data Order.succ from classical choice.

Eric Wieser (Dec 24 2024 at 20:36):

The alternative is to make a LocallyFiniteLinearOrder class that extends LinearOrder, LocallyFiniteOrder, SuccOrder, PredOrder, right?

Yury G. Kudryashov (Dec 24 2024 at 20:48):

Why not [LinearOrder α] [LocallyFiniteOrder α] [SuccOrder α] [PredOrder α]?

Eric Wieser (Dec 24 2024 at 23:57):

Are they all mixins? Or does that give you multiple LEs?

Edward van de Meent (Dec 24 2024 at 23:59):

Only LinearOrder is not a mixin

Johan Commelin (Dec 25 2024 at 05:29):

Fixed in #20235

Yury G. Kudryashov (Dec 25 2024 at 07:30):

I'm trying to drop SuccOrder/PredOrder assumptions you've introduced.

Johan Commelin (Dec 25 2024 at 07:59):

Great! Feel free to push directly to that PR

Yury G. Kudryashov (Dec 25 2024 at 08:23):

Pushed

Yury G. Kudryashov (Dec 25 2024 at 08:26):

Also opened #20237


Last updated: May 02 2025 at 03:31 UTC