/- Copyright 2026 The Formal Conjectures Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -/ module public import Mathlib@[expose] public sectionnoncomputable def maxCosetDim (K V : Type*) [DivisionRing K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] (A : Set V) : := sSup { Module.finrank K S.direction | (S : AffineSubspace K V) (_h : (S : Set V) A) }open scoped Pointwise

The maximum coset dimension in the entire vector space $V$ is exactly the dimension of $V$.

All goals completed! 🐙

The maximum coset dimension in the empty set $\emptyset$ is $0$.

All goals completed! 🐙

If $A \subseteq B$, then the maximum coset dimension achievable in $A$ cannot exceed the maximum coset dimension achievable in $B$.

theorem maxCosetDim_mono (K V : Type*) [DivisionRing K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] {A B : Set V} (h : A B) : maxCosetDim K V A maxCosetDim K V B := K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VA:Set VB:Set Vh:A BmaxCosetDim K V A maxCosetDim K V B K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VA:Set VB:Set Vh:A BsSup {x | S, (_ : S A), Module.finrank K S.direction = x} sSup {x | S, (_ : S B), Module.finrank K S.direction = x} -- We show that any dimension achievable in A is bounded by the supremum in B K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VA:Set VB:Set Vh:A B{x | S, (_ : S A), Module.finrank K S.direction = x}.NonemptyK:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VA:Set VB:Set Vh:A B b {x | S, (_ : S A), Module.finrank K S.direction = x}, b sSup {x | S, (_ : S B), Module.finrank K S.direction = x} K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VA:Set VB:Set Vh:A B{x | S, (_ : S A), Module.finrank K S.direction = x}.Nonempty K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VA:Set VB:Set Vh:A B0 {x | S, (_ : S A), Module.finrank K S.direction = x} K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VA:Set VB:Set Vh:A B (_ : A), Module.finrank K .direction = 0 All goals completed! 🐙 K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VA:Set VB:Set Vh:A B b {x | S, (_ : S A), Module.finrank K S.direction = x}, b sSup {x | S, (_ : S B), Module.finrank K S.direction = x} K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VA:Set VB:Set Vh:A BS:AffineSubspace K VhS:S AModule.finrank K S.direction sSup {x | S, (_ : S B), Module.finrank K S.direction = x} K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VA:Set VB:Set Vh:A BS:AffineSubspace K VhS:S ABddAbove {x | S, (_ : S B), Module.finrank K S.direction = x}K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VA:Set VB:Set Vh:A BS:AffineSubspace K VhS:S AModule.finrank K S.direction {x | S, (_ : S B), Module.finrank K S.direction = x} K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VA:Set VB:Set Vh:A BS:AffineSubspace K VhS:S ABddAbove {x | S, (_ : S B), Module.finrank K S.direction = x} -- Prove the set of dimensions in B is bounded above K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VA:Set VB:Set Vh:A BS:AffineSubspace K VhS:S AModule.finrank K V upperBounds {x | S, (_ : S B), Module.finrank K S.direction = x} K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VA:Set VB:Set Vh:A BS:AffineSubspace K VhS:S AS':AffineSubspace K Vw✝:S' BModule.finrank K S'.direction Module.finrank K V All goals completed! 🐙 K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VA:Set VB:Set Vh:A BS:AffineSubspace K VhS:S AModule.finrank K S.direction {x | S, (_ : S B), Module.finrank K S.direction = x} -- The witness S in A is also a witness in B K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VA:Set VB:Set Vh:A BS:AffineSubspace K VhS:S A (_ : S B), Module.finrank K S.direction = Module.finrank K S.direction All goals completed! 🐙

If the target set $A$ is already an affine subspace, the function returns exactly the rank of its direction.

theorem maxCosetDim_affineSubspace (K V : Type*) [DivisionRing K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] (S : AffineSubspace K V) : maxCosetDim K V (S : Set V) = Module.finrank K S.direction := K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K VmaxCosetDim K V S = Module.finrank K S.direction K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K VsSup {x | S_1, (_ : S_1 S), Module.finrank K S_1.direction = x} = Module.finrank K S.direction K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K VsSup {x | S_1, (_ : S_1 S), Module.finrank K S_1.direction = x} Module.finrank K S.directionK:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K VModule.finrank K S.direction sSup {x | S_1, (_ : S_1 S), Module.finrank K S_1.direction = x} K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K VsSup {x | S_1, (_ : S_1 S), Module.finrank K S_1.direction = x} Module.finrank K S.direction K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K V{x | S_1, (_ : S_1 S), Module.finrank K S_1.direction = x}.NonemptyK:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K V b {x | S_1, (_ : S_1 S), Module.finrank K S_1.direction = x}, b Module.finrank K S.direction K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K V{x | S_1, (_ : S_1 S), Module.finrank K S_1.direction = x}.Nonempty K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K V0 {x | S_1, (_ : S_1 S), Module.finrank K S_1.direction = x} K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K V (_ : S), Module.finrank K .direction = 0 All goals completed! 🐙 K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K V b {x | S_1, (_ : S_1 S), Module.finrank K S_1.direction = x}, b Module.finrank K S.direction K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K VS':AffineSubspace K VhS':S' SModule.finrank K S'.direction Module.finrank K S.direction All goals completed! 🐙 K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K VModule.finrank K S.direction sSup {x | S_1, (_ : S_1 S), Module.finrank K S_1.direction = x} K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K VBddAbove {x | S_1, (_ : S_1 S), Module.finrank K S_1.direction = x}K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K VModule.finrank K S.direction {x | S_1, (_ : S_1 S), Module.finrank K S_1.direction = x} K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K VBddAbove {x | S_1, (_ : S_1 S), Module.finrank K S_1.direction = x} K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K VModule.finrank K V upperBounds {x | S_1, (_ : S_1 S), Module.finrank K S_1.direction = x} K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K VS':AffineSubspace K Vw✝:S' SModule.finrank K S'.direction Module.finrank K V All goals completed! 🐙 K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K VS:AffineSubspace K VModule.finrank K S.direction {x | S_1, (_ : S_1 S), Module.finrank K S_1.direction = x} All goals completed! 🐙

Similar to the empty set, a set containing exactly one vector should yield a maximum dimension of 0.

All goals completed! 🐙All goals completed! 🐙

Translating a set by a vector does not change its maximum coset dimension.

K:Type u_1V:Type u_2inst✝³:DivisionRing Kinst✝²:AddCommGroup Vinst✝¹:Module K Vinst✝:FiniteDimensional K Vv:VA:Set Vh:maxCosetDim K V A maxCosetDim K V (v +ᵥ A)h_cancel:-v +ᵥ v +ᵥ A = AmaxCosetDim K V A maxCosetDim K V (v +ᵥ A) All goals completed! 🐙