File: Mathlib/Data/Finset/NatAntidiagonal.lean

full_name: Finset.Nat.instHasAntidiagonal
code: /-- The antidiagonal of a natural number `n` is
    the finset of pairs `(i, j)` such that `i + j = n`. -/
instance instHasAntidiagonal : HasAntidiagonal ℕ 
goal: Finset.HasAntidiagonal ℕ

full_name: Finset.Nat.antidiagonal_eq_map
code: lemma antidiagonal_eq_map (n : ℕ) :
    antidiagonal n = (range (n + 1)).map ⟨fun i ↦ (i, n - i), fun _ _ h ↦ (Prod.ext_iff.1 h).1⟩ 
goal: Finset.antidiagonal n = Finset.map { toFun := fun i => (i, n - i), inj' := ⋯ } (Finset.range (n + 1))

full_name: Finset.Nat.antidiagonal_eq_map'
code: lemma antidiagonal_eq_map' (n : ℕ) :
    antidiagonal n =
      (range (n + 1)).map ⟨fun i ↦ (n - i, i), fun _ _ h ↦ (Prod.ext_iff.1 h).2⟩ 
goal: Finset.antidiagonal n = Finset.map { toFun := fun i => (n - i, i), inj' := ⋯ } (Finset.range (n + 1))

full_name: Finset.Nat.antidiagonal_eq_image
code: lemma antidiagonal_eq_image (n : ℕ) :
    antidiagonal n = (range (n + 1)).image fun i ↦ (i, n - i) 
goal: Finset.antidiagonal n = Finset.image (fun i => (i, n - i)) (Finset.range (n + 1))

full_name: Finset.Nat.antidiagonal_eq_image'
code: lemma antidiagonal_eq_image' (n : ℕ) :
    antidiagonal n = (range (n + 1)).image fun i ↦ (n - i, i) 
goal: Finset.antidiagonal n = Finset.image (fun i => (n - i, i)) (Finset.range (n + 1))

full_name: Finset.Nat.card_antidiagonal
code: /-- The cardinality of the antidiagonal of `n` is `n + 1`. -/
@[simp]
theorem card_antidiagonal (n : ℕ) : (antidiagonal n).card = n + 1 
goal: (Finset.antidiagonal n).card = n + 1

full_name: Finset.Nat.antidiagonal_zero
code: /-- The antidiagonal of `0` is the list `[(0, 0)]` -/
@[simp]
theorem antidiagonal_zero : antidiagonal 0 = {(0, 0)} 
goal: Finset.antidiagonal 0 = {(0, 0)}

full_name: Finset.Nat.antidiagonal_succ
code: theorem antidiagonal_succ (n : ℕ) :
    antidiagonal (n + 1) =
      cons (0, n + 1)
        ((antidiagonal n).map
          (Embedding.prodMap ⟨Nat.succ, Nat.succ_injective⟩ (Embedding.refl _)))
        (by simp) 
goal: Finset.antidiagonal (n + 1) =
  Finset.cons (0, n + 1)
    (Finset.map ({ toFun := Nat.succ, inj' := Nat.succ_injective }.prodMap (Function.Embedding.refl ℕ))
      (Finset.antidiagonal n))
    ⋯

full_name: Finset.Nat.antidiagonal_succ'
code: theorem antidiagonal_succ' (n : ℕ) :
    antidiagonal (n + 1) =
      cons (n + 1, 0)
        ((antidiagonal n).map
          (Embedding.prodMap (Embedding.refl _) ⟨Nat.succ, Nat.succ_injective⟩))
        (by simp) 
goal: Finset.antidiagonal (n + 1) =
  Finset.cons (n + 1, 0)
    (Finset.map ((Function.Embedding.refl ℕ).prodMap { toFun := Nat.succ, inj' := Nat.succ_injective })
      (Finset.antidiagonal n))
    ⋯

full_name: Finset.Nat.antidiagonal_succ_succ'
code: theorem antidiagonal_succ_succ' {n : ℕ} :
    antidiagonal (n + 2) =
      cons (0, n + 2)
        (cons (n + 2, 0)
            ((antidiagonal n).map
              (Embedding.prodMap ⟨Nat.succ, Nat.succ_injective⟩
                ⟨Nat.succ, Nat.succ_injective⟩)) <|
          by simp)
        (by simp) 
goal: Finset.antidiagonal (n + 2) =
  Finset.cons (0, n + 2)
    (Finset.cons (n + 2, 0)
      (Finset.map
        ({ toFun := Nat.succ, inj' := Nat.succ_injective }.prodMap { toFun := Nat.succ, inj' := Nat.succ_injective })
        (Finset.antidiagonal n))
      ⋯)
    ⋯

full_name: Finset.Nat.antidiagonal.fst_lt
code: theorem antidiagonal.fst_lt {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagonal n) : kl.1 < n + 1 
goal: kl.1 < n + 1

full_name: Finset.Nat.antidiagonal.snd_lt
code: theorem antidiagonal.snd_lt {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagonal n) : kl.2 < n + 1 
goal: kl.2 < n + 1

full_name: Finset.Nat.antidiagonal_filter_snd_le_of_le
code: @[simp] lemma antidiagonal_filter_snd_le_of_le {n k : ℕ} (h : k ≤ n) :
    (antidiagonal n).filter (fun a ↦ a.snd ≤ k) = (antidiagonal k).map
      (Embedding.prodMap ⟨_, add_left_injective (n - k)⟩ (Embedding.refl ℕ)) 
goal: Finset.filter (fun a => a.2 ≤ k) (Finset.antidiagonal n) =
  Finset.map ({ toFun := fun x => x + (n - k), inj' := ⋯ }.prodMap (Function.Embedding.refl ℕ)) (Finset.antidiagonal k)

full_name: Finset.Nat.antidiagonal_filter_fst_le_of_le
code: @[simp] lemma antidiagonal_filter_fst_le_of_le {n k : ℕ} (h : k ≤ n) :
    (antidiagonal n).filter (fun a ↦ a.fst ≤ k) = (antidiagonal k).map
      (Embedding.prodMap (Embedding.refl ℕ) ⟨_, add_left_injective (n - k)⟩) 
goal: Finset.filter (fun a => a.1 ≤ k) (Finset.antidiagonal n) =
  Finset.map ((Function.Embedding.refl ℕ).prodMap { toFun := fun x => x + (n - k), inj' := ⋯ }) (Finset.antidiagonal k)

full_name: Finset.Nat.antidiagonal_filter_le_fst_of_le
code: @[simp] lemma antidiagonal_filter_le_fst_of_le {n k : ℕ} (h : k ≤ n) :
    (antidiagonal n).filter (fun a ↦ k ≤ a.fst) = (antidiagonal (n - k)).map
      (Embedding.prodMap ⟨_, add_left_injective k⟩ (Embedding.refl ℕ)) 
goal: Finset.filter (fun a => k ≤ a.1) (Finset.antidiagonal n) =
  Finset.map ({ toFun := fun x => x + k, inj' := ⋯ }.prodMap (Function.Embedding.refl ℕ)) (Finset.antidiagonal (n - k))

full_name: Finset.Nat.antidiagonal_filter_le_snd_of_le
code: @[simp] lemma antidiagonal_filter_le_snd_of_le {n k : ℕ} (h : k ≤ n) :
    (antidiagonal n).filter (fun a ↦ k ≤ a.snd) = (antidiagonal (n - k)).map
      (Embedding.prodMap (Embedding.refl ℕ) ⟨_, add_left_injective k⟩) 
goal: Finset.filter (fun a => k ≤ a.2) (Finset.antidiagonal n) =
  Finset.map ((Function.Embedding.refl ℕ).prodMap { toFun := fun x => x + k, inj' := ⋯ }) (Finset.antidiagonal (n - k))

full_name: Finset.Nat.antidiagonalEquivFin_apply_val
code: /-- The set `antidiagonal n` is equivalent to `Fin (n+1)`, via the first projection. --/
@[simps]
def antidiagonalEquivFin (n : ℕ) : antidiagonal n ≃ Fin (n + 1) 
goal: ∀ (x : { x // x ∈ Finset.antidiagonal n }), ↑((Finset.Nat.antidiagonalEquivFin n) x) = x.1.1

full_name: Finset.Nat.antidiagonalEquivFin_symm_apply_coe
code: /-- The set `antidiagonal n` is equivalent to `Fin (n+1)`, via the first projection. --/
@[simps]
def antidiagonalEquivFin (n : ℕ) : antidiagonal n ≃ Fin (n + 1) 
goal: ∀ (x : Fin (n + 1)), ↑((Finset.Nat.antidiagonalEquivFin n).symm x) = (↑x, n - ↑x)

full_name: Finset.Nat.antidiagonalEquivFin
code: /-- The set `antidiagonal n` is equivalent to `Fin (n+1)`, via the first projection. --/
@[simps]
def antidiagonalEquivFin (n : ℕ) : antidiagonal n ≃ Fin (n + 1) 
goal: { x // x ∈ Finset.antidiagonal n } ≃ Fin (n + 1)