-
Notifications
You must be signed in to change notification settings - Fork 342
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] - chore: better failures for linear_combination
#15791
Conversation
PR summary 0440177643Import changes for modified filesNo significant changes to the import graph Import changes for all files
Declarations diffNo declarations were harmed in the making of this PR! 🐙 You can run this locally as follows## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>
## more verbose report:
./scripts/declarations_diff.sh long <optional_commit> The doc-module for |
Seems good. Maybe it could make sense to move withoutErrToSorry earlier, but where you have it currently is definitely justified since it's for elaboration of syntax generated by the tactic itself. bors r+ |
The implementation of `linear_combination` is as a macro performing effectively `refine ******; ring`. If the term provided to `refine` fails to elaborate, Lean inserts sorries where needed and then continues on to `ring`. This produces a confusing error message. For example, the problem ```lean example (x y : ℤ) (h1 : x * y + 2 * x = 1) (h2 : x = y) : x * y + 2 * x = 1 := by linear_combination h1 + (0 : ℝ) * h2 ``` produces both the "true" error message ``` application type mismatch Mathlib.Tactic.LinearCombination.c_mul_pf h2 0 argument 0 has type ℝ : Type but is expected to have type ℤ : Type ``` and the "tactic is confused because it persevered when it shouldn't have" error message ``` ring failed, ring expressions not equal x y : ℤ h1 : x * y + 2 * x = 1 h2 : x = y ⊢ -(x * sorryAx ℤ true) + y * sorryAx ℤ true = 0 ``` This PR fixes this by strategically inserting a `Term.withoutErrToSorry`. In examples such as the above, it now stops after the `refine`, so the second error message does not appear.
Build failed (retrying...): |
The implementation of `linear_combination` is as a macro performing effectively `refine ******; ring`. If the term provided to `refine` fails to elaborate, Lean inserts sorries where needed and then continues on to `ring`. This produces a confusing error message. For example, the problem ```lean example (x y : ℤ) (h1 : x * y + 2 * x = 1) (h2 : x = y) : x * y + 2 * x = 1 := by linear_combination h1 + (0 : ℝ) * h2 ``` produces both the "true" error message ``` application type mismatch Mathlib.Tactic.LinearCombination.c_mul_pf h2 0 argument 0 has type ℝ : Type but is expected to have type ℤ : Type ``` and the "tactic is confused because it persevered when it shouldn't have" error message ``` ring failed, ring expressions not equal x y : ℤ h1 : x * y + 2 * x = 1 h2 : x = y ⊢ -(x * sorryAx ℤ true) + y * sorryAx ℤ true = 0 ``` This PR fixes this by strategically inserting a `Term.withoutErrToSorry`. In examples such as the above, it now stops after the `refine`, so the second error message does not appear.
Pull request successfully merged into master. Build succeeded: |
linear_combination
linear_combination
The implementation of `linear_combination` is as a macro performing effectively `refine ******; ring`. If the term provided to `refine` fails to elaborate, Lean inserts sorries where needed and then continues on to `ring`. This produces a confusing error message. For example, the problem ```lean example (x y : ℤ) (h1 : x * y + 2 * x = 1) (h2 : x = y) : x * y + 2 * x = 1 := by linear_combination h1 + (0 : ℝ) * h2 ``` produces both the "true" error message ``` application type mismatch Mathlib.Tactic.LinearCombination.c_mul_pf h2 0 argument 0 has type ℝ : Type but is expected to have type ℤ : Type ``` and the "tactic is confused because it persevered when it shouldn't have" error message ``` ring failed, ring expressions not equal x y : ℤ h1 : x * y + 2 * x = 1 h2 : x = y ⊢ -(x * sorryAx ℤ true) + y * sorryAx ℤ true = 0 ``` This PR fixes this by strategically inserting a `Term.withoutErrToSorry`. In examples such as the above, it now stops after the `refine`, so the second error message does not appear.
The implementation of `linear_combination` is as a macro performing effectively `refine ******; ring`. If the term provided to `refine` fails to elaborate, Lean inserts sorries where needed and then continues on to `ring`. This produces a confusing error message. For example, the problem ```lean example (x y : ℤ) (h1 : x * y + 2 * x = 1) (h2 : x = y) : x * y + 2 * x = 1 := by linear_combination h1 + (0 : ℝ) * h2 ``` produces both the "true" error message ``` application type mismatch Mathlib.Tactic.LinearCombination.c_mul_pf h2 0 argument 0 has type ℝ : Type but is expected to have type ℤ : Type ``` and the "tactic is confused because it persevered when it shouldn't have" error message ``` ring failed, ring expressions not equal x y : ℤ h1 : x * y + 2 * x = 1 h2 : x = y ⊢ -(x * sorryAx ℤ true) + y * sorryAx ℤ true = 0 ``` This PR fixes this by strategically inserting a `Term.withoutErrToSorry`. In examples such as the above, it now stops after the `refine`, so the second error message does not appear.
The implementation of `linear_combination` is as a macro performing effectively `refine ******; ring`. If the term provided to `refine` fails to elaborate, Lean inserts sorries where needed and then continues on to `ring`. This produces a confusing error message. For example, the problem ```lean example (x y : ℤ) (h1 : x * y + 2 * x = 1) (h2 : x = y) : x * y + 2 * x = 1 := by linear_combination h1 + (0 : ℝ) * h2 ``` produces both the "true" error message ``` application type mismatch Mathlib.Tactic.LinearCombination.c_mul_pf h2 0 argument 0 has type ℝ : Type but is expected to have type ℤ : Type ``` and the "tactic is confused because it persevered when it shouldn't have" error message ``` ring failed, ring expressions not equal x y : ℤ h1 : x * y + 2 * x = 1 h2 : x = y ⊢ -(x * sorryAx ℤ true) + y * sorryAx ℤ true = 0 ``` This PR fixes this by strategically inserting a `Term.withoutErrToSorry`. In examples such as the above, it now stops after the `refine`, so the second error message does not appear.
The implementation of
linear_combination
is as a macro performing effectivelyrefine ******; ring
. If the term provided torefine
fails to elaborate, Lean inserts sorries where needed and then continues on toring
. This produces a confusing error message. For example, the problemproduces both the "true" error message
and the "tactic is confused because it persevered when it shouldn't have" error message
This PR fixes this by strategically inserting a
Term.withoutErrToSorry
. In examples such as the above, it now stops after therefine
, so the second error message does not appear.