Subtypes #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
This file provides basic API for subtypes, which are defined in core.
A subtype is a type made from restricting another type, say α
, to its elements that satisfy some
predicate, say p : α → Prop
. Specifically, it is the type of pairs ⟨val, property⟩
where
val : α
and property : p val
. It is denoted subtype p
and notation {val : α // p val}
is
available.
A subtype has a natural coercion to the parent type, by coercing ⟨val, property⟩
to val
. As
such, subtypes can be thought of as bundled sets, the difference being that elements of a set are
still of type α
while elements of a subtype aren't.
See Note [custom simps projection]
Equations
- subtype.simps.coe x = ↑x
A version of x.property
or x.2
where p
is syntactically applied to the coercion of x
instead of x.1
. A similar result is subtype.mem
in data.set.basic
.
An alternative version of subtype.forall
. This one is useful if Lean cannot figure out q
when using subtype.forall
from right to left.
An alternative version of subtype.exists
. This one is useful if Lean cannot figure out q
when using subtype.exists
from right to left.
Equations
- subtype.setoid p = {r := has_equiv.equiv (subtype.has_equiv p), iseqv := _}
Some facts about sets, which require that α
is a type.