Zulip Chat Archive

Stream: lean4

Topic: map out of restricted comprehension


Dean Young (Dec 18 2022 at 16:09):

How would you construct a map out of a restricted comprehension?

variable {X : Type 1}
variable {B : Type 1}
variable {p : X -> Prop}
def A := {x : X // p x }
def f : A -> B := ???

Kevin Buzzard (Dec 18 2022 at 16:29):

variable {X : Type 1}
variable {B : Type 1}
variable (p : X -> Prop)
def A := {x : X // p x }
def f : A p -> B := λ x, hx => _
def f' : A p -> X := λ a => a.val
def f'' : A p -> A p := λ a => a.val, a.property

Dean Young (Dec 19 2022 at 00:22):

Kevin Buzzard said:

variable {X : Type 1}
variable {B : Type 1}
variable (p : X -> Prop)
def A := {x : X // p x }
def f : A p -> B := λ x, hx => _
def f' : A p -> X := λ a => a.val
def f'' : A p -> A p := λ a => a.val, a.property

I get

Main.lean:54:28: error: invalid pattern, constructor or constant marked with '[match_pattern]' expected

Kevin Buzzard (Dec 19 2022 at 00:23):

Are you on an up to date version of lean 4?

Dean Young (Dec 20 2022 at 00:17):

Kevin Buzzard said:

Are you on an up to date version of lean 4?

I managed to fix it thanks :)


Last updated: Dec 20 2023 at 11:08 UTC