-- Mathlib/.lake/packages/lean4/src/lean/Std/Data/DHashMap/Internal/Model.lean
theorem getThenInsertIfNew?_eq_get?ₘ [BEq α] [Hashable α] [LawfulBEq α] (m : Raw₀ α β) (a : α)
    (b : β a) : (m.getThenInsertIfNew? a b).1 = m.get?ₘ a

Proof state:
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : LawfulBEq α
m : Raw₀ α β
a : α
b : β a
⊢ (match AssocList.getCast? a m.1.buckets[(mkIdx m.1.buckets.size ⋯ (hash a)).val.toNat] with
      | none =>
        (none,
          expandIfNecessary
            ⟨{ size := m.1.size + 1,
                buckets :=
                  m.1.buckets.set (mkIdx m.1.buckets.size ⋯ (hash a)).val.toNat
                    (AssocList.cons a b m.1.buckets[(mkIdx m.1.buckets.size ⋯ (hash a)).val.toNat]) ⋯ },
              ⋯⟩)
      | some v => (some v, ⟨{ size := m.1.size, buckets := m.1.buckets }, ⋯⟩)).fst =
    AssocList.getCast? a m.val.buckets[(mkIdx m.val.buckets.size ⋯ (hash a)).val.toNat]

Tactic:
split <;> simp_all

Result:
no goals

Proof state:
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : LawfulBEq α
m : Raw₀ α β
a : α
b : β a
⊢ (m.getThenInsertIfNew? a b).fst = m.get?ₘ a

Tactic:
rw [getThenInsertIfNew?, get?ₘ, bucket]

Result:
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : LawfulBEq α
m : Raw₀ α β
a : α
b : β a
⊢ (match mkIdx m.1.buckets.size ⋯ (hash a) with
      | ⟨i, h⟩ =>
        let bkt := m.1.buckets[i];
        match AssocList.getCast? a bkt with
        | none =>
          let size' := m.1.size + 1;
          let buckets' := m.1.buckets.uset i (AssocList.cons a b bkt) h;
          (none, expandIfNecessary ⟨{ size := size', buckets := buckets' }, ⋯⟩)
        | some v => (some v, ⟨{ size := m.1.size, buckets := m.1.buckets }, ⋯⟩)).fst =
    AssocList.getCast? a
      (match mkIdx m.val.buckets.size ⋯ (hash a) with
      | ⟨i, h⟩ => m.val.buckets[i])

Proof state:
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : LawfulBEq α
m : Raw₀ α β
a : α
b : β a
⊢ (match mkIdx m.1.buckets.size ⋯ (hash a) with
      | ⟨i, h⟩ =>
        let bkt := m.1.buckets[i];
        match AssocList.getCast? a bkt with
        | none =>
          let size' := m.1.size + 1;
          let buckets' := m.1.buckets.uset i (AssocList.cons a b bkt) h;
          (none, expandIfNecessary ⟨{ size := size', buckets := buckets' }, ⋯⟩)
        | some v => (some v, ⟨{ size := m.1.size, buckets := m.1.buckets }, ⋯⟩)).fst =
    AssocList.getCast? a
      (match mkIdx m.val.buckets.size ⋯ (hash a) with
      | ⟨i, h⟩ => m.val.buckets[i])

Tactic:
dsimp only [Array.ugetElem_eq_getElem, Array.uset]

Result:
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : LawfulBEq α
m : Raw₀ α β
a : α
b : β a
⊢ (match AssocList.getCast? a m.1.buckets[(mkIdx m.1.buckets.size ⋯ (hash a)).val.toNat] with
      | none =>
        (none,
          expandIfNecessary
            ⟨{ size := m.1.size + 1,
                buckets :=
                  m.1.buckets.set (mkIdx m.1.buckets.size ⋯ (hash a)).val.toNat
                    (AssocList.cons a b m.1.buckets[(mkIdx m.1.buckets.size ⋯ (hash a)).val.toNat]) ⋯ },
              ⋯⟩)
      | some v => (some v, ⟨{ size := m.1.size, buckets := m.1.buckets }, ⋯⟩)).fst =
    AssocList.getCast? a m.val.buckets[(mkIdx m.val.buckets.size ⋯ (hash a)).val.toNat]