Documentation

Projects.Util.Data.Map.Part_002

theorem Map.get?_erase {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {i j : α} :
get? i (m.erase j) = if j = i then none else get? i m
@[simp]
theorem Map.insert_erase {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {i : α} {x : β} :
(m.erase i).insert i x = m.insert i x
@[simp]
theorem Map.toList_erase {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [ha : LinearOrder α] {i : α} :
(m.erase i).toList = List.filter (fun (x : α × β) => decide (x.1 ≠ i)) m.toList
@[simp]
theorem Map.sum_values_erase {α : Type u} [hh₁ : DecidableEq α] [hh₂ : Hashable α] [ha : LinearOrder α] {m : Map α ℕ} {i : α} :
(m.erase i).values.sum = m.values.sum - (get? i m).getD 0
@[simp]
theorem Map.le_sum_values_of_get?_eq_some {α : Type u} [hh₁ : DecidableEq α] [hh₂ : Hashable α] [ha : LinearOrder α] {m : Map α ℕ} {i : α} {x : ℕ} (h : get? i m = some x) :
@[simp]
theorem Map.sum_values_insert {α : Type u} [hh₁ : DecidableEq α] [hh₂ : Hashable α] [ha : LinearOrder α] {m : Map α ℕ} {i : α} {x : ℕ} :
(m.insert i x).values.sum = m.values.sum + x - (get? i m).getD 0
@[simp]
theorem Map.sum_values_push {α : Type u} [hh₁ : DecidableEq α] [hh₂ : Hashable α] [ha : LinearOrder α] {m : Map α ℕ} {x : α} :
(m.push x).values.sum = m.values.sum + 1
@[simp]
theorem Map.get?_insert_of_eq {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {i : α} {x : β} :
get? i (m.insert i x) = some x
theorem Map.cntrex₁ :
¬∀ {α β : Type} [inst : DecidableEq α] [inst_1 : Hashable α] (xs : List (α × β)) (x : β) (i : α), (∀ (i : α), get? i (ofList xs) ≠ some x) → (i, x) ∉ xs
theorem Map.cntrex₂ :
¬∀ {α β : Type} [inst : DecidableEq α] [inst_1 : Hashable α] (xs : List (α × β)) (x : β), (∀ (i : α), get? i (ofList xs) ≠ some x) ↔ ∀ (i : α), (i, x) ∉ xs
theorem Map.get?_ne_some_of_forall_not_mem {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {xs : List (α × β)} {x : β} {i : α} (h : ∀ (i : α), (i, x) ∉ xs) :
get? i (ofList xs) ≠ some x
class Map.HasNoVal {α : Type u_1} {β : Type u_2} [DecidableEq α] [Hashable α] (x : β) (m : Map α β) :
  • not_mem_values' : x ∉ m.values
Instances
    def Map.ofListD {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] [hb : DecidableEq β] (x : β) (xs : List (α × β)) :
    Map α β
    Equations
    Instances For
      def Map.insertD {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] [hb : DecidableEq β] (x : β) (m : Map α β) (i : α) (y : β) :
      Map α β
      Equations
      Instances For
        def Map.getD {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] (x : β) (m : Map α β) (i : α) :
        β
        Equations
        Instances For
          theorem Map.HasNoVal.iff {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {x : β} :
          HasNoVal x m ↔ ∀ (i : α), get? i m ≠ some x
          instance Map.instHasNoValOfListD {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] [hb : DecidableEq β] {x : β} {xs : List (α × β)} :
          HasNoVal x (ofListD x xs)
          instance Map.instHasNoValInsertD {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [hb : DecidableEq β] {i : α} {x y : β} [h : HasNoVal x m] :
          HasNoVal x (insertD x m i y)
          instance Map.instHasNoValErase {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {i : α} {x : β} [h : HasNoVal x m] :
          HasNoVal x (m.erase i)
          @[simp]
          theorem Map.HasNoVal.get?_ne_some {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {x : β} {i : α} [h : HasNoVal x m] :
          get? i m ≠ some x
          theorem Map.HasNoVal.not_mem_values {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [ha : LinearOrder α] {x : β} [h : HasNoVal x m] :
          x ∉ m.values
          theorem Map.get?_eq_find?_toList {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [ha : LinearOrder α] {i : α} :
          get? i m = Option.map (fun (x : α × β) => x.2) (List.find? (fun (x : α × β) => decide (x.1 = i)) m.toList)
          theorem Map.get?_eq_find?_toList_ext {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] [ha : LinearOrder α] :
          get? = fun (i : α) (m : Map α β) => Option.map (fun (x : α × β) => x.2) (List.find? (fun (x : α × β) => decide (x.1 = i)) m.toList)
          @[simp]
          theorem Map.erase_erase_of_eq {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {mp : Map α β} {i : α} :
          (mp.erase i).erase i = mp.erase i
          @[simp]
          theorem Map.insert_erase_of_eq {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {mp : Map α β} {i : α} {x : β} :
          (mp.erase i).insert i x = mp.insert i x
          @[simp]
          theorem Map.insertD_insertD_of_eq {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [hb : DecidableEq β] {i : α} {x y z : β} :
          insertD x (insertD x m i y) i z = insertD x m i z
          @[simp]
          theorem Map.insert_eq_self_iff {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {i : α} {x : β} :
          m.insert i x = m ↔ get? i m = some x
          @[simp]
          theorem Map.ofListD_nil {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] [hb : DecidableEq β] {x : β} :
          @[simp]
          theorem Map.getD_empty {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {x : β} {i : α} :
          getD x ∅ i = x
          @[simp]
          theorem Map.cntrex₃ :
          ¬∀ (α β : Type) [inst : DecidableEq α] [inst_1 : Hashable α] [inst_2 : DecidableEq β] (xs : List (α × β)) (x : β) (i : α), getD x (ofListD x xs) i = (get? i (ofList xs)).getD x
          @[simp]
          theorem Map.getD_insert_of_eq {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {x : β} {i : α} {y : β} :
          getD x (m.insert i y) i = y
          theorem Map.getD_insert_of_ne {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {x : β} {i j : α} {y : β} (h : i ≠ j) :
          getD x (m.insert i y) j = getD x m j
          @[simp]
          theorem Map.insertD_of_eq {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [hb : DecidableEq β] {x : β} {i : α} :
          insertD x m i x = m.erase i
          @[simp]
          theorem Map.erase_insert_of_eq {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {i : α} {x : β} :
          (m.insert i x).erase i = m.erase i
          @[simp]
          theorem Map.erase_insertD_of_eq {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [hb : DecidableEq β] {x : β} {i : α} {y : β} :
          (insertD x m i y).erase i = m.erase i
          @[simp]
          theorem Map.erase_eq_self_iff {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {i : α} :
          m.erase i = m ↔ i ∉ m
          @[simp]
          theorem Map.erase_empty {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {i : α} :
          @[simp]
          theorem Map.mem_insertD_iff {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [hb : DecidableEq β] {x y : β} {i j : α} :
          j ∈ insertD x m i y ↔ if j = i then y ≠ x else j ∈ m
          @[simp]
          theorem Map.get?_erase_of_eq {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {i : α} :
          get? i (m.erase i) = none
          @[simp]
          theorem Map.ofListD_zip_replicte {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] [hb : DecidableEq β] {x : β} {xs : List α} {n : ℕ} :
          theorem Map.erase_eq_self_of {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {i : α} (h : i ∉ m) :
          m.erase i = m
          theorem Map.insert_eq_self_of {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {i : α} {x : β} (h : get? i m = some x) :
          m.insert i x = m
          @[simp]
          theorem Map.get?_insertD_of_ne {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [hb : DecidableEq β] {i j : α} {x y : β} (h : i ≠ j) :
          get? j (insertD x m i y) = get? j m
          theorem Map.insertD_eq_self_of {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [hb : DecidableEq β] {i : α} {x y : β} (h₁ : if y = x then i ∉ m else get? i m = some y) :
          insertD x m i y = m
          @[simp]
          theorem Map.insertD_eq_self_iff {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [hb : DecidableEq β] {i : α} {x y : β} :
          insertD x m i y = m ↔ if y = x then i ∉ m else get? i m = some y
          @[simp]
          theorem Map.getD_insertD_of_ne {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [hb : DecidableEq β] {i j : α} {x y : β} (h : i ≠ j) :
          getD x (insertD x m i y) j = getD x m j
          @[simp]
          theorem Map.getD_eq_iff_some_of_ne {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {i : α} {x y : β} (h : y ≠ x) :
          getD x m i = y ↔ get? i m = some y
          @[simp]
          theorem Map.get?_insertD_of_eq {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [hb : DecidableEq β] {i : α} {x y : β} :
          get? i (insertD x m i y) = if y = x then none else some y
          @[simp]
          theorem Map.getD_insertD_of_eq {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [hb : DecidableEq β] {i : α} {x y : β} :
          getD x (insertD x m i y) i = y
          @[simp]
          theorem Map.keys_eq_nil_iff {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [ha : LinearOrder α] :
          @[simp]
          theorem Map.nil_eq_keys_iff {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [ha : LinearOrder α] :
          @[simp]
          theorem Map.erase_eq_empty_iff {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {i : α} :
          m.erase i = ∅ ↔ m = ∅ ∨ ∃ (x : β), m = ∅.insert i x
          @[simp]
          theorem Map.insertD_eq_empty_iff {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [hb : DecidableEq β] {i : α} {x y : β} :
          insertD x m i y = ∅ ↔ x = y ∧ (m = ∅ ∨ ∃ (x : β), m = ∅.insert i x)
          @[simp]
          theorem Map.empty_eq_insertD_iff {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [hb : DecidableEq β] {i : α} {x y : β} :
          ∅ = insertD x m i y ↔ x = y ∧ (m = ∅ ∨ ∃ (x : β), m = ∅.insert i x)
          theorem Map.insertD_comm {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [hb : DecidableEq β] {i j : α} {x y z : β} (h : i ≠ j) :
          insertD x (insertD x m i y) j z = insertD x (insertD x m j z) i y
          theorem Map.getD_insertD {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [hb : DecidableEq β] {i j : α} {x y : β} :
          getD x (insertD x m i y) j = if j = i then y else getD x m j
          theorem Map.insertD_of_ne {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [hb : DecidableEq β] {i : α} {x y : β} (h : y ≠ x) :
          insertD x m i y = m.insert i y
          theorem Map.ext_getD_iff {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m₁ m₂ : Map α β} (x : β) (h₁ : ∀ (i : α), get? i m₁ ≠ some x) (h₂ : ∀ (i : α), get? i m₂ ≠ some x) :
          m₁ = m₂ ↔ ∀ (i : α), getD x m₁ i = getD x m₂ i
          theorem Map.forall_get?_ne_some_iff {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [ha : LinearOrder α] {x : β} :
          (∀ (i : α), get? i m ≠ some x) ↔ x ∉ m.values
          @[simp]
          instance Map.hasNoVal_empty {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {x : β} :
          instance Map.hasNoVal_union {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m₁ m₂ : Map α β} {x : β} [h₁ : HasNoVal x m₁] [h₂ : HasNoVal x m₂] :
          HasNoVal x (m₁ ∪ m₂)
          instance Map.hasNoVal_insertD {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [hb : DecidableEq β] {x y : β} {i : α} [h : HasNoVal x m] :
          HasNoVal x (insertD x m i y)
          instance Map.hasNoVal_erase {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {x : β} {i : α} [h : HasNoVal x m] :
          HasNoVal x (m.erase i)
          @[simp]
          theorem Map.getD_eq_dflt_iff {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {x : β} {i : α} [h : HasNoVal x m] :
          getD x m i = x ↔ i ∉ m
          theorem Map.getD_insertD_of_eq' {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} [hb : DecidableEq β] {i j : α} {x y : β} (h : j = i) :
          getD x (insertD x m i y) j = y
          @[simp]
          theorem Map.getD_erase_of_eq {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m : Map α β} {i : α} {x : β} :
          getD x (m.erase i) i = x
          theorem Map.getD_eq_getD_iff {α : Type u} {β : Type v} [hh₁ : DecidableEq α] [hh₂ : Hashable α] {m₁ m₂ : Map α β} {x : β} {i j : α} [h₁ : HasNoVal x m₁] [h₂ : HasNoVal x m₂] :
          getD x m₁ i = getD x m₂ j ↔ get? i m₁ = get? j m₂