l3lab/ntp-mathlib huggingface dataset:
/-- Transposing Young diagrams is an `OrderIso`. -/
@[simps]
def transposeOrderIso : YoungDiagram ≃o YoungDiagram :=
  ⟨⟨transpose, transpose, fun _ => by simp, fun _ => by 

Proof state:
x✝ : YoungDiagram
⊢ transpose (transpose x✝) = x✝

Next tactic:
simp
/-- Transposing Young diagrams is an `OrderIso`. -/
@[simps]
def transposeOrderIso : YoungDiagram ≃o YoungDiagram :=
  ⟨⟨transpose, transpose, fun _ => by simp, fun _ => by simp⟩, by 

Proof state:
⊢ ∀ {a b : YoungDiagram},
    { toFun := transpose, invFun := transpose, left_inv := (_ : ∀ (x : YoungDiagram), transpose (transpose x) = x),
            right_inv := (_ : ∀ (x : YoungDiagram), transpose (transpose x) = x) }
          a ≤
        { toFun := transpose, invFun := transpose, left_inv := (_ : ∀ (x : YoungDiagram), transpose (transpose x) = x),
            right_inv := (_ : ∀ (x : YoungDiagram), transpose (transpose x) = x) }
          b ↔
      a ≤ b

Next tactic:
simp
theorem mem_row_iff {μ : YoungDiagram} {i : ℕ} {c : ℕ × ℕ} : c ∈ μ.row i ↔ c ∈ μ ∧ c.fst = i := by
  

Proof state:
μ : YoungDiagram
i : ℕ
c : ℕ × ℕ
⊢ c ∈ row μ i ↔ c ∈ μ ∧ c.1 = i

Next tactic:
simp [row]
theorem mk_mem_row_iff {μ : YoungDiagram} {i j : ℕ} : (i, j) ∈ μ.row i ↔ (i, j) ∈ μ := by 

Proof state:
μ : YoungDiagram
i j : ℕ
⊢ (i, j) ∈ row μ i ↔ (i, j) ∈ μ

Next tactic:
simp [row]
protected theorem exists_not_mem_row (μ : YoungDiagram) (i : ℕ) : ∃ j, (i, j) ∉ μ := by
  

Proof state:
μ : YoungDiagram
i : ℕ
⊢ ∃ j, (i, j) ∉ μ

Next tactic:
obtain ⟨j, hj⟩ :=
    Infinite.exists_not_mem_finset
      (μ.cells.preimage (Prod.mk i) fun _ _ _ _ h => by
        cases h
        rfl)
