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 Mathlib/Data/Set/Basic.lean.
An alternative version of Subtype.forall. This one is useful if Lean cannot figure out q
when using Subtype.forall from right to left.
Restrict a (dependent) function to a subtype
Equations
- Subtype.restrict p f x = f ↑x
Instances For
Some facts about sets, which require that α is a type.