mathlib4 review helperopen PRs by @themathqueen on leanprover-community/mathlib4

← queue

#32497 chore: make FiniteDimensional.complete π•œ an instance when π•œ is RCLike

merge-conflict t-analysis awaiting-bench draft CI success merge conflict

+3 βˆ’26 Β· 2 files Β· 3 commits Β· head a12292e Β· updated 190 days ago Β· Files changed on GitHub

In plain words

Makes "a finite-dimensional inner product space over or is complete" an instance, so CompleteSpace E no longer has to be introduced by hand with haveI := FiniteDimensional.complete π•œ E. With the instance available, the PR deletes those local haves from statements and proofs about the adjoint of linear maps between finite-dimensional inner product spaces (LinearMap.adjoint and its API) and from LinearMap.IsPositive.conj_adjoint.

Transcriptions are drafted with an LLM from the diff and are a reading aid, not a verified statement: the Lean code is the reference.

PR description

![Open in Gitpod](gitpod.io/from-referrer/)

Conversation on GitHub 4
github-actions[bot] Β· comment Β· 2025-12-06
PR summary 9fdb8ee77b
Import changes for modified files

No significant changes to the import graph

<details><summary>Import changes for all files</summary>

|Files|Import difference| |-|-|

</details>


Declarations diff

+ instance _root_.InnerProductSpace.completeSpaceOfFiniteDimensional [FiniteDimensional π•œ E] : <details> <summary>You can run this locally as follows</summary>

## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

</details>

The doc-module for script/declarations_diff.sh contains some details about this script.


<details><summary>No changes to technical debt.</summary>

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

</details>

themathqueen Β· comment Β· 2025-12-06

!bench

leanprover-radar Β· comment Β· 2025-12-06

Benchmark results for df732760d2f2bf7bd1acb013b972699842c68797 against ee728d5a73a3a557f840ef64fa3abb6a20cd3ac0 are in! @themathqueen <details open> <summary>Minor changes (2)</summary>

  • πŸŸ₯ build/module/Mathlib.Analysis.CStarAlgebra.Matrix//instructions: +5.1G (+2.3%)
  • πŸŸ₯ build/module/Mathlib.Analysis.InnerProductSpace.Adjoint//instructions: +6.6G (+2.4%) from estimate, -794.7M (-0.3%) from previous value

</details>

mathlib-merge-conflicts[bot] Β· comment Β· 2026-05-29

This pull request has conflicts, please merge master and resolve them.

Mathlib/Analysis/InnerProductSpace/Adjoint.lean +3 βˆ’24