protected theorem exists_not_mem_row (μ : YoungDiagram) (i : ℕ) : ∃ j, (i, j) ∉ μ := by
  obtain ⟨j, hj⟩ :=
    Infinite.exists_not_mem_finset
      (μ.cells.preimage (Prod.mk i) fun _ _ _ _ h => by
        

Proof state:
μ : YoungDiagram
i x✝³ : ℕ
x✝² : x✝³ ∈ Prod.mk i ⁻¹' ↑μ.cells
x✝¹ : ℕ
x✝ : x✝¹ ∈ Prod.mk i ⁻¹' ↑μ.cells
h : (i, x✝³) = (i, x✝¹)
⊢ x✝³ = x✝¹

Next tactic:
cases h
protected theorem exists_not_mem_row (μ : YoungDiagram) (i : ℕ) : ∃ j, (i, j) ∉ μ := by
  obtain ⟨j, hj⟩ :=
    Infinite.exists_not_mem_finset
      (μ.cells.preimage (Prod.mk i) fun _ _ _ _ h => by
        cases h
        

Proof state:
case refl
μ : YoungDiagram
i x✝² : ℕ
x✝¹ x✝ : x✝² ∈ Prod.mk i ⁻¹' ↑μ.cells
⊢ x✝² = x✝²

Next tactic:
rfl
protected theorem exists_not_mem_row (μ : YoungDiagram) (i : ℕ) : ∃ j, (i, j) ∉ μ := by
  obtain ⟨j, hj⟩ :=
    Infinite.exists_not_mem_finset
      (μ.cells.preimage (Prod.mk i) fun _ _ _ _ h => by
        cases h
        rfl)
  

Proof state:
case intro
μ : YoungDiagram
i j : ℕ
hj :
  j ∉
    Finset.preimage μ.cells (Prod.mk i)
      (_ : ∀ x ∈ Prod.mk i ⁻¹' ↑μ.cells, ∀ x_2 ∈ Prod.mk i ⁻¹' ↑μ.cells, (i, x) = (i, x_2) → x = x_2)
⊢ ∃ j, (i, j) ∉ μ

Next tactic:
rw [Finset.mem_preimage] at hj
protected theorem exists_not_mem_row (μ : YoungDiagram) (i : ℕ) : ∃ j, (i, j) ∉ μ := by
  obtain ⟨j, hj⟩ :=
    Infinite.exists_not_mem_finset
      (μ.cells.preimage (Prod.mk i) fun _ _ _ _ h => by
        cases h
        rfl)
  rw [Finset.mem_preimage] at hj
  

Proof state:
case intro
μ : YoungDiagram
i j : ℕ
hj : (i, j) ∉ μ.cells
⊢ ∃ j, (i, j) ∉ μ

Next tactic:
exact ⟨j, hj⟩
theorem mem_iff_lt_rowLen {μ : YoungDiagram} {i j : ℕ} : (i, j) ∈ μ ↔ j < μ.rowLen i := by
  

Proof state:
μ : YoungDiagram
i j : ℕ
⊢ (i, j) ∈ μ ↔ j < rowLen μ i

Next tactic:
rw [rowLen, Nat.lt_find_iff]
theorem mem_iff_lt_rowLen {μ : YoungDiagram} {i j : ℕ} : (i, j) ∈ μ ↔ j < μ.rowLen i := by
  rw [rowLen, Nat.lt_find_iff]
  

Proof state:
μ : YoungDiagram
i j : ℕ
⊢ (i, j) ∈ μ ↔ ∀ m ≤ j, ¬(i, m) ∉ μ

Next tactic:
push_neg
theorem mem_iff_lt_rowLen {μ : YoungDiagram} {i j : ℕ} : (i, j) ∈ μ ↔ j < μ.rowLen i := by
  rw [rowLen, Nat.lt_find_iff]
  push_neg
  

Proof state:
μ : YoungDiagram
i j : ℕ
⊢ (i, j) ∈ μ ↔ ∀ m ≤ j, (i, m) ∈ μ

Next tactic:
exact ⟨fun h _ hmj => μ.up_left_mem (by rfl) hmj h, fun h => h _ (by rfl)⟩
theorem mem_iff_lt_rowLen {μ : YoungDiagram} {i j : ℕ} : (i, j) ∈ μ ↔ j < μ.rowLen i := by
  rw [rowLen, Nat.lt_find_iff]
  push_neg
  exact ⟨fun h _ hmj => μ.up_left_mem (by 

Proof state:
μ : YoungDiagram
i j : ℕ
h : (i, j) ∈ μ
x✝ : ℕ
hmj : x✝ ≤ j
⊢ i ≤ i

Next tactic:
rfl
theorem mem_iff_lt_rowLen {μ : YoungDiagram} {i j : ℕ} : (i, j) ∈ μ ↔ j < μ.rowLen i := by
  rw [rowLen, Nat.lt_find_iff]
  push_neg
  exact ⟨fun h _ hmj => μ.up_left_mem (by rfl) hmj h, fun h => h _ (by 

Proof state:
μ : YoungDiagram
i j : ℕ
h : ∀ m ≤ j, (i, m) ∈ μ
⊢ j ≤ j

Next tactic:
rfl
theorem row_eq_prod {μ : YoungDiagram} {i : ℕ} : μ.row i = {i} ×ˢ Finset.range (μ.rowLen i) := by
  

Proof state:
μ : YoungDiagram
i : ℕ
⊢ row μ i = {i} ×ˢ Finset.range (rowLen μ i)

Next tactic:
ext ⟨a, b⟩
theorem row_eq_prod {μ : YoungDiagram} {i : ℕ} : μ.row i = {i} ×ˢ Finset.range (μ.rowLen i) := by
  ext ⟨a, b⟩
  

Proof state:
case a.mk
μ : YoungDiagram
i a b : ℕ
⊢ (a, b) ∈ row μ i ↔ (a, b) ∈ {i} ×ˢ Finset.range (rowLen μ i)

Next tactic:
simp only [Finset.mem_product, Finset.mem_singleton, Finset.mem_range, mem_row_iff,
    mem_iff_lt_rowLen, and_comm, and_congr_right_iff]
theorem row_eq_prod {μ : YoungDiagram} {i : ℕ} : μ.row i = {i} ×ˢ Finset.range (μ.rowLen i) := by
  ext ⟨a, b⟩
  simp only [Finset.mem_product, Finset.mem_singleton, Finset.mem_range, mem_row_iff,
    mem_iff_lt_rowLen, and_comm, and_congr_right_iff]
  

Proof state:
case a.mk
μ : YoungDiagram
i a b : ℕ
⊢ a = i → (b < rowLen μ a ↔ b < rowLen μ i)

Next tactic:
rintro rfl
theorem row_eq_prod {μ : YoungDiagram} {i : ℕ} : μ.row i = {i} ×ˢ Finset.range (μ.rowLen i) := by
  ext ⟨a, b⟩
  simp only [Finset.mem_product, Finset.mem_singleton, Finset.mem_range, mem_row_iff,
    mem_iff_lt_rowLen, and_comm, and_congr_right_iff]
  rintro rfl
  

Proof state:
case a.mk
μ : YoungDiagram
a b : ℕ
⊢ b < rowLen μ a ↔ b < rowLen μ a

Next tactic:
rfl
theorem rowLen_eq_card (μ : YoungDiagram) {i : ℕ} : μ.rowLen i = (μ.row i).card := by
  

Proof state:
μ : YoungDiagram
i : ℕ
⊢ rowLen μ i = Finset.card (row μ i)

Next tactic:
simp [row_eq_prod]
@[mono]
theorem rowLen_anti (μ : YoungDiagram) (i1 i2 : ℕ) (hi : i1 ≤ i2) : μ.rowLen i2 ≤ μ.rowLen i1 := by
  

Proof state:
μ : YoungDiagram
i1 i2 : ℕ
hi : i1 ≤ i2
⊢ rowLen μ i2 ≤ rowLen μ i1

Next tactic:
by_contra! h_lt
@[mono]
theorem rowLen_anti (μ : YoungDiagram) (i1 i2 : ℕ) (hi : i1 ≤ i2) : μ.rowLen i2 ≤ μ.rowLen i1 := by
  by_contra! h_lt
  

Proof state:
μ : YoungDiagram
i1 i2 : ℕ
hi : i1 ≤ i2
h_lt : rowLen μ i1 < rowLen μ i2
⊢ False

Next tactic:
rw [← lt_self_iff_false (μ.rowLen i1)]
@[mono]
theorem rowLen_anti (μ : YoungDiagram) (i1 i2 : ℕ) (hi : i1 ≤ i2) : μ.rowLen i2 ≤ μ.rowLen i1 := by
  by_contra! h_lt
  rw [← lt_self_iff_false (μ.rowLen i1)]
  

Proof state:
μ : YoungDiagram
i1 i2 : ℕ
hi : i1 ≤ i2
h_lt : rowLen μ i1 < rowLen μ i2
⊢ rowLen μ i1 < rowLen μ i1

Next tactic:
rw [← mem_iff_lt_rowLen] at h_lt ⊢
@[mono]
theorem rowLen_anti (μ : YoungDiagram) (i1 i2 : ℕ) (hi : i1 ≤ i2) : μ.rowLen i2 ≤ μ.rowLen i1 := by
  by_contra! h_lt
  rw [← lt_self_iff_false (μ.rowLen i1)]
  rw [← mem_iff_lt_rowLen] at h_lt ⊢
  

Proof state:
μ : YoungDiagram
i1 i2 : ℕ
hi : i1 ≤ i2
h_lt : (i2, rowLen μ i1) ∈ μ
⊢ (i1, rowLen μ i1) ∈ μ

Next tactic:
exact μ.up_left_mem hi (by rfl) h_lt
@[mono]
theorem rowLen_anti (μ : YoungDiagram) (i1 i2 : ℕ) (hi : i1 ≤ i2) : μ.rowLen i2 ≤ μ.rowLen i1 := by
  by_contra! h_lt
  rw [← lt_self_iff_false (μ.rowLen i1)]
  rw [← mem_iff_lt_rowLen] at h_lt ⊢
  exact μ.up_left_mem hi (by 

Proof state:
μ : YoungDiagram
i1 i2 : ℕ
hi : i1 ≤ i2
h_lt : (i2, rowLen μ i1) ∈ μ
⊢ rowLen μ i1 ≤ rowLen μ i1

Next tactic:
rfl
theorem mem_col_iff {μ : YoungDiagram} {j : ℕ} {c : ℕ × ℕ} : c ∈ μ.col j ↔ c ∈ μ ∧ c.snd = j := by
  

Proof state:
μ : YoungDiagram
j : ℕ
c : ℕ × ℕ
⊢ c ∈ col μ j ↔ c ∈ μ ∧ c.2 = j

Next tactic:
simp [col]
theorem mk_mem_col_iff {μ : YoungDiagram} {i j : ℕ} : (i, j) ∈ μ.col j ↔ (i, j) ∈ μ := by 

Proof state:
μ : YoungDiagram
i j : ℕ
⊢ (i, j) ∈ col μ j ↔ (i, j) ∈ μ

Next tactic:
simp [col]
protected theorem exists_not_mem_col (μ : YoungDiagram) (j : ℕ) : ∃ i, (i, j) ∉ μ.cells := by
  

Proof state:
μ : YoungDiagram
j : ℕ
⊢ ∃ i, (i, j) ∉ μ.cells

Next tactic:
convert μ.transpose.exists_not_mem_row j using 1
protected theorem exists_not_mem_col (μ : YoungDiagram) (j : ℕ) : ∃ i, (i, j) ∉ μ.cells := by
  convert μ.transpose.exists_not_mem_row j using 1
  

Proof state:
case h.e'_2
μ : YoungDiagram
j : ℕ
⊢ (fun i => (i, j) ∉ μ.cells) = fun j_1 => (j, j_1) ∉ transpose μ

Next tactic:
simp
@[simp]
theorem colLen_transpose (μ : YoungDiagram) (j : ℕ) : μ.transpose.colLen j = μ.rowLen j := by
  

Proof state:
μ : YoungDiagram
j : ℕ
⊢ colLen (transpose μ) j = rowLen μ j

Next tactic:
simp [rowLen, colLen]
@[simp]
theorem rowLen_transpose (μ : YoungDiagram) (i : ℕ) : μ.transpose.rowLen i = μ.colLen i := by
  

Proof state:
μ : YoungDiagram
i : ℕ
⊢ rowLen (transpose μ) i = colLen μ i

Next tactic:
simp [rowLen, colLen]
theorem mem_iff_lt_colLen {μ : YoungDiagram} {i j : ℕ} : (i, j) ∈ μ ↔ i < μ.colLen j := by
  

Proof state:
μ : YoungDiagram
i j : ℕ
⊢ (i, j) ∈ μ ↔ i < colLen μ j

Next tactic:
rw [← rowLen_transpose, ← mem_iff_lt_rowLen]
theorem mem_iff_lt_colLen {μ : YoungDiagram} {i j : ℕ} : (i, j) ∈ μ ↔ i < μ.colLen j := by
  rw [← rowLen_transpose, ← mem_iff_lt_rowLen]
  

Proof state:
μ : YoungDiagram
i j : ℕ
⊢ (i, j) ∈ μ ↔ (j, i) ∈ transpose μ

Next tactic:
simp
theorem col_eq_prod {μ : YoungDiagram} {j : ℕ} : μ.col j = Finset.range (μ.colLen j) ×ˢ {j} := by
  

Proof state:
μ : YoungDiagram
j : ℕ
⊢ col μ j = Finset.range (colLen μ j) ×ˢ {j}

Next tactic:
ext ⟨a, b⟩
theorem col_eq_prod {μ : YoungDiagram} {j : ℕ} : μ.col j = Finset.range (μ.colLen j) ×ˢ {j} := by
  ext ⟨a, b⟩
  

Proof state:
case a.mk
μ : YoungDiagram
j a b : ℕ
⊢ (a, b) ∈ col μ j ↔ (a, b) ∈ Finset.range (colLen μ j) ×ˢ {j}

Next tactic:
simp only [Finset.mem_product, Finset.mem_singleton, Finset.mem_range, mem_col_iff,
    mem_iff_lt_colLen, and_comm, and_congr_right_iff]
theorem col_eq_prod {μ : YoungDiagram} {j : ℕ} : μ.col j = Finset.range (μ.colLen j) ×ˢ {j} := by
  ext ⟨a, b⟩
  simp only [Finset.mem_product, Finset.mem_singleton, Finset.mem_range, mem_col_iff,
    mem_iff_lt_colLen, and_comm, and_congr_right_iff]
  

Proof state:
case a.mk
μ : YoungDiagram
j a b : ℕ
⊢ b = j → (a < colLen μ b ↔ a < colLen μ j)

Next tactic:
rintro rfl
theorem col_eq_prod {μ : YoungDiagram} {j : ℕ} : μ.col j = Finset.range (μ.colLen j) ×ˢ {j} := by
  ext ⟨a, b⟩
  simp only [Finset.mem_product, Finset.mem_singleton, Finset.mem_range, mem_col_iff,
    mem_iff_lt_colLen, and_comm, and_congr_right_iff]
  rintro rfl
  

Proof state:
case a.mk
μ : YoungDiagram
a b : ℕ
⊢ a < colLen μ b ↔ a < colLen μ b

Next tactic:
rfl
theorem colLen_eq_card (μ : YoungDiagram) {j : ℕ} : μ.colLen j = (μ.col j).card := by
  

Proof state:
μ : YoungDiagram
j : ℕ
⊢ colLen μ j = Finset.card (col μ j)

Next tactic:
simp [col_eq_prod]
@[mono]
theorem colLen_anti (μ : YoungDiagram) (j1 j2 : ℕ) (hj : j1 ≤ j2) : μ.colLen j2 ≤ μ.colLen j1 := by
  

Proof state:
μ : YoungDiagram
j1 j2 : ℕ
hj : j1 ≤ j2
⊢ colLen μ j2 ≤ colLen μ j1

Next tactic:
convert μ.transpose.rowLen_anti j1 j2 hj using 1
@[mono]
theorem colLen_anti (μ : YoungDiagram) (j1 j2 : ℕ) (hj : j1 ≤ j2) : μ.colLen j2 ≤ μ.colLen j1 := by
  convert μ.transpose.rowLen_anti j1 j2 hj using 1 <;> 

Proof state:
case h.e'_3
μ : YoungDiagram
j1 j2 : ℕ
hj : j1 ≤ j2
⊢ colLen μ j2 = rowLen (transpose μ) j2

Next tactic:
simp
@[mono]
theorem colLen_anti (μ : YoungDiagram) (j1 j2 : ℕ) (hj : j1 ≤ j2) : μ.colLen j2 ≤ μ.colLen j1 := by
  convert μ.transpose.rowLen_anti j1 j2 hj using 1 <;> 

Proof state:
case h.e'_4
μ : YoungDiagram
j1 j2 : ℕ
hj : j1 ≤ j2
⊢ colLen μ j1 = rowLen (transpose μ) j1

Next tactic:
simp
@[simp]
theorem get_rowLens {μ : YoungDiagram} {i} :
    μ.rowLens.get i = μ.rowLen i := by 

Proof state:
μ : YoungDiagram
i : Fin (List.length (rowLens μ))
⊢ List.get (rowLens μ) i = rowLen μ ↑i

Next tactic:
simp only [rowLens, List.get_range, List.get_map]
@[simp]
theorem length_rowLens {μ : YoungDiagram} : μ.rowLens.length = μ.colLen 0 := by
  

Proof state:
μ : YoungDiagram
⊢ List.length (rowLens μ) = colLen μ 0

Next tactic:
simp only [rowLens, List.length_map, List.length_range]
theorem pos_of_mem_rowLens (μ : YoungDiagram) (x : ℕ) (hx : x ∈ μ.rowLens) : 0 < x := by
  

Proof state:
μ : YoungDiagram
x : ℕ
hx : x ∈ rowLens μ
⊢ 0 < x

Next tactic:
rw [rowLens, List.mem_map] at hx
theorem pos_of_mem_rowLens (μ : YoungDiagram) (x : ℕ) (hx : x ∈ μ.rowLens) : 0 < x := by
  rw [rowLens, List.mem_map] at hx
  

Proof state:
μ : YoungDiagram
x : ℕ
hx : ∃ a ∈ List.range (colLen μ 0), rowLen μ a = x
⊢ 0 < x

Next tactic:
obtain ⟨i, hi, rfl : μ.rowLen i = x⟩ := hx
theorem pos_of_mem_rowLens (μ : YoungDiagram) (x : ℕ) (hx : x ∈ μ.rowLens) : 0 < x := by
  rw [rowLens, List.mem_map] at hx
  obtain ⟨i, hi, rfl : μ.rowLen i = x⟩ := hx
  

Proof state:
case intro.intro
μ : YoungDiagram
i : ℕ
hi : i ∈ List.range (colLen μ 0)
⊢ 0 < rowLen μ i

Next tactic:
rwa [List.mem_range, ← mem_iff_lt_colLen, mem_iff_lt_rowLen] at hi
protected theorem mem_cellsOfRowLens {w : List ℕ} {c : ℕ × ℕ} :
    c ∈ YoungDiagram.cellsOfRowLens w ↔ ∃ h : c.fst < w.length, c.snd < w.get ⟨c.fst, h⟩  := by
  

Proof state:
w : List ℕ
c : ℕ × ℕ
⊢ c ∈ YoungDiagram.cellsOfRowLens w ↔ ∃ (h : c.1 < List.length w), c.2 < List.get w { val := c.1, isLt := h }

Next tactic:
induction' w with w_hd w_tl w_ih generalizing c
protected theorem mem_cellsOfRowLens {w : List ℕ} {c : ℕ × ℕ} :
    c ∈ YoungDiagram.cellsOfRowLens w ↔ ∃ h : c.fst < w.length, c.snd < w.get ⟨c.fst, h⟩  := by
  induction' w with w_hd w_tl w_ih generalizing c <;> 

Proof state:
case nil
c : ℕ × ℕ
⊢ c ∈ YoungDiagram.cellsOfRowLens [] ↔ ∃ (h : c.1 < List.length []), c.2 < List.get [] { val := c.1, isLt := h }

Next tactic:
rw [YoungDiagram.cellsOfRowLens]
protected theorem mem_cellsOfRowLens {w : List ℕ} {c : ℕ × ℕ} :
    c ∈ YoungDiagram.cellsOfRowLens w ↔ ∃ h : c.fst < w.length, c.snd < w.get ⟨c.fst, h⟩  := by
  induction' w with w_hd w_tl w_ih generalizing c <;> 

Proof state:
case cons
w_hd : ℕ
w_tl : List ℕ
w_ih :
  ∀ {c : ℕ × ℕ},
    c ∈ YoungDiagram.cellsOfRowLens w_tl ↔ ∃ (h : c.1 < List.length w_tl), c.2 < List.get w_tl { val := c.1, isLt := h }
c : ℕ × ℕ
⊢ c ∈ YoungDiagram.cellsOfRowLens (w_hd :: w_tl) ↔
    ∃ (h : c.1 < List.length (w_hd :: w_tl)), c.2 < List.get (w_hd :: w_tl) { val := c.1, isLt := h }

Next tactic:
rw [YoungDiagram.cellsOfRowLens]
protected theorem mem_cellsOfRowLens {w : List ℕ} {c : ℕ × ℕ} :
    c ∈ YoungDiagram.cellsOfRowLens w ↔ ∃ h : c.fst < w.length, c.snd < w.get ⟨c.fst, h⟩  := by
  induction' w with w_hd w_tl w_ih generalizing c <;> rw [YoungDiagram.cellsOfRowLens]
  · 

Proof state:
case nil
c : ℕ × ℕ
⊢ c ∈ ∅ ↔ ∃ (h : c.1 < List.length []), c.2 < List.get [] { val := c.1, isLt := h }

Next tactic:
simp [YoungDiagram.cellsOfRowLens]
protected theorem mem_cellsOfRowLens {w : List ℕ} {c : ℕ × ℕ} :
    c ∈ YoungDiagram.cellsOfRowLens w ↔ ∃ h : c.fst < w.length, c.snd < w.get ⟨c.fst, h⟩  := by
  induction' w with w_hd w_tl w_ih generalizing c <;> rw [YoungDiagram.cellsOfRowLens]
  · simp [YoungDiagram.cellsOfRowLens]
  · 

Proof state:
case cons
w_hd : ℕ
w_tl : List ℕ
w_ih :
  ∀ {c : ℕ × ℕ},
    c ∈ YoungDiagram.cellsOfRowLens w_tl ↔ ∃ (h : c.1 < List.length w_tl), c.2 < List.get w_tl { val := c.1, isLt := h }
c : ℕ × ℕ
⊢ c ∈
      {0} ×ˢ Finset.range w_hd ∪
        Finset.map (Embedding.prodMap { toFun := Nat.succ, inj' := Nat.succ_injective } (Embedding.refl ℕ))
          (YoungDiagram.cellsOfRowLens w_tl) ↔
    ∃ (h : c.1 < List.length (w_hd :: w_tl)), c.2 < List.get (w_hd :: w_tl) { val := c.1, isLt := h }

Next tactic:
rcases c with ⟨⟨_, _⟩, _⟩
protected theorem mem_cellsOfRowLens {w : List ℕ} {c : ℕ × ℕ} :
    c ∈ YoungDiagram.cellsOfRowLens w ↔ ∃ h : c.fst < w.length, c.snd < w.get ⟨c.fst, h⟩  := by
  induction' w with w_hd w_tl w_ih generalizing c <;> rw [YoungDiagram.cellsOfRowLens]
  · simp [YoungDiagram.cellsOfRowLens]
  · rcases c with ⟨⟨_, _⟩, _⟩
    · 

Proof state:
case cons.mk.zero
w_hd : ℕ
w_tl : List ℕ
w_ih :
  ∀ {c : ℕ × ℕ},
    c ∈ YoungDiagram.cellsOfRowLens w_tl ↔ ∃ (h : c.1 < List.length w_tl), c.2 < List.get w_tl { val := c.1, isLt := h }
snd✝ : ℕ
⊢ (Nat.zero, snd✝) ∈
      {0} ×ˢ Finset.range w_hd ∪
        Finset.map (Embedding.prodMap { toFun := Nat.succ, inj' := Nat.succ_injective } (Embedding.refl ℕ))
          (YoungDiagram.cellsOfRowLens w_tl) ↔
    ∃ (h : (Nat.zero, snd✝).1 < List.length (w_hd :: w_tl)),
      (Nat.zero, snd✝).2 < List.get (w_hd :: w_tl) { val := (Nat.zero, snd✝).1, isLt := h }

Next tactic:
simp
protected theorem mem_cellsOfRowLens {w : List ℕ} {c : ℕ × ℕ} :
    c ∈ YoungDiagram.cellsOfRowLens w ↔ ∃ h : c.fst < w.length, c.snd < w.get ⟨c.fst, h⟩  := by
  induction' w with w_hd w_tl w_ih generalizing c <;> rw [YoungDiagram.cellsOfRowLens]
  · simp [YoungDiagram.cellsOfRowLens]
  · rcases c with ⟨⟨_, _⟩, _⟩
    · simp
    -- Porting note: was `simpa`
    · 

Proof state:
case cons.mk.succ
w_hd : ℕ
w_tl : List ℕ
w_ih :
  ∀ {c : ℕ × ℕ},
    c ∈ YoungDiagram.cellsOfRowLens w_tl ↔ ∃ (h : c.1 < List.length w_tl), c.2 < List.get w_tl { val := c.1, isLt := h }
snd✝ n✝ : ℕ
⊢ (Nat.succ n✝, snd✝) ∈
      {0} ×ˢ Finset.range w_hd ∪
        Finset.map (Embedding.prodMap { toFun := Nat.succ, inj' := Nat.succ_injective } (Embedding.refl ℕ))
          (YoungDiagram.cellsOfRowLens w_tl) ↔
    ∃ (h : (Nat.succ n✝, snd✝).1 < List.length (w_hd :: w_tl)),
      (Nat.succ n✝, snd✝).2 < List.get (w_hd :: w_tl) { val := (Nat.succ n✝, snd✝).1, isLt := h }

Next tactic:
simp [w_ih, -Finset.singleton_product, Nat.succ_lt_succ_iff]
/-- Young diagram from a sorted list -/
def ofRowLens (w : List ℕ) (hw : w.Sorted (· ≥ ·)) : YoungDiagram
    where
  cells := YoungDiagram.cellsOfRowLens w
  isLowerSet := by
    

Proof state:
w : List ℕ
hw : List.Sorted (fun x x_1 => x ≥ x_1) w
⊢ IsLowerSet ↑(YoungDiagram.cellsOfRowLens w)

Next tactic:
rintro ⟨i2, j2⟩ ⟨i1, j1⟩ ⟨hi : i1 ≤ i2, hj : j1 ≤ j2⟩ hcell
/-- Young diagram from a sorted list -/
def ofRowLens (w : List ℕ) (hw : w.Sorted (· ≥ ·)) : YoungDiagram
    where
  cells := YoungDiagram.cellsOfRowLens w
  isLowerSet := by
    rintro ⟨i2, j2⟩ ⟨i1, j1⟩ ⟨hi : i1 ≤ i2, hj : j1 ≤ j2⟩ hcell
    

Proof state:
case mk.mk.intro
w : List ℕ
hw : List.Sorted (fun x x_1 => x ≥ x_1) w
i2 j2 i1 j1 : ℕ
hi : i1 ≤ i2
hj : j1 ≤ j2
hcell : (i2, j2) ∈ ↑(YoungDiagram.cellsOfRowLens w)
⊢ (i1, j1) ∈ ↑(YoungDiagram.cellsOfRowLens w)

Next tactic:
rw [Finset.mem_coe, YoungDiagram.mem_cellsOfRowLens] at hcell ⊢
/-- Young diagram from a sorted list -/
def ofRowLens (w : List ℕ) (hw : w.Sorted (· ≥ ·)) : YoungDiagram
    where
  cells := YoungDiagram.cellsOfRowLens w
  isLowerSet := by
    rintro ⟨i2, j2⟩ ⟨i1, j1⟩ ⟨hi : i1 ≤ i2, hj : j1 ≤ j2⟩ hcell
    rw [Finset.mem_coe, YoungDiagram.mem_cellsOfRowLens] at hcell ⊢
    

Proof state:
case mk.mk.intro
w : List ℕ
hw : List.Sorted (fun x x_1 => x ≥ x_1) w
i2 j2 i1 j1 : ℕ
hi : i1 ≤ i2
hj : j1 ≤ j2
hcell : ∃ (h : (i2, j2).1 < List.length w), (i2, j2).2 < List.get w { val := (i2, j2).1, isLt := h }
⊢ ∃ (h : (i1, j1).1 < List.length w), (i1, j1).2 < List.get w { val := (i1, j1).1, isLt := h }

Next tactic:
obtain ⟨h1, h2⟩ := hcell
/-- Young diagram from a sorted list -/
def ofRowLens (w : List ℕ) (hw : w.Sorted (· ≥ ·)) : YoungDiagram
    where
  cells := YoungDiagram.cellsOfRowLens w
  isLowerSet := by
    rintro ⟨i2, j2⟩ ⟨i1, j1⟩ ⟨hi : i1 ≤ i2, hj : j1 ≤ j2⟩ hcell
    rw [Finset.mem_coe, YoungDiagram.mem_cellsOfRowLens] at hcell ⊢
    obtain ⟨h1, h2⟩ := hcell
    

Proof state:
case mk.mk.intro.intro
w : List ℕ
hw : List.Sorted (fun x x_1 => x ≥ x_1) w
i2 j2 i1 j1 : ℕ
hi : i1 ≤ i2
hj : j1 ≤ j2
h1 : (i2, j2).1 < List.length w
h2 : (i2, j2).2 < List.get w { val := (i2, j2).1, isLt := h1 }
⊢ ∃ (h : (i1, j1).1 < List.length w), (i1, j1).2 < List.get w { val := (i1, j1).1, isLt := h }

Next tactic:
refine' ⟨hi.trans_lt h1, _⟩
/-- Young diagram from a sorted list -/
def ofRowLens (w : List ℕ) (hw : w.Sorted (· ≥ ·)) : YoungDiagram
    where
  cells := YoungDiagram.cellsOfRowLens w
  isLowerSet := by
    rintro ⟨i2, j2⟩ ⟨i1, j1⟩ ⟨hi : i1 ≤ i2, hj : j1 ≤ j2⟩ hcell
    rw [Finset.mem_coe, YoungDiagram.mem_cellsOfRowLens] at hcell ⊢
    obtain ⟨h1, h2⟩ := hcell
    refine' ⟨hi.trans_lt h1, _⟩
    

Proof state:
case mk.mk.intro.intro
w : List ℕ
hw : List.Sorted (fun x x_1 => x ≥ x_1) w
i2 j2 i1 j1 : ℕ
hi : i1 ≤ i2
hj : j1 ≤ j2
h1 : (i2, j2).1 < List.length w
h2 : (i2, j2).2 < List.get w { val := (i2, j2).1, isLt := h1 }
⊢ (i1, j1).2 < List.get w { val := (i1, j1).1, isLt := (_ : i1 < List.length w) }

Next tactic:
calc
      j1 ≤ j2 := hj
      _ < w.get ⟨i2, _⟩  := h2
      _ ≤ w.get ⟨i1, _⟩ := by
        obtain rfl | h := eq_or_lt_of_le hi
        · convert le_refl (w.get ⟨i1, h1⟩)
        · exact List.pairwise_iff_get.mp hw _ _ h
/-- Young diagram from a sorted list -/
def ofRowLens (w : List ℕ) (hw : w.Sorted (· ≥ ·)) : YoungDiagram
    where
  cells := YoungDiagram.cellsOfRowLens w
  isLowerSet := by
    rintro ⟨i2, j2⟩ ⟨i1, j1⟩ ⟨hi : i1 ≤ i2, hj : j1 ≤ j2⟩ hcell
    rw [Finset.mem_coe, YoungDiagram.mem_cellsOfRowLens] at hcell ⊢
    obtain ⟨h1, h2⟩ := hcell
    refine' ⟨hi.trans_lt h1, _⟩
    calc
      j1 ≤ j2 := hj
      _ < w.get ⟨i2, _⟩  := h2
      _ ≤ w.get ⟨i1, _⟩ := by
        

Proof state:
w : List ℕ
hw : List.Sorted (fun x x_1 => x ≥ x_1) w
i2 j2 i1 j1 : ℕ
hi : i1 ≤ i2
hj : j1 ≤ j2
h1 : (i2, j2).1 < List.length w
h2 : (i2, j2).2 < List.get w { val := (i2, j2).1, isLt := h1 }
⊢ List.get w { val := i2, isLt := h1 } ≤ List.get w { val := i1, isLt := (_ : i1 < List.length w) }

Next tactic:
obtain rfl | h := eq_or_lt_of_le hi
/-- Young diagram from a sorted list -/
def ofRowLens (w : List ℕ) (hw : w.Sorted (· ≥ ·)) : YoungDiagram
    where
  cells := YoungDiagram.cellsOfRowLens w
  isLowerSet := by
    rintro ⟨i2, j2⟩ ⟨i1, j1⟩ ⟨hi : i1 ≤ i2, hj : j1 ≤ j2⟩ hcell
    rw [Finset.mem_coe, YoungDiagram.mem_cellsOfRowLens] at hcell ⊢
    obtain ⟨h1, h2⟩ := hcell
    refine' ⟨hi.trans_lt h1, _⟩
    calc
      j1 ≤ j2 := hj
      _ < w.get ⟨i2, _⟩  := h2
      _ ≤ w.get ⟨i1, _⟩ := by
        obtain rfl | h := eq_or_lt_of_le hi
        · 

Proof state:
case inl
w : List ℕ
hw : List.Sorted (fun x x_1 => x ≥ x_1) w
j2 i1 j1 : ℕ
hj : j1 ≤ j2
hi : i1 ≤ i1
h1 : (i1, j2).1 < List.length w
h2 : (i1, j2).2 < List.get w { val := (i1, j2).1, isLt := h1 }
⊢ List.get w { val := i1, isLt := h1 } ≤ List.get w { val := i1, isLt := (_ : i1 < List.length w) }

Next tactic:
convert le_refl (w.get ⟨i1, h1⟩)
/-- Young diagram from a sorted list -/
def ofRowLens (w : List ℕ) (hw : w.Sorted (· ≥ ·)) : YoungDiagram
    where
  cells := YoungDiagram.cellsOfRowLens w
  isLowerSet := by
    rintro ⟨i2, j2⟩ ⟨i1, j1⟩ ⟨hi : i1 ≤ i2, hj : j1 ≤ j2⟩ hcell
    rw [Finset.mem_coe, YoungDiagram.mem_cellsOfRowLens] at hcell ⊢
    obtain ⟨h1, h2⟩ := hcell
    refine' ⟨hi.trans_lt h1, _⟩
    calc
      j1 ≤ j2 := hj
      _ < w.get ⟨i2, _⟩  := h2
      _ ≤ w.get ⟨i1, _⟩ := by
        obtain rfl | h := eq_or_lt_of_le hi
        · convert le_refl (w.get ⟨i1, h1⟩)
        · 

Proof state:
case inr
w : List ℕ
hw : List.Sorted (fun x x_1 => x ≥ x_1) w
i2 j2 i1 j1 : ℕ
hi : i1 ≤ i2
hj : j1 ≤ j2
h1 : (i2, j2).1 < List.length w
h2 : (i2, j2).2 < List.get w { val := (i2, j2).1, isLt := h1 }
h : i1 < i2
⊢ List.get w { val := i2, isLt := h1 } ≤ List.get w { val := i1, isLt := (_ : i1 < List.length w) }

Next tactic:
exact List.pairwise_iff_get.mp hw _ _ h
/-- The number of rows in `ofRowLens w hw` is the length of `w` -/
theorem rowLens_length_ofRowLens {w : List ℕ} {hw : w.Sorted (· ≥ ·)} (hpos : ∀ x ∈ w, 0 < x) :
    (ofRowLens w hw).rowLens.length = w.length := by
  

Proof state:
w : List ℕ
hw : List.Sorted (fun x x_1 => x ≥ x_1) w
hpos : ∀ x ∈ w, 0 < x
⊢ List.length (rowLens (ofRowLens w hw)) = List.length w

Next tactic:
simp only [length_rowLens, colLen, Nat.find_eq_iff, mem_cells, mem_ofRowLens,
    lt_self_iff_false, IsEmpty.exists_iff, Classical.not_not]