Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore({algebra,data/rat}): use forgetful inheritance for
algebra_rat
(
#14894) Throughout mathlib we've been struggling with diamonds arising from the `algebra_rat [division_ring K] [char_zero K] : algebra ℚ K` instance: since this instance provided its own inclusion map `to_fun : ℚ → K` and scalar multiplication by rationals `smul : ℚ → K → K`, it would not be definitionally equal to other instances such as `algebra.id`, and we'd need tactics like `convert` to deal with this inequality. Following the previous `nsmul` and `zmul` refactors, this PR applies the forgetful inheritance pattern to the `algebra_rat` instance, allowing you to supply a definitionally convenient value for the conflicting `to_fun` and `smul` fields as the fields `of_rat` and `qsmul` in the `division_ring K` instance. `of_rat` is used to define the coercion `ℚ → K` (in the instance `rat.cast_coe`), whic is used to define the map `rat.cast_hom : ℚ →+* K`, which is used along with `qsmul` to define `algebra_rat`. A default value for `of_rat` and `qsmul` and coherence proofs are provided using the `opt_param`/`auto_param` mechanism, just like for `nsmul` and `zsmul`. I have included a test after the definition of `algebra_rat`, to ensure definitional equality with `algebra.id`.
- Loading branch information
1 parent
5797ef5
commit 2ee2bae
Showing
13 changed files
with
208 additions
and
54 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
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
Oops, something went wrong.