Repository navigation
feat: homogenization increases (finite) dimension by one #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /- | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file and the one below are leanprover-community/mathlib4#43910 |
||
| Copyright (c) 2026 Vlad Tsyrklevich. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Vlad Tsyrklevich | ||
| -/ | ||
| module | ||
|
|
||
| public import Mathlib.LinearAlgebra.AffineSpace.Dimension | ||
| public import Mathlib.LinearAlgebra.AffineSpace.FiniteDimensional | ||
|
|
||
| /-! Finite-dimensional affine space lemmas -/ | ||
|
|
||
| @[expose] public section | ||
|
|
||
| open Affine | ||
|
|
||
| section AffineSpace' | ||
|
|
||
| variable (k : Type*) {V : Type*} {P : Type*} | ||
|
|
||
| open AffineSubspace Module | ||
|
|
||
| variable [DivisionRing k] [AddCommGroup V] [Module k V] [AffineSpace V P] | ||
|
|
||
| variable {k} | ||
|
|
||
| theorem AffineIndepOn.ncard_eq_succ_finDim_affineSpan {s : Set P} (hai : AffineIndepOn k id s) | ||
| [hf : FiniteDimensional k (vectorSpan k s)] : s.ncard = (affineSpan k s).finDim.succ := by | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should first define
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a bigger mathlib refactor than just this change, as it stands this is the canonical way to spell it.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't it just defining an affine version of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it depends, do you expect this to be a def or an abbrev? Either way, the difference is that this file upstream already uses this pattern, as do others, so it would make more sense to do a targetted refactor rather then try to fix it here.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I am not happy that it got to mathlib in this form. To some degree I am okay with leaving it with the hack here if we are really sure we get rid of it sometime soon (we should add plenty comments to highlight that this is temporary). On the other hand, looking into your other PR, this seems to have further implications for how we write lemmas, and we should not let this get out of hand.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't this force us to require that the ambient space is finite dimensional rather than just the subspace we are looking at?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you use it, yes. You don't have to use it :P You should use a "the set is finite dim" variant. This is the distinction between
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now the (draft) PR contains Affine.FinDim for sets. What are your thoughts. Will this work? Codex actually implemented some of your lemmas to demonstrate that it works :D
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The definition seems fine, it's an abbrev which I think is good. There's a lot of unnecessary copy-and-paste slop that is hard to wade through. I'm not sure why the use of this typeclass was changed from a typeclass parameter to an explicit hypothesis and another thing I find odd is that AffineSubspace.FinDim is defined using AffineSubspace.direction but Affine.FinDim is defined using
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are good points. Let's continue discussing over there. |
||
| rcases Set.eq_empty_or_nonempty s with rfl | hs | ||
| · simp | ||
| rw [← Subtype.range_coe (s := s)] at hf | ||
| have := finiteDimensional_iff_setFinite k hai |>.mp hf | ||
| have := hai.finrank_vectorSpan this hs | ||
| rw [finDim_eq_finrank (by simp [Set.nonempty_iff_ne_empty.mp hs]), direction_affineSpan, | ||
| WithBot.succ_natCast, this] | ||
| grind only [Set.ncard_eq_zero, Set.not_nonempty_empty] | ||
|
|
||
| theorem AffineIndependent.ncard_eq_succ_finDim_affineSpan {s : Set P} | ||
| (hai : AffineIndependent k ((↑) : s → P)) [hf : FiniteDimensional k (vectorSpan k s)] : | ||
| s.ncard = (affineSpan k s).finDim.succ := | ||
| AffineIndepOn.ncard_eq_succ_finDim_affineSpan ((affineIndependent_subtype_iff _).mp hai) | ||
|
|
||
| variable (k) | ||
|
|
||
| variable (V) in | ||
| theorem exists_affineIndependent_of_finiteDimensional (s : Set P) | ||
| [F : FiniteDimensional k (vectorSpan k s)] : | ||
| ∃ t ⊆ s, affineSpan k t = affineSpan k s ∧ AffineIndependent k ((↑) : t → P) ∧ | ||
| t.ncard = (affineSpan k s).finDim.succ := by | ||
| obtain ⟨t, ht₁, ht₂, ht₃⟩ := exists_affineIndependent k V s | ||
| refine ⟨t, ht₁, ht₂, ht₃, ?_⟩ | ||
| rw [← direction_affineSpan, ← ht₂, direction_affineSpan] at F | ||
| exact ht₂ ▸ ht₃.ncard_eq_succ_finDim_affineSpan | ||
|
|
||
| variable (V) in | ||
| theorem exists_affineIndepOn_of_finiteDimensional (s : Set P) | ||
| [F : FiniteDimensional k (vectorSpan k s)] : | ||
| ∃ t ⊆ s, affineSpan k t = affineSpan k s ∧ AffineIndepOn k id t ∧ | ||
| t.ncard = (affineSpan k s).finDim.succ := | ||
| exists_affineIndependent_of_finiteDimensional k V s | ||
|
|
||
| end AffineSpace' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /- | ||
| Copyright (c) 2026 Vlad Tsyrklevich. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Vlad Tsyrklevich | ||
| -/ | ||
| module | ||
|
|
||
| public import Mathlib.LinearAlgebra.AffineSpace.Independent | ||
|
|
||
| /-! Affine independence lemmas -/ | ||
|
|
||
| @[expose] public section | ||
|
|
||
| open Affine | ||
|
|
||
| section DivisionRing | ||
|
|
||
| variable (k : Type*) (V : Type*) {P : Type*} [DivisionRing k] [AddCommGroup V] [Module k V] | ||
| variable [AffineSpace V P] | ||
|
|
||
| theorem exists_affineIndepOn (s : Set P) : | ||
| ∃ t ⊆ s, affineSpan k t = affineSpan k s ∧ AffineIndepOn k id t := | ||
| exists_affineIndependent k V s | ||
|
|
||
| end DivisionRing |
Uh oh!
There was an error while loading. Please reload this page.