-- Mathlib/.lake/packages/lean4/src/lean/Std/Data/DHashMap/Internal/WF.lean
theorem isHashSelf_alterₘ [BEq α] [Hashable α] [LawfulBEq α] (m : Raw₀ α β) (h : Raw.WFImp m.1)
    (a : α) (f : Option (β a) → Option (β a)) : IsHashSelf (m.alterₘ a f).1.buckets

Proof state:
case isTrue
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : LawfulBEq α
m : Raw₀ α β
h : Raw.WFImp m.val
a : α
f : Option (β a) → Option (β a)
h✝ : m.containsₘ a = true
⊢ IsHashSelf
    ⟨{
            size :=
              if
                  containsₘ
                      ⟨{ size := computeSize (updateBucket m.val.buckets ⋯ a fun l => AssocList.alter a f l),
                          buckets := updateBucket m.val.buckets ⋯ a fun l => AssocList.alter a f l },
                        ⋯⟩
                      a =
                    true then
                m.val.size
              else m.val.size - 1,
            buckets := updateBucket m.val.buckets ⋯ a fun l => AssocList.alter a f l },
          ⋯⟩.val.buckets

Tactic:
exact isHashSelf_updateBucket_alter h

Result:
no goals

Proof state:
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : LawfulBEq α
m : Raw₀ α β
h : Raw.WFImp m.val
a : α
f : Option (β a) → Option (β a)
⊢ IsHashSelf (m.alterₘ a f).val.buckets

Tactic:
dsimp only [alterₘ, withComputedSize]

Result:
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : LawfulBEq α
m : Raw₀ α β
h : Raw.WFImp m.val
a : α
f : Option (β a) → Option (β a)
⊢ IsHashSelf
    (if h : m.containsₘ a = true then
          ⟨{
              size :=
                if
                    containsₘ
                        ⟨{ size := computeSize (updateBucket m.val.buckets ⋯ a fun l => AssocList.alter a f l),
                            buckets := updateBucket m.val.buckets ⋯ a fun l => AssocList.alter a f l },
                          ⋯⟩
                        a =
                      true then
                  m.val.size
                else m.val.size - 1,
              buckets := updateBucket m.val.buckets ⋯ a fun l => AssocList.alter a f l },
            ⋯⟩
        else
          match f none with
          | none => m
          | some b => (m.consₘ a b).expandIfNecessary).val.buckets

Proof state:
case h_2
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : LawfulBEq α
m : Raw₀ α β
h : Raw.WFImp m.val
a : α
f : Option (β a) → Option (β a)
hc : ¬m.containsₘ a = true
x✝ : Option (β a)
b✝ : β a
heq✝ : f none = some b✝
⊢ m.containsₘ a = false

Tactic:
exact Bool.not_eq_true _ ▸ hc

Result:
no goals

Proof state:
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : LawfulBEq α
m : Raw₀ α β
h : Raw.WFImp m.val
a : α
f : Option (β a) → Option (β a)
hc : ¬m.containsₘ a = true
⊢ IsHashSelf
    (match f none with
        | none => m
        | some b => (m.consₘ a b).expandIfNecessary).val.buckets

Tactic:
split

Result:
case h_1
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : LawfulBEq α
m : Raw₀ α β
h : Raw.WFImp m.val
a : α
f : Option (β a) → Option (β a)
hc : ¬m.containsₘ a = true
x✝ : Option (β a)
heq✝ : f none = none
⊢ IsHashSelf m.val.buckets

case h_2
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : LawfulBEq α
m : Raw₀ α β
h : Raw.WFImp m.val
a : α
f : Option (β a) → Option (β a)
hc : ¬m.containsₘ a = true
x✝ : Option (β a)
b✝ : β a
heq✝ : f none = some b✝
⊢ IsHashSelf (m.consₘ a b✝).expandIfNecessary.val.buckets

Proof state:
case h_2
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : LawfulBEq α
m : Raw₀ α β
h : Raw.WFImp m.val
a : α
f : Option (β a) → Option (β a)
hc : ¬m.containsₘ a = true
x✝ : Option (β a)
b✝ : β a
heq✝ : f none = some b✝
⊢ IsHashSelf (m.consₘ a b✝).expandIfNecessary.val.buckets

Tactic:
refine (wfImp_expandIfNecessary _ (wfImp_consₘ _ h _ _ ?_)).buckets_hash_self

Result:
case h_2
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : LawfulBEq α
m : Raw₀ α β
h : Raw.WFImp m.val
a : α
f : Option (β a) → Option (β a)
hc : ¬m.containsₘ a = true
x✝ : Option (β a)
b✝ : β a
heq✝ : f none = some b✝
⊢ m.containsₘ a = false

Proof state:
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : LawfulBEq α
m : Raw₀ α β
h : Raw.WFImp m.val
a : α
f : Option (β a) → Option (β a)
⊢ IsHashSelf
    (if h : m.containsₘ a = true then
          ⟨{
              size :=
                if
                    containsₘ
                        ⟨{ size := computeSize (updateBucket m.val.buckets ⋯ a fun l => AssocList.alter a f l),
                            buckets := updateBucket m.val.buckets ⋯ a fun l => AssocList.alter a f l },
                          ⋯⟩
                        a =
                      true then
                  m.val.size
                else m.val.size - 1,
              buckets := updateBucket m.val.buckets ⋯ a fun l => AssocList.alter a f l },
            ⋯⟩
        else
          match f none with
          | none => m
          | some b => (m.consₘ a b).expandIfNecessary).val.buckets

Tactic:
split

Result:
case isTrue
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : LawfulBEq α
m : Raw₀ α β
h : Raw.WFImp m.val
a : α
f : Option (β a) → Option (β a)
h✝ : m.containsₘ a = true
⊢ IsHashSelf
    ⟨{
            size :=
              if
                  containsₘ
                      ⟨{ size := computeSize (updateBucket m.val.buckets ⋯ a fun l => AssocList.alter a f l),
                          buckets := updateBucket m.val.buckets ⋯ a fun l => AssocList.alter a f l },
                        ⋯⟩
                      a =
                    true then
                m.val.size
              else m.val.size - 1,
            buckets := updateBucket m.val.buckets ⋯ a fun l => AssocList.alter a f l },
          ⋯⟩.val.buckets

case isFalse
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : LawfulBEq α
m : Raw₀ α β
h : Raw.WFImp m.val
a : α
f : Option (β a) → Option (β a)
h✝ : ¬m.containsₘ a = true
⊢ IsHashSelf
    (match f none with
        | none => m
        | some b => (m.consₘ a b).expandIfNecessary).val.buckets

Proof state:
case h_1
α : Type u
β : α → Type v
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : LawfulBEq α
m : Raw₀ α β
h : Raw.WFImp m.val
a : α
f : Option (β a) → Option (β a)
hc : ¬m.containsₘ a = true
x✝ : Option (β a)
heq✝ : f none = none
⊢ IsHashSelf m.val.buckets

Tactic:
exact h.buckets_hash_self

Result:
no goals