Zulip Chat Archive
Stream: lean4
Topic: universe level not normalized in DecidableLT
Jovan Gerbscheid (Apr 26 2025 at 14:18):
When working on the @[to_dual]
attribute, I ran into the problem that DecidableLT
has type Sort (max 1 (u+1))
. The way it gets pretty printed varies:
import Lean
open Lean
-- DecidableLT.{u} (α : Type u) [LT α] : Type u
#check DecidableLT
-- (α : Type u) → [inst : LT α] → Type (max 0 u)
run_meta logInfo m! "{(← getConstInfo ``DecidableLT).type}"
This is an issue because I want to define the dual DecidableGT
/DecidableLT'
, but that one does live in the expected Type u
.
I wrote a program to find more occurences of this
code
And here are the bad declarations it found in Lean/Batteries:
-- Batteries.Data.BinomialHeap.Basic
#check Batteries.BinomialHeap
-- Batteries.Data.PairingHeap
#check Batteries.PairingHeap
-- Init.Core
#check @Subtype.instDecidableEq
-- Init.Data.Array.Lemmas
#check @Array.swapAt!.eq_1
-- Init.Data.Array.QSort
#check @Array.qpartition.loop.eq_def✝
-- Init.Data.Vector.Lemmas
#check @Vector.insertIdx!.eq_1
#check @Vector.eraseIdx!.eq_1
-- Init.Prelude
#check NonemptyType
#check DecidableLT
#check DecidableLE
-- Init.WF
#check PSigma.skipLeft
-- Lean.Data.HashSet
#check HashSetBucket
#check HashSet
-- Lean.Data.SSet
#check SSet
Eric Wieser (Apr 26 2025 at 14:40):
Just to take #check
out of the picture, inferType
also reports the "clean" universe:
import Lean
import Qq
open Lean Qq
-- (α : Type u) → [inst : LT α] → Type u
run_meta do
let u : Level := .param `u
let e := q(@DecidableLT.{u})
logInfo m!"{← Meta.inferType e}"
Last updated: May 02 2025 at 03:31 UTC