Theorem: List.filterMap_eq_map_iff_forall_eq_some
File: Mathlib/Data/List/Basic.lean

tactic: induction' l with a l ih
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → Option β
g : α → β
l : List α
⊢ filterMap f l = map g l → ∀ (x : α), x ∈ l → f x = some (g x)
state_after: case nil
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → Option β
g : α → β
⊢ filterMap f [] = map g [] → ∀ (x : α), x ∈ [] → f x = some (g x)

case cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → Option β
g : α → β
a : α
l : List α
ih : filterMap f l = map g l → ∀ (x : α), x ∈ l → f x = some (g x)
⊢ filterMap f (a :: l) = map g (a :: l) → ∀ (x : α), x ∈ a :: l → f x = some (g x)

tactic: cases' ha : f a with b <;> simp [ha, filterMap_cons]
state_before: case cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → Option β
g : α → β
a : α
l : List α
ih : filterMap f l = map g l → ∀ (x : α), x ∈ l → f x = some (g x)
⊢ filterMap f (a :: l) = map g (a :: l) → ∀ (x : α), x ∈ a :: l → f x = some (g x)
state_after: case cons.none
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → Option β
g : α → β
a : α
l : List α
ih : filterMap f l = map g l → ∀ (x : α), x ∈ l → f x = some (g x)
ha : f a = none
⊢ ¬filterMap f l = g a :: map g l

case cons.some
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → Option β
g : α → β
a : α
l : List α
ih : filterMap f l = map g l → ∀ (x : α), x ∈ l → f x = some (g x)
b : β
ha : f a = some b
⊢ b = g a → filterMap f l = map g l → b = g a ∧ ∀ (a : α), a ∈ l → f a = some (g a)

tactic: simp
state_before: case nil
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → Option β
g : α → β
⊢ filterMap f [] = map g [] → ∀ (x : α), x ∈ [] → f x = some (g x)
state_after: no goals

tactic: intro h
state_before: case cons.none
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → Option β
g : α → β
a : α
l : List α
ih : filterMap f l = map g l → ∀ (x : α), x ∈ l → f x = some (g x)
ha : f a = none
⊢ ¬filterMap f l = g a :: map g l
state_after: case cons.none
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → Option β
g : α → β
a : α
l : List α
ih : filterMap f l = map g l → ∀ (x : α), x ∈ l → f x = some (g x)
ha : f a = none
h : filterMap f l = g a :: map g l
⊢ False

tactic: simpa [show (filterMap f l).length = l.length + 1 from by simp[h], Nat.add_one_le_iff]
  using List.length_filterMap_le f l
state_before: case cons.none
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → Option β
g : α → β
a : α
l : List α
ih : filterMap f l = map g l → ∀ (x : α), x ∈ l → f x = some (g x)
ha : f a = none
h : filterMap f l = g a :: map g l
⊢ False
state_after: no goals

tactic: simp[h]
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → Option β
g : α → β
a : α
l : List α
ih : filterMap f l = map g l → ∀ (x : α), x ∈ l → f x = some (g x)
ha : f a = none
h : filterMap f l = g a :: map g l
⊢ (filterMap f l).length = l.length + 1
state_after: no goals

tactic: rintro rfl h
state_before: case cons.some
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → Option β
g : α → β
a : α
l : List α
ih : filterMap f l = map g l → ∀ (x : α), x ∈ l → f x = some (g x)
b : β
ha : f a = some b
⊢ b = g a → filterMap f l = map g l → b = g a ∧ ∀ (a : α), a ∈ l → f a = some (g a)
state_after: case cons.some
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → Option β
g : α → β
a : α
l : List α
ih : filterMap f l = map g l → ∀ (x : α), x ∈ l → f x = some (g x)
ha : f a = some (g a)
h : filterMap f l = map g l
⊢ g a = g a ∧ ∀ (a : α), a ∈ l → f a = some (g a)

tactic: exact ⟨rfl, ih h⟩
state_before: case cons.some
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → Option β
g : α → β
a : α
l : List α
ih : filterMap f l = map g l → ∀ (x : α), x ∈ l → f x = some (g x)
ha : f a = some (g a)
h : filterMap f l = map g l
⊢ g a = g a ∧ ∀ (a : α), a ∈ l → f a = some (g a)
state_after: no goals

tactic: simpa
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → Option β
g : α → β
l : List α
h : ∀ (x : α), x ∈ l → f x = some (g x)
⊢ ∀ (x : α), x ∈ l → f x = (some ∘ g) x
state_after: no goals