Utilities for lists of sigmas #
This file includes several ways of interacting with List (Sigma β), treated as a key-value store.
If α : Type* and β : α → Type*, then we regard s : Sigma β as having key s.1 : α and value
s.2 : β s.1. Hence, List (Sigma β) behaves like a key-value store.
Main Definitions #
List.keysextracts the list of keys.List.NodupKeysdetermines if the store has duplicate keys.List.lookup/lookup_allaccesses the value(s) of a particular key.List.kreplacereplaces the first value with a given key by a given value.List.keraseremoves a value.List.kinsertinserts a value.List.kunioncomputes the union of two stores.List.kextractreturns a value with a given key and the rest of the values.
dlookup a l is the first value in l corresponding to the key a,
or none if no such element exists.
Instances For
@[simp]
theorem List.dlookup_map {α : Type u} {α' : Type u'} {β : α → Type v} {β' : α' → Type v'} [DecidableEq α] [DecidableEq α'] (l : List (Sigma β)) {f : α → α'} (hf : Function.Injective f) (g : (a : α) → β a → β' (f a)) (a : α) :
theorem List.dlookup_map₁ {α : Type u} {α' : Type u'} [DecidableEq α] [DecidableEq α'] {β : Type v} (l : List ((_ : α) × β)) {f : α → α'} (hf : Function.Injective f) (a : α) :
theorem List.dlookup_map₂ {α : Type u} [DecidableEq α] {γ : α → Type u_1} {δ : α → Type u_2} {l : List ((a : α) × γ a)} {f : (a : α) → γ a → δ a} (a : α) :
lookup_all a l is the list of all values in l corresponding to the key a.
Instances For
theorem List.lookupAll_nodup {α : Type u} {β : α → Type v} [DecidableEq α] (a : α) {l : List (Sigma β)} (h : l.NodupKeys) :
Replaces the first value with key a by b.
Instances For
theorem List.Perm.kreplace {α : Type u} {β : α → Type v} [DecidableEq α] {a : α} {b : β a} {l₁ l₂ : List (Sigma β)} (nd : l₁.NodupKeys) :
l₁.Perm l₂ → (List.kreplace a b l₁).Perm (List.kreplace a b l₂)
Remove the first pair with the key a.
Instances For
theorem List.kerase_sublist {α : Type u} {β : α → Type v} [DecidableEq α] (a : α) (l : List (Sigma β)) :
theorem List.NodupKeys.kerase {α : Type u} {β : α → Type v} {l : List (Sigma β)} [DecidableEq α] (a : α) :
l.NodupKeys → (List.kerase a l).NodupKeys
theorem List.Perm.kerase {α : Type u} {β : α → Type v} [DecidableEq α] {a : α} {l₁ l₂ : List (Sigma β)} (nd : l₁.NodupKeys) :
l₁.Perm l₂ → (List.kerase a l₁).Perm (List.kerase a l₂)
def List.kinsert {α : Type u} {β : α → Type v} [DecidableEq α] (a : α) (b : β a) (l : List (Sigma β)) :
Insert the pair ⟨a, b⟩ and erase the first pair with the key a.
Instances For
theorem List.kinsert_nodupKeys {α : Type u} {β : α → Type v} [DecidableEq α] (a : α) (b : β a) {l : List (Sigma β)} (nd : l.NodupKeys) :
theorem List.Perm.kinsert {α : Type u} {β : α → Type v} [DecidableEq α] {a : α} {b : β a} {l₁ l₂ : List (Sigma β)} (nd₁ : l₁.NodupKeys) (p : l₁.Perm l₂) :
(List.kinsert a b l₁).Perm (List.kinsert a b l₂)
Remove entries with duplicate keys from l : List (Sigma β).
Instances For
theorem List.nodupKeys_dedupKeys {α : Type u} {β : α → Type v} [DecidableEq α] (l : List (Sigma β)) :