Documentation

CslibFrontier.Foundations.Data.List.ListsUpTo

Short lists over a list #

List.listsUpTo l r lists the lists of length at most r whose entries come from l (List.mem_listsUpTo). There are at most (l.length + 1) ^ r of them (List.length_listsUpTo_le), and fewer than l.length ^ (r + 1) when 2 ≤ l.length (List.length_listsUpTo_lt_pow), so for a fixed r the listing has polynomial length.

Main definitions #

Main results #

def List.listsUpTo {α : Type u_1} (l : List α) :
ℕ → List (List α)

The lists of length at most r with entries from l: the empty list, then each entry of l followed by each list of length at most r - 1.

theorem List.mem_listsUpTo {α : Type u_1} {l : List α} {r : ℕ} {P : List α} :
P ∈ l.listsUpTo r ↔ P.length ≤ r ∧ ∀ a ∈ P, a ∈ l

A list is in listsUpTo l r exactly when it has length at most r and entries from l.

theorem List.length_listsUpTo_le {α : Type u_1} (l : List α) (r : ℕ) :
(l.listsUpTo r).length ≤ (l.length + 1) ^ r

There are at most (l.length + 1) ^ r lists of length at most r with entries from l.

theorem List.length_listsUpTo_lt_pow {α : Type u_1} {l : List α} (hl : 2 ≤ l.length) (r : ℕ) :
(l.listsUpTo r).length < l.length ^ (r + 1)

With at least two entries to choose from, there are fewer than l.length ^ (r + 1) lists of length at most r (List.length_listsUpTo_le gives (l.length + 1) ^ r for every l).

theorem List.nodup_listsUpTo {α : Type u_1} {l : List α} (hl : l.Nodup) (r : ℕ) :

Over a list without duplicates, the short lists have no duplicates.