theorem orthogonal_range (T : E β†’L[π•œ] F) :
191 rw [← (LinearMap.ker (T†)).orthogonal_orthogonal, (T†).orthogonal_ker]
192 simp
instance _root_.InnerProductSpace.completeSpaceOfFiniteDimensional newL194–195
194instance _root_.InnerProductSpace.completeSpaceOfFiniteDimensional [FiniteDimensional π•œ E] :
195 CompleteSpace E := FiniteDimensional.complete π•œ E
197omit [CompleteSpace E] in
theorem ker_le_ker_iff_range_le_range changedL198–204
198theorem ker_le_ker_iff_range_le_range [FiniteDimensional π•œ E] {T U : E β†’L[π•œ] E}
199 (hT : T.IsSymmetric) (hU : U.IsSymmetric) :
200 LinearMap.ker U ≀ LinearMap.ker T ↔ LinearMap.range T ≀ LinearMap.range U := by
201 refine ⟨fun h ↦ ?_, LinearMap.ker_le_ker_of_range hT hU⟩
βˆ’ have := FiniteDimensional.complete π•œ E
202 simpa [orthogonal_ker, hT, hU] using Submodule.orthogonal_le h
204/-- `E β†’L[π•œ] E` is a star algebra with the adjoint as the star operation. -/
variable [FiniteDimensional π•œ E] [FiniteDimensional π•œ F] [FiniteDimensiona
def adjoint changedL459–464
459/-- The adjoint of an operator from the finite-dimensional inner product space `E` to the
460finite-dimensional inner product space `F`. -/
461def adjoint : (E β†’β‚—[π•œ] F) ≃ₗ⋆[π•œ] F β†’β‚—[π•œ] E :=
βˆ’ haveI := FiniteDimensional.complete π•œ E
βˆ’ haveI := FiniteDimensional.complete π•œ F
βˆ’ /- Note: Instead of the two instances above, the following works:
βˆ’ ```
βˆ’ haveI := FiniteDimensional.complete π•œ
βˆ’ haveI := FiniteDimensional.complete π•œ
βˆ’ ```
βˆ’ But removing one of the `have`s makes it fail. The reason is that `E` and `F` don't live
βˆ’ in the same universe, so the first `have` can no longer be used for `F` after its universe
βˆ’ metavariable has been assigned to that of `E`!
βˆ’ -/
462 ((LinearMap.toContinuousLinearMap : (E β†’β‚—[π•œ] F) ≃ₗ[π•œ] E β†’L[π•œ] F).trans
463 ContinuousLinearMap.adjoint.toLinearEquiv).trans
464 LinearMap.toContinuousLinearMap.symm
theorem adjoint_toContinuousLinearMap changedL466–468
466theorem adjoint_toContinuousLinearMap (A : E β†’β‚—[π•œ] F) :
βˆ’ haveI := FiniteDimensional.complete π•œ E
βˆ’ haveI := FiniteDimensional.complete π•œ F
467 A.adjoint.toContinuousLinearMap = A.toContinuousLinearMap.adjoint :=
468 rfl
theorem adjoint_eq_toCLM_adjoint changedL470–472
470theorem adjoint_eq_toCLM_adjoint (A : E β†’β‚—[π•œ] F) :
βˆ’ haveI := FiniteDimensional.complete π•œ E
βˆ’ haveI := FiniteDimensional.complete π•œ F
471 A.adjoint = A.toContinuousLinearMap.adjoint :=
472 rfl
theorem adjoint_inner_left changedL474–477
474/-- The fundamental property of the adjoint. -/
475theorem adjoint_inner_left (A : E β†’β‚—[π•œ] F) (x : E) (y : F) : βŸͺadjoint A y, x⟫ = βŸͺy, A x⟫ := by
βˆ’ have := FiniteDimensional.complete π•œ E
βˆ’ have := FiniteDimensional.complete π•œ F
476 rw [← coe_toContinuousLinearMap A, adjoint_eq_toCLM_adjoint]
477 exact ContinuousLinearMap.adjoint_inner_left _ x y
theorem adjoint_inner_right changedL479–482
479/-- The fundamental property of the adjoint. -/
480theorem adjoint_inner_right (A : E β†’β‚—[π•œ] F) (x : E) (y : F) : βŸͺx, adjoint A y⟫ = βŸͺA x, y⟫ := by
βˆ’ have := FiniteDimensional.complete π•œ E
βˆ’ have := FiniteDimensional.complete π•œ F
481 rw [← coe_toContinuousLinearMap A, adjoint_eq_toCLM_adjoint]
482 exact ContinuousLinearMap.adjoint_inner_right _ x y
theorem im_inner_adjoint_mul_self_eq_zero (T : E β†’β‚—[π•œ] E) (x : E) :
585 norm_cast
theorem isSelfAdjoint_toContinuousLinearMap_iff changedL587–590
587theorem isSelfAdjoint_toContinuousLinearMap_iff (T : E β†’β‚—[π•œ] E) :
βˆ’ have := FiniteDimensional.complete π•œ E
588 IsSelfAdjoint T.toContinuousLinearMap ↔ IsSelfAdjoint T := by
589 simp [IsSelfAdjoint, star, adjoint,
590 ContinuousLinearMap.toLinearMap_eq_iff_eq_toContinuousLinearMap]
theorem _root_.ContinuousLinearMap.isSelfAdjoint_toLinearMap_iff changedL592–597
592theorem _root_.ContinuousLinearMap.isSelfAdjoint_toLinearMap_iff (T : E β†’L[π•œ] E) :
βˆ’ have := FiniteDimensional.complete π•œ E
593 IsSelfAdjoint T.toLinearMap ↔ IsSelfAdjoint T := by
594 simp only [IsSelfAdjoint, star, adjoint, LinearEquiv.trans_apply,
595 coe_toContinuousLinearMap_symm,
596 ContinuousLinearMap.toLinearMap_eq_iff_eq_toContinuousLinearMap]
597 rfl
theorem isStarProjection_toContinuousLinearMap_iff changedL599–602
599theorem isStarProjection_toContinuousLinearMap_iff {T : E β†’β‚—[π•œ] E} :
βˆ’ have := FiniteDimensional.complete π•œ E
600 IsStarProjection (toContinuousLinearMap T) ↔ IsStarProjection T := by
601 simp [isStarProjection_iff, isSelfAdjoint_toContinuousLinearMap_iff,
602 ← ContinuousLinearMap.isIdempotentElem_toLinearMap_iff]
open LinearMap in
theorem IsStarProjection.ext_iff changedL611–616
611theorem IsStarProjection.ext_iff {S T : E β†’β‚—[π•œ] E}
612 (hS : IsStarProjection S) (hT : IsStarProjection T) :
613 S = T ↔ LinearMap.range S = LinearMap.range T := by
βˆ’ have := FiniteDimensional.complete π•œ E
614 simpa using ContinuousLinearMap.IsStarProjection.ext_iff
615 (S.isStarProjection_toContinuousLinearMap_iff.mpr hS)
616 (T.isStarProjection_toContinuousLinearMap_iff.mpr hT)

Mathlib/Analysis/InnerProductSpace/Positive.lean +0 βˆ’2

variable [FiniteDimensional π•œ E] [FiniteDimensional π•œ F]
theorem _root_.LinearMap.IsPositive.conj_adjoint changedL367–371
367@[aesop safe apply]
368theorem _root_.LinearMap.IsPositive.conj_adjoint {T : E β†’β‚—[π•œ] E}
369 (hT : T.IsPositive) (S : E β†’β‚—[π•œ] F) : (S βˆ˜β‚— T βˆ˜β‚— S.adjoint).IsPositive := by
βˆ’ have := FiniteDimensional.complete π•œ E
βˆ’ have := FiniteDimensional.complete π•œ F
370 simpa [← isPositive_toContinuousLinearMap_iff] using
371 ((T.isPositive_toContinuousLinearMap_iff.mpr hT).conj_adjoint S.toContinuousLinearMap)
0/12 declarations checked

Your review, as Markdown

Paste it as a comment or a review on the PR. Line links to the head commit unfold into code snippets on GitHub.