import Mathlib import OAI.Probability.CriticalPercolation.LinearGroups.StrongAbstractSpan import OAI.Probability.CriticalPercolation.LinearGroups.InvariantSubspaceDensity import OAI.Probability.CriticalPercolation.LinearGroups.InvariantBlockSolvability import OAI.Probability.CriticalPercolation.Nilpotent.CharacteristicNilpotentCore namespace OAI section noncomputable section open Set Function Module open scoped Classical namespace CriticalPercolation.LinearGrowth lemma finiteIndex_comap_surjective {A B : Type*} [Group A] [Group B] (f : A →* B) (hf : Surjective f) (P : Subgroup B) [P.FiniteIndex] : (P.comap f).FiniteIndex := by constructor rw [Subgroup.index_comap,f.range_eq_top_of_surjective hf,Subgroup.relIndex_top_right] exact Subgroup.FiniteIndex.index_ne_zero lemma solvable_range_of_mem {A B : Type*} [Group A] [Group B] (f : A →* B) (P : Subgroup B) [Group.IsSolvable P] (hp : ∀ a, f a∈P) : Group.IsSolvable f.range := by have hh : f.range≤P := by rintro _ ⟨a,rfl⟩; exact hp a exact Group.isSolvable_of_isSolvable_injective (f:=Subgroup.inclusion hh) (Subgroup.inclusion_injective hh) lemma solvable_restricted_range {A B : Type*} [Group A] [Group B] (f : A →* B) (P : Subgroup f.range) [Group.IsSolvable P] (J : Subgroup A) (hJ : J≤P.comap f.rangeRestrict) : Group.IsSolvable (f.comp J.subtype).range := by let Q := P.map f.range.subtype let e := P.equivMapOfInjective f.range.subtype Subtype.val_injective let : Group.IsSolvable Q := Group.isSolvable_of_surjective (f:=e.toMonoidHom) e.surjective apply solvable_range_of_mem (f.comp J.subtype) Q intro j exact ⟨f.rangeRestrict j.val,hJ j.property,rfl⟩ lemma virtually_solvable_linear_of_rank (K : Type) [Field K] [CharZero K] [Countable K] [IsAlgClosed K] (r : ℕ) : ∀ (V G : Type) [AddCommGroup V] [Module K V] [FiniteDimensional K V] [Group G] [DecidableEq G], finrank K V=r → ∀ (ρ : G →* (V ≃ₗ[K] V)), Injective ρ → ∀ d, SparseGrowth.HasPolynomialDegree G d → ∃ H : Subgroup G, H.FiniteIndex ∧ Group.IsSolvable H := by induction r using Nat.strong_induction_on with | h r ih => intro V G _ _ _ _ _ hr ρ hρ d hg rcases subsingleton_or_nontrivial V with hv | hv · let := hv have hc : ∀ g h : G, g*h=h*g := by intro g h apply hρ exact Subsingleton.elim _ _ let : Group.IsSolvable G := Group.isSolvable_of_comm hc exact ⟨⊤,inferInstance,inferInstance⟩ let := hv by_cases hd : StrongFullSpan ρ · obtain ⟨H,hHi,hH⟩ := hd.virtually_comm_range ρ hg let : Group.IsSolvable (ρ.comp H.subtype).range := Group.isSolvable_of_comm hH have hinj : Injective (ρ.comp H.subtype).rangeRestrict := by intro x y he apply Subtype.ext apply hρ exact congrArg Subtype.val he exact ⟨H,hHi,Group.isSolvable_of_isSolvable_injective hinj⟩ obtain ⟨H,hHi,hH⟩ : ∃ H : Subgroup G, H.FiniteIndex ∧ ¬FullSpan (ρ.comp H.subtype) := by simp only [StrongFullSpan,not_forall] at hd obtain ⟨H,hHi,hH⟩ := hd exact ⟨H,hHi,hH⟩ let := hHi let ρH := ρ.comp H.subtype have hgH := hg.finiteIndex_subgroup H obtain ⟨W,hW0,hW1,hW⟩ := invariant_subspace_of_not_fullSpan ρH hH let σ := subspaceRepresentation ρH W hW let τ := quotientRepresentation ρH W hW have hWrank : finrank K W