theorem
list.nodupkeys.pairwise_ne
{α : Type u}
{β : α → Type v}
{l : list (sigma β)}
(h : l.nodupkeys) :
list.pairwise (λ (s s' : sigma β), s.fst ≠ s'.fst) l
def
list.lookup
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
(a_1 : list (sigma β)) :
option (β a)
lookup a l
is the first value in l
corresponding to the key a
,
or none
if no such element exists.
Equations
- list.lookup a (⟨a', b⟩ :: l) = dite (a' = a) (λ (h : a' = a), some (h.rec_on b)) (λ (h : ¬a' = a), list.lookup a l)
- list.lookup a list.nil = none
@[simp]
@[simp]
theorem
list.lookup_cons_eq
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(l : list (Σ (a : α), β a))
(a : α)
(b : β a) :
list.lookup a (⟨a, b⟩ :: l) = some b
@[simp]
theorem
list.lookup_cons_ne
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(l : list (sigma β))
{a : α}
(s : sigma β)
(a_1 : a ≠ s.fst) :
list.lookup a (s :: l) = list.lookup a l
theorem
list.lookup_is_some
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{l : list (sigma β)} :
theorem
list.lookup_eq_none
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{l : list (sigma β)} :
theorem
list.of_mem_lookup
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{b : β a}
{l : list (sigma β)}
(a_1 : b ∈ list.lookup a l) :
theorem
list.mem_lookup
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{b : β a}
{l : list (sigma β)}
(nd : l.nodupkeys)
(h : ⟨a, b⟩ ∈ l) :
b ∈ list.lookup a l
theorem
list.map_lookup_eq_find
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
(l : list (sigma β)) :
option.map (sigma.mk a) (list.lookup a l) = list.find (λ (s : sigma β), a = s.fst) l
theorem
list.mem_lookup_iff
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{b : β a}
{l : list (sigma β)}
(nd : l.nodupkeys) :
b ∈ list.lookup a l ↔ ⟨a, b⟩ ∈ l
theorem
list.perm_lookup
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
{l₁ l₂ : list (sigma β)}
(nd₁ : l₁.nodupkeys)
(nd₂ : l₂.nodupkeys)
(p : l₁ ~ l₂) :
list.lookup a l₁ = list.lookup a l₂
theorem
list.lookup_ext
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{l₀ l₁ : list (sigma β)}
(nd₀ : l₀.nodupkeys)
(nd₁ : l₁.nodupkeys)
(h : ∀ (x : α) (y : β x), y ∈ list.lookup x l₀ ↔ y ∈ list.lookup x l₁) :
l₀ ~ l₁
def
list.lookup_all
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
(a_1 : list (sigma β)) :
list (β a)
lookup_all a l
is the list of all values in l
corresponding to the key a
.
Equations
- list.lookup_all a (⟨a', b⟩ :: l) = dite (a' = a) (λ (h : a' = a), h.rec_on b :: list.lookup_all a l) (λ (h : ¬a' = a), list.lookup_all a l)
- list.lookup_all a list.nil = list.nil
@[simp]
@[simp]
theorem
list.lookup_all_cons_eq
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(l : list (Σ (a : α), β a))
(a : α)
(b : β a) :
list.lookup_all a (⟨a, b⟩ :: l) = b :: list.lookup_all a l
@[simp]
theorem
list.lookup_all_cons_ne
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(l : list (sigma β))
{a : α}
(s : sigma β)
(a_1 : a ≠ s.fst) :
list.lookup_all a (s :: l) = list.lookup_all a l
theorem
list.lookup_all_eq_nil
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{l : list (sigma β)} :
theorem
list.head_lookup_all
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
(l : list (sigma β)) :
(list.lookup_all a l).head' = list.lookup a l
theorem
list.mem_lookup_all
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{b : β a}
{l : list (sigma β)} :
b ∈ list.lookup_all a l ↔ ⟨a, b⟩ ∈ l
theorem
list.lookup_all_sublist
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
(l : list (sigma β)) :
list.map (sigma.mk a) (list.lookup_all a l) <+ l
theorem
list.lookup_all_length_le_one
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
{l : list (sigma β)}
(h : l.nodupkeys) :
(list.lookup_all a l).length ≤ 1
theorem
list.lookup_all_eq_lookup
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
{l : list (sigma β)}
(h : l.nodupkeys) :
list.lookup_all a l = (list.lookup a l).to_list
theorem
list.lookup_all_nodup
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
{l : list (sigma β)}
(h : l.nodupkeys) :
(list.lookup_all a l).nodup
theorem
list.perm_lookup_all
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
{l₁ l₂ : list (sigma β)}
(nd₁ : l₁.nodupkeys)
(nd₂ : l₂.nodupkeys)
(p : l₁ ~ l₂) :
list.lookup_all a l₁ = list.lookup_all a l₂
theorem
list.kreplace_of_forall_not
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
(b : β a)
{l : list (sigma β)}
(H : ∀ (b : β a), ⟨a, b⟩ ∉ l) :
list.kreplace a b l = l
theorem
list.kreplace_self
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{b : β a}
{l : list (sigma β)}
(nd : l.nodupkeys)
(h : ⟨a, b⟩ ∈ l) :
list.kreplace a b l = l
theorem
list.keys_kreplace
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
(b : β a)
(l : list (sigma β)) :
(list.kreplace a b l).keys = l.keys
theorem
list.kreplace_nodupkeys
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
(b : β a)
{l : list (sigma β)} :
(list.kreplace a b l).nodupkeys ↔ l.nodupkeys
theorem
list.perm.kreplace
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{b : β a}
{l₁ l₂ : list (sigma β)}
(nd : l₁.nodupkeys)
(a_1 : l₁ ~ l₂) :
list.kreplace a b l₁ ~ list.kreplace a b l₂
Remove the first pair with the key a
.
Equations
- list.kerase a = list.erasep (λ (s : sigma β), a = s.fst)
@[simp]
@[simp]
theorem
list.kerase_cons_eq
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{s : sigma β}
{l : list (sigma β)}
(h : a = s.fst) :
list.kerase a (s :: l) = l
@[simp]
theorem
list.kerase_cons_ne
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{s : sigma β}
{l : list (sigma β)}
(h : a ≠ s.fst) :
list.kerase a (s :: l) = s :: list.kerase a l
@[simp]
theorem
list.kerase_of_not_mem_keys
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{l : list (sigma β)}
(h : a ∉ l.keys) :
list.kerase a l = l
theorem
list.kerase_sublist
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
(l : list (sigma β)) :
list.kerase a l <+ l
theorem
list.kerase_keys_subset
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
(l : list (sigma β)) :
(list.kerase a l).keys ⊆ l.keys
theorem
list.mem_keys_of_mem_keys_kerase
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a₁ a₂ : α}
{l : list (sigma β)}
(a : a₁ ∈ (list.kerase a₂ l).keys) :
@[simp]
theorem
list.mem_keys_kerase_of_ne
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a₁ a₂ : α}
{l : list (sigma β)}
(h : a₁ ≠ a₂) :
theorem
list.keys_kerase
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{l : list (sigma β)} :
(list.kerase a l).keys = l.keys.erase a
theorem
list.kerase_kerase
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a a' : α}
{l : list (sigma β)} :
list.kerase a (list.kerase a' l) = list.kerase a' (list.kerase a l)
theorem
list.kerase_nodupkeys
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
{l : list (sigma β)}
(a_1 : l.nodupkeys) :
(list.kerase a l).nodupkeys
theorem
list.perm.kerase
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{l₁ l₂ : list (sigma β)}
(nd : l₁.nodupkeys)
(a_1 : l₁ ~ l₂) :
list.kerase a l₁ ~ list.kerase a l₂
@[simp]
theorem
list.not_mem_keys_kerase
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
{l : list (sigma β)}
(nd : l.nodupkeys) :
a ∉ (list.kerase a l).keys
@[simp]
theorem
list.lookup_kerase
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
{l : list (sigma β)}
(nd : l.nodupkeys) :
list.lookup a (list.kerase a l) = none
@[simp]
theorem
list.lookup_kerase_ne
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a a' : α}
{l : list (sigma β)}
(h : a ≠ a') :
list.lookup a (list.kerase a' l) = list.lookup a l
theorem
list.kerase_append_left
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{l₁ l₂ : list (sigma β)}
(a_1 : a ∈ l₁.keys) :
list.kerase a (l₁ ++ l₂) = list.kerase a l₁ ++ l₂
theorem
list.kerase_append_right
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{l₁ l₂ : list (sigma β)}
(a_1 : a ∉ l₁.keys) :
list.kerase a (l₁ ++ l₂) = l₁ ++ list.kerase a l₂
theorem
list.kerase_comm
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a₁ a₂ : α)
(l : list (sigma β)) :
list.kerase a₂ (list.kerase a₁ l) = list.kerase a₁ (list.kerase a₂ l)
theorem
list.sizeof_kerase
{α : Type u_1}
{β : α → Type u_2}
[decidable_eq α]
[has_sizeof (sigma β)]
(x : α)
(xs : list (sigma β)) :
sizeof (list.kerase x xs) ≤ sizeof xs
def
list.kinsert
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
(b : β a)
(l : list (sigma β)) :
Insert the pair ⟨a, b⟩
and erase the first pair with the key a
.
Equations
- list.kinsert a b l = ⟨a, b⟩ :: list.kerase a l
@[simp]
theorem
list.kinsert_def
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{b : β a}
{l : list (sigma β)} :
list.kinsert a b l = ⟨a, b⟩ :: list.kerase a l
theorem
list.mem_keys_kinsert
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a a' : α}
{b' : β a'}
{l : list (sigma β)} :
theorem
list.kinsert_nodupkeys
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
(b : β a)
{l : list (sigma β)}
(nd : l.nodupkeys) :
(list.kinsert a b l).nodupkeys
theorem
list.perm.kinsert
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{b : β a}
{l₁ l₂ : list (sigma β)}
(nd₁ : l₁.nodupkeys)
(p : l₁ ~ l₂) :
list.kinsert a b l₁ ~ list.kinsert a b l₂
theorem
list.lookup_kinsert
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{b : β a}
(l : list (sigma β)) :
list.lookup a (list.kinsert a b l) = some b
theorem
list.lookup_kinsert_ne
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a a' : α}
{b' : β a'}
{l : list (sigma β)}
(h : a ≠ a') :
list.lookup a (list.kinsert a' b' l) = list.lookup a l
@[simp]
theorem
list.kextract_eq_lookup_kerase
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
(l : list (sigma β)) :
list.kextract a l = (list.lookup a l, list.kerase a l)
Remove entries with duplicate keys from l : list (sigma β)
.
Equations
- list.erase_dupkeys = list.foldr (λ (x : sigma β), list.kinsert x.fst x.snd) list.nil
theorem
list.erase_dupkeys_cons
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{x : sigma β}
(l : list (sigma β)) :
(x :: l).erase_dupkeys = list.kinsert x.fst x.snd l.erase_dupkeys
theorem
list.nodupkeys_erase_dupkeys
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(l : list (sigma β)) :
theorem
list.lookup_erase_dupkeys
{α : Type u}
{β : α → Type v}
[decidable_eq α]
(a : α)
(l : list (sigma β)) :
list.lookup a l.erase_dupkeys = list.lookup a l
theorem
list.sizeof_erase_dupkeys
{α : Type u_1}
{β : α → Type u_2}
[decidable_eq α]
[has_sizeof (sigma β)]
(xs : list (sigma β)) :
sizeof xs.erase_dupkeys ≤ sizeof xs
kunion l₁ l₂
is the append to l₁ of l₂ after, for each key in l₁, the
first matching pair in l₂ is erased.
@[simp]
@[simp]
@[simp]
theorem
list.kunion_cons
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{s : sigma β}
{l₁ l₂ : list (sigma β)} :
@[simp]
theorem
list.kunion_kerase
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{l₁ l₂ : list (sigma β)} :
(list.kerase a l₁).kunion (list.kerase a l₂) = list.kerase a (l₁.kunion l₂)
theorem
list.kunion_nodupkeys
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{l₁ l₂ : list (sigma β)}
(nd₁ : l₁.nodupkeys)
(nd₂ : l₂.nodupkeys) :
@[simp]
theorem
list.lookup_kunion_left
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{l₁ l₂ : list (sigma β)}
(h : a ∈ l₁.keys) :
list.lookup a (l₁.kunion l₂) = list.lookup a l₁
@[simp]
theorem
list.lookup_kunion_right
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{l₁ l₂ : list (sigma β)}
(h : a ∉ l₁.keys) :
list.lookup a (l₁.kunion l₂) = list.lookup a l₂
@[simp]
theorem
list.mem_lookup_kunion
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{b : β a}
{l₁ l₂ : list (sigma β)} :
b ∈ list.lookup a (l₁.kunion l₂) ↔ b ∈ list.lookup a l₁ ∨ a ∉ l₁.keys ∧ b ∈ list.lookup a l₂
theorem
list.mem_lookup_kunion_middle
{α : Type u}
{β : α → Type v}
[decidable_eq α]
{a : α}
{b : β a}
{l₁ l₂ l₃ : list (sigma β)}
(h₁ : b ∈ list.lookup a (l₁.kunion l₃))
(h₂ : a ∉ l₂.keys) :
b ∈ list.lookup a ((l₁.kunion l₂).kunion l₃)