Zulip Chat Archive
Stream: Lean Together 2024
Topic: CvxLean: modeling convex optimization problems in Lean
Andrés Goens (Jan 12 2024 at 17:19):
@Ramon Fernández Mir is there a fundamental reason why you don't do the change of variables in the equality saturation part as a rewrite?
Ramon Fernández Mir (Jan 12 2024 at 17:27):
That is a great question!! I tried to do that initially.
If you do it naively by adding a rule that merges and , then you have an issue when analyzing curvatures because the same e-class could have , and . I assume that terms represented by the same e-class only have one known curvature (e-classes will have nodes that are a mixture of {DCP unknown, DCP convex} or {DCP unknown, DCP concave} or {DCP unknown, DCP affine}). Or, in other words, rewrites preserve the "mathematical" curvature of expressions.
I think it might be possible to make egg explore changes of variables, but it is not straightforward because they are a problem-level transformation, so it cannot be done locally by replacing var nodes.
Ramon Fernández Mir (Jan 12 2024 at 17:28):
It was also a bit of a design decision, where I wanted to split what the user does and what egg can do more clearly. But if we could use egg to discover changes of variables, that would be very cool, especially for more complicated ones.
Andrés Goens (Jan 12 2024 at 17:55):
oh interesting! Yeah that makes sense, the change of variables does not fall into the type of equivalence of terms you're considering there? even if the resulting domains are equivalent?
Andrés Goens (Jan 12 2024 at 17:56):
or is it more subtle (that the convexity is not an invariant of the equivalence class of the terms)?
Martin Dvořák (Jan 12 2024 at 17:57):
When working with Matrix.Computable.dotProduct
, can you reuse mathlib theorems about Matrix.dotProduct
?
Ramon Fernández Mir (Jan 12 2024 at 18:06):
Andrés Goens said:
oh interesting! Yeah that makes sense, the change of variables does not fall into the type of equivalence of terms you're considering there? even if the resulting domains are equivalent?
Basically they are not a "rewrite" but rather a map where is the change of variables. Note that this is an issue because what we send egg is the "skolemized" objective function and constraints. So in order to do that properly, we would need to have functions (so you have to deal with binders, which is annoying in egg) as part of our language in egg and rules for composition. If we had that, then you could add it as a rewrite rule.
We support some maps, but these are of the form , which are easy to simulate as rewrites.
Ramon Fernández Mir (Jan 12 2024 at 18:10):
Martin Dvořák said:
When working with
Matrix.Computable.dotProduct
, can you reuse mathlib theorems aboutMatrix.dotProduct
?
No, we indeed lose any lemma about dot products. These are only used once you have your reduced problem and you want to extract the coefficients so that you can solve it (say, a constraint is posOrthCone (dotProduct a x)
where a
is constant). Then, in general, you need to compute to extract a
. So we replace every real function by its floating-point counter parts and get the coefficients of the problem. And we do not prove any correctness result about that step.
Ramon Fernández Mir (Jan 12 2024 at 18:10):
Ramon Fernández Mir said:
Andrés Goens said:
oh interesting! Yeah that makes sense, the change of variables does not fall into the type of equivalence of terms you're considering there? even if the resulting domains are equivalent?
Basically they are not a "rewrite" but rather a map where is the change of variables. Note that this is an issue because what we send egg is the "skolemized" objective function and constraints. So in order to do that properly, we would need to have functions (so you have to deal with binders, which is annoying in egg) as part of our language in egg and rules for composition. If we had that, then you could add it as a rewrite rule.
We support some maps, but these are of the form , which are easy to simulate as rewrites.
Here by I mean objective function and constraints
Martin Dvořák (Jan 12 2024 at 18:18):
Ramon Fernández Mir said:
Martin Dvořák said:
When working with
Matrix.Computable.dotProduct
, can you reuse mathlib theorems aboutMatrix.dotProduct
?No, we indeed lose any lemma about dot products. These are only used once you have your reduced problem and you want to extract the coefficients so that you can solve it (say, a constraint is
posOrthCone (dotProduct a x)
wherea
is constant). Then, in general, you need to compute to extracta
. So we replace every real function by its floating-point counter parts and get the coefficients of the problem. And we do not prove any correctness result about that step.
You define Matrix.Computable.dotProduct
generically but then you use it only for α
being Float
? Or are there also integer types?
Ramon Fernández Mir (Jan 12 2024 at 18:19):
It is only used for Float
at the moment
Last updated: May 02 2025 at 03:31 UTC