Type class for finitely enumerable types. The property is stronger
than Fintype
in that it assigns each element a rank in a finite
enumeration.
FinEnum α
means that α
is finite and can be enumerated in some order,
i.e. α
has an explicit bijection with Fin n
for some n.
- card : ℕ
FinEnum.card
is the cardinality of theFinEnum
- equiv : α ≃ Fin (FinEnum.card α)
- decEq : DecidableEq α
Instances
transport a FinEnum
instance across an equivalence
Equations
- FinEnum.ofEquiv α h = FinEnum.mk (FinEnum.card α) (h.trans FinEnum.equiv)
Instances For
create a FinEnum
instance from an exhaustive list without duplicates
Equations
- One or more equations did not get rendered due to their size.
Instances For
create a FinEnum
instance from an exhaustive list; duplicates are removed
Equations
- FinEnum.ofList xs h = FinEnum.ofNodupList (List.dedup xs) (_ : ∀ (a : α), a ∈ List.dedup xs) (_ : List.Nodup (List.dedup xs))
Instances For
create an exhaustive list of the values of a given type
Equations
- FinEnum.toList α = List.map (⇑FinEnum.equiv.symm) (List.finRange (FinEnum.card α))
Instances For
create a FinEnum
instance using a surjection
Equations
- FinEnum.ofSurjective f h = FinEnum.ofList (List.map f (FinEnum.toList β)) (_ : ∀ (x : α), x ∈ List.map f (FinEnum.toList β))
Instances For
create a FinEnum
instance using an injection
Equations
- FinEnum.ofInjective f h = FinEnum.ofList (List.filterMap (Function.partialInv f) (FinEnum.toList β)) (_ : ∀ (x : α), x ∈ List.filterMap (Function.partialInv f) (FinEnum.toList β))
Instances For
Equations
Equations
Equations
Equations
- FinEnum.prod = FinEnum.ofList (FinEnum.toList α ×ˢ FinEnum.toList β) (_ : ∀ (x : α × β), x ∈ FinEnum.toList α ×ˢ FinEnum.toList β)
Equations
- FinEnum.fin = FinEnum.ofList (List.finRange n) (_ : ∀ (a : Fin n), a ∈ List.finRange n)
Equations
- FinEnum.Quotient.enum s = FinEnum.ofSurjective Quotient.mk'' (_ : ∀ (x : Quotient s), ∃ (a : α), Quotient.mk'' a = x)
enumerate all finite sets of a given type
Equations
- FinEnum.Finset.enum [] = [∅]
- FinEnum.Finset.enum (x_1 :: xs) = do let r ← FinEnum.Finset.enum xs [r, {x_1} ∪ r]
Instances For
Equations
- FinEnum.Finset.finEnum = FinEnum.ofList (FinEnum.Finset.enum (FinEnum.toList α)) (_ : ∀ (x : Finset α), x ∈ FinEnum.Finset.enum (FinEnum.toList α))
Equations
- One or more equations did not get rendered due to their size.
Equations
- FinEnum.PSigma.finEnum = FinEnum.ofEquiv ((i : α) × β i) (Equiv.psigmaEquivSigma fun (a : α) => β a)
Equations
- FinEnum.instFintype = { elems := Finset.map (Equiv.toEmbedding FinEnum.equiv.symm) Finset.univ, complete := (_ : ∀ (x : α), x ∈ Finset.map (Equiv.toEmbedding FinEnum.equiv.symm) Finset.univ) }
For Pi.cons x xs y f
create a function where every i ∈ xs
is mapped to f i
and
x
is mapped to y
Equations
Instances For
Given f
a function whose domain is x :: xs
, produce a function whose domain
is restricted to xs
.
Equations
- FinEnum.Pi.tail f x✝ x = match x✝, x with | a, h => f a (_ : a ∈ x✝¹ :: xs)
Instances For
pi xs f
creates the list of functions g
such that, for x ∈ xs
, g x ∈ f x
Equations
- FinEnum.pi [] x = [fun (x : α) (h : x ∈ []) => (_ : False).elim]
- FinEnum.pi (x_2 :: xs) x = Seq.seq (FinEnum.Pi.cons x_2 xs <$> x x_2) fun (x_1 : Unit) => FinEnum.pi xs x
Instances For
enumerate all functions whose domain and range are finitely enumerable
Equations
- FinEnum.pi.enum β = List.map (fun (f : (a : α) → a ∈ FinEnum.toList α → β a) (x : α) => f x (_ : x ∈ FinEnum.toList α)) (FinEnum.pi (FinEnum.toList α) fun (x : α) => FinEnum.toList (β x))
Instances For
Equations
- FinEnum.pi.finEnum = FinEnum.ofList (FinEnum.pi.enum fun (a : α) => β a) (_ : ∀ (x : (a : α) → β a), x ∈ FinEnum.pi.enum fun (a : α) => β a)