Zulip Chat Archive
Stream: lean4
Topic: Running `evalConst` in `Type 1`
Anand Rao Tadipatri (Oct 19 2024 at 11:09):
I have a definition that lives in Type 1
import Lean
open Lean Elab Meta Command
structure Test where
map : Type → Type
#check Test -- Type 1
def instTestList : Test where
map := List
#check show MetaM _ from do
evalConst Test ``instTestList
/- ERROR
application type mismatch
evalConst Test
argument
Test
has type
Type 1 : Type 2
but is expected to have type
Type : Type 1
-/
This makes it difficult to use it in conjunction with evalConst
and MetaM
, which expect a term of type Type
. Is there a way around this?
Eric Wieser (Oct 19 2024 at 11:13):
Can you give a more complex example? There's nothing to evaluate in this one
Kyle Miller (Oct 19 2024 at 17:32):
evalConst
would only work with computationally relevant values. Type
has no runtime representation.
Anand Rao Tadipatri (Oct 20 2024 at 22:26):
Apologies for the delay, I've updated my example.
Kyle Miller (Oct 20 2024 at 22:42):
If you wanting to evaluate Test
at runtime, this has problems because Type -> Type
has no runtime representation.
Is this a toy example for what you actually want to do?
Anand Rao Tadipatri (Oct 20 2024 at 22:44):
Thanks. Yes, it's a toy example for the actual situation I would like to use it in.
Kyle Miller (Oct 20 2024 at 22:49):
Ok, I see. Unfortunately Lean.evalConst
has that universe constraint, but if you use docs#Lean.Environment.evalConst directly you can evaluate it.
Eric Wieser (Oct 20 2024 at 23:00):
What's the Intended difference between that and docs#Lean.evalConst ?
Eric Wieser (Oct 20 2024 at 23:02):
Oh, I guess the latter uses the monad stack for convenience, but is stuck in Type as a result
Last updated: May 02 2025 at 03:31 UTC