|
| 1 | +import Mathlib.Algebra.Ring.Pi |
| 2 | +import Mathlib.Data.Fintype.Pi |
| 3 | +import Mathlib.Data.Matrix.Rank |
| 4 | + |
| 5 | +open scoped BigOperators |
| 6 | + |
| 7 | +variable {ι R : Type*} [DecidableEq ι] {α : ι → Type*} [Semiring R] {m n : ℕ} |
| 8 | + {f f₁ f₂ : (∀ i, α i) → R} |
| 9 | + |
| 10 | +/-- A function `f` *has slice-rank at most* `n` if it can be written as the sum of `n` functions |
| 11 | +of the form `x ↦ g (x i) * h (x 1, ..., x (i - 1), x (i + 1), ..., x k)`. -/ |
| 12 | +@[mk_iff hasSliceRankLE_iff] |
| 13 | +inductive HasSliceRankLE : ℕ → ((∀ i, α i) → R) → Prop |
| 14 | + | zero : HasSliceRankLE 0 0 |
| 15 | + | succ ⦃n f i⦄ (g : α i → R) (h : (∀ j ≠ i, α j) → R) : |
| 16 | + HasSliceRankLE n f → HasSliceRankLE (n + 1) (f + (fun x ↦ g (x i) * h (fun j _ ↦ x j))) |
| 17 | + |
| 18 | +@[simp] lemma hasSliceRankLE_zero : HasSliceRankLE 0 f ↔ f = 0 := by |
| 19 | + rw [hasSliceRankLE_iff]; simp [@eq_comm _ 0] |
| 20 | + |
| 21 | +lemma hasSliceRankLE_succ : |
| 22 | + HasSliceRankLE (n + 1) f ↔ ∃ f' i, ∃ (g : α i → R) (h : (∀ j ≠ i, α j) → R), |
| 23 | + HasSliceRankLE n f' ∧ f = f' + fun x ↦ g (x i) * h fun j _ ↦ x j := by |
| 24 | + rw [hasSliceRankLE_iff]; aesop |
| 25 | + |
| 26 | +lemma hasSliceRankLE_one : |
| 27 | + HasSliceRankLE 1 f ↔ ∃ i, ∃ (g : α i → R) (h : (∀ j ≠ i, α j) → R), |
| 28 | + f = fun x ↦ g (x i) * h fun j _ ↦ x j := by simp [hasSliceRankLE_succ] |
| 29 | + |
| 30 | +lemma hasSliceRankLE_iff_exists_sum : |
| 31 | + HasSliceRankLE n f ↔ ∃ (i : Fin n → ι) (g : ∀ k, α (i k) → R) (h : ∀ k, (∀ j ≠ i k, α j) → R), |
| 32 | + f = ∑ k, fun x ↦ g k (x (i k)) * h k fun j _ ↦ x j := by |
| 33 | + induction' n with n ih generalizing f |
| 34 | + · simp |
| 35 | + simp_rw [hasSliceRankLE_succ, ih] |
| 36 | + constructor |
| 37 | + · rintro ⟨f', iₙ, gₙ, hₙ, ⟨i, g, h, rfl⟩, rfl⟩ |
| 38 | + refine ⟨Fin.cons iₙ i, Fin.cons gₙ g, Fin.cons hₙ h, ?_⟩ |
| 39 | + ext x |
| 40 | + simp only [ne_eq, Pi.add_apply, Finset.sum_apply, add_comm (_ * _), Fin.sum_univ_succ, |
| 41 | + Fin.cons_zero, Fin.cons_succ] |
| 42 | + congr |
| 43 | + · rintro ⟨i, g, h, rfl⟩ |
| 44 | + refine ⟨_, i 0, g 0, h 0, ⟨Fin.tail i, Fin.tail g, Fin.tail h, rfl⟩, ?_⟩ |
| 45 | + ext x |
| 46 | + simp only [ne_eq, Pi.add_apply, Finset.sum_apply, add_comm (_ * _), Fin.sum_univ_succ, |
| 47 | + Fin.cons_zero, Fin.cons_succ] |
| 48 | + congr |
| 49 | + |
| 50 | +lemma HasSliceRankLE.add (h₁ : HasSliceRankLE m f₁) : |
| 51 | + ∀ {n f₂}, HasSliceRankLE n f₂ → HasSliceRankLE (m + n) (f₁ + f₂) |
| 52 | + | _, _, .zero => by simpa |
| 53 | + | _, _, .succ g h h₂ => by simpa [add_assoc] using (h₁.add h₂).succ g h |
| 54 | + |
| 55 | +/-- Any function has slice-rank bounded by the cardinality of its domain. -/ |
| 56 | +lemma hasSliceRankLE_card [Fintype ι] [∀ i, Fintype (α i)] (f : (∀ i, α i) → R) : |
| 57 | + HasSliceRankLE (Fintype.card (∀ i, α i)) f := by |
| 58 | + rw [hasSliceRankLE_iff_exists_sum] |
| 59 | + sorry |
| 60 | + |
| 61 | +/-- Any function from a finite type has finite slice-rank. -/ |
| 62 | +lemma exists_hasSliceRankLE [Finite ι] [∀ i, Finite (α i)] (f : (∀ i, α i) → R) : |
| 63 | + ∃ n, HasSliceRankLE n f := by |
| 64 | + cases nonempty_fintype ι |
| 65 | + have (i) := Fintype.ofFinite (α i) |
| 66 | + exact ⟨_, hasSliceRankLE_card _⟩ |
0 commit comments