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

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

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

Result:
no goals

Proof state:
α : Type u
inst✝¹ : BEq α
β : Type v
inst✝ : EquivBEq α
k k' : α
f : Option β → Option β
l : List ((_ : α) × β)
hl : DistinctKeys l
hc : containsKey k' (alterKey k f l) = true
this : some (getValue k' (alterKey k f l) hc) = if (k == k') = true then f (getValue? k l) else getValue? k' l
heq : (k == k') = true
⊢ getValue k' (alterKey k f l) hc = (f (getValue? k l)).get ⋯

Tactic:
apply Option.some_inj.mp

Result:
α : Type u
inst✝¹ : BEq α
β : Type v
inst✝ : EquivBEq α
k k' : α
f : Option β → Option β
l : List ((_ : α) × β)
hl : DistinctKeys l
hc : containsKey k' (alterKey k f l) = true
this : some (getValue k' (alterKey k f l) hc) = if (k == k') = true then f (getValue? k l) else getValue? k' l
heq : (k == k') = true
⊢ some (getValue k' (alterKey k f l) hc) = some ((f (getValue? k l)).get ⋯)

Proof state:
α : Type u
inst✝¹ : BEq α
β : Type v
inst✝ : EquivBEq α
k k' : α
f : Option β → Option β
l : List ((_ : α) × β)
hl : DistinctKeys l
hc : containsKey k' (alterKey k f l) = true
this : getValue? k' (alterKey k f l) = if (k == k') = true then f (getValue? k l) else getValue? k' l
⊢ getValue k' (alterKey k f l) hc = if h : (k == k') = true then (f (getValue? k l)).get ⋯ else getValue k' l ⋯

Tactic:
rw [getValue?_eq_some_getValue hc] at this

Result:
α : Type u
inst✝¹ : BEq α
β : Type v
inst✝ : EquivBEq α
k k' : α
f : Option β → Option β
l : List ((_ : α) × β)
hl : DistinctKeys l
hc : containsKey k' (alterKey k f l) = true
this : some (getValue k' (alterKey k f l) hc) = if (k == k') = true then f (getValue? k l) else getValue? k' l
⊢ getValue k' (alterKey k f l) hc = if h : (k == k') = true then (f (getValue? k l)).get ⋯ else getValue k' l ⋯

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

Tactic:
simp_all only [Bool.false_eq_true, ite_false]

Result:
α : Type u
inst✝¹ : BEq α
β : Type v
inst✝ : EquivBEq α
k k' : α
f : Option β → Option β
l : List ((_ : α) × β)
hl : DistinctKeys l
hc : containsKey k' (alterKey k f l) = true
heq : ¬(k == k') = true
this : some (getValue k' (alterKey k f l) hc) = getValue? k' l
⊢ getValue? k' l = some (getValue k' l ⋯)

Proof state:
case isTrue
α : Type u
inst✝¹ : BEq α
β : Type v
inst✝ : EquivBEq α
k k' : α
f : Option β → Option β
l : List ((_ : α) × β)
hl : DistinctKeys l
hc : containsKey k' (alterKey k f l) = true
this : some (getValue k' (alterKey k f l) hc) = if (k == k') = true then f (getValue? k l) else getValue? k' l
h✝ : (k == k') = true
⊢ getValue k' (alterKey k f l) hc = (f (getValue? k l)).get ⋯

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

Result:
no goals

Proof state:
α : Type u
β✝ : α → Type v
γ : α → Type w
inst✝¹ : BEq α
β : Type v
inst✝ : EquivBEq α
k k' : α
f : Option β → Option β
l : List ((_ : α) × β)
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
inst✝¹ : BEq α
β : Type v
inst✝ : EquivBEq α
k k' : α
f : Option β → Option β
l : List ((_ : α) × β)
hl : DistinctKeys l
hc : containsKey k' (alterKey k f l) = true
this : some (getValue k' (alterKey k f l) hc) = if (k == k') = true then f (getValue? k l) else getValue? k' l
⊢ getValue k' (alterKey k f l) hc = if h : (k == k') = true then (f (getValue? k l)).get ⋯ else getValue k' l ⋯

Tactic:
split

Result:
case isTrue
α : Type u
inst✝¹ : BEq α
β : Type v
inst✝ : EquivBEq α
k k' : α
f : Option β → Option β
l : List ((_ : α) × β)
hl : DistinctKeys l
hc : containsKey k' (alterKey k f l) = true
this : some (getValue k' (alterKey k f l) hc) = if (k == k') = true then f (getValue? k l) else getValue? k' l
h✝ : (k == k') = true
⊢ getValue k' (alterKey k f l) hc = (f (getValue? k l)).get ⋯

case isFalse
α : Type u
inst✝¹ : BEq α
β : Type v
inst✝ : EquivBEq α
k k' : α
f : Option β → Option β
l : List ((_ : α) × β)
hl : DistinctKeys l
hc : containsKey k' (alterKey k f l) = true
this : some (getValue k' (alterKey k f l) hc) = if (k == k') = true then f (getValue? k l) else getValue? k' l
h✝ : ¬(k == k') = true
⊢ getValue k' (alterKey k f l) hc = getValue k' l ⋯

Proof state:
α : Type u
inst✝¹ : BEq α
β : Type v
inst✝ : EquivBEq α
k k' : α
f : Option β → Option β
l : List ((_ : α) × β)
hl : DistinctKeys l
hc : containsKey k' (alterKey k f l) = true
heq : ¬(k == k') = true
this : some (getValue k' (alterKey k f l) hc) = getValue? k' l
⊢ getValue? k' l = some (getValue k' l ⋯)

Tactic:
rw [getValue?_eq_some_getValue]

Result:
no goals

Proof state:
α : Type u
inst✝¹ : BEq α
β : Type v
inst✝ : EquivBEq α
k k' : α
f : Option β → Option β
l : List ((_ : α) × β)
hl : DistinctKeys l
hc : containsKey k' (alterKey k f l) = true
⊢ getValue k' (alterKey k f l) hc = if h : (k == k') = true then (f (getValue? k l)).get ⋯ else getValue k' l ⋯

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

Result:
α : Type u
inst✝¹ : BEq α
β : Type v
inst✝ : EquivBEq α
k k' : α
f : Option β → Option β
l : List ((_ : α) × β)
hl : DistinctKeys l
hc : containsKey k' (alterKey k f l) = true
this : getValue? k' (alterKey k f l) = if (k == k') = true then f (getValue? k l) else getValue? k' l
⊢ getValue k' (alterKey k f l) hc = if h : (k == k') = true then (f (getValue? k l)).get ⋯ else getValue k' l ⋯

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

Tactic:
apply Option.some_inj.mp

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

Proof state:
case isFalse
α : Type u
inst✝¹ : BEq α
β : Type v
inst✝ : EquivBEq α
k k' : α
f : Option β → Option β
l : List ((_ : α) × β)
hl : DistinctKeys l
hc : containsKey k' (alterKey k f l) = true
this : some (getValue k' (alterKey k f l) hc) = if (k == k') = true then f (getValue? k l) else getValue? k' l
h✝ : ¬(k == k') = true
⊢ getValue k' (alterKey k f l) hc = getValue k' l ⋯

Tactic:
next heq =>
apply Option.some_inj.mp
simp_all only [Bool.false_eq_true, ite_false]
rw [getValue?_eq_some_getValue]

Result:
no goals