l3lab/ntp-mathlib huggingface dataset:
theorem kreplace_self {a : α} {b : β a} {l : List (Sigma β)} (nd : NodupKeys l)
    (h : Sigma.mk a b ∈ l) : kreplace a b l = l := by
  refine' (lookmap_congr _).trans (lookmap_id' (Option.guard fun (s : Sigma β) => a = s.1) _ _)
  · rintro ⟨a', b'⟩ h'
    dsimp [Option.guard]
    split_ifs
    · subst a'
      simp [nd.eq_of_mk_mem h h']
    · rfl
  · rintro ⟨a₁, b₁⟩ ⟨a₂, b₂⟩
    

Proof state:
case refine'_2.mk.mk
α : Type u
β : α → Type v
l✝ l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
l : List (Sigma β)
nd : NodupKeys l
h : { fst := a, snd := b } ∈ l
a₁ : α
b₁ : β a₁
a₂ : α
b₂ : β a₂
⊢ { fst := a₂, snd := b₂ } ∈ Option.guard (fun s => a = s.fst) { fst := a₁, snd := b₁ } →
    { fst := a₁, snd := b₁ } = { fst := a₂, snd := b₂ }

Next tactic:
dsimp [Option.guard]
theorem kreplace_self {a : α} {b : β a} {l : List (Sigma β)} (nd : NodupKeys l)
    (h : Sigma.mk a b ∈ l) : kreplace a b l = l := by
  refine' (lookmap_congr _).trans (lookmap_id' (Option.guard fun (s : Sigma β) => a = s.1) _ _)
  · rintro ⟨a', b'⟩ h'
    dsimp [Option.guard]
    split_ifs
    · subst a'
      simp [nd.eq_of_mk_mem h h']
    · rfl
  · rintro ⟨a₁, b₁⟩ ⟨a₂, b₂⟩
    dsimp [Option.guard]
    

Proof state:
case refine'_2.mk.mk
α : Type u
β : α → Type v
l✝ l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
l : List (Sigma β)
nd : NodupKeys l
h : { fst := a, snd := b } ∈ l
a₁ : α
b₁ : β a₁
a₂ : α
b₂ : β a₂
⊢ ({ fst := a₂, snd := b₂ } ∈ if a = a₁ then some { fst := a₁, snd := b₁ } else none) →
    { fst := a₁, snd := b₁ } = { fst := a₂, snd := b₂ }

Next tactic:
split_ifs
theorem kreplace_self {a : α} {b : β a} {l : List (Sigma β)} (nd : NodupKeys l)
    (h : Sigma.mk a b ∈ l) : kreplace a b l = l := by
  refine' (lookmap_congr _).trans (lookmap_id' (Option.guard fun (s : Sigma β) => a = s.1) _ _)
  · rintro ⟨a', b'⟩ h'
    dsimp [Option.guard]
    split_ifs
    · subst a'
      simp [nd.eq_of_mk_mem h h']
    · rfl
  · rintro ⟨a₁, b₁⟩ ⟨a₂, b₂⟩
    dsimp [Option.guard]
    split_ifs
    · 

Proof state:
case pos
α : Type u
β : α → Type v
l✝ l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
l : List (Sigma β)
nd : NodupKeys l
h : { fst := a, snd := b } ∈ l
a₁ : α
b₁ : β a₁
a₂ : α
b₂ : β a₂
h✝ : a = a₁
⊢ { fst := a₂, snd := b₂ } ∈ some { fst := a₁, snd := b₁ } → { fst := a₁, snd := b₁ } = { fst := a₂, snd := b₂ }

Next tactic:
simp
theorem kreplace_self {a : α} {b : β a} {l : List (Sigma β)} (nd : NodupKeys l)
    (h : Sigma.mk a b ∈ l) : kreplace a b l = l := by
  refine' (lookmap_congr _).trans (lookmap_id' (Option.guard fun (s : Sigma β) => a = s.1) _ _)
  · rintro ⟨a', b'⟩ h'
    dsimp [Option.guard]
    split_ifs
    · subst a'
      simp [nd.eq_of_mk_mem h h']
    · rfl
  · rintro ⟨a₁, b₁⟩ ⟨a₂, b₂⟩
    dsimp [Option.guard]
    split_ifs
    · simp
    · 

Proof state:
case neg
α : Type u
β : α → Type v
l✝ l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
l : List (Sigma β)
nd : NodupKeys l
h : { fst := a, snd := b } ∈ l
a₁ : α
b₁ : β a₁
a₂ : α
b₂ : β a₂
h✝ : ¬a = a₁
⊢ { fst := a₂, snd := b₂ } ∈ none → { fst := a₁, snd := b₁ } = { fst := a₂, snd := b₂ }

Next tactic:
rintro ⟨⟩
theorem keys_kreplace (a : α) (b : β a) : ∀ l : List (Sigma β), (kreplace a b l).keys = l.keys :=
  lookmap_map_eq _ _ <| by
    

Proof state:
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
⊢ ∀ (a_1 b_1 : Sigma β), (b_1 ∈ if a = a_1.fst then some { fst := a, snd := b } else none) → a_1.fst = b_1.fst

Next tactic:
rintro ⟨a₁, b₂⟩ ⟨a₂, b₂⟩
theorem keys_kreplace (a : α) (b : β a) : ∀ l : List (Sigma β), (kreplace a b l).keys = l.keys :=
  lookmap_map_eq _ _ <| by
    rintro ⟨a₁, b₂⟩ ⟨a₂, b₂⟩
    

Proof state:
case mk.mk
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
a₁ : α
b₂✝ : β a₁
a₂ : α
b₂ : β a₂
⊢ ({ fst := a₂, snd := b₂ } ∈ if a = { fst := a₁, snd := b₂✝ }.fst then some { fst := a, snd := b } else none) →
    { fst := a₁, snd := b₂✝ }.fst = { fst := a₂, snd := b₂ }.fst

Next tactic:
dsimp
theorem keys_kreplace (a : α) (b : β a) : ∀ l : List (Sigma β), (kreplace a b l).keys = l.keys :=
  lookmap_map_eq _ _ <| by
    rintro ⟨a₁, b₂⟩ ⟨a₂, b₂⟩
    dsimp
    

Proof state:
case mk.mk
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
a₁ : α
b₂✝ : β a₁
a₂ : α
b₂ : β a₂
⊢ ({ fst := a₂, snd := b₂ } ∈ if a = a₁ then some { fst := a, snd := b } else none) → a₁ = a₂

Next tactic:
split_ifs with h
theorem keys_kreplace (a : α) (b : β a) : ∀ l : List (Sigma β), (kreplace a b l).keys = l.keys :=
  lookmap_map_eq _ _ <| by
    rintro ⟨a₁, b₂⟩ ⟨a₂, b₂⟩
    dsimp
    split_ifs with h <;> 

Proof state:
case pos
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
a₁ : α
b₂✝ : β a₁
a₂ : α
b₂ : β a₂
h : a = a₁
⊢ { fst := a₂, snd := b₂ } ∈ some { fst := a, snd := b } → a₁ = a₂

Next tactic:
simp (config := { contextual := true }) [h]
theorem keys_kreplace (a : α) (b : β a) : ∀ l : List (Sigma β), (kreplace a b l).keys = l.keys :=
  lookmap_map_eq _ _ <| by
    rintro ⟨a₁, b₂⟩ ⟨a₂, b₂⟩
    dsimp
    split_ifs with h <;> 

Proof state:
case neg
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
a₁ : α
b₂✝ : β a₁
a₂ : α
b₂ : β a₂
h : ¬a = a₁
⊢ { fst := a₂, snd := b₂ } ∈ none → a₁ = a₂

Next tactic:
simp (config := { contextual := true }) [h]
theorem kreplace_nodupKeys (a : α) (b : β a) {l : List (Sigma β)} :
    (kreplace a b l).NodupKeys ↔ l.NodupKeys := by 

Proof state:
α : Type u
β : α → Type v
l✝ l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
l : List (Sigma β)
⊢ NodupKeys (kreplace a b l) ↔ NodupKeys l

Next tactic:
simp [NodupKeys, keys_kreplace]
theorem Perm.kreplace {a : α} {b : β a} {l₁ l₂ : List (Sigma β)} (nd : l₁.NodupKeys) :
    l₁ ~ l₂ → kreplace a b l₁ ~ kreplace a b l₂ :=
  perm_lookmap _ <| by
    

Proof state:
α : Type u
β : α → Type v
l l₁✝ l₂✝ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
l₁ l₂ : List (Sigma β)
nd : NodupKeys l₁
⊢ Pairwise
    (fun a_1 b_1 =>
      ∀ c ∈ if a = a_1.fst then some { fst := a, snd := b } else none,
        ∀ d ∈ if a = b_1.fst then some { fst := a, snd := b } else none, a_1 = b_1 ∧ c = d)
    l₁

Next tactic:
refine' nd.pairwise_ne.imp _
theorem Perm.kreplace {a : α} {b : β a} {l₁ l₂ : List (Sigma β)} (nd : l₁.NodupKeys) :
    l₁ ~ l₂ → kreplace a b l₁ ~ kreplace a b l₂ :=
  perm_lookmap _ <| by
    refine' nd.pairwise_ne.imp _
    

Proof state:
α : Type u
β : α → Type v
l l₁✝ l₂✝ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
l₁ l₂ : List (Sigma β)
nd : NodupKeys l₁
⊢ ∀ {a_1 b_1 : Sigma β},
    a_1.fst ≠ b_1.fst →
      ∀ c ∈ if a = a_1.fst then some { fst := a, snd := b } else none,
        ∀ d ∈ if a = b_1.fst then some { fst := a, snd := b } else none, a_1 = b_1 ∧ c = d

Next tactic:
intro x y h z h₁ w h₂
theorem Perm.kreplace {a : α} {b : β a} {l₁ l₂ : List (Sigma β)} (nd : l₁.NodupKeys) :
    l₁ ~ l₂ → kreplace a b l₁ ~ kreplace a b l₂ :=
  perm_lookmap _ <| by
    refine' nd.pairwise_ne.imp _
    intro x y h z h₁ w h₂
    

Proof state:
α : Type u
β : α → Type v
l l₁✝ l₂✝ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
l₁ l₂ : List (Sigma β)
nd : NodupKeys l₁
x y : Sigma β
h : x.fst ≠ y.fst
z : Sigma β
h₁ : z ∈ if a = x.fst then some { fst := a, snd := b } else none
w : Sigma β
h₂ : w ∈ if a = y.fst then some { fst := a, snd := b } else none
⊢ x = y ∧ z = w

Next tactic:
split_ifs at h₁ h₂ with h_2 h_1
theorem Perm.kreplace {a : α} {b : β a} {l₁ l₂ : List (Sigma β)} (nd : l₁.NodupKeys) :
    l₁ ~ l₂ → kreplace a b l₁ ~ kreplace a b l₂ :=
  perm_lookmap _ <| by
    refine' nd.pairwise_ne.imp _
    intro x y h z h₁ w h₂
    split_ifs at h₁ h₂ with h_2 h_1 <;> 

Proof state:
case pos
α : Type u
β : α → Type v
l l₁✝ l₂✝ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
l₁ l₂ : List (Sigma β)
nd : NodupKeys l₁
x y : Sigma β
h : x.fst ≠ y.fst
z w : Sigma β
h_2 : a = x.fst
h₁ : z ∈ some { fst := a, snd := b }
h_1 : a = y.fst
h₂ : w ∈ some { fst := a, snd := b }
⊢ x = y ∧ z = w

Next tactic:
cases h₁
theorem Perm.kreplace {a : α} {b : β a} {l₁ l₂ : List (Sigma β)} (nd : l₁.NodupKeys) :
    l₁ ~ l₂ → kreplace a b l₁ ~ kreplace a b l₂ :=
  perm_lookmap _ <| by
    refine' nd.pairwise_ne.imp _
    intro x y h z h₁ w h₂
    split_ifs at h₁ h₂ with h_2 h_1 <;> 

Proof state:
case neg
α : Type u
β : α → Type v
l l₁✝ l₂✝ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
l₁ l₂ : List (Sigma β)
nd : NodupKeys l₁
x y : Sigma β
h : x.fst ≠ y.fst
z w : Sigma β
h_2 : a = x.fst
h₁ : z ∈ some { fst := a, snd := b }
h_1 : ¬a = y.fst
h₂ : w ∈ none
⊢ x = y ∧ z = w

Next tactic:
cases h₁
theorem Perm.kreplace {a : α} {b : β a} {l₁ l₂ : List (Sigma β)} (nd : l₁.NodupKeys) :
    l₁ ~ l₂ → kreplace a b l₁ ~ kreplace a b l₂ :=
  perm_lookmap _ <| by
    refine' nd.pairwise_ne.imp _
    intro x y h z h₁ w h₂
    split_ifs at h₁ h₂ with h_2 h_1 <;> 

Proof state:
case pos
α : Type u
β : α → Type v
l l₁✝ l₂✝ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
l₁ l₂ : List (Sigma β)
nd : NodupKeys l₁
x y : Sigma β
h : x.fst ≠ y.fst
z w : Sigma β
h_2 : ¬a = x.fst
h₁ : z ∈ none
h✝ : a = y.fst
h₂ : w ∈ some { fst := a, snd := b }
⊢ x = y ∧ z = w

Next tactic:
cases h₁
theorem Perm.kreplace {a : α} {b : β a} {l₁ l₂ : List (Sigma β)} (nd : l₁.NodupKeys) :
    l₁ ~ l₂ → kreplace a b l₁ ~ kreplace a b l₂ :=
  perm_lookmap _ <| by
    refine' nd.pairwise_ne.imp _
    intro x y h z h₁ w h₂
    split_ifs at h₁ h₂ with h_2 h_1 <;> 

Proof state:
case neg
α : Type u
β : α → Type v
l l₁✝ l₂✝ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
l₁ l₂ : List (Sigma β)
nd : NodupKeys l₁
x y : Sigma β
h : x.fst ≠ y.fst
z w : Sigma β
h_2 : ¬a = x.fst
h₁ : z ∈ none
h✝ : ¬a = y.fst
h₂ : w ∈ none
⊢ x = y ∧ z = w

Next tactic:
cases h₁
theorem Perm.kreplace {a : α} {b : β a} {l₁ l₂ : List (Sigma β)} (nd : l₁.NodupKeys) :
    l₁ ~ l₂ → kreplace a b l₁ ~ kreplace a b l₂ :=
  perm_lookmap _ <| by
    refine' nd.pairwise_ne.imp _
    intro x y h z h₁ w h₂
    split_ifs at h₁ h₂ with h_2 h_1 <;> cases h₁ <;> 

Proof state:
case pos.refl
α : Type u
β : α → Type v
l l₁✝ l₂✝ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
l₁ l₂ : List (Sigma β)
nd : NodupKeys l₁
x y : Sigma β
h : x.fst ≠ y.fst
w : Sigma β
h_2 : a = x.fst
h_1 : a = y.fst
h₂ : w ∈ some { fst := a, snd := b }
⊢ x = y ∧ { fst := a, snd := b } = w

Next tactic:
cases h₂
theorem Perm.kreplace {a : α} {b : β a} {l₁ l₂ : List (Sigma β)} (nd : l₁.NodupKeys) :
    l₁ ~ l₂ → kreplace a b l₁ ~ kreplace a b l₂ :=
  perm_lookmap _ <| by
    refine' nd.pairwise_ne.imp _
    intro x y h z h₁ w h₂
    split_ifs at h₁ h₂ with h_2 h_1 <;> cases h₁ <;> 

Proof state:
case neg.refl
α : Type u
β : α → Type v
l l₁✝ l₂✝ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
l₁ l₂ : List (Sigma β)
nd : NodupKeys l₁
x y : Sigma β
h : x.fst ≠ y.fst
w : Sigma β
h_2 : a = x.fst
h_1 : ¬a = y.fst
h₂ : w ∈ none
⊢ x = y ∧ { fst := a, snd := b } = w

Next tactic:
cases h₂
theorem Perm.kreplace {a : α} {b : β a} {l₁ l₂ : List (Sigma β)} (nd : l₁.NodupKeys) :
    l₁ ~ l₂ → kreplace a b l₁ ~ kreplace a b l₂ :=
  perm_lookmap _ <| by
    refine' nd.pairwise_ne.imp _
    intro x y h z h₁ w h₂
    split_ifs at h₁ h₂ with h_2 h_1 <;> cases h₁ <;> cases h₂
    

Proof state:
case pos.refl.refl
α : Type u
β : α → Type v
l l₁✝ l₂✝ : List (Sigma β)
inst✝ : DecidableEq α
a : α
b : β a
l₁ l₂ : List (Sigma β)
nd : NodupKeys l₁
x y : Sigma β
h : x.fst ≠ y.fst
h_2 : a = x.fst
h_1 : a = y.fst
⊢ x = y ∧ { fst := a, snd := b } = { fst := a, snd := b }

Next tactic:
exact (h (h_2.symm.trans h_1)).elim
@[simp]
theorem kerase_cons_eq {a} {s : Sigma β} {l : List (Sigma β)} (h : a = s.1) :
    kerase a (s :: l) = l := by 

Proof state:
α : Type u
β : α → Type v
l✝ l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
s : Sigma β
l : List (Sigma β)
h : a = s.fst
⊢ kerase a (s :: l) = l

Next tactic:
simp [kerase, h]
@[simp]
theorem kerase_cons_ne {a} {s : Sigma β} {l : List (Sigma β)} (h : a ≠ s.1) :
    kerase a (s :: l) = s :: kerase a l := by 

Proof state:
α : Type u
β : α → Type v
l✝ l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
s : Sigma β
l : List (Sigma β)
h : a ≠ s.fst
⊢ kerase a (s :: l) = s :: kerase a l

Next tactic:
simp [kerase, h]
@[simp]
theorem kerase_of_not_mem_keys {a} {l : List (Sigma β)} (h : a ∉ l.keys) : kerase a l = l := by
  

Proof state:
α : Type u
β : α → Type v
l✝ l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
l : List (Sigma β)
h : a ∉ keys l
⊢ kerase a l = l

Next tactic:
induction' l with _ _ ih <;> [rfl; (simp [not_or] at h; simp [h.1, ih h.2])]
@[simp]
theorem kerase_of_not_mem_keys {a} {l : List (Sigma β)} (h : a ∉ l.keys) : kerase a l = l := by
  

Proof state:
α : Type u
β : α → Type v
l✝ l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
l : List (Sigma β)
h : a ∉ keys l
⊢ kerase a l = l

Next tactic:
induction' l with _ _ ih
@[simp]
theorem kerase_of_not_mem_keys {a} {l : List (Sigma β)} (h : a ∉ l.keys) : kerase a l = l := by
  induction' l with _ _ ih <;> [

Proof state:
case nil
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
h : a ∉ keys []
⊢ kerase a [] = []

Next tactic:
rfl
@[simp]
theorem kerase_of_not_mem_keys {a} {l : List (Sigma β)} (h : a ∉ l.keys) : kerase a l = l := by
  induction' l with _ _ ih <;> [rfl; (

Proof state:
case cons
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
head✝ : Sigma β
tail✝ : List (Sigma β)
ih : a ∉ keys tail✝ → kerase a tail✝ = tail✝
h : a ∉ keys (head✝ :: tail✝)
⊢ kerase a (head✝ :: tail✝) = head✝ :: tail✝

Next tactic:
simp [not_or] at h
@[simp]
theorem kerase_of_not_mem_keys {a} {l : List (Sigma β)} (h : a ∉ l.keys) : kerase a l = l := by
  induction' l with _ _ ih <;> [rfl; (simp [not_or] at h; 

Proof state:
case cons
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
head✝ : Sigma β
tail✝ : List (Sigma β)
ih : a ∉ keys tail✝ → kerase a tail✝ = tail✝
h : ¬a = head✝.fst ∧ a ∉ keys tail✝
⊢ kerase a (head✝ :: tail✝) = head✝ :: tail✝

Next tactic:
simp [h.1, ih h.2]
theorem exists_of_kerase {a : α} {l : List (Sigma β)} (h : a ∈ l.keys) :
    ∃ (b : β a) (l₁ l₂ : List (Sigma β)),
      a ∉ l₁.keys ∧ l = l₁ ++ ⟨a, b⟩ :: l₂ ∧ kerase a l = l₁ ++ l₂ := by
  

Proof state:
α : Type u
β : α → Type v
l✝ l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
l : List (Sigma β)
h : a ∈ keys l
⊢ ∃ b l₁ l₂, a ∉ keys l₁ ∧ l = l₁ ++ { fst := a, snd := b } :: l₂ ∧ kerase a l = l₁ ++ l₂

Next tactic:
induction l with
  | nil => cases h
  | cons hd tl ih =>
    by_cases e : a = hd.1
    · subst e
      exact ⟨hd.2, [], tl, by simp, by cases hd; rfl, by simp⟩
    · simp at h
      cases' h with h h
      exact absurd h e
      rcases ih h with ⟨b, tl₁, tl₂, h₁, h₂, h₃⟩
      exact ⟨b, hd :: tl₁, tl₂, not_mem_cons_of_ne_of_not_mem e h₁, by (rw [h₂]; rfl), by
            simp [e, h₃]⟩
theorem exists_of_kerase {a : α} {l : List (Sigma β)} (h : a ∈ l.keys) :
    ∃ (b : β a) (l₁ l₂ : List (Sigma β)),
      a ∉ l₁.keys ∧ l = l₁ ++ ⟨a, b⟩ :: l₂ ∧ kerase a l = l₁ ++ l₂ := by
  induction l with
  

Proof state:
case nil
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
h : a ∈ keys []
⊢ ∃ b l₁ l₂, a ∉ keys l₁ ∧ [] = l₁ ++ { fst := a, snd := b } :: l₂ ∧ kerase a [] = l₁ ++ l₂

Next tactic:
| nil => cases h
theorem exists_of_kerase {a : α} {l : List (Sigma β)} (h : a ∈ l.keys) :
    ∃ (b : β a) (l₁ l₂ : List (Sigma β)),
      a ∉ l₁.keys ∧ l = l₁ ++ ⟨a, b⟩ :: l₂ ∧ kerase a l = l₁ ++ l₂ := by
  induction l with
  | nil => 

Proof state:
case nil
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
h : a ∈ keys []
⊢ ∃ b l₁ l₂, a ∉ keys l₁ ∧ [] = l₁ ++ { fst := a, snd := b } :: l₂ ∧ kerase a [] = l₁ ++ l₂

Next tactic:
cases h
theorem exists_of_kerase {a : α} {l : List (Sigma β)} (h : a ∈ l.keys) :
    ∃ (b : β a) (l₁ l₂ : List (Sigma β)),
      a ∉ l₁.keys ∧ l = l₁ ++ ⟨a, b⟩ :: l₂ ∧ kerase a l = l₁ ++ l₂ := by
  induction l with
  | nil => cases h
  

Proof state:
case cons
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
hd : Sigma β
tl : List (Sigma β)
ih : a ∈ keys tl → ∃ b l₁ l₂, a ∉ keys l₁ ∧ tl = l₁ ++ { fst := a, snd := b } :: l₂ ∧ kerase a tl = l₁ ++ l₂
h : a ∈ keys (hd :: tl)
⊢ ∃ b l₁ l₂, a ∉ keys l₁ ∧ hd :: tl = l₁ ++ { fst := a, snd := b } :: l₂ ∧ kerase a (hd :: tl) = l₁ ++ l₂

Next tactic:
| cons hd tl ih =>
    by_cases e : a = hd.1
    · subst e
      exact ⟨hd.2, [], tl, by simp, by cases hd; rfl, by simp⟩
    · simp at h
      cases' h with h h
      exact absurd h e
      rcases ih h with ⟨b, tl₁, tl₂, h₁, h₂, h₃⟩
      exact ⟨b, hd :: tl₁, tl₂, not_mem_cons_of_ne_of_not_mem e h₁, by (rw [h₂]; rfl), by
            simp [e, h₃]⟩
theorem exists_of_kerase {a : α} {l : List (Sigma β)} (h : a ∈ l.keys) :
    ∃ (b : β a) (l₁ l₂ : List (Sigma β)),
      a ∉ l₁.keys ∧ l = l₁ ++ ⟨a, b⟩ :: l₂ ∧ kerase a l = l₁ ++ l₂ := by
  induction l with
  | nil => cases h
  | cons hd tl ih =>
    

Proof state:
case cons
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
hd : Sigma β
tl : List (Sigma β)
ih : a ∈ keys tl → ∃ b l₁ l₂, a ∉ keys l₁ ∧ tl = l₁ ++ { fst := a, snd := b } :: l₂ ∧ kerase a tl = l₁ ++ l₂
h : a ∈ keys (hd :: tl)
⊢ ∃ b l₁ l₂, a ∉ keys l₁ ∧ hd :: tl = l₁ ++ { fst := a, snd := b } :: l₂ ∧ kerase a (hd :: tl) = l₁ ++ l₂

Next tactic:
by_cases e : a = hd.1
theorem exists_of_kerase {a : α} {l : List (Sigma β)} (h : a ∈ l.keys) :
    ∃ (b : β a) (l₁ l₂ : List (Sigma β)),
      a ∉ l₁.keys ∧ l = l₁ ++ ⟨a, b⟩ :: l₂ ∧ kerase a l = l₁ ++ l₂ := by
  induction l with
  | nil => cases h
  | cons hd tl ih =>
    by_cases e : a = hd.1
    · 

Proof state:
case pos
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
hd : Sigma β
tl : List (Sigma β)
ih : a ∈ keys tl → ∃ b l₁ l₂, a ∉ keys l₁ ∧ tl = l₁ ++ { fst := a, snd := b } :: l₂ ∧ kerase a tl = l₁ ++ l₂
h : a ∈ keys (hd :: tl)
e : a = hd.fst
⊢ ∃ b l₁ l₂, a ∉ keys l₁ ∧ hd :: tl = l₁ ++ { fst := a, snd := b } :: l₂ ∧ kerase a (hd :: tl) = l₁ ++ l₂

Next tactic:
subst e
theorem exists_of_kerase {a : α} {l : List (Sigma β)} (h : a ∈ l.keys) :
    ∃ (b : β a) (l₁ l₂ : List (Sigma β)),
      a ∉ l₁.keys ∧ l = l₁ ++ ⟨a, b⟩ :: l₂ ∧ kerase a l = l₁ ++ l₂ := by
  induction l with
  | nil => cases h
  | cons hd tl ih =>
    by_cases e : a = hd.1
    · subst e
      

Proof state:
case pos
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
hd : Sigma β
tl : List (Sigma β)
ih :
  hd.fst ∈ keys tl →
    ∃ b l₁ l₂, hd.fst ∉ keys l₁ ∧ tl = l₁ ++ { fst := hd.fst, snd := b } :: l₂ ∧ kerase hd.fst tl = l₁ ++ l₂
h : hd.fst ∈ keys (hd :: tl)
⊢ ∃ b l₁ l₂, hd.fst ∉ keys l₁ ∧ hd :: tl = l₁ ++ { fst := hd.fst, snd := b } :: l₂ ∧ kerase hd.fst (hd :: tl) = l₁ ++ l₂

Next tactic:
exact ⟨hd.2, [], tl, by simp, by cases hd; rfl, by simp⟩
theorem exists_of_kerase {a : α} {l : List (Sigma β)} (h : a ∈ l.keys) :
    ∃ (b : β a) (l₁ l₂ : List (Sigma β)),
      a ∉ l₁.keys ∧ l = l₁ ++ ⟨a, b⟩ :: l₂ ∧ kerase a l = l₁ ++ l₂ := by
  induction l with
  | nil => cases h
  | cons hd tl ih =>
    by_cases e : a = hd.1
    · subst e
      exact ⟨hd.2, [], tl, by 

Proof state:
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
hd : Sigma β
tl : List (Sigma β)
ih :
  hd.fst ∈ keys tl →
    ∃ b l₁ l₂, hd.fst ∉ keys l₁ ∧ tl = l₁ ++ { fst := hd.fst, snd := b } :: l₂ ∧ kerase hd.fst tl = l₁ ++ l₂
h : hd.fst ∈ keys (hd :: tl)
⊢ hd.fst ∉ keys []

Next tactic:
simp
theorem exists_of_kerase {a : α} {l : List (Sigma β)} (h : a ∈ l.keys) :
    ∃ (b : β a) (l₁ l₂ : List (Sigma β)),
      a ∉ l₁.keys ∧ l = l₁ ++ ⟨a, b⟩ :: l₂ ∧ kerase a l = l₁ ++ l₂ := by
  induction l with
  | nil => cases h
  | cons hd tl ih =>
    by_cases e : a = hd.1
    · subst e
      exact ⟨hd.2, [], tl, by simp, by 

Proof state:
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
hd : Sigma β
tl : List (Sigma β)
ih :
  hd.fst ∈ keys tl →
    ∃ b l₁ l₂, hd.fst ∉ keys l₁ ∧ tl = l₁ ++ { fst := hd.fst, snd := b } :: l₂ ∧ kerase hd.fst tl = l₁ ++ l₂
h : hd.fst ∈ keys (hd :: tl)
⊢ hd :: tl = [] ++ { fst := hd.fst, snd := hd.snd } :: tl

Next tactic:
cases hd
theorem exists_of_kerase {a : α} {l : List (Sigma β)} (h : a ∈ l.keys) :
    ∃ (b : β a) (l₁ l₂ : List (Sigma β)),
      a ∉ l₁.keys ∧ l = l₁ ++ ⟨a, b⟩ :: l₂ ∧ kerase a l = l₁ ++ l₂ := by
  induction l with
  | nil => cases h
  | cons hd tl ih =>
    by_cases e : a = hd.1
    · subst e
      exact ⟨hd.2, [], tl, by simp, by cases hd; 

Proof state:
case mk
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
tl : List (Sigma β)
fst✝ : α
snd✝ : β fst✝
ih :
  { fst := fst✝, snd := snd✝ }.fst ∈ keys tl →
    ∃ b l₁ l₂,
      { fst := fst✝, snd := snd✝ }.fst ∉ keys l₁ ∧
        tl = l₁ ++ { fst := { fst := fst✝, snd := snd✝ }.fst, snd := b } :: l₂ ∧
          kerase { fst := fst✝, snd := snd✝ }.fst tl = l₁ ++ l₂
h : { fst := fst✝, snd := snd✝ }.fst ∈ keys ({ fst := fst✝, snd := snd✝ } :: tl)
⊢ { fst := fst✝, snd := snd✝ } :: tl =
    [] ++ { fst := { fst := fst✝, snd := snd✝ }.fst, snd := { fst := fst✝, snd := snd✝ }.snd } :: tl

Next tactic:
rfl
theorem exists_of_kerase {a : α} {l : List (Sigma β)} (h : a ∈ l.keys) :
    ∃ (b : β a) (l₁ l₂ : List (Sigma β)),
      a ∉ l₁.keys ∧ l = l₁ ++ ⟨a, b⟩ :: l₂ ∧ kerase a l = l₁ ++ l₂ := by
  induction l with
  | nil => cases h
  | cons hd tl ih =>
    by_cases e : a = hd.1
    · subst e
      exact ⟨hd.2, [], tl, by simp, by cases hd; rfl, by 

Proof state:
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
hd : Sigma β
tl : List (Sigma β)
ih :
  hd.fst ∈ keys tl →
    ∃ b l₁ l₂, hd.fst ∉ keys l₁ ∧ tl = l₁ ++ { fst := hd.fst, snd := b } :: l₂ ∧ kerase hd.fst tl = l₁ ++ l₂
h : hd.fst ∈ keys (hd :: tl)
⊢ kerase hd.fst (hd :: tl) = [] ++ tl

Next tactic:
simp
theorem exists_of_kerase {a : α} {l : List (Sigma β)} (h : a ∈ l.keys) :
    ∃ (b : β a) (l₁ l₂ : List (Sigma β)),
      a ∉ l₁.keys ∧ l = l₁ ++ ⟨a, b⟩ :: l₂ ∧ kerase a l = l₁ ++ l₂ := by
  induction l with
  | nil => cases h
  | cons hd tl ih =>
    by_cases e : a = hd.1
    · subst e
      exact ⟨hd.2, [], tl, by simp, by cases hd; rfl, by simp⟩
    · 

Proof state:
case neg
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
hd : Sigma β
tl : List (Sigma β)
ih : a ∈ keys tl → ∃ b l₁ l₂, a ∉ keys l₁ ∧ tl = l₁ ++ { fst := a, snd := b } :: l₂ ∧ kerase a tl = l₁ ++ l₂
h : a ∈ keys (hd :: tl)
e : ¬a = hd.fst
⊢ ∃ b l₁ l₂, a ∉ keys l₁ ∧ hd :: tl = l₁ ++ { fst := a, snd := b } :: l₂ ∧ kerase a (hd :: tl) = l₁ ++ l₂

Next tactic:
simp at h
theorem exists_of_kerase {a : α} {l : List (Sigma β)} (h : a ∈ l.keys) :
    ∃ (b : β a) (l₁ l₂ : List (Sigma β)),
      a ∉ l₁.keys ∧ l = l₁ ++ ⟨a, b⟩ :: l₂ ∧ kerase a l = l₁ ++ l₂ := by
  induction l with
  | nil => cases h
  | cons hd tl ih =>
    by_cases e : a = hd.1
    · subst e
      exact ⟨hd.2, [], tl, by simp, by cases hd; rfl, by simp⟩
    · simp at h
      

Proof state:
case neg
α : Type u
β : α → Type v
l l₁ l₂ : List (Sigma β)
inst✝ : DecidableEq α
a : α
hd : Sigma β
tl : List (Sigma β)
ih : a ∈ keys tl → ∃ b l₁ l₂, a ∉ keys l₁ ∧ tl = l₁ ++ { fst := a, snd := b } :: l₂ ∧ kerase a tl = l₁ ++ l₂
e : ¬a = hd.fst
h : a = hd.fst ∨ a ∈ keys tl
⊢ ∃ b l₁ l₂, a ∉ keys l₁ ∧ hd :: tl = l₁ ++ { fst := a, snd := b } :: l₂ ∧ kerase a (hd :: tl) = l₁ ++ l₂

Next tactic:
cases' h with h h