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

tactic: ext ⟨a, b⟩
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.1 = m) (antidiagonal n) = if m ≤ n then {(m, n - m)} else ∅
state_after: case a.mk
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)
a b : A
⊢ (a, b) ∈ filter (fun x => x.1 = m) (antidiagonal n) ↔ (a, b) ∈ if m ≤ n then {(m, n - m)} else ∅

tactic: suffices a = m → (a + b = n ↔ m ≤ n ∧ b = n - m) by
  rw [mem_filter, mem_antidiagonal, apply_ite (fun n ↦ (a, b) ∈ n), mem_singleton,
    Prod.mk.inj_iff, ite_prop_iff_or]
  simpa [ ← and_assoc, @and_right_comm _ (a = _), and_congr_left_iff]
state_before: case a.mk
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)
a b : A
⊢ (a, b) ∈ filter (fun x => x.1 = m) (antidiagonal n) ↔ (a, b) ∈ if m ≤ n then {(m, n - m)} else ∅
state_after: case a.mk
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)
a b : A
⊢ a = m → (a + b = n ↔ m ≤ n ∧ b = n - m)

tactic: rintro rfl
state_before: case a.mk
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)
a b : A
⊢ a = m → (a + b = n ↔ m ≤ n ∧ b = n - m)
state_after: case a.mk
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 a b : A
inst✝¹ : DecidablePred fun x => x = a
inst✝ : Decidable (a ≤ n)
⊢ a + b = n ↔ a ≤ n ∧ b = n - a

tactic: constructor
state_before: case a.mk
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 a b : A
inst✝¹ : DecidablePred fun x => x = a
inst✝ : Decidable (a ≤ n)
⊢ a + b = n ↔ a ≤ n ∧ b = n - a
state_after: case a.mk.mp
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 a b : A
inst✝¹ : DecidablePred fun x => x = a
inst✝ : Decidable (a ≤ n)
⊢ a + b = n → a ≤ n ∧ b = n - a

case a.mk.mpr
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 a b : A
inst✝¹ : DecidablePred fun x => x = a
inst✝ : Decidable (a ≤ n)
⊢ a ≤ n ∧ b = n - a → a + b = n

tactic: rw [mem_filter, mem_antidiagonal, apply_ite (fun n ↦ (a, b) ∈ n), mem_singleton,
  Prod.mk.inj_iff, ite_prop_iff_or]
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)
a b : A
this : a = m → (a + b = n ↔ m ≤ n ∧ b = n - m)
⊢ (a, b) ∈ filter (fun x => x.1 = m) (antidiagonal n) ↔ (a, b) ∈ if m ≤ n then {(m, n - 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)
a b : A
this : a = m → (a + b = n ↔ m ≤ n ∧ b = n - m)
⊢ (a, b).1 + (a, b).2 = n ∧ (a, b).1 = m ↔ m ≤ n ∧ a = m ∧ b = n - m ∨ ¬m ≤ n ∧ (a, b) ∈ ∅

tactic: simpa [ ← and_assoc, @and_right_comm _ (a = _), and_congr_left_iff]
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)
a b : A
this : a = m → (a + b = n ↔ m ≤ n ∧ b = n - m)
⊢ (a, b).1 + (a, b).2 = n ∧ (a, b).1 = m ↔ m ≤ n ∧ a = m ∧ b = n - m ∨ ¬m ≤ n ∧ (a, b) ∈ ∅
state_after: no goals

tactic: rintro rfl
state_before: case a.mk.mp
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 a b : A
inst✝¹ : DecidablePred fun x => x = a
inst✝ : Decidable (a ≤ n)
⊢ a + b = n → a ≤ n ∧ b = n - a
state_after: case a.mk.mp
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
a b : A
inst✝¹ : DecidablePred fun x => x = a
inst✝ : Decidable (a ≤ a + b)
⊢ a ≤ a + b ∧ b = a + b - a

tactic: exact ⟨le_add_right le_rfl, (add_tsub_cancel_left _ _).symm⟩
state_before: case a.mk.mp
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
a b : A
inst✝¹ : DecidablePred fun x => x = a
inst✝ : Decidable (a ≤ a + b)
⊢ a ≤ a + b ∧ b = a + b - a
state_after: no goals

tactic: rintro ⟨h, rfl⟩
state_before: case a.mk.mpr
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 a b : A
inst✝¹ : DecidablePred fun x => x = a
inst✝ : Decidable (a ≤ n)
⊢ a ≤ n ∧ b = n - a → a + b = n
state_after: case a.mk.mpr.intro
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 a : A
inst✝¹ : DecidablePred fun x => x = a
inst✝ : Decidable (a ≤ n)
h : a ≤ n
⊢ a + (n - a) = n

tactic: exact add_tsub_cancel_of_le h
state_before: case a.mk.mpr.intro
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 a : A
inst✝¹ : DecidablePred fun x => x = a
inst✝ : Decidable (a ≤ n)
h : a ≤ n
⊢ a + (n - a) = n
state_after: no goals