Skip to content

Add FiniteDimensional for affine subspaces - #111

Draft
martinwintermath wants to merge 6 commits into
mainfrom
affine-finiteDimensional
Draft

martinwintermath wants to merge 6 commits into
mainfrom
affine-finiteDimensional

Conversation

@martinwintermath

Copy link
Copy Markdown
Collaborator

No description provided.

Comment on lines +36 to +37
unfold Affine.FinDim
rw [vectorSpan_convexHull]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the sort of lemmas that should be proved by simping away the new definition. I advise you use this proof as much as possible to make sure that we have all the required simp lemmas:

Suggested change
unfold Affine.FinDim
rw [vectorSpan_convexHull]
simp [Affine.FinDim]

unfold Affine.FinDim
rw [vectorSpan_convexHull]

theorem _root_.Affine.FinDim.convexHull {s : Set A} (hs : Affine.FinDim R s) :

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
theorem _root_.Affine.FinDim.convexHull {s : Set A} (hs : Affine.FinDim R s) :
protected theorem _root_.Affine.FinDim.convexHull {s : Set A} (hs : Affine.FinDim R s) :

theorem finiteDimensional_iff_affineSpace (s : AffineSubspace K P) [Nonempty s] :
s.FinDim ↔ AffineSpace.FiniteDimensional K s := Iff.rfl

theorem dim_eq_affine_dim (s : AffineSubspace K P) [Nonempty s] :

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
theorem dim_eq_affine_dim (s : AffineSubspace K P) [Nonempty s] :
theorem dim_eq_affineSpaceDim (s : AffineSubspace K P) [Nonempty s] :

Same below

Comment on lines +60 to +61
theorem finiteDimensional_top_iff :
(⊤ : AffineSubspace K P).FinDim ↔ _root_.FiniteDimensional K V := by

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
theorem finiteDimensional_top_iff :
(⊤ : AffineSubspace K P).FinDim ↔ _root_.FiniteDimensional K V := by
theorem finDim_top_iff :
(⊤ : AffineSubspace K P).FinDim ↔ _root_.FiniteDimensional K V := by

Comment on lines +157 to +158
theorem finiteDimensional_iff_of_equiv (e : P ≃ᵃ[K] Q) :
FiniteDimensional K P ↔ FiniteDimensional K Q := by

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
theorem finiteDimensional_iff_of_equiv (e : P ≃ᵃ[K] Q) :
FiniteDimensional K P ↔ FiniteDimensional K Q := by
theorem finiteDimensional_congr (e : P ≃ᵃ[K] Q) :
FiniteDimensional K P ↔ FiniteDimensional K Q := by

let := h
exact FiniteDimensional.of_equiv e.symm

theorem finDim_eq_of_equiv (e : P ≃ᵃ[K] Q) : finDim K P = finDim K Q :=

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
theorem finDim_eq_of_equiv (e : P ≃ᵃ[K] Q) : finDim K P = finDim K Q :=
theorem finDim_congr (e : P ≃ᵃ[K] Q) : finDim K P = finDim K Q :=

@martinwintermath
martinwintermath marked this pull request as draft October 1, 2026 21:16
@martinwintermath

martinwintermath commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator Author

@YaelDillies Your are fast! Sorry, this PR is 100% AI generated and not even read by me in detail. I was just a proof of concept to show @vlad902 what I have in mind. Still something I hope to go for. Feedback still welcome of course! But I worry there will be too many improvements at this point 😄 .

@YaelDillies

Copy link
Copy Markdown
Contributor

I am a compulsive reviewer, sorry 😁

@martinwintermath

martinwintermath commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

@vlad902

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

Can you say were exactly?
Do you mean this?:

theorem _root_.Affine.FinDim.convexHull {s : Set A} (hs : Affine.FinDim R s)

Why should it be a typeclass argument?

and another thing I find odd is that AffineSubspace.FinDim is defined using AffineSubspace.direction but Affine.FinDim is defined using vectorSpan, maybe it should be defined using FinDim (affineSpan R s).direction instead to match?

I was also wondering whether there should be both FinDim for sets and affine subspaces. I tend to say yes. The next question is how similar they should be. For example, is there a good reason to have them similar e.g. because of defeq? Otherwise implementation convenience might point the other way.

And did you mean Affine.FinDim can be FinDim (affineSpan R s) (without .directions).

@martinwintermath

martinwintermath commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

My goal is to discuss what of this AI generated code we want in principle, and then I (or someone else, who is quicker) can make this into a proper PR. My understanding is that we want all three of these:

  • a definition Affine.FinDim for sets
  • a definition AffineSubspace.FinDim for affine subspaces
  • a class AffineSpace.FiniteDimensional for affine spaces

Yes, this causes duplication of API, but I see no way this can currently be handled otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants