Skip to content

feat: homogenization increases (finite) dimension by one - #107

Open
vlad902 wants to merge 2 commits into
ooovi:mainfrom
Workshop-Polyhedra-In-Lean:findim-affinespan-homogenize
Open

vlad902 wants to merge 2 commits into
ooovi:mainfrom
Workshop-Polyhedra-In-Lean:findim-affinespan-homogenize

Conversation

@vlad902

@vlad902 vlad902 commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

finDim_affineSpan_eq_pred_finrank_homogenize is the ingredient I need in the next PR (#108) adding grading of the polytope face lattice by dimension of the affine span of the face.

`finDim_affineSpan_eq_pred_finrank_homogenize` is the ingredient I need
in the next PR adding grading of the polytope face lattice by dimension
of the affine span of the face.
@@ -0,0 +1,62 @@
/-

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This file and the one below are leanprover-community/mathlib4#43910

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

@martinwintermath martinwintermath Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should first define FiniteDimensional on affine spaces directly. Going via the vector span is a hack.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Isn't it just defining an affine version of FiniteDimensional in the same way as you just defined range for AffineMap by copying LinearMap.range?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

@martinwintermath martinwintermath Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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?

@martinwintermath martinwintermath Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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 Module.Finite and PointedCone.FinRank.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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

@vlad902 vlad902 Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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 vectorSpan, maybe it should be defined using FinDim (affineSpan R s).direction instead to match?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These are good points. Let's continue discussing over there.

Comment on lines +178 to +181
theorem finDim_affineSpan_homogenize
(K : ConvexSet R A) [Module.Finite R (vectorSpan R (K : Set A))] :
(affineSpan R (homogenize W K : Set W)).finDim =
Order.succ (affineSpan R (K : Set A)).finDim := by

@martinwintermath martinwintermath Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Something feels off here. We are we taking an affine span on the linear side. Should't we take the linear span and its rank? And also, we should (and probably already have) a notion of rank for a cone, and don't need to go via span.

And maybe we should have a notion dimension for sets (or at least convex sets) rather than needing to go via affineSpan.

@vlad902 vlad902 Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fair point, I've update the PR to use PointedCone.finrank here instead. We have a rank/finrank defined for arbitrary Set (Polyhedral/Mathlib/LinearAlgebra/AffineSpace/Defs.lean) which I think is the wrong definition for mathlib, but moving this definition for ConvexSet seems reasonable. Shall I make redefining it and adding some basic API a precursor change to this one?

@martinwintermath martinwintermath Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@ooovi is currently removing bundled ConvexSet (at least all its uses for now). The fundamental object on the affine side will be Set. Why do you think this is wrong for mathlib?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it's wrong unless we have a different name or assumptions for it, otherwise the graph of y = x^2 in ℝ^2 has dimension 2

@martinwintermath martinwintermath Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That would be intentional (at least from my side). It is (or should be) called Affine.dim as opposed to Manifold.dim or so. There can be several notions of dimension.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think Affine.dim would be fine, just not Set.rank/Set.finrank as it is now.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Oh yeah, Set.rank/Set.finrank would be bad.

Comment thread Polyhedral/Mathlib/Geometry/Convex/Cone/Pointed/Rank.lean
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.

3 participants