Zulip Chat Archive
Stream: Is there code for X?
Topic: Laplacian
Sanjay Verma (Jul 11 2024 at 18:11):
Hey all, I'm pretty new to lean and I am trying to generate some proofs about PDEs by using the sorry tactic for basic assumptions and then working with those. I was wondering if anyone had created any way to express Laplacian in n-dimensions?
Yury G. Kudryashov (Jul 11 2024 at 18:17):
What exactly do you want? Laplacian of a function from docs#EuclideanSpace? From a general finite dimensional inner product space? Something else?
Yury G. Kudryashov (Jul 11 2024 at 18:17):
In first case, you can take the usual sum of second derivatives.
Sanjay Verma (Jul 11 2024 at 18:38):
Yury G. Kudryashov said:
In first case, you can take the usual sum of second derivatives.
Thank you for the response! I meant from EuclideanSpace; sorry would you mind writing down how you would express the usual sum of second derivatives in two dimensions or is there somewhere I can check mine against
Yury G. Kudryashov (Jul 11 2024 at 20:25):
Something like this:
import Mathlib.Analysis.Calculus.LineDeriv.Basic
import Mathlib.Analysis.InnerProductSpace.PiL2
open scoped BigOperators
noncomputable def laplacian {n : Type*} [Fintype n] [DecidableEq n]
{E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
(f : EuclideanSpace ℝ n → E) (x : EuclideanSpace ℝ n) : E :=
∑ i, lineDeriv ℝ (lineDeriv ℝ f · (EuclideanSpace.single i 1)) x (EuclideanSpace.single i 1)
Yury G. Kudryashov (Jul 11 2024 at 20:26):
Note that this won't apply to, e.g., WithLp 2 (Real × Real)
Yury G. Kudryashov (Jul 11 2024 at 20:28):
Or like this:
import Mathlib.Analysis.Calculus.ContDiff.Basic
import Mathlib.Analysis.InnerProductSpace.PiL2
open scoped BigOperators
noncomputable def laplacian {n : Type*} [Fintype n] [DecidableEq n]
{E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
(f : EuclideanSpace ℝ n → E) (x : EuclideanSpace ℝ n) : E :=
∑ i, iteratedFDeriv ℝ 2 f x fun _ ↦ EuclideanSpace.single i 1
Yury G. Kudryashov (Jul 11 2024 at 20:28):
For nice functions these definitions are equal.
Yury G. Kudryashov (Jul 11 2024 at 20:31):
For a general inner product space, you probably want to define the "trace" (or what's the right name?) of a quadratic form (represented as docs#ContinuousMultilinearMap), then apply it to iteratedFDeriv Real 2 f x
Kevin Buzzard (Jul 11 2024 at 22:54):
I know very little about differential equations but perhaps it's true that on a finite dimensional normed real vector space there's an intrinsic notion of the Laplacian which is independent of choice of orthonormal coordinate system. If I'm not talking nonsense, how would one state this? For the proof, first I guess you define it for R^n like above, and then for a general space you can choose an isomorphism with R^n, pull back the definition, and then prove it's independent of the pullback. Do we have all the tools necessary to do this? Apologies if I'm talking nonsense, I just have this vague idea that the Laplacian is intrinsic in some way.
Eric Wieser (Jul 11 2024 at 23:22):
Elsewhere we handle this kind of thing by working with Trunc (Basis ..), where the quotient forces us to prove invariance immediately
Eric Wieser (Jul 11 2024 at 23:22):
Then you use choice to actually pick an arbitrary basis to put in the Trunc
Kevin Buzzard (Jul 11 2024 at 23:24):
Or Squash...
Yury G. Kudryashov (Jul 11 2024 at 23:30):
Indeed, Laplacian (with 2nd definition) is invariant under orthogonal coordinate changes, so the Mathlib way to define it is to
- define it for a basis and a bilinear form as the trace of the corresponding matrix;
- show that it's invariant under orthogonal changes of coordinates;
- define
laplacian fas the laplacian ofiteratedFDeriv Real f xw.r.t. to some orthogonormal basis (usingTrunc,Squash, orClassical.choice).
Sanjay Verma (Jul 12 2024 at 00:50):
So this is what I have for the next step in my proof but I'm getting error with trying to assign n as a Natural number and with the norm. I'm not quite sure what I am doing wrong. Any input is appreciated.
import Mathlib.Analysis.Calculus.LineDeriv.Basic
import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.Analysis.SpecialFunctions.Pow.Deriv
open scoped BigOperators
noncomputable def laplacian {n : Type*} [Fintype n] [DecidableEq n]
{E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
(f : EuclideanSpace ℝ n → E) (x : EuclideanSpace ℝ n) : E :=
∑ i, lineDeriv ℝ (lineDeriv ℝ f · (EuclideanSpace.single i 1)) x (EuclideanSpace.single I 1)
noncomputable def fundamental_solution (n : ℕ) (x : EuclideanSpace ℝ n) : ℝ :=
if h : n ≥ 3 then
let ω_n := 2 * real.pi^(n / 2) / real.gamma (n / 2)
1 / ((n - 2) * ω_n * ∥x∥^(n - 2))
else 0
Yury G. Kudryashov (Jul 12 2024 at 02:30):
It's EuclideanSpace Real (Fin n)
Eric Wieser (Mar 12 2025 at 01:18):
I've created #22861 with @Yury G. Kudryashov's first step above
Yury G. Kudryashov (Mar 12 2025 at 04:01):
I see that there are (at least) 2 competing approaches. I have no preferences. Please tell me when you decide which one you're going to use.
A. (Mar 12 2025 at 07:24):
How about this?
We define the Laplace operator on a Riemannian manifold , with metric , in a way that naturally generalizes the characterizations of the Laplace operator on Euclidean space, given by (1.49), (1.62), and (1.63). Taking (1.62) as fundamental, we define the Laplace operator on to be the second-order differential operator satisfying
for .
p. 153 Taylor Partial Differential Equations I
Eric Wieser (Mar 12 2025 at 10:37):
That doesn't look like a definition to me, but a characterization
Eric Wieser (Mar 12 2025 at 10:38):
Independently of whether we want to define the laplacian via BilinForm.trace; is BilinForm.trace useful / correct in its own right?
Kevin Buzzard (Mar 12 2025 at 12:15):
Eric Wieser said:
That doesn't look like a definition to me, but a characterization
yeah that's IsLaplacian : Prop
A. (Mar 12 2025 at 13:32):
Eric Wieser said:
That doesn't look like a definition to me, but a characterization
Well I'm sorry about that but it is more general.
Kevin Buzzard (Mar 12 2025 at 20:56):
No, it's just different. For example it doesn't rule out the possibility that no such differential operator exists. You may need both things, the construction and the characterisation, in order to make a robust API (see for example docs#Localization and docs#IsLocalization, or docs#TensorProduct and docs#IsTensorProduct etc etc).
A. (Mar 12 2025 at 22:01):
Kevin Buzzard said:
No, it's just different. For example it doesn't rule out the possibility that no such differential operator exists...
This is to explain why Taylor's setup with manifolds is not more general? I'm confused.
Eric Wieser (Mar 12 2025 at 22:06):
Kevin is pointing out that a characterization and a definition are very different things, rather than commenting on any specific characterization or definition
A. (Mar 12 2025 at 22:16):
I’ll follow those links to see if they enlighten me as to the difference. I do see that where one has a constructive proof of existence it’s nice to use that in the definition, but presumably that’s not always the case?
Kevin Buzzard (Mar 13 2025 at 00:13):
It depends on whether you want to say "for all differential operators which satisfy the axiom defining the Laplacian, ..." or whether you want to apply the actual Laplacian to something. Here you don't need IsLaplacian because all Laplacians are equal in lean (in contrast to localisations, which are only isomorphic). So your characterisation falls short of what would be needed -- you still need to write down a definition.
Jz Pan (Mar 13 2025 at 05:41):
But what if there is no constructive proof of existence? This will force us to define IsLaplacian : Prop first, prove that Nonempty ..., and the definition of laplacian have to be Classical.choice ....
Johan Commelin (Mar 13 2025 at 05:57):
Sure. This discussion is orthogonal to the question of being constructive (which at least Kevin doesn't care about at all).
Johan Commelin (Mar 13 2025 at 05:59):
If you say: "I define FooBar to be the Wombat y that satisfies x < y + z", then you need to
- realize that the word "the" in "the Wombat" is doing some heavy lifting
- certainly you need to show that such a
yexists... because maybe{y : Wombat | x < y + z}is empty! - preferably show that
yis unique, otherwise "the Wombat" is a bit misleading
A. (Mar 13 2025 at 07:09):
Johan Commelin said:
Sure. This discussion is orthogonal to the question of being constructive (which at least Kevin doesn't care about at all).
I brought up constructiveness so if, as it seems, the purpose of this discussion is to educate @A. then it is relevant.
A. (Mar 13 2025 at 07:25):
To be clear, I never wished to claim that the snippet I copied contains all the maths required. There are many pages in that book both before and after, and two subsequent volumes.
Bennett Chow (Oct 01 2025 at 12:13):
Does it make sense to first define the Laplacian acting on functions on a Riemannian manifold ? Assuming that we can define tensor fields on manifolds, Levi-Civita connection, covariant differentiation of tensors, and curvatures --- Riemann, Ricci, and scalar --- one of the first things in Ricci flow could be to derive the heat-type equation for the scalar curvature . Just a thought for a future direction for stuff related to the Laplacian on manifolds from the geometric flows point of view.
Michael Rothgang (Oct 01 2025 at 17:36):
We have docs#InnerProductSpace.laplacianWithin and docs#InnerProductSpace.laplacian now. We almost surely don't have the Laplacian on a Riemannian manifold yet.
Antoine Chambert-Loir (Oct 02 2025 at 06:18):
In the context of Taylor's book, the given characterization also gives a definition, once you can take all possible . But it would probably be easier here to split the definition into the definition of the two differential operators div and grad. The first one maps a -function to a -vector field and is defined by taking the differential of and using the Riemann tensor to convert it to a vector field. The second one maps a -vector field to a function, and passes via the Lie derivative of the canonical volume form.
Antoine Chambert-Loir (Oct 02 2025 at 06:30):
Even if one works on the standard , maybe with a (nonconstant) Riemannian metric, @Heather Macbeth keeps telling me that for mathlib, it will be valuable to do PDE in a coordinate free way.
Moritz Doll (Oct 02 2025 at 09:29):
I would think that the Laplacian on forms should be the main definition (for functions one term vanishes and the other one is exactly div grad). Obviously geometric differential operators should be defined invariantly, but I am sceptical that we will avoid coordinates completely (or some way of decomposing parts of manifolds that is basically identical to using local coordinates)
Moritz Doll (Oct 02 2025 at 09:43):
The more crucial question is what is the correct domain. While C^2 looks reasonable, it is bad from both a functional analysis point of view and also if you care about regularity theory. The most general domain would be distributions, and if you want to solve constant coefficient PDEs and not do partitions of unity, then tempered distributions is the right choice.
I don't know what the state of distributions is, but tempered distributions is a (wip) PR and I am working on getting all the fancy things to prove regularity for
Filippo A. E. Nuccio (Oct 02 2025 at 14:05):
@Anatole Dedecker might have something to say about distributions
Michael Rothgang (Oct 03 2025 at 09:06):
My understanding is that the definition of distributions is done (by Anatole and @Luigi Massacci, and will be PRed to mathlib very soon).
Luigi Massacci (Oct 03 2025 at 12:50):
Yes, pinky promise you'll have like 18 PRs to review by Monday. I'm nearly done splitting up the code in manageable bits and adding all the various docstrings, etc
Antoine Chambert-Loir (Oct 03 2025 at 13:03):
About the domain, I don't exactly agree, or I would say that the question of the naïve laplacian (on ) functions is an existing object that is not exactly defined by its version on -functions, nor by its version on the Sobolev space , nor by its version on distributions. Moreover, the functional analysis point of view has to take into account the subtle question of the closure of those naïve operators (defined on a dense) subspace. So to summary, the definition of the naïve operators will be a prerequisite for all these interesting works.
Anatole Dedecker (Oct 03 2025 at 15:03):
I agree with Antoine: we will need the laplacian in any case, so one might as well start here.
Anatole Dedecker (Oct 03 2025 at 17:56):
I actually think that we will be able to define the Laplacian on distributions without talking about coordinates. The plan is to define F-valued distributions as the continuous linear maps from scalar-valued test-functions to F (this way, the Schwartz kernel theorem says that you can curryfy distributions). Then, one can define the differential of an F-valued distribution on (an open subset of) E (finite dimensional) as a E →L[𝕜] F-valued distribution. Iterating this process and taking the trace with respect to an inner product on E (this has yet to be defined I think), one gets the Laplacian.
Moritz Doll (Oct 03 2025 at 20:36):
I would think that you can just define a transpose operator that takes a bounded linear map on test functions and spits out a bounded linear map on distributions, that should be practically the same as what you described, but makes all of the proofs trivial. This is what I did for tempered distributions and it works very well.
Moritz Doll (Oct 03 2025 at 20:47):
The PR for tempered distributions is mathlib4#29819 (very wip, but the main step in how to define distributions is there)
Anatole Dedecker (Oct 04 2025 at 14:16):
Of course you can just define the distributional laplacians as the transpose of the one acting on test functions :man_facepalming: For some reason it seemed way more natural to me to define it in terms of the differentiation operator on distributions.
I guess one thing is that my approach would yield the fact that the distributional laplacian coincides with the usual one immediately from the corresponding fact on differentiation, while with your approach it requires proving before that the Laplacian is formally self adjoint, but none of this is very hard.
Anatole Dedecker (Oct 04 2025 at 14:20):
Moritz Doll said:
I would think that you can just define a transpose operator that takes a bounded linear map on test functions and spits out a bounded linear map on distributions, that should be practically the same as what you described, but makes all of the proofs trivial. This is what I did for tempered distributions and it works very well.
Yes, of course the idea is to use docs#ContinuousLinearMap.precomp as much as possible! Note that for the (coordinate free, but vector-valued) differentiation of distributions, one needs a very slight extra argument because the target space changes, but this is still essentially trivial
Moritz Doll (Oct 04 2025 at 15:17):
Ah cool, I didn't know that precomp exists without normed spaces. I agree all of these approaches are essentially equivalent and I can't imagine one is significantly better than another.
A. (Oct 05 2025 at 10:30):
Antoine Chambert-Loir said:
In the context of Taylor's book, the given characterization also gives a definition, once you can take all possible .
Thanks for saying so. I thought I was going mad when everyone piled in to tell me otherwise.
Last updated: Dec 20 2025 at 21:32 UTC