-- Mathlib/.lake/packages/lean4/src/lean/Std/Data/DHashMap/Internal/List/Associative.lean
theorem getValueCast_alterKey (k k' : α) (f : Option (β k) → Option (β k))
    (l : List ((a : α) × β a)) (hl : DistinctKeys l) (hc : containsKey k' (alterKey k f l)) :
    getValueCast k' (alterKey k f l) hc =
      if h : k == k' then
        haveI hc' : (f (getValueCast? k l)).isSome

Proof state:
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
hc : containsKey k' (alterKey k f l) = true
this :
  some (getValueCast k' (alterKey k f l) hc) =
    if h : (k == k') = true then cast ⋯ (f (getValueCast? k l)) else getValueCast? k' l
heq : ¬(k == k') = true
⊢ some (getValueCast k' (alterKey k f l) hc) = some (getValueCast k' l ⋯)

Tactic:
simp_all only [Bool.false_eq_true, Function.comp_apply, dite_false]

Result:
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
hc : containsKey k' (alterKey k f l) = true
heq : ¬(k == k') = true
this : some (getValueCast k' (alterKey k f l) hc) = getValueCast? k' l
⊢ getValueCast? k' l = some (getValueCast 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
hc : containsKey k' (alterKey k f l) = true
this :
  some (getValueCast k' (alterKey k f l) hc) =
    if h : (k == k') = true then cast ⋯ (f (getValueCast? k l)) else getValueCast? k' l
h✝ : (k == k') = true
⊢ getValueCast k' (alterKey k f l) hc = cast ⋯ ((f (getValueCast? k l)).get ⋯)

Tactic:
next heq =>
cases eq_of_beq heq
apply Option.some_inj.mp
simp_all

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
hc : containsKey k' (alterKey k f l) = true
⊢ getValueCast k' (alterKey k f l) hc =
    if h : (k == k') = true then cast ⋯ ((f (getValueCast? k l)).get ⋯) else getValueCast k' l ⋯

Tactic:
have := getValueCast?_alterKey  k k' f l hl

Result:
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
hc : containsKey k' (alterKey k f l) = true
this :
  getValueCast? k' (alterKey k f l) =
    if h : (k == k') = true then cast ⋯ (f (getValueCast? k l)) else getValueCast? k' l
⊢ getValueCast k' (alterKey k f l) hc =
    if h : (k == k') = true then cast ⋯ ((f (getValueCast? k l)).get ⋯) else getValueCast 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
hc : containsKey k' (alterKey k f l) = true
this :
  some (getValueCast k' (alterKey k f l) hc) =
    if h : (k == k') = true then cast ⋯ (f (getValueCast? k l)) else getValueCast? k' l
heq : (k == k') = true
⊢ getValueCast k' (alterKey k f l) hc = cast ⋯ ((f (getValueCast? k l)).get ⋯)

Tactic:
cases eq_of_beq heq

Result:
case refl
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
hc : containsKey k (alterKey k f l) = true
this :
  some (getValueCast k (alterKey k f l) hc) =
    if h : (k == k) = true then cast ⋯ (f (getValueCast? k l)) else getValueCast? k l
heq : (k == k) = true
⊢ getValueCast k (alterKey k f l) hc = cast ⋯ ((f (getValueCast? k l)).get ⋯)

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

Tactic:
rwa [containsKey_alterKey hl, if_neg h] at hc

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
hc : containsKey k' (alterKey k f l) = true
this :
  some (getValueCast k' (alterKey k f l) hc) =
    if h : (k == k') = true then cast ⋯ (f (getValueCast? k l)) else getValueCast? k' l
heq : ¬(k == k') = true
⊢ getValueCast k' (alterKey k f l) hc = getValueCast k' l ⋯

Tactic:
apply Option.some_inj.mp

Result:
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k k' : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
hc : containsKey k' (alterKey k f l) = true
this :
  some (getValueCast k' (alterKey k f l) hc) =
    if h : (k == k') = true then cast ⋯ (f (getValueCast? k l)) else getValueCast? k' l
heq : ¬(k == k') = true
⊢ some (getValueCast k' (alterKey k f l) hc) = some (getValueCast k' l ⋯)

Proof state:
case refl
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
hc : containsKey k (alterKey k f l) = true
this :
  some (getValueCast k (alterKey k f l) hc) =
    if h : (k == k) = true then cast ⋯ (f (getValueCast? k l)) else getValueCast? k l
heq : (k == k) = true
⊢ some (getValueCast k (alterKey k f l) hc) = some (cast ⋯ ((f (getValueCast? k l)).get ⋯))

Tactic:
simp_all

Result:
no goals

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

Tactic:
rwa [containsKey_alterKey hl, if_pos h] at hc

Result:
no goals

Proof state:
case refl
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
hc : containsKey k (alterKey k f l) = true
this :
  some (getValueCast k (alterKey k f l) hc) =
    if h : (k == k) = true then cast ⋯ (f (getValueCast? k l)) else getValueCast? k l
heq : (k == k) = true
⊢ getValueCast k (alterKey k f l) hc = cast ⋯ ((f (getValueCast? k l)).get ⋯)

Tactic:
apply Option.some_inj.mp

Result:
case refl
α : Type u
β : α → Type v
inst✝¹ : BEq α
inst✝ : LawfulBEq α
k : α
f : Option (β k) → Option (β k)
l : List ((a : α) × β a)
hl : DistinctKeys l
hc : containsKey k (alterKey k f l) = true
this :
  some (getValueCast k (alterKey k f l) hc) =
    if h : (k == k) = true then cast ⋯ (f (getValueCast? k l)) else getValueCast? k l
heq : (k == k) = true
⊢ some (getValueCast k (alterKey k f l) hc) = some (cast ⋯ ((f (getValueCast? k l)).get ⋯))