Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: don't inline
DivInvMonoid
default value for Div
, for bette…
…r instance transparency (#1897) See [Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Instance.20transparency.20issue.3F/near/323637092). This will make particular `DivInvMonoid`s whose `Div` field is constructed using the default value (such as `ℝ`) behave the same way as generic ones, at the instance transparency level, fixing examples such as the following: ```lean import Mathlib.Data.Real.Basic variable [LinearOrderedField α] /- `.reducible` transparency works correctly over `ℝ`. -/ example {a b : ℝ} : a / 2 ≤ b / 2 := by with_reducible (apply mul_le_mul) -- fails, as desired /- `.instance` transparency works correctly over a generic field. -/ example {a b : α} : a / 2 ≤ b / 2 := by with_reducible_and_instances (apply mul_le_mul) -- fails, as desired /- `.instance` transparency does not work correctly over `ℝ`. -/ example {a b : ℝ} : a / 2 ≤ b / 2 := by with_reducible_and_instances (apply mul_le_mul) -- succeeds, wanted it not to all_goals sorry ```
- Loading branch information
Showing
4 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Mathlib.Data.Real.Basic | ||
|
||
/-! # Test transparency level of `Div` field in `DivInvMonoid` | ||
It is desirable that particular `DivInvMonoid`s have their `Div` instance not unfold at `.instance` | ||
transparency level, in the same way that the `Div` field of a generic `DivInvMonoid` does not. | ||
To ensure this, in examples where the `Div` field is defined as `fun a b ↦ a * b⁻¹`, we hide this | ||
under one layer of other function (so for example the `Div` instance for `Rat` is defined to be | ||
`⟨Rat.div⟩`, where `Rat.div` is defined to be `fun a b ↦ a * b⁻¹`). | ||
This file checks that this and similar tricks have had the desired effect: | ||
`with_reducible_and_instances apply mul_le_mul` fails although `apply mul_le_mul` succeeds. | ||
-/ | ||
|
||
example {a b : α} [LinearOrderedField α] : a / 2 ≤ b / 2 := by | ||
fail_if_success with_reducible_and_instances apply mul_le_mul -- fails, as desired | ||
sorry | ||
|
||
example {a b : ℚ} : a / 2 ≤ b / 2 := by | ||
fail_if_success with_reducible_and_instances apply mul_le_mul -- fails, as desired | ||
apply mul_le_mul | ||
repeat sorry | ||
|
||
example {a b : ℝ} : a / 2 ≤ b / 2 := by | ||
fail_if_success with_reducible_and_instances apply mul_le_mul -- fails, as desired | ||
apply mul_le_mul | ||
repeat sorry |