Zulip Chat Archive

Stream: new members

Topic: subtype


Alex Zhang (Jul 17 2021 at 13:57):

Is it possible to prove that two subtypes are equal?

import data.fintype.card

variables {α β : Type*} (p q : α  Prop)

example (h:  a, p a  q a) : subtype p = subtype q :=
by {sorry}

Eric Wieser (Jul 17 2021 at 14:01):

Yes, first show p = q

Eric Wieser (Jul 17 2021 at 14:02):

Which you should be able to do by combining docs#propext and docs#funext

Victor Porton (Apr 02 2022 at 00:25):

Is there a notion of subtype (like subset)?

Arthur Paulino (Apr 02 2022 at 00:36):

If you scroll up this thread you'll see that there's indeed a subtype. It's defined in core as

/- Remark: subtype must take a Sort instead of Type because of the axiom strong_indefinite_description. -/
structure subtype {α : Sort u} (p : α  Prop) :=
(val : α) (property : p val)

But I'm not sure this is what you mean by "subtype"

Eric Wieser (Apr 02 2022 at 00:37):

(docs#subtype)

Victor Porton (Apr 02 2022 at 00:37):

@Arthur Paulino I mean subtype relation like subset relation.

Victor Porton (Apr 02 2022 at 00:38):

@Eric Wieser Not this.

Eric Wieser (Apr 02 2022 at 00:38):

Can you elaborate on what you mean?

Kyle Miller (Apr 02 2022 at 00:38):

The answer is "no" in the way you'd probably want -- every term has a type and only one type, and if you had subset-like subtypes you'd have to allow terms with more than one type.

Instead, what we have is that for every set (equivalently, every predicate on a type), there exists a type whose terms are, in some sense, in one-to-one correspondence with the elements of the set. There's an injective function from that type to the original type whose image consists of the elements of that set. One possible implementation of this type is subtype.

Kyle Miller (Apr 02 2022 at 00:39):

If you like to hear things like "subobject classifiers" I once posted a diagram.

Kyle Miller (Apr 02 2022 at 00:40):

In Lean/mathlib we use coercions to make it seem like subtype is a "subtype" in the sense you want, but you have to get used to it.

Kyle Miller (Apr 02 2022 at 00:41):

For example, when I write

example (s : set ) (x : s) :  := x

Lean is automatically inserting coercions so that it's actually

example (s : set ) (x : subtype s) :  := x.val

Kyle Miller (Apr 02 2022 at 00:43):

If you're wanting to consider more than one "subtype" of a type and relate them in different ways, it's usually less of a pain to work with sets, which, just to be clear, are just predicates on a type:

def set (α : Type*) := α  Prop

Last updated: Dec 20 2023 at 11:08 UTC