Subtypes #
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.
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.
Alias of the forward direction of Subtype.coe_ne_coe
.
Restrict a (dependent) function to a subtype
Equations
- Subtype.restrict p f x = f ↑x
Instances For
Defining a map into a subtype, this can be seen as a "coinduction principle" of Subtype
Equations
- Subtype.coind f h a = ⟨f a, ⋯⟩
Instances For
Restriction of a function to a function on subtypes.
Equations
- Subtype.map f h x = ⟨f ↑x, ⋯⟩
Instances For
Some facts about sets, which require that α
is a type.