Zulip Chat Archive

Stream: mathlib4

Topic: Non-computable bot in Fin.


Wrenna Robson (Nov 14 2024 at 15:15):

There are some instances here for Fin n with [NeZero n]: in particular there's Fin.instBoundedOrder. This is meant to prevent non-computable instances being used to construct these instances non-computably.

However, in practice if I use in a definition, Lean flags it as noncomputable, and it seems ultimately to be constructing from the CompleteLinearOrder on Fin n, which is non-computable.

Can we either: a) define the complete linear order on Fin n in a computable way that extends these other instances, or b) stop this non-computable instance of being used?

Wrenna Robson (Nov 14 2024 at 15:20):

Possibly related: Lean does not seem able to synthesise an OrderBot for Fin n simply using its BoundedOrder instance.

Yaël Dillies (Nov 14 2024 at 15:26):

In these situations, we have in the past added computable shortcut instances

Yaël Dillies (Nov 14 2024 at 15:27):

Can you click through the infoview to tell us exactly how it went from Bot to CompleteLinearOrder in this case?

Wrenna Robson (Nov 14 2024 at 15:27):

Aye, and it seems like that ought to work here (Fin.instBoundedOrder is computable!) but in practice it uses non-computable.

Yaël Dillies (Nov 14 2024 at 15:27):

... or give us a MWE to do so ourselves

Wrenna Robson (Nov 14 2024 at 15:27):

Aye, one sec.

Yaël Dillies (Nov 14 2024 at 15:28):

Wrenna Robson said:

Aye, and it seems like that ought to work here (Fin.instBoundedOrder is computable!) but in practice it uses non-computable.

There might be paths from Bot and CompleteLinearOrder that don't go through BoundedOrder

Eric Wieser (Nov 14 2024 at 15:28):

I think this will be fixed in the next Lean release

Wrenna Robson (Nov 14 2024 at 15:28):

Yeah that is what I think is happening. Just trying to work out how to click through.

Eric Wieser (Nov 14 2024 at 15:29):

In the meantime

attribute [-instance] Fin.completeLinearOrder in
instance : Bot (Fin 3) := inferInstance

fixes it

Wrenna Robson (Nov 14 2024 at 15:29):

Aha

Wrenna Robson (Nov 14 2024 at 15:30):

Thank you.


Last updated: May 02 2025 at 03:31 UTC