data.finset.nat_antidiagonal
⟷
Mathlib.Data.Finset.NatAntidiagonal
The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(last sync)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -140,7 +140,7 @@ theorem Finset.filter_fst_eq_antidiagonal (n m : ℕ) :
ext ⟨x, y⟩
simp only [mem_filter, nat.mem_antidiagonal]
split_ifs with h h
- · simp (config := { contextual := true }) [and_comm', eq_tsub_iff_add_eq_of_le h, add_comm]
+ · simp (config := { contextual := true }) [and_comm, eq_tsub_iff_add_eq_of_le h, add_comm]
· rw [not_le] at h
simp only [not_mem_empty, iff_false_iff, not_and]
exact fun hn => ne_of_lt (lt_of_le_of_lt (le_self_add.trans hn.le) h)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -110,7 +110,7 @@ theorem Finset.antidiagonal_congr {n : ℕ} {p q : ℕ × ℕ} (hp : p ∈ antid
(hq : q ∈ antidiagonal n) : p = q ↔ p.fst = q.fst :=
by
refine' ⟨congr_arg Prod.fst, fun h => Prod.ext h ((add_right_inj q.fst).mp _)⟩
- rw [mem_antidiagonal] at hp hq
+ rw [mem_antidiagonal] at hp hq
rw [hq, ← h, hp]
#align finset.nat.antidiagonal_congr Finset.antidiagonal_congr
-/
@@ -120,7 +120,7 @@ theorem Finset.antidiagonal.fst_le {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ ant
by
rw [le_iff_exists_add]
use kl.2
- rwa [mem_antidiagonal, eq_comm] at hlk
+ rwa [mem_antidiagonal, eq_comm] at hlk
#align finset.nat.antidiagonal.fst_le Finset.antidiagonal.fst_le
-/
@@ -129,7 +129,7 @@ theorem Finset.antidiagonal.snd_le {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ ant
by
rw [le_iff_exists_add]
use kl.1
- rwa [mem_antidiagonal, eq_comm, add_comm] at hlk
+ rwa [mem_antidiagonal, eq_comm, add_comm] at hlk
#align finset.nat.antidiagonal.snd_le Finset.antidiagonal.snd_le
-/
@@ -141,7 +141,7 @@ theorem Finset.filter_fst_eq_antidiagonal (n m : ℕ) :
simp only [mem_filter, nat.mem_antidiagonal]
split_ifs with h h
· simp (config := { contextual := true }) [and_comm', eq_tsub_iff_add_eq_of_le h, add_comm]
- · rw [not_le] at h
+ · rw [not_le] at h
simp only [not_mem_empty, iff_false_iff, not_and]
exact fun hn => ne_of_lt (lt_of_le_of_lt (le_self_add.trans hn.le) h)
#align finset.nat.filter_fst_eq_antidiagonal Finset.filter_fst_eq_antidiagonal
@@ -169,7 +169,7 @@ def Finset.sigmaAntidiagonalEquivProd : (Σ n : ℕ, antidiagonal n) ≃ ℕ ×
invFun x := ⟨x.1 + x.2, x, mem_antidiagonal.mpr rfl⟩
left_inv := by
rintro ⟨n, ⟨k, l⟩, h⟩
- rw [mem_antidiagonal] at h
+ rw [mem_antidiagonal] at h
exact Sigma.subtype_ext h rfl
right_inv x := rfl
#align finset.nat.sigma_antidiagonal_equiv_prod Finset.sigmaAntidiagonalEquivProd
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -28,21 +28,17 @@ namespace Finset
namespace Nat
-#print Finset.Nat.antidiagonal /-
/-- The antidiagonal of a natural number `n` is
the finset of pairs `(i, j)` such that `i + j = n`. -/
def antidiagonal (n : ℕ) : Finset (ℕ × ℕ) :=
⟨Multiset.Nat.antidiagonal n, Multiset.Nat.nodup_antidiagonal n⟩
#align finset.nat.antidiagonal Finset.Nat.antidiagonal
--/
-#print Finset.Nat.mem_antidiagonal /-
/-- A pair (i, j) is contained in the antidiagonal of `n` if and only if `i + j = n`. -/
@[simp]
theorem mem_antidiagonal {n : ℕ} {x : ℕ × ℕ} : x ∈ antidiagonal n ↔ x.1 + x.2 = n := by
rw [antidiagonal, mem_def, Multiset.Nat.mem_antidiagonal]
#align finset.nat.mem_antidiagonal Finset.Nat.mem_antidiagonal
--/
#print Finset.Nat.card_antidiagonal /-
/-- The cardinality of the antidiagonal of `n` is `n + 1`. -/
@@ -101,44 +97,44 @@ theorem antidiagonal_succ_succ' {n : ℕ} :
#align finset.nat.antidiagonal_succ_succ' Finset.Nat.antidiagonal_succ_succ'
-/
-#print Finset.Nat.map_swap_antidiagonal /-
-theorem map_swap_antidiagonal {n : ℕ} :
+#print Finset.map_swap_antidiagonal /-
+theorem Finset.map_swap_antidiagonal {n : ℕ} :
(antidiagonal n).map ⟨Prod.swap, Prod.swap_rightInverse.Injective⟩ = antidiagonal n :=
eq_of_veq <| by simp [antidiagonal, Multiset.Nat.map_swap_antidiagonal]
-#align finset.nat.map_swap_antidiagonal Finset.Nat.map_swap_antidiagonal
+#align finset.nat.map_swap_antidiagonal Finset.map_swap_antidiagonal
-/
-#print Finset.Nat.antidiagonal_congr /-
+#print Finset.antidiagonal_congr /-
/-- A point in the antidiagonal is determined by its first co-ordinate. -/
-theorem antidiagonal_congr {n : ℕ} {p q : ℕ × ℕ} (hp : p ∈ antidiagonal n)
+theorem Finset.antidiagonal_congr {n : ℕ} {p q : ℕ × ℕ} (hp : p ∈ antidiagonal n)
(hq : q ∈ antidiagonal n) : p = q ↔ p.fst = q.fst :=
by
refine' ⟨congr_arg Prod.fst, fun h => Prod.ext h ((add_right_inj q.fst).mp _)⟩
rw [mem_antidiagonal] at hp hq
rw [hq, ← h, hp]
-#align finset.nat.antidiagonal_congr Finset.Nat.antidiagonal_congr
+#align finset.nat.antidiagonal_congr Finset.antidiagonal_congr
-/
-#print Finset.Nat.antidiagonal.fst_le /-
-theorem antidiagonal.fst_le {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagonal n) : kl.1 ≤ n :=
+#print Finset.antidiagonal.fst_le /-
+theorem Finset.antidiagonal.fst_le {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagonal n) : kl.1 ≤ n :=
by
rw [le_iff_exists_add]
use kl.2
rwa [mem_antidiagonal, eq_comm] at hlk
-#align finset.nat.antidiagonal.fst_le Finset.Nat.antidiagonal.fst_le
+#align finset.nat.antidiagonal.fst_le Finset.antidiagonal.fst_le
-/
-#print Finset.Nat.antidiagonal.snd_le /-
-theorem antidiagonal.snd_le {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagonal n) : kl.2 ≤ n :=
+#print Finset.antidiagonal.snd_le /-
+theorem Finset.antidiagonal.snd_le {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagonal n) : kl.2 ≤ n :=
by
rw [le_iff_exists_add]
use kl.1
rwa [mem_antidiagonal, eq_comm, add_comm] at hlk
-#align finset.nat.antidiagonal.snd_le Finset.Nat.antidiagonal.snd_le
+#align finset.nat.antidiagonal.snd_le Finset.antidiagonal.snd_le
-/
-#print Finset.Nat.filter_fst_eq_antidiagonal /-
-theorem filter_fst_eq_antidiagonal (n m : ℕ) :
+#print Finset.filter_fst_eq_antidiagonal /-
+theorem Finset.filter_fst_eq_antidiagonal (n m : ℕ) :
filter (fun x : ℕ × ℕ => x.fst = m) (antidiagonal n) = if m ≤ n then {(m, n - m)} else ∅ :=
by
ext ⟨x, y⟩
@@ -148,26 +144,26 @@ theorem filter_fst_eq_antidiagonal (n m : ℕ) :
· rw [not_le] at h
simp only [not_mem_empty, iff_false_iff, not_and]
exact fun hn => ne_of_lt (lt_of_le_of_lt (le_self_add.trans hn.le) h)
-#align finset.nat.filter_fst_eq_antidiagonal Finset.Nat.filter_fst_eq_antidiagonal
+#align finset.nat.filter_fst_eq_antidiagonal Finset.filter_fst_eq_antidiagonal
-/
-#print Finset.Nat.filter_snd_eq_antidiagonal /-
-theorem filter_snd_eq_antidiagonal (n m : ℕ) :
+#print Finset.filter_snd_eq_antidiagonal /-
+theorem Finset.filter_snd_eq_antidiagonal (n m : ℕ) :
filter (fun x : ℕ × ℕ => x.snd = m) (antidiagonal n) = if m ≤ n then {(n - m, m)} else ∅ :=
by
have : (fun x : ℕ × ℕ => x.snd = m) ∘ Prod.swap = fun x : ℕ × ℕ => x.fst = m := by ext; simp
rw [← map_swap_antidiagonal]
simp [filter_map, this, filter_fst_eq_antidiagonal, apply_ite (Finset.map _)]
-#align finset.nat.filter_snd_eq_antidiagonal Finset.Nat.filter_snd_eq_antidiagonal
+#align finset.nat.filter_snd_eq_antidiagonal Finset.filter_snd_eq_antidiagonal
-/
section EquivProd
-#print Finset.Nat.sigmaAntidiagonalEquivProd /-
+#print Finset.sigmaAntidiagonalEquivProd /-
/-- The disjoint union of antidiagonals `Σ (n : ℕ), antidiagonal n` is equivalent to the product
`ℕ × ℕ`. This is such an equivalence, obtained by mapping `(n, (k, l))` to `(k, l)`. -/
@[simps]
-def sigmaAntidiagonalEquivProd : (Σ n : ℕ, antidiagonal n) ≃ ℕ × ℕ
+def Finset.sigmaAntidiagonalEquivProd : (Σ n : ℕ, antidiagonal n) ≃ ℕ × ℕ
where
toFun x := x.2
invFun x := ⟨x.1 + x.2, x, mem_antidiagonal.mpr rfl⟩
@@ -176,7 +172,7 @@ def sigmaAntidiagonalEquivProd : (Σ n : ℕ, antidiagonal n) ≃ ℕ × ℕ
rw [mem_antidiagonal] at h
exact Sigma.subtype_ext h rfl
right_inv x := rfl
-#align finset.nat.sigma_antidiagonal_equiv_prod Finset.Nat.sigmaAntidiagonalEquivProd
+#align finset.nat.sigma_antidiagonal_equiv_prod Finset.sigmaAntidiagonalEquivProd
-/
end EquivProd
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,8 +3,8 @@ Copyright (c) 2019 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
-import Mathbin.Data.Finset.Card
-import Mathbin.Data.Multiset.NatAntidiagonal
+import Data.Finset.Card
+import Data.Multiset.NatAntidiagonal
#align_import data.finset.nat_antidiagonal from "leanprover-community/mathlib"@"cc70d9141824ea8982d1562ce009952f2c3ece30"
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,15 +2,12 @@
Copyright (c) 2019 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-
-! This file was ported from Lean 3 source module data.finset.nat_antidiagonal
-! leanprover-community/mathlib commit cc70d9141824ea8982d1562ce009952f2c3ece30
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Data.Finset.Card
import Mathbin.Data.Multiset.NatAntidiagonal
+#align_import data.finset.nat_antidiagonal from "leanprover-community/mathlib"@"cc70d9141824ea8982d1562ce009952f2c3ece30"
+
/-!
# Antidiagonals in ℕ × ℕ as finsets
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -140,6 +140,7 @@ theorem antidiagonal.snd_le {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagon
#align finset.nat.antidiagonal.snd_le Finset.Nat.antidiagonal.snd_le
-/
+#print Finset.Nat.filter_fst_eq_antidiagonal /-
theorem filter_fst_eq_antidiagonal (n m : ℕ) :
filter (fun x : ℕ × ℕ => x.fst = m) (antidiagonal n) = if m ≤ n then {(m, n - m)} else ∅ :=
by
@@ -151,7 +152,9 @@ theorem filter_fst_eq_antidiagonal (n m : ℕ) :
simp only [not_mem_empty, iff_false_iff, not_and]
exact fun hn => ne_of_lt (lt_of_le_of_lt (le_self_add.trans hn.le) h)
#align finset.nat.filter_fst_eq_antidiagonal Finset.Nat.filter_fst_eq_antidiagonal
+-/
+#print Finset.Nat.filter_snd_eq_antidiagonal /-
theorem filter_snd_eq_antidiagonal (n m : ℕ) :
filter (fun x : ℕ × ℕ => x.snd = m) (antidiagonal n) = if m ≤ n then {(n - m, m)} else ∅ :=
by
@@ -159,6 +162,7 @@ theorem filter_snd_eq_antidiagonal (n m : ℕ) :
rw [← map_swap_antidiagonal]
simp [filter_map, this, filter_fst_eq_antidiagonal, apply_ite (Finset.map _)]
#align finset.nat.filter_snd_eq_antidiagonal Finset.Nat.filter_snd_eq_antidiagonal
+-/
section EquivProd
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -117,7 +117,7 @@ theorem antidiagonal_congr {n : ℕ} {p q : ℕ × ℕ} (hp : p ∈ antidiagonal
(hq : q ∈ antidiagonal n) : p = q ↔ p.fst = q.fst :=
by
refine' ⟨congr_arg Prod.fst, fun h => Prod.ext h ((add_right_inj q.fst).mp _)⟩
- rw [mem_antidiagonal] at hp hq
+ rw [mem_antidiagonal] at hp hq
rw [hq, ← h, hp]
#align finset.nat.antidiagonal_congr Finset.Nat.antidiagonal_congr
-/
@@ -127,7 +127,7 @@ theorem antidiagonal.fst_le {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagon
by
rw [le_iff_exists_add]
use kl.2
- rwa [mem_antidiagonal, eq_comm] at hlk
+ rwa [mem_antidiagonal, eq_comm] at hlk
#align finset.nat.antidiagonal.fst_le Finset.Nat.antidiagonal.fst_le
-/
@@ -136,7 +136,7 @@ theorem antidiagonal.snd_le {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagon
by
rw [le_iff_exists_add]
use kl.1
- rwa [mem_antidiagonal, eq_comm, add_comm] at hlk
+ rwa [mem_antidiagonal, eq_comm, add_comm] at hlk
#align finset.nat.antidiagonal.snd_le Finset.Nat.antidiagonal.snd_le
-/
@@ -147,7 +147,7 @@ theorem filter_fst_eq_antidiagonal (n m : ℕ) :
simp only [mem_filter, nat.mem_antidiagonal]
split_ifs with h h
· simp (config := { contextual := true }) [and_comm', eq_tsub_iff_add_eq_of_le h, add_comm]
- · rw [not_le] at h
+ · rw [not_le] at h
simp only [not_mem_empty, iff_false_iff, not_and]
exact fun hn => ne_of_lt (lt_of_le_of_lt (le_self_add.trans hn.le) h)
#align finset.nat.filter_fst_eq_antidiagonal Finset.Nat.filter_fst_eq_antidiagonal
@@ -166,13 +166,13 @@ section EquivProd
/-- The disjoint union of antidiagonals `Σ (n : ℕ), antidiagonal n` is equivalent to the product
`ℕ × ℕ`. This is such an equivalence, obtained by mapping `(n, (k, l))` to `(k, l)`. -/
@[simps]
-def sigmaAntidiagonalEquivProd : (Σn : ℕ, antidiagonal n) ≃ ℕ × ℕ
+def sigmaAntidiagonalEquivProd : (Σ n : ℕ, antidiagonal n) ≃ ℕ × ℕ
where
toFun x := x.2
invFun x := ⟨x.1 + x.2, x, mem_antidiagonal.mpr rfl⟩
left_inv := by
rintro ⟨n, ⟨k, l⟩, h⟩
- rw [mem_antidiagonal] at h
+ rw [mem_antidiagonal] at h
exact Sigma.subtype_ext h rfl
right_inv x := rfl
#align finset.nat.sigma_antidiagonal_equiv_prod Finset.Nat.sigmaAntidiagonalEquivProd
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -140,12 +140,6 @@ theorem antidiagonal.snd_le {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagon
#align finset.nat.antidiagonal.snd_le Finset.Nat.antidiagonal.snd_le
-/
-/- warning: finset.nat.filter_fst_eq_antidiagonal -> Finset.Nat.filter_fst_eq_antidiagonal is a dubious translation:
-lean 3 declaration is
- forall (n : Nat) (m : Nat), Eq.{1} (Finset.{0} (Prod.{0, 0} Nat Nat)) (Finset.filter.{0} (Prod.{0, 0} Nat Nat) (fun (x : Prod.{0, 0} Nat Nat) => Eq.{1} Nat (Prod.fst.{0, 0} Nat Nat x) m) (fun (a : Prod.{0, 0} Nat Nat) => Nat.decidableEq (Prod.fst.{0, 0} Nat Nat a) m) (Finset.Nat.antidiagonal n)) (ite.{1} (Finset.{0} (Prod.{0, 0} Nat Nat)) (LE.le.{0} Nat Nat.hasLe m n) (Nat.decidableLe m n) (Singleton.singleton.{0, 0} (Prod.{0, 0} Nat Nat) (Finset.{0} (Prod.{0, 0} Nat Nat)) (Finset.hasSingleton.{0} (Prod.{0, 0} Nat Nat)) (Prod.mk.{0, 0} Nat Nat m (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) n m))) (EmptyCollection.emptyCollection.{0} (Finset.{0} (Prod.{0, 0} Nat Nat)) (Finset.hasEmptyc.{0} (Prod.{0, 0} Nat Nat))))
-but is expected to have type
- forall (n : Nat) (m : Nat), Eq.{1} (Finset.{0} (Prod.{0, 0} Nat Nat)) (Finset.filter.{0} (Prod.{0, 0} Nat Nat) (fun (x : Prod.{0, 0} Nat Nat) => Eq.{1} Nat (Prod.fst.{0, 0} Nat Nat x) m) (fun (a : Prod.{0, 0} Nat Nat) => instDecidableEqNat (Prod.fst.{0, 0} Nat Nat a) m) (Finset.Nat.antidiagonal n)) (ite.{1} (Finset.{0} (Prod.{0, 0} Nat Nat)) (LE.le.{0} Nat instLENat m n) (Nat.decLe m n) (Singleton.singleton.{0, 0} (Prod.{0, 0} Nat Nat) (Finset.{0} (Prod.{0, 0} Nat Nat)) (Finset.instSingletonFinset.{0} (Prod.{0, 0} Nat Nat)) (Prod.mk.{0, 0} Nat Nat m (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) n m))) (EmptyCollection.emptyCollection.{0} (Finset.{0} (Prod.{0, 0} Nat Nat)) (Finset.instEmptyCollectionFinset.{0} (Prod.{0, 0} Nat Nat))))
-Case conversion may be inaccurate. Consider using '#align finset.nat.filter_fst_eq_antidiagonal Finset.Nat.filter_fst_eq_antidiagonalₓ'. -/
theorem filter_fst_eq_antidiagonal (n m : ℕ) :
filter (fun x : ℕ × ℕ => x.fst = m) (antidiagonal n) = if m ≤ n then {(m, n - m)} else ∅ :=
by
@@ -158,12 +152,6 @@ theorem filter_fst_eq_antidiagonal (n m : ℕ) :
exact fun hn => ne_of_lt (lt_of_le_of_lt (le_self_add.trans hn.le) h)
#align finset.nat.filter_fst_eq_antidiagonal Finset.Nat.filter_fst_eq_antidiagonal
-/- warning: finset.nat.filter_snd_eq_antidiagonal -> Finset.Nat.filter_snd_eq_antidiagonal is a dubious translation:
-lean 3 declaration is
- forall (n : Nat) (m : Nat), Eq.{1} (Finset.{0} (Prod.{0, 0} Nat Nat)) (Finset.filter.{0} (Prod.{0, 0} Nat Nat) (fun (x : Prod.{0, 0} Nat Nat) => Eq.{1} Nat (Prod.snd.{0, 0} Nat Nat x) m) (fun (a : Prod.{0, 0} Nat Nat) => Nat.decidableEq (Prod.snd.{0, 0} Nat Nat a) m) (Finset.Nat.antidiagonal n)) (ite.{1} (Finset.{0} (Prod.{0, 0} Nat Nat)) (LE.le.{0} Nat Nat.hasLe m n) (Nat.decidableLe m n) (Singleton.singleton.{0, 0} (Prod.{0, 0} Nat Nat) (Finset.{0} (Prod.{0, 0} Nat Nat)) (Finset.hasSingleton.{0} (Prod.{0, 0} Nat Nat)) (Prod.mk.{0, 0} Nat Nat (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) n m) m)) (EmptyCollection.emptyCollection.{0} (Finset.{0} (Prod.{0, 0} Nat Nat)) (Finset.hasEmptyc.{0} (Prod.{0, 0} Nat Nat))))
-but is expected to have type
- forall (n : Nat) (m : Nat), Eq.{1} (Finset.{0} (Prod.{0, 0} Nat Nat)) (Finset.filter.{0} (Prod.{0, 0} Nat Nat) (fun (x : Prod.{0, 0} Nat Nat) => Eq.{1} Nat (Prod.snd.{0, 0} Nat Nat x) m) (fun (a : Prod.{0, 0} Nat Nat) => instDecidableEqNat (Prod.snd.{0, 0} Nat Nat a) m) (Finset.Nat.antidiagonal n)) (ite.{1} (Finset.{0} (Prod.{0, 0} Nat Nat)) (LE.le.{0} Nat instLENat m n) (Nat.decLe m n) (Singleton.singleton.{0, 0} (Prod.{0, 0} Nat Nat) (Finset.{0} (Prod.{0, 0} Nat Nat)) (Finset.instSingletonFinset.{0} (Prod.{0, 0} Nat Nat)) (Prod.mk.{0, 0} Nat Nat (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) n m) m)) (EmptyCollection.emptyCollection.{0} (Finset.{0} (Prod.{0, 0} Nat Nat)) (Finset.instEmptyCollectionFinset.{0} (Prod.{0, 0} Nat Nat))))
-Case conversion may be inaccurate. Consider using '#align finset.nat.filter_snd_eq_antidiagonal Finset.Nat.filter_snd_eq_antidiagonalₓ'. -/
theorem filter_snd_eq_antidiagonal (n m : ℕ) :
filter (fun x : ℕ × ℕ => x.snd = m) (antidiagonal n) = if m ≤ n then {(n - m, m)} else ∅ :=
by
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -100,9 +100,7 @@ theorem antidiagonal_succ_succ' {n : ℕ} :
⟨Nat.succ, Nat.succ_injective⟩)) <|
by simp)
(by simp) :=
- by
- simp_rw [antidiagonal_succ (n + 1), antidiagonal_succ', Finset.map_cons, map_map]
- rfl
+ by simp_rw [antidiagonal_succ (n + 1), antidiagonal_succ', Finset.map_cons, map_map]; rfl
#align finset.nat.antidiagonal_succ_succ' Finset.Nat.antidiagonal_succ_succ'
-/
@@ -169,10 +167,7 @@ Case conversion may be inaccurate. Consider using '#align finset.nat.filter_snd_
theorem filter_snd_eq_antidiagonal (n m : ℕ) :
filter (fun x : ℕ × ℕ => x.snd = m) (antidiagonal n) = if m ≤ n then {(n - m, m)} else ∅ :=
by
- have : (fun x : ℕ × ℕ => x.snd = m) ∘ Prod.swap = fun x : ℕ × ℕ => x.fst = m :=
- by
- ext
- simp
+ have : (fun x : ℕ × ℕ => x.snd = m) ∘ Prod.swap = fun x : ℕ × ℕ => x.fst = m := by ext; simp
rw [← map_swap_antidiagonal]
simp [filter_map, this, filter_fst_eq_antidiagonal, apply_ite (Finset.map _)]
#align finset.nat.filter_snd_eq_antidiagonal Finset.Nat.filter_snd_eq_antidiagonal
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
@@ -72,7 +72,7 @@ theorem antidiagonal_succ (n : ℕ) :
(by simp) := by
apply eq_of_veq
rw [cons_val, map_val]
- · apply Multiset.Nat.antidiagonal_succ
+ apply Multiset.Nat.antidiagonal_succ
#align finset.nat.antidiagonal_succ Finset.Nat.antidiagonal_succ
theorem antidiagonal_succ' (n : ℕ) :
Data.{Nat,Int}{.Order}.Basic
in group vs ring instances (#11924)
Scatter the content of Data.Nat.Basic
across:
Data.Nat.Defs
for the lemmas having no dependenciesAlgebra.Group.Nat
for the monoid instances and the few miscellaneous lemmas needing them.Algebra.Ring.Nat
for the semiring instance and the few miscellaneous lemmas following it.Similarly, scatter
Data.Int.Basic
across Data.Int.Defs
, Algebra.Group.Int
, Algebra.Ring.Int
Data.Nat.Order.Basic
across Data.Nat.Defs
, Algebra.Order.Group.Nat
, Algebra.Order.Ring.Nat
Data.Int.Order.Basic
across Data.Int.Defs
, Algebra.Order.Group.Int
, Algebra.Order.Ring.Int
Also move a few lemmas from Data.Nat.Order.Lemmas
to Data.Nat.Defs
.
Before
After
@@ -3,9 +3,10 @@ Copyright (c) 2019 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
+import Mathlib.Algebra.Order.Ring.CharZero
+import Mathlib.Data.Finset.Antidiagonal
import Mathlib.Data.Finset.Card
import Mathlib.Data.Multiset.NatAntidiagonal
-import Mathlib.Data.Finset.Antidiagonal
#align_import data.finset.nat_antidiagonal from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
$
with <|
(#9319)
See Zulip thread for the discussion.
@@ -99,10 +99,10 @@ theorem antidiagonal_succ_succ' {n : ℕ} :
#align finset.nat.antidiagonal_succ_succ' Finset.Nat.antidiagonal_succ_succ'
theorem antidiagonal.fst_lt {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagonal n) : kl.1 < n + 1 :=
- Nat.lt_succ_of_le $ antidiagonal.fst_le hlk
+ Nat.lt_succ_of_le <| antidiagonal.fst_le hlk
theorem antidiagonal.snd_lt {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagonal n) : kl.2 < n + 1 :=
- Nat.lt_succ_of_le $ antidiagonal.snd_le hlk
+ Nat.lt_succ_of_le <| antidiagonal.snd_le hlk
@[simp] lemma antidiagonal_filter_snd_le_of_le {n k : ℕ} (h : k ≤ n) :
(antidiagonal n).filter (fun a ↦ a.snd ≤ k) = (antidiagonal k).map
@@ -35,6 +35,23 @@ instance instHasAntidiagonal : HasAntidiagonal ℕ where
mem_antidiagonal {n} {xy} := by
rw [mem_def, Multiset.Nat.mem_antidiagonal]
+lemma antidiagonal_eq_map (n : ℕ) :
+ antidiagonal n = (range (n + 1)).map ⟨fun i ↦ (i, n - i), fun _ _ h ↦ (Prod.ext_iff.1 h).1⟩ :=
+ rfl
+
+lemma antidiagonal_eq_map' (n : ℕ) :
+ antidiagonal n =
+ (range (n + 1)).map ⟨fun i ↦ (n - i, i), fun _ _ h ↦ (Prod.ext_iff.1 h).2⟩ := by
+ rw [← map_swap_antidiagonal, antidiagonal_eq_map, map_map]; rfl
+
+lemma antidiagonal_eq_image (n : ℕ) :
+ antidiagonal n = (range (n + 1)).image fun i ↦ (i, n - i) := by
+ simp only [antidiagonal_eq_map, map_eq_image, Function.Embedding.coeFn_mk]
+
+lemma antidiagonal_eq_image' (n : ℕ) :
+ antidiagonal n = (range (n + 1)).image fun i ↦ (n - i, i) := by
+ simp only [antidiagonal_eq_map', map_eq_image, Function.Embedding.coeFn_mk]
+
/-- The cardinality of the antidiagonal of `n` is `n + 1`. -/
@[simp]
theorem card_antidiagonal (n : ℕ) : (antidiagonal n).card = n + 1 := by simp [antidiagonal]
Finset.Nat.antidiagonal
(#7486)
We define a type class Finset.HasAntidiagonal A
which contains a function
antidiagonal : A → Finset (A × A)
such that antidiagonal n
is the Finset of all pairs adding to n
, as witnessed by mem_antidiagonal
.
When A
is a canonically ordered add monoid with locally finite order
this typeclass can be instantiated with Finset.antidiagonalOfLocallyFinite
.
This applies in particular when A
is ℕ
, more generally or σ →₀ ℕ
,
or even ι →₀ A
under the additional assumption OrderedSub A
that make it a canonically ordered add monoid.
(In fact, we would just need an AddMonoid
with a compatible order,
finite Iic
, such that if a + b = n
, then a, b ≤ n
,
and any finiteness condition would be OK.)
For computational reasons it is better to manually provide instances for ℕ
and σ →₀ ℕ
, to avoid quadratic runtime performance.
These instances are provided as Finset.Nat.instHasAntidiagonal
and Finsupp.instHasAntidiagonal
.
This is why Finset.antidiagonalOfLocallyFinite
is an abbrev
and not an instance
.
This definition does not exactly match with that of Multiset.antidiagonal
defined in Mathlib.Data.Multiset.Antidiagonal
, because of the multiplicities.
Indeed, by counting multiplicities, Multiset α
is equivalent to α →₀ ℕ
,
but Finset.antidiagonal
and Multiset.antidiagonal
will return different objects.
For example, for s : Multiset ℕ := {0,0,0}
, Multiset.antidiagonal s
has 8 elements
but Finset.antidiagonal s
has only 4.
def s : Multiset ℕ := {0, 0, 0}
#eval (Finset.antidiagonal s).card -- 4
#eval Multiset.card (Multiset.antidiagonal s) -- 8
HasMulAntidiagonal
(for monoids).
For PNat
, we will recover the set of divisors of a strictly positive integer.This closes #7917
Co-authored by: María Inés de Frutos-Fernández <mariaines.dff@gmail.com> and Eric Wieser <efw27@cam.ac.uk>
Co-authored-by: Antoine Chambert-Loir <antoine.chambert-loir@math.univ-paris-diderot.fr> Co-authored-by: Mario Carneiro <di.gama@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@@ -5,6 +5,7 @@ Authors: Johan Commelin
-/
import Mathlib.Data.Finset.Card
import Mathlib.Data.Multiset.NatAntidiagonal
+import Mathlib.Data.Finset.Antidiagonal
#align_import data.finset.nat_antidiagonal from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
@@ -17,7 +18,8 @@ generally for sums going from `0` to `n`.
## Notes
-This refines files `Data.List.NatAntidiagonal` and `Data.Multiset.NatAntidiagonal`.
+This refines files `Data.List.NatAntidiagonal` and `Data.Multiset.NatAntidiagonal`, providing an
+instance enabling `Finset.antidiagonal` on `Nat`.
-/
open Function
@@ -28,15 +30,10 @@ namespace Nat
/-- The antidiagonal of a natural number `n` is
the finset of pairs `(i, j)` such that `i + j = n`. -/
-def antidiagonal (n : ℕ) : Finset (ℕ × ℕ) :=
- ⟨Multiset.Nat.antidiagonal n, Multiset.Nat.nodup_antidiagonal n⟩
-#align finset.nat.antidiagonal Finset.Nat.antidiagonal
-
-/-- A pair (i, j) is contained in the antidiagonal of `n` if and only if `i + j = n`. -/
-@[simp]
-theorem mem_antidiagonal {n : ℕ} {x : ℕ × ℕ} : x ∈ antidiagonal n ↔ x.1 + x.2 = n := by
- rw [antidiagonal, mem_def, Multiset.Nat.mem_antidiagonal]
-#align finset.nat.mem_antidiagonal Finset.Nat.mem_antidiagonal
+instance instHasAntidiagonal : HasAntidiagonal ℕ where
+ antidiagonal n := ⟨Multiset.Nat.antidiagonal n, Multiset.Nat.nodup_antidiagonal n⟩
+ mem_antidiagonal {n} {xy} := by
+ rw [mem_def, Multiset.Nat.mem_antidiagonal]
/-- The cardinality of the antidiagonal of `n` is `n + 1`. -/
@[simp]
@@ -44,7 +41,8 @@ theorem card_antidiagonal (n : ℕ) : (antidiagonal n).card = n + 1 := by simp [
#align finset.nat.card_antidiagonal Finset.Nat.card_antidiagonal
/-- The antidiagonal of `0` is the list `[(0, 0)]` -/
-@[simp]
+-- nolint as this is for dsimp
+@[simp, nolint simpNF]
theorem antidiagonal_zero : antidiagonal 0 = {(0, 0)} := rfl
#align finset.nat.antidiagonal_zero Finset.Nat.antidiagonal_zero
@@ -83,66 +81,12 @@ theorem antidiagonal_succ_succ' {n : ℕ} :
rfl
#align finset.nat.antidiagonal_succ_succ' Finset.Nat.antidiagonal_succ_succ'
-/-- See also `Finset.map.map_prodComm_antidiagonal`. -/
-@[simp] theorem map_swap_antidiagonal {n : ℕ} :
- (antidiagonal n).map ⟨Prod.swap, Prod.swap_injective⟩ = antidiagonal n :=
- eq_of_veq <| by simp [antidiagonal, Multiset.Nat.map_swap_antidiagonal]
-#align finset.nat.map_swap_antidiagonal Finset.Nat.map_swap_antidiagonal
-
-@[simp] theorem map_prodComm_antidiagonal {n : ℕ} :
- (antidiagonal n).map (Equiv.prodComm ℕ ℕ) = antidiagonal n :=
- map_swap_antidiagonal
-
-/-- A point in the antidiagonal is determined by its first co-ordinate. -/
-theorem antidiagonal_congr {n : ℕ} {p q : ℕ × ℕ} (hp : p ∈ antidiagonal n)
- (hq : q ∈ antidiagonal n) : p = q ↔ p.fst = q.fst := by
- refine' ⟨congr_arg Prod.fst, fun h ↦ Prod.ext h ((add_right_inj q.fst).mp _)⟩
- rw [mem_antidiagonal] at hp hq
- rw [hq, ← h, hp]
-#align finset.nat.antidiagonal_congr Finset.Nat.antidiagonal_congr
-
-/-- A point in the antidiagonal is determined by its first co-ordinate (subtype version of
-`antidiagonal_congr`). This lemma is used by the `ext` tactic. -/
-@[ext] theorem antidiagonal_subtype_ext {n : ℕ} {p q : antidiagonal n} (h : p.val.1 = q.val.1) :
- p = q := Subtype.ext ((antidiagonal_congr p.prop q.prop).mpr h)
-
-theorem antidiagonal.fst_le {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagonal n) : kl.1 ≤ n := by
- rw [le_iff_exists_add]
- use kl.2
- rwa [mem_antidiagonal, eq_comm] at hlk
-#align finset.nat.antidiagonal.fst_le Finset.Nat.antidiagonal.fst_le
-
theorem antidiagonal.fst_lt {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagonal n) : kl.1 < n + 1 :=
Nat.lt_succ_of_le $ antidiagonal.fst_le hlk
-theorem antidiagonal.snd_le {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagonal n) : kl.2 ≤ n := by
- rw [le_iff_exists_add]
- use kl.1
- rwa [mem_antidiagonal, eq_comm, add_comm] at hlk
-#align finset.nat.antidiagonal.snd_le Finset.Nat.antidiagonal.snd_le
-
theorem antidiagonal.snd_lt {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagonal n) : kl.2 < n + 1 :=
Nat.lt_succ_of_le $ antidiagonal.snd_le hlk
-theorem filter_fst_eq_antidiagonal (n m : ℕ) :
- filter (fun x : ℕ × ℕ ↦ x.fst = m) (antidiagonal n) = if m ≤ n then {(m, n - m)} else ∅ := by
- ext ⟨x, y⟩
- simp only [mem_filter, Nat.mem_antidiagonal]
- split_ifs with h
- · simp (config := { contextual := true }) [and_comm, eq_tsub_iff_add_eq_of_le h, add_comm]
- · rw [not_le] at h
- simp only [not_mem_empty, iff_false_iff, not_and, decide_eq_true_eq]
- exact fun hn => ne_of_lt (lt_of_le_of_lt (le_self_add.trans hn.le) h)
-#align finset.nat.filter_fst_eq_antidiagonal Finset.Nat.filter_fst_eq_antidiagonal
-
-theorem filter_snd_eq_antidiagonal (n m : ℕ) :
- filter (fun x : ℕ × ℕ ↦ x.snd = m) (antidiagonal n) = if m ≤ n then {(n - m, m)} else ∅ := by
- have : (fun x : ℕ × ℕ ↦ (x.snd = m)) ∘ Prod.swap = fun x : ℕ × ℕ ↦ x.fst = m := by
- ext; simp
- rw [← map_swap_antidiagonal, filter_map]
- simp [this, filter_fst_eq_antidiagonal, apply_ite (Finset.map _)]
-#align finset.nat.filter_snd_eq_antidiagonal Finset.Nat.filter_snd_eq_antidiagonal
-
@[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 ℕ)) := by
@@ -192,26 +136,6 @@ theorem filter_snd_eq_antidiagonal (n m : ℕ) :
ext ⟨i, j⟩
simpa using aux₂ i j
-section EquivProd
-
-/-- The disjoint union of antidiagonals `Σ (n : ℕ), antidiagonal n` is equivalent to the product
- `ℕ × ℕ`. This is such an equivalence, obtained by mapping `(n, (k, l))` to `(k, l)`. -/
-@[simps]
-def sigmaAntidiagonalEquivProd : (Σn : ℕ, antidiagonal n) ≃ ℕ × ℕ where
- toFun x := x.2
- invFun x := ⟨x.1 + x.2, x, mem_antidiagonal.mpr rfl⟩
- left_inv := by
- rintro ⟨n, ⟨k, l⟩, h⟩
- rw [mem_antidiagonal] at h
- exact Sigma.subtype_ext h rfl
- right_inv x := rfl
-#align finset.nat.sigma_antidiagonal_equiv_prod Finset.Nat.sigmaAntidiagonalEquivProd
-#align finset.nat.sigma_antidiagonal_equiv_prod_symm_apply_fst Finset.Nat.sigmaAntidiagonalEquivProd_symm_apply_fst
-#align finset.nat.sigma_antidiagonal_equiv_prod_symm_apply_snd_coe Finset.Nat.sigmaAntidiagonalEquivProd_symm_apply_snd_coe
-#align finset.nat.sigma_antidiagonal_equiv_prod_apply Finset.Nat.sigmaAntidiagonalEquivProd_apply
-
-end EquivProd
-
/-- The set `antidiagonal n` is equivalent to `Fin (n+1)`, via the first projection. --/
@[simps]
def antidiagonalEquivFin (n : ℕ) : antidiagonal n ≃ Fin (n + 1) where
Many proofs use the "stream of consciousness" style from Lean 3, rather than have ... :=
or suffices ... from/by
.
This PR updates a fraction of these to the preferred Lean 4 style.
I think a good goal would be to delete the "deferred" versions of have
, suffices
, and let
at the bottom of Mathlib.Tactic.Have
(Anyone who would like to contribute more cleanup is welcome to push directly to this branch.)
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@@ -147,8 +147,7 @@ theorem filter_snd_eq_antidiagonal (n m : ℕ) :
(antidiagonal n).filter (fun a ↦ a.snd ≤ k) = (antidiagonal k).map
(Embedding.prodMap ⟨_, add_left_injective (n - k)⟩ (Embedding.refl ℕ)) := by
ext ⟨i, j⟩
- suffices : i + j = n ∧ j ≤ k ↔ ∃ a, a + j = k ∧ a + (n - k) = i
- · simpa
+ suffices i + j = n ∧ j ≤ k ↔ ∃ a, a + j = k ∧ a + (n - k) = i by simpa
refine' ⟨fun hi ↦ ⟨k - j, tsub_add_cancel_of_le hi.2, _⟩, _⟩
· rw [add_comm, tsub_add_eq_add_tsub h, ← hi.1, add_assoc, Nat.add_sub_of_le hi.2,
add_tsub_cancel_right]
@@ -173,8 +172,7 @@ theorem filter_snd_eq_antidiagonal (n m : ℕ) :
(antidiagonal n).filter (fun a ↦ k ≤ a.fst) = (antidiagonal (n - k)).map
(Embedding.prodMap ⟨_, add_left_injective k⟩ (Embedding.refl ℕ)) := by
ext ⟨i, j⟩
- suffices : i + j = n ∧ k ≤ i ↔ ∃ a, a + j = n - k ∧ a + k = i
- · simpa
+ suffices i + j = n ∧ k ≤ i ↔ ∃ a, a + j = n - k ∧ a + k = i by simpa
refine' ⟨fun hi ↦ ⟨i - k, _, tsub_add_cancel_of_le hi.2⟩, _⟩
· rw [← Nat.sub_add_comm hi.2, hi.1]
· rintro ⟨l, hl, rfl⟩
and add simps
, as pointed out by @eric-wieser in
https://github.com/leanprover-community/mathlib4/pull/6766#pullrequestreview-1595354618
@@ -215,7 +215,8 @@ def sigmaAntidiagonalEquivProd : (Σn : ℕ, antidiagonal n) ≃ ℕ × ℕ wher
end EquivProd
/-- The set `antidiagonal n` is equivalent to `Fin (n+1)`, via the first projection. --/
-def antidiagonal_equiv_fin (n : ℕ) : antidiagonal n ≃ Fin (n + 1) where
+@[simps]
+def antidiagonalEquivFin (n : ℕ) : antidiagonal n ≃ Fin (n + 1) where
toFun := fun ⟨⟨i, j⟩, h⟩ ↦ ⟨i, antidiagonal.fst_lt h⟩
invFun := fun ⟨i, h⟩ ↦ ⟨⟨i, n - i⟩, by
rw [mem_antidiagonal, add_comm, tsub_add_cancel_iff_le]
as suggested by @ocfnash in https://github.com/leanprover-community/mathlib4/pull/6425#discussion_r1304089614
@@ -101,18 +101,29 @@ theorem antidiagonal_congr {n : ℕ} {p q : ℕ × ℕ} (hp : p ∈ antidiagonal
rw [hq, ← h, hp]
#align finset.nat.antidiagonal_congr Finset.Nat.antidiagonal_congr
+/-- A point in the antidiagonal is determined by its first co-ordinate (subtype version of
+`antidiagonal_congr`). This lemma is used by the `ext` tactic. -/
+@[ext] theorem antidiagonal_subtype_ext {n : ℕ} {p q : antidiagonal n} (h : p.val.1 = q.val.1) :
+ p = q := Subtype.ext ((antidiagonal_congr p.prop q.prop).mpr h)
+
theorem antidiagonal.fst_le {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagonal n) : kl.1 ≤ n := by
rw [le_iff_exists_add]
use kl.2
rwa [mem_antidiagonal, eq_comm] at hlk
#align finset.nat.antidiagonal.fst_le Finset.Nat.antidiagonal.fst_le
+theorem antidiagonal.fst_lt {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagonal n) : kl.1 < n + 1 :=
+ Nat.lt_succ_of_le $ antidiagonal.fst_le hlk
+
theorem antidiagonal.snd_le {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagonal n) : kl.2 ≤ n := by
rw [le_iff_exists_add]
use kl.1
rwa [mem_antidiagonal, eq_comm, add_comm] at hlk
#align finset.nat.antidiagonal.snd_le Finset.Nat.antidiagonal.snd_le
+theorem antidiagonal.snd_lt {n : ℕ} {kl : ℕ × ℕ} (hlk : kl ∈ antidiagonal n) : kl.2 < n + 1 :=
+ Nat.lt_succ_of_le $ antidiagonal.snd_le hlk
+
theorem filter_fst_eq_antidiagonal (n m : ℕ) :
filter (fun x : ℕ × ℕ ↦ x.fst = m) (antidiagonal n) = if m ≤ n then {(m, n - m)} else ∅ := by
ext ⟨x, y⟩
@@ -203,6 +214,15 @@ def sigmaAntidiagonalEquivProd : (Σn : ℕ, antidiagonal n) ≃ ℕ × ℕ wher
end EquivProd
+/-- The set `antidiagonal n` is equivalent to `Fin (n+1)`, via the first projection. --/
+def antidiagonal_equiv_fin (n : ℕ) : antidiagonal n ≃ Fin (n + 1) where
+ toFun := fun ⟨⟨i, j⟩, h⟩ ↦ ⟨i, antidiagonal.fst_lt h⟩
+ invFun := fun ⟨i, h⟩ ↦ ⟨⟨i, n - i⟩, by
+ rw [mem_antidiagonal, add_comm, tsub_add_cancel_iff_le]
+ exact Nat.le_of_lt_succ h⟩
+ left_inv := by rintro ⟨⟨i, j⟩, h⟩; ext; rfl
+ right_inv x := rfl
+
end Nat
end Finset
@@ -20,6 +20,7 @@ generally for sums going from `0` to `n`.
This refines files `Data.List.NatAntidiagonal` and `Data.Multiset.NatAntidiagonal`.
-/
+open Function
namespace Finset
@@ -51,7 +52,7 @@ theorem antidiagonal_succ (n : ℕ) :
antidiagonal (n + 1) =
cons (0, n + 1)
((antidiagonal n).map
- (Function.Embedding.prodMap ⟨Nat.succ, Nat.succ_injective⟩ (Function.Embedding.refl _)))
+ (Embedding.prodMap ⟨Nat.succ, Nat.succ_injective⟩ (Embedding.refl _)))
(by simp) := by
apply eq_of_veq
rw [cons_val, map_val]
@@ -62,7 +63,7 @@ theorem antidiagonal_succ' (n : ℕ) :
antidiagonal (n + 1) =
cons (n + 1, 0)
((antidiagonal n).map
- (Function.Embedding.prodMap (Function.Embedding.refl _) ⟨Nat.succ, Nat.succ_injective⟩))
+ (Embedding.prodMap (Embedding.refl _) ⟨Nat.succ, Nat.succ_injective⟩))
(by simp) := by
apply eq_of_veq
rw [cons_val, map_val]
@@ -74,7 +75,7 @@ theorem antidiagonal_succ_succ' {n : ℕ} :
cons (0, n + 2)
(cons (n + 2, 0)
((antidiagonal n).map
- (Function.Embedding.prodMap ⟨Nat.succ, Nat.succ_injective⟩
+ (Embedding.prodMap ⟨Nat.succ, Nat.succ_injective⟩
⟨Nat.succ, Nat.succ_injective⟩)) <|
by simp)
(by simp) := by
@@ -82,11 +83,16 @@ theorem antidiagonal_succ_succ' {n : ℕ} :
rfl
#align finset.nat.antidiagonal_succ_succ' Finset.Nat.antidiagonal_succ_succ'
-theorem map_swap_antidiagonal {n : ℕ} :
+/-- See also `Finset.map.map_prodComm_antidiagonal`. -/
+@[simp] theorem map_swap_antidiagonal {n : ℕ} :
(antidiagonal n).map ⟨Prod.swap, Prod.swap_injective⟩ = antidiagonal n :=
eq_of_veq <| by simp [antidiagonal, Multiset.Nat.map_swap_antidiagonal]
#align finset.nat.map_swap_antidiagonal Finset.Nat.map_swap_antidiagonal
+@[simp] theorem map_prodComm_antidiagonal {n : ℕ} :
+ (antidiagonal n).map (Equiv.prodComm ℕ ℕ) = antidiagonal n :=
+ map_swap_antidiagonal
+
/-- A point in the antidiagonal is determined by its first co-ordinate. -/
theorem antidiagonal_congr {n : ℕ} {p q : ℕ × ℕ} (hp : p ∈ antidiagonal n)
(hq : q ∈ antidiagonal n) : p = q ↔ p.fst = q.fst := by
@@ -122,10 +128,61 @@ theorem filter_snd_eq_antidiagonal (n m : ℕ) :
filter (fun x : ℕ × ℕ ↦ x.snd = m) (antidiagonal n) = if m ≤ n then {(n - m, m)} else ∅ := by
have : (fun x : ℕ × ℕ ↦ (x.snd = m)) ∘ Prod.swap = fun x : ℕ × ℕ ↦ x.fst = m := by
ext; simp
- rw [← map_swap_antidiagonal]
- simp [filter_map, this, filter_fst_eq_antidiagonal, apply_ite (Finset.map _)]
+ rw [← map_swap_antidiagonal, filter_map]
+ simp [this, filter_fst_eq_antidiagonal, apply_ite (Finset.map _)]
#align finset.nat.filter_snd_eq_antidiagonal Finset.Nat.filter_snd_eq_antidiagonal
+@[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 ℕ)) := by
+ ext ⟨i, j⟩
+ suffices : i + j = n ∧ j ≤ k ↔ ∃ a, a + j = k ∧ a + (n - k) = i
+ · simpa
+ refine' ⟨fun hi ↦ ⟨k - j, tsub_add_cancel_of_le hi.2, _⟩, _⟩
+ · rw [add_comm, tsub_add_eq_add_tsub h, ← hi.1, add_assoc, Nat.add_sub_of_le hi.2,
+ add_tsub_cancel_right]
+ · rintro ⟨l, hl, rfl⟩
+ refine' ⟨_, hl ▸ Nat.le_add_left j l⟩
+ rw [add_assoc, add_comm, add_assoc, add_comm j l, hl]
+ exact Nat.sub_add_cancel h
+
+@[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)⟩) := by
+ have aux₁ : fun a ↦ a.fst ≤ k = (fun a ↦ a.snd ≤ k) ∘ (Equiv.prodComm ℕ ℕ).symm := rfl
+ have aux₂ : ∀ i j, (∃ a b, a + b = k ∧ b = i ∧ a + (n - k) = j) ↔
+ ∃ a b, a + b = k ∧ a = i ∧ b + (n - k) = j :=
+ fun i j ↦ by rw [exists_comm]; exact exists₂_congr (fun a b ↦ by rw [add_comm])
+ rw [← map_prodComm_antidiagonal]
+ simp_rw [aux₁, ← map_filter, antidiagonal_filter_snd_le_of_le h, map_map]
+ ext ⟨i, j⟩
+ simpa using aux₂ i j
+
+@[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 ℕ)) := by
+ ext ⟨i, j⟩
+ suffices : i + j = n ∧ k ≤ i ↔ ∃ a, a + j = n - k ∧ a + k = i
+ · simpa
+ refine' ⟨fun hi ↦ ⟨i - k, _, tsub_add_cancel_of_le hi.2⟩, _⟩
+ · rw [← Nat.sub_add_comm hi.2, hi.1]
+ · rintro ⟨l, hl, rfl⟩
+ refine' ⟨_, Nat.le_add_left k l⟩
+ rw [add_right_comm, hl]
+ exact tsub_add_cancel_of_le h
+
+@[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⟩) := by
+ have aux₁ : fun a ↦ k ≤ a.snd = (fun a ↦ k ≤ a.fst) ∘ (Equiv.prodComm ℕ ℕ).symm := rfl
+ have aux₂ : ∀ i j, (∃ a b, a + b = n - k ∧ b = i ∧ a + k = j) ↔
+ ∃ a b, a + b = n - k ∧ a = i ∧ b + k = j :=
+ fun i j ↦ by rw [exists_comm]; exact exists₂_congr (fun a b ↦ by rw [add_comm])
+ rw [← map_prodComm_antidiagonal]
+ simp_rw [aux₁, ← map_filter, antidiagonal_filter_le_fst_of_le h, map_map]
+ ext ⟨i, j⟩
+ simpa using aux₂ i j
+
section EquivProd
/-- The disjoint union of antidiagonals `Σ (n : ℕ), antidiagonal n` is equivalent to the product
@@ -2,15 +2,12 @@
Copyright (c) 2019 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-
-! This file was ported from Lean 3 source module data.finset.nat_antidiagonal
-! leanprover-community/mathlib commit 9003f28797c0664a49e4179487267c494477d853
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Data.Finset.Card
import Mathlib.Data.Multiset.NatAntidiagonal
+#align_import data.finset.nat_antidiagonal from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
+
/-!
# Antidiagonals in ℕ × ℕ as finsets
This is the second half of the changes originally in #5699, removing all occurrences of ;
after a space and implementing a linter rule to enforce it.
In most cases this 2-character substring has a space after it, so the following command was run first:
find . -type f -name "*.lean" -exec sed -i -E 's/ ; /; /g' {} \;
The remaining cases were few enough in number that they were done manually.
@@ -124,7 +124,7 @@ theorem filter_fst_eq_antidiagonal (n m : ℕ) :
theorem filter_snd_eq_antidiagonal (n m : ℕ) :
filter (fun x : ℕ × ℕ ↦ x.snd = m) (antidiagonal n) = if m ≤ n then {(n - m, m)} else ∅ := by
have : (fun x : ℕ × ℕ ↦ (x.snd = m)) ∘ Prod.swap = fun x : ℕ × ℕ ↦ x.fst = m := by
- ext ; simp
+ ext; simp
rw [← map_swap_antidiagonal]
simp [filter_map, this, filter_fst_eq_antidiagonal, apply_ite (Finset.map _)]
#align finset.nat.filter_snd_eq_antidiagonal Finset.Nat.filter_snd_eq_antidiagonal
This PR is the result of a slight variant on the following "algorithm"
_
and make all uppercase letters into lowercase_
and make all uppercase letters into lowercase(original_lean3_name, OriginalLean4Name)
#align
statement just before the next empty line#align
statement to have been inserted too early)@@ -143,6 +143,9 @@ def sigmaAntidiagonalEquivProd : (Σn : ℕ, antidiagonal n) ≃ ℕ × ℕ wher
exact Sigma.subtype_ext h rfl
right_inv x := rfl
#align finset.nat.sigma_antidiagonal_equiv_prod Finset.Nat.sigmaAntidiagonalEquivProd
+#align finset.nat.sigma_antidiagonal_equiv_prod_symm_apply_fst Finset.Nat.sigmaAntidiagonalEquivProd_symm_apply_fst
+#align finset.nat.sigma_antidiagonal_equiv_prod_symm_apply_snd_coe Finset.Nat.sigmaAntidiagonalEquivProd_symm_apply_snd_coe
+#align finset.nat.sigma_antidiagonal_equiv_prod_apply Finset.Nat.sigmaAntidiagonalEquivProd_apply
end EquivProd
@@ -123,7 +123,7 @@ theorem filter_fst_eq_antidiagonal (n m : ℕ) :
theorem filter_snd_eq_antidiagonal (n m : ℕ) :
filter (fun x : ℕ × ℕ ↦ x.snd = m) (antidiagonal n) = if m ≤ n then {(n - m, m)} else ∅ := by
- have : (fun x : ℕ × ℕ ↦ (x.snd = m : Bool)) ∘ Prod.swap = fun x : ℕ × ℕ ↦ x.fst = m := by
+ have : (fun x : ℕ × ℕ ↦ (x.snd = m)) ∘ Prod.swap = fun x : ℕ × ℕ ↦ x.fst = m := by
ext ; simp
rw [← map_swap_antidiagonal]
simp [filter_map, this, filter_fst_eq_antidiagonal, apply_ite (Finset.map _)]
The unported dependencies are