-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - feat(Tactic/Linarith): Simplex Algorithm oracle #12014
Conversation
!bench |
Here are the benchmark results for commit 5567bba. Benchmark Metric Change
================================================================
+ ~Mathlib.Analysis.Normed.Group.AddCircle instructions -65.0% |
At first glance this looks great! Could you add the examples from the two issues this closes as test cases in the It's unfortunate that over mathlib as a whole this has almost no performance impact (besides the outlier |
@eric-wieser Thank you for your feedback! I have addressed your comments and slightly revised the code, making it shorter and (I hope) easier to read. |
!bench |
Here are the benchmark results for commit 6bff856. |
!bench |
Here are the benchmark results for commit 18974fc. Benchmark Metric Change
===================================================================
+ ~Mathlib.Analysis.Normed.Group.AddCircle instructions -62.6%
- ~Mathlib.Geometry.Manifold.Instances.Sphere instructions 7.0% |
bors merge |
- Reduce the `linarith` certificate search problem to some Linear Programming problem and implement the Simplex Algorithm to solve it. - Set the default oracle for `linarith` to this. - Remove unnecessary hypotheses in `Mathlib/Analysis/Calculus/BumpFunction/FiniteDimension.lean` and `Mathlib/Analysis/Distribution/SchwartzSpace.lean` which were needed with the Fourier-Motzkin oracle. - Adjust the definition of `CerficateOracle` to enable dot notation to choose between oracles. This addresses #2717 and #8875 (except when the user overrides the oracle) Also, this oracle is far more efficient: The example below takes lots of time with the Fourier-Motzkin oracle: I waited 5 minutes and still didn't get it. But with the just implemented `Linarith.SimplexAlgo.produceCertificate` oracle the proof succeeds in less than a second. ```lean import Mathlib.Tactic.Linarith example (x0 x1 x2 x3 x4 : ℚ) : 3 * x0 - 15 * x1 - 30 * x2 + 20 * x3 + 12 * x4 ≤ 0 → 35 * x0 - 30 * x1 + 12 * x2 - 15 * x3 + 18 * x4 ≤ 0 → 5 * x0 + 20 * x1 + 24 * x2 + 20 * x3 + 9 * x4 ≤ 0 → -2 * x0 - 30 * x1 + 30 * x2 - 10 * x3 - 12 * x4 ≤ 0 → -4 * x0 - 25 * x1 + 6 * x2 - 20 * x3 ≤ 0 → 25 * x1 + 30 * x2 - 25 * x3 + 12 * x4 ≤ 0 → 10 * x1 - 18 * x2 - 30 * x3 + 18 * x4 ≤ 0 → 4 * x0 + 10 * x1 - 18 * x2 - 15 * x3 + 15 * x4 ≤ 0 → -4 * x0 + 15 * x1 - 30 * x2 + 15 * x3 + 6 * x4 ≤ 0 → -2 * x0 - 5 * x1 + 18 * x2 - 25 * x3 - 161 * x4 ≤ 0 → -6 * x0 + 30 * x1 + 6 * x2 - 15 * x3 ≤ 0 → 3 * x0 + 10 * x1 - 30 * x2 + 25 * x3 + 12 * x4 ≤ 0 → 2 * x0 + 10 * x1 - 24 * x2 - 15 * x3 + 3 * x4 ≤ 0 → 82 * x1 + 36 * x2 + 20 * x3 + 9 * x4 ≤ 0 → 2 * x0 - 30 * x1 - 30 * x2 - 15 * x3 + 6 * x4 ≤ 0 → 4 * x0 - 15 * x1 + 25 * x2 < 0 → -4 * x0 - 10 * x1 + 30 * x2 - 15 * x3 ≤ 0 → 2 * x0 + 6 * x2 + 133 * x3 + 12 * x4 ≤ 0 → 3 * x0 + 15 * x1 - 6 * x2 - 15 * x3 - 15 * x4 ≤ 0 → 10 * x1 + 6 * x2 - 25 * x3 + 3 * x4 ≤ 0 → -2 * x0 + 5 * x1 + 12 * x2 - 20 * x3 + 12 * x4 ≤ 0 → -5 * x0 - 25 * x1 + 30 * x3 - 12 * x4 ≤ 0 → -6 * x0 - 30 * x1 - 36 * x2 + 20 * x3 + 12 * x4 ≤ 0 → 5 * x0 - 5 * x1 + 6 * x2 - 25 * x3 ≤ 0 → -3 * x0 - 20 * x1 - 30 * x2 + 5 * x3 + 3 * x4 ≤ 0 → False := by intros; linarith (config := {oracle := Linarith.FourierMotzkin.produceCertificate}) ``` I am planning to prove the "completeness" of the oracle in the next PRs, but so far I have run a stress test on randomly generated examples of various sizes, and it seems that everything is OK. Co-authored-by: Eric Wieser <[email protected]>
Pull request successfully merged into master. Build succeeded: |
- Reduce the `linarith` certificate search problem to some Linear Programming problem and implement the Simplex Algorithm to solve it. - Set the default oracle for `linarith` to this. - Remove unnecessary hypotheses in `Mathlib/Analysis/Calculus/BumpFunction/FiniteDimension.lean` and `Mathlib/Analysis/Distribution/SchwartzSpace.lean` which were needed with the Fourier-Motzkin oracle. - Adjust the definition of `CerficateOracle` to enable dot notation to choose between oracles. This addresses #2717 and #8875 (except when the user overrides the oracle) Also, this oracle is far more efficient: The example below takes lots of time with the Fourier-Motzkin oracle: I waited 5 minutes and still didn't get it. But with the just implemented `Linarith.SimplexAlgo.produceCertificate` oracle the proof succeeds in less than a second. ```lean import Mathlib.Tactic.Linarith example (x0 x1 x2 x3 x4 : ℚ) : 3 * x0 - 15 * x1 - 30 * x2 + 20 * x3 + 12 * x4 ≤ 0 → 35 * x0 - 30 * x1 + 12 * x2 - 15 * x3 + 18 * x4 ≤ 0 → 5 * x0 + 20 * x1 + 24 * x2 + 20 * x3 + 9 * x4 ≤ 0 → -2 * x0 - 30 * x1 + 30 * x2 - 10 * x3 - 12 * x4 ≤ 0 → -4 * x0 - 25 * x1 + 6 * x2 - 20 * x3 ≤ 0 → 25 * x1 + 30 * x2 - 25 * x3 + 12 * x4 ≤ 0 → 10 * x1 - 18 * x2 - 30 * x3 + 18 * x4 ≤ 0 → 4 * x0 + 10 * x1 - 18 * x2 - 15 * x3 + 15 * x4 ≤ 0 → -4 * x0 + 15 * x1 - 30 * x2 + 15 * x3 + 6 * x4 ≤ 0 → -2 * x0 - 5 * x1 + 18 * x2 - 25 * x3 - 161 * x4 ≤ 0 → -6 * x0 + 30 * x1 + 6 * x2 - 15 * x3 ≤ 0 → 3 * x0 + 10 * x1 - 30 * x2 + 25 * x3 + 12 * x4 ≤ 0 → 2 * x0 + 10 * x1 - 24 * x2 - 15 * x3 + 3 * x4 ≤ 0 → 82 * x1 + 36 * x2 + 20 * x3 + 9 * x4 ≤ 0 → 2 * x0 - 30 * x1 - 30 * x2 - 15 * x3 + 6 * x4 ≤ 0 → 4 * x0 - 15 * x1 + 25 * x2 < 0 → -4 * x0 - 10 * x1 + 30 * x2 - 15 * x3 ≤ 0 → 2 * x0 + 6 * x2 + 133 * x3 + 12 * x4 ≤ 0 → 3 * x0 + 15 * x1 - 6 * x2 - 15 * x3 - 15 * x4 ≤ 0 → 10 * x1 + 6 * x2 - 25 * x3 + 3 * x4 ≤ 0 → -2 * x0 + 5 * x1 + 12 * x2 - 20 * x3 + 12 * x4 ≤ 0 → -5 * x0 - 25 * x1 + 30 * x3 - 12 * x4 ≤ 0 → -6 * x0 - 30 * x1 - 36 * x2 + 20 * x3 + 12 * x4 ≤ 0 → 5 * x0 - 5 * x1 + 6 * x2 - 25 * x3 ≤ 0 → -3 * x0 - 20 * x1 - 30 * x2 + 5 * x3 + 3 * x4 ≤ 0 → False := by intros; linarith (config := {oracle := Linarith.FourierMotzkin.produceCertificate}) ``` I am planning to prove the "completeness" of the oracle in the next PRs, but so far I have run a stress test on randomly generated examples of various sizes, and it seems that everything is OK. Co-authored-by: Eric Wieser <[email protected]>
- Reduce the `linarith` certificate search problem to some Linear Programming problem and implement the Simplex Algorithm to solve it. - Set the default oracle for `linarith` to this. - Remove unnecessary hypotheses in `Mathlib/Analysis/Calculus/BumpFunction/FiniteDimension.lean` and `Mathlib/Analysis/Distribution/SchwartzSpace.lean` which were needed with the Fourier-Motzkin oracle. - Adjust the definition of `CerficateOracle` to enable dot notation to choose between oracles. This addresses #2717 and #8875 (except when the user overrides the oracle) Also, this oracle is far more efficient: The example below takes lots of time with the Fourier-Motzkin oracle: I waited 5 minutes and still didn't get it. But with the just implemented `Linarith.SimplexAlgo.produceCertificate` oracle the proof succeeds in less than a second. ```lean import Mathlib.Tactic.Linarith example (x0 x1 x2 x3 x4 : ℚ) : 3 * x0 - 15 * x1 - 30 * x2 + 20 * x3 + 12 * x4 ≤ 0 → 35 * x0 - 30 * x1 + 12 * x2 - 15 * x3 + 18 * x4 ≤ 0 → 5 * x0 + 20 * x1 + 24 * x2 + 20 * x3 + 9 * x4 ≤ 0 → -2 * x0 - 30 * x1 + 30 * x2 - 10 * x3 - 12 * x4 ≤ 0 → -4 * x0 - 25 * x1 + 6 * x2 - 20 * x3 ≤ 0 → 25 * x1 + 30 * x2 - 25 * x3 + 12 * x4 ≤ 0 → 10 * x1 - 18 * x2 - 30 * x3 + 18 * x4 ≤ 0 → 4 * x0 + 10 * x1 - 18 * x2 - 15 * x3 + 15 * x4 ≤ 0 → -4 * x0 + 15 * x1 - 30 * x2 + 15 * x3 + 6 * x4 ≤ 0 → -2 * x0 - 5 * x1 + 18 * x2 - 25 * x3 - 161 * x4 ≤ 0 → -6 * x0 + 30 * x1 + 6 * x2 - 15 * x3 ≤ 0 → 3 * x0 + 10 * x1 - 30 * x2 + 25 * x3 + 12 * x4 ≤ 0 → 2 * x0 + 10 * x1 - 24 * x2 - 15 * x3 + 3 * x4 ≤ 0 → 82 * x1 + 36 * x2 + 20 * x3 + 9 * x4 ≤ 0 → 2 * x0 - 30 * x1 - 30 * x2 - 15 * x3 + 6 * x4 ≤ 0 → 4 * x0 - 15 * x1 + 25 * x2 < 0 → -4 * x0 - 10 * x1 + 30 * x2 - 15 * x3 ≤ 0 → 2 * x0 + 6 * x2 + 133 * x3 + 12 * x4 ≤ 0 → 3 * x0 + 15 * x1 - 6 * x2 - 15 * x3 - 15 * x4 ≤ 0 → 10 * x1 + 6 * x2 - 25 * x3 + 3 * x4 ≤ 0 → -2 * x0 + 5 * x1 + 12 * x2 - 20 * x3 + 12 * x4 ≤ 0 → -5 * x0 - 25 * x1 + 30 * x3 - 12 * x4 ≤ 0 → -6 * x0 - 30 * x1 - 36 * x2 + 20 * x3 + 12 * x4 ≤ 0 → 5 * x0 - 5 * x1 + 6 * x2 - 25 * x3 ≤ 0 → -3 * x0 - 20 * x1 - 30 * x2 + 5 * x3 + 3 * x4 ≤ 0 → False := by intros; linarith (config := {oracle := Linarith.FourierMotzkin.produceCertificate}) ``` I am planning to prove the "completeness" of the oracle in the next PRs, but so far I have run a stress test on randomly generated examples of various sizes, and it seems that everything is OK. Co-authored-by: Eric Wieser <[email protected]>
This PR updates the documentation following the integration of the oracle based on the Simplex Algorithm, as merged in PRs #12014, #13535, #12819, and #13800. Additionally, it moves the `SimplexAlgorithm` folder into the `Oracle` directory. Co-authored-by: Rob Lewis <[email protected]>
This PR updates the documentation following the integration of the oracle based on the Simplex Algorithm, as merged in PRs #12014, #13535, #12819, and #13800. Additionally, it moves the `SimplexAlgorithm` folder into the `Oracle` directory. Co-authored-by: Rob Lewis <[email protected]>
This PR updates the documentation following the integration of the oracle based on the Simplex Algorithm, as merged in PRs #12014, #13535, #12819, and #13800. Additionally, it moves the `SimplexAlgorithm` folder into the `Oracle` directory. Co-authored-by: Rob Lewis <[email protected]>
linarith
certificate search problem to some Linear Programming problem and implement the Simplex Algorithm to solve it.linarith
to this.Mathlib/Analysis/Calculus/BumpFunction/FiniteDimension.lean
andMathlib/Analysis/Distribution/SchwartzSpace.lean
which were needed with the Fourier-Motzkin oracle.CerficateOracle
to enable dot notation to choose between oracles.This addresses #2717 and #8875 (except when the user overrides the oracle)
Also, this oracle is far more efficient:
The example below takes lots of time with the Fourier-Motzkin oracle: I waited 5 minutes and still didn't get it. But with the just implemented
Linarith.SimplexAlgo.produceCertificate
oracle the proof succeeds in less than a second.I am planning to prove the "completeness" of the oracle in the next PRs, but so far I have run a stress test on randomly generated examples of various sizes, and it seems that everything is OK.