Documentation

CslibFrontier.Foundations.Data.List.NodupFlatMap

Distinct items of mapped lists #

The items f i k for the distinct indices i of a list and the distinct entries k of lists ks i are distinct when f determines both i and k (List.nodup_flatMap_map).

Main results #

References #

From VP ≠ VNP over every field [Ant26], Appendix J.3: the keys of the units that the evaluator of the proof of Theorem J.3 writes (p. 54); source module Nc.Grp.StepBase.

theorem List.nodup_flatMap_map {ι : Type u_1} {κ : Type u_2} {β : Type u_3} {l : List ι} (hl : l.Nodup) {ks : ι → List κ} (hks : ∀ (i : ι), (ks i).Nodup) {f : ι → κ → β} (hf : ∀ (i : ι) (k : κ) (i' : ι) (k' : κ), f i k = f i' k' → i = i' ∧ k = k') :
(flatMap (fun (i : ι) => map (f i) (ks i)) l).Nodup

The items f i k of several lists ks i, for the indices i of a list without duplicates, are distinct if the lists have no duplicates and f i k determines i and k.

theorem List.nodup_flatMap_zipIdx {α : Type u_1} {β : Type u_2} {γ : Type u_3} (l : List α) (ks : α → List β) {f : α × ℕ → β × ℕ → γ} (key : γ → ℕ × ℕ) (hkey : ∀ (i : α × ℕ) (k : β × ℕ), key (f i k) = (i.2, k.2)) :
(flatMap (fun (i : α × ℕ) => map (f i) (ks i.1).zipIdx) l.zipIdx).Nodup

A flattened enumeration has distinct entries if each output identifies its two indices.