-- Mathlib/.lake/packages/lean4/src/lean/Std/Data/DHashMap/Internal/List/Associative.lean
theorem getKey!_alterKey [Inhabited α] {k k' : α} {f : Option (β k) → Option (β k)}
    (l : List ((a : α) × β a)) (hl : DistinctKeys l) :
    getKey! k' (alterKey k f l) =
      if k == k' then
        if (f (getValueCast? k l)).isSome then k else default
      else
        getKey! k' l

Proof state:
case isTrue
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : LawfulBEq α
inst✝ : Inhabited α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
h✝ : (k == k') = true
⊢ (if (f (getValueCast? k l)).isSome = true then some k else none).get! =
    if (f (getValueCast? k l)).isSome = true then k else default

Tactic:
next heq =>
cases eq_of_beq heq
split <;> rfl

Result:
no goals

Proof state:
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : LawfulBEq α
inst✝ : Inhabited α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
heq : ¬(k == k') = true
⊢ (getKey? k' l).get! = (getKey? k' l).get!

Tactic:
rfl

Result:
no goals

Proof state:
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : LawfulBEq α
inst✝ : Inhabited α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
heq : (k == k') = true
⊢ (if (f (getValueCast? k l)).isSome = true then some k else none).get! =
    if (f (getValueCast? k l)).isSome = true then k else default

Tactic:
cases eq_of_beq heq

Result:
case refl
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : LawfulBEq α
inst✝ : Inhabited α
k : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
heq : (k == k) = true
⊢ (if (f (getValueCast? k l)).isSome = true then some k else none).get! =
    if (f (getValueCast? k l)).isSome = true then k else default

Proof state:
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : LawfulBEq α
inst✝ : Inhabited α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
⊢ (if (k == k') = true then if (f (getValueCast? k l)).isSome = true then some k else none else getKey? k' l).get! =
    if (k == k') = true then if (f (getValueCast? k l)).isSome = true then k else default else (getKey? k' l).get!

Tactic:
split

Result:
case isTrue
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : LawfulBEq α
inst✝ : Inhabited α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
h✝ : (k == k') = true
⊢ (if (f (getValueCast? k l)).isSome = true then some k else none).get! =
    if (f (getValueCast? k l)).isSome = true then k else default

case isFalse
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : LawfulBEq α
inst✝ : Inhabited α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
h✝ : ¬(k == k') = true
⊢ (getKey? k' l).get! = (getKey? k' l).get!

Proof state:
case refl
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : LawfulBEq α
inst✝ : Inhabited α
k : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
heq : (k == k) = true
⊢ (if (f (getValueCast? k l)).isSome = true then some k else none).get! =
    if (f (getValueCast? k l)).isSome = true then k else default

Tactic:
split <;> rfl

Result:
no goals

Proof state:
case isFalse
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : LawfulBEq α
inst✝ : Inhabited α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
h✝ : ¬(k == k') = true
⊢ (getKey? k' l).get! = (getKey? k' l).get!

Tactic:
next heq =>
rfl

Result:
no goals

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

Tactic:
simp only [getKey!_eq_getKey?, hl, getKey?_alterKey, beq_iff_eq]

Result:
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : LawfulBEq α
inst✝ : Inhabited α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
⊢ (if (k == k') = true then if (f (getValueCast? k l)).isSome = true then some k else none else getKey? k' l).get! =
    if (k == k') = true then if (f (getValueCast? k l)).isSome = true then k else default else (getKey? k' l).get!