Theorem: Finset.filter_snd_eq_antidiagonal
File: Mathlib/Algebra/Order/Antidiag/Prod.lean

tactic: have : (fun x : A × A ↦ (x.snd = m)) ∘ Prod.swap = fun x : A × A ↦ x.fst = m := by
  ext; simp
state_before: A : Type u_1
inst✝⁶ : CanonicallyOrderedAddCommMonoid A
inst✝⁵ : Sub A
inst✝⁴ : OrderedSub A
inst✝³ : ContravariantClass A A (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1
inst✝² : HasAntidiagonal A
n m : A
inst✝¹ : DecidablePred fun x => x = m
inst✝ : Decidable (m ≤ n)
⊢ filter (fun x => x.2 = m) (antidiagonal n) = if m ≤ n then {(n - m, m)} else ∅
state_after: A : Type u_1
inst✝⁶ : CanonicallyOrderedAddCommMonoid A
inst✝⁵ : Sub A
inst✝⁴ : OrderedSub A
inst✝³ : ContravariantClass A A (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1
inst✝² : HasAntidiagonal A
n m : A
inst✝¹ : DecidablePred fun x => x = m
inst✝ : Decidable (m ≤ n)
this : (fun x => x.2 = m) ∘ Prod.swap = fun x => x.1 = m
⊢ filter (fun x => x.2 = m) (antidiagonal n) = if m ≤ n then {(n - m, m)} else ∅

tactic: rw [← map_swap_antidiagonal, filter_map]
state_before: A : Type u_1
inst✝⁶ : CanonicallyOrderedAddCommMonoid A
inst✝⁵ : Sub A
inst✝⁴ : OrderedSub A
inst✝³ : ContravariantClass A A (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1
inst✝² : HasAntidiagonal A
n m : A
inst✝¹ : DecidablePred fun x => x = m
inst✝ : Decidable (m ≤ n)
this : (fun x => x.2 = m) ∘ Prod.swap = fun x => x.1 = m
⊢ filter (fun x => x.2 = m) (antidiagonal n) = if m ≤ n then {(n - m, m)} else ∅
state_after: A : Type u_1
inst✝⁶ : CanonicallyOrderedAddCommMonoid A
inst✝⁵ : Sub A
inst✝⁴ : OrderedSub A
inst✝³ : ContravariantClass A A (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1
inst✝² : HasAntidiagonal A
n m : A
inst✝¹ : DecidablePred fun x => x = m
inst✝ : Decidable (m ≤ n)
this : (fun x => x.2 = m) ∘ Prod.swap = fun x => x.1 = m
⊢ map { toFun := Prod.swap, inj' := ⋯ }
      (filter ((fun x => x.2 = m) ∘ ⇑{ toFun := Prod.swap, inj' := ⋯ }) (antidiagonal n)) =
    if m ≤ n then {(n - m, m)} else ∅

tactic: simp [this, filter_fst_eq_antidiagonal, apply_ite (Finset.map _)]
state_before: A : Type u_1
inst✝⁶ : CanonicallyOrderedAddCommMonoid A
inst✝⁵ : Sub A
inst✝⁴ : OrderedSub A
inst✝³ : ContravariantClass A A (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1
inst✝² : HasAntidiagonal A
n m : A
inst✝¹ : DecidablePred fun x => x = m
inst✝ : Decidable (m ≤ n)
this : (fun x => x.2 = m) ∘ Prod.swap = fun x => x.1 = m
⊢ map { toFun := Prod.swap, inj' := ⋯ }
      (filter ((fun x => x.2 = m) ∘ ⇑{ toFun := Prod.swap, inj' := ⋯ }) (antidiagonal n)) =
    if m ≤ n then {(n - m, m)} else ∅
state_after: no goals

tactic: ext
state_before: A : Type u_1
inst✝⁶ : CanonicallyOrderedAddCommMonoid A
inst✝⁵ : Sub A
inst✝⁴ : OrderedSub A
inst✝³ : ContravariantClass A A (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1
inst✝² : HasAntidiagonal A
n m : A
inst✝¹ : DecidablePred fun x => x = m
inst✝ : Decidable (m ≤ n)
⊢ (fun x => x.2 = m) ∘ Prod.swap = fun x => x.1 = m
state_after: case h.a
A : Type u_1
inst✝⁶ : CanonicallyOrderedAddCommMonoid A
inst✝⁵ : Sub A
inst✝⁴ : OrderedSub A
inst✝³ : ContravariantClass A A (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1
inst✝² : HasAntidiagonal A
n m : A
inst✝¹ : DecidablePred fun x => x = m
inst✝ : Decidable (m ≤ n)
x✝ : A × A
⊢ ((fun x => x.2 = m) ∘ Prod.swap) x✝ ↔ x✝.1 = m

tactic: simp
state_before: case h.a
A : Type u_1
inst✝⁶ : CanonicallyOrderedAddCommMonoid A
inst✝⁵ : Sub A
inst✝⁴ : OrderedSub A
inst✝³ : ContravariantClass A A (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1
inst✝² : HasAntidiagonal A
n m : A
inst✝¹ : DecidablePred fun x => x = m
inst✝ : Decidable (m ≤ n)
x✝ : A × A
⊢ ((fun x => x.2 = m) ∘ Prod.swap) x✝ ↔ x✝.1 = m
state_after: no goals