Zulip Chat Archive

Stream: general

Topic: dependent fields in structures


Bhakti Shah (Jul 10 2023 at 16:51):

Is something like

def strlt : String -> String -> Prop := (fun x x' => x < x')

structure X where
f1 : List String
f2 : List.Sorted strlt f1

a valid definition? It seems to typecheck but I suspect it's inferring the f1 within f2 to be a free variable and not the field itself.
as a follow up, is it even possible to define something where f2 is dependent on f1?

Eric Wieser (Jul 10 2023 at 16:57):

That does exactly what you want it to; you can confirm this with #check X.f2

Eric Wieser (Jul 10 2023 at 16:57):

If you're worried about free variables being introduced, turn on set_option autoImplicit false to make that never happen


Last updated: Dec 20 2023 at 11:08 UTC