-- Mathlib/.lake/packages/lean4/src/lean/Std/Data/DHashMap/Internal/List/Associative.lean
theorem containsKey_alterKey {k k' : α} {f : Option (β k) → Option (β k)}
    {l : List ((a : α) × β a)} (hl : DistinctKeys l) :
    containsKey k' (alterKey k f l) =
      if k == k' then
        f (getValueCast? k l) |>.isSome
      else
        containsKey k' l

Proof state:
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
h : ¬(k == k') = true
⊢ containsKey k' (alterKey k f l) = containsKey k' l

Tactic:
rw [alterKey]

Result:
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
h : ¬(k == k') = true
⊢ containsKey k'
      (match f (getValueCast? k l) with
      | none => eraseKey k l
      | some v => insertEntry k v l) =
    containsKey k' l

Proof state:
case some
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
h : ¬(k == k') = true
val✝ : β k
⊢ containsKey k'
      (match some val✝ with
      | none => eraseKey k l
      | some v => insertEntry k v l) =
    containsKey k' l

Tactic:
simp_all

Result:
no goals

Proof state:
case none
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
h : ¬(k == k') = true
⊢ containsKey k'
      (match none with
      | none => eraseKey k l
      | some v => insertEntry k v l) =
    containsKey k' l

Tactic:
simp [containsKey_eraseKey_of_false (Bool.not_eq_true _ ▸ h)]

Result:
no goals

Proof state:
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
h : (k == k') = true
⊢ containsKey k' (alterKey k f l) = (f (getValueCast? k l)).isSome

Tactic:
rw [← containsKey_congr h, containsKey_alterKey_self hl]

Result:
no goals

Proof state:
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
⊢ containsKey k' (alterKey k f l) = if (k == k') = true then (f (getValueCast? k l)).isSome else containsKey k' l

Tactic:
split

Result:
case isTrue
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
h✝ : (k == k') = true
⊢ containsKey k' (alterKey k f l) = (f (getValueCast? k l)).isSome

case isFalse
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
h✝ : ¬(k == k') = true
⊢ containsKey k' (alterKey k f l) = containsKey k' l

Proof state:
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
h : ¬(k == k') = true
⊢ containsKey k'
      (match f (getValueCast? k l) with
      | none => eraseKey k l
      | some v => insertEntry k v l) =
    containsKey k' l

Tactic:
cases f (getValueCast? k l)

Result:
case none
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
h : ¬(k == k') = true
⊢ containsKey k'
      (match none with
      | none => eraseKey k l
      | some v => insertEntry k v l) =
    containsKey k' l

case some
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
h : ¬(k == k') = true
val✝ : β k
⊢ containsKey k'
      (match some val✝ with
      | none => eraseKey k l
      | some v => insertEntry k v l) =
    containsKey k' l

Proof state:
case isTrue
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
h✝ : (k == k') = true
⊢ containsKey k' (alterKey k f l) = (f (getValueCast? k l)).isSome

Tactic:
next h =>
rw [← containsKey_congr h, containsKey_alterKey_self hl]

Result:
no goals