This repository was archived by the owner on Jul 24, 2024. It is now read-only.
Commit 46b633f
committed
refactor(analysis/inner_product_space/basic): do not extend normed_add_comm_group (#18583)
This replaces `[inner_product_space K V]` with `[normed_add_comm_group V] [inner_product_space K V]`.
Before this PR, we had `inner_product_space K V extends normed_add_comm_group V`.
At first glance this is a rather strange arrangement; we certainly don't have `module R V extends add_comm_group V`.
The argument usually goes that `Derived A B extends Base B` is unsafe, because the `Derived.toBase` instance has no way of knowing which `A` to look for.
For `inner_product_space K V` we argued that this problem doesn't apply, as `is_R_or_C K` means that in practice there are only two possible values of `K`. This is indeed enough to stop typeclass search grinding to a halt.
The motivation for the old design is described by @dupuisf [on Zulip](https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/Dangerous.20instance.20vs.20elaboration.20problems/near/210594971):
> However, when I do (the contents of this PR), I run into some very annoying elaboration issues where I have to constantly spoonfeed it `𝕜` and/or `α` in lemmas that rewrite norms in terms of inner products, even though the relevant instance is directly present in the context.
While it may ease elaboration issues, there are a number of new problems that `inner_product_space K V extends normed_add_comm_group V` causes:
1. It is confusing when compared to all other typeclasses. After being told to write
```lean
variables [add_comm_group U] [module R U]
variables [normed_add_comm_group V] [normed_space R V]
```
it is natural to assume that the inner product space version would be
```lean
variables [normed_add_comm_group W] [inner_product_space K W]
```
But writing this leads to `W` having two unrelated addition operations!
2. It doesn't allow a space `W` to be an inner product space over both R and C. For a (normed) module, you can write
```lean
variables [add_comm_group U] [module R U] [module C U]
variables [normed_add_comm_group V] [normed_space R V] [normed_space C V]
```
but writing `[inner_product_space R W] [inner_product_space C W]` again puts two unrelated `+` operators on `V`
3. It doesn't compose with other normed typeclasses. We can talk about a (normed) module with multiplication as
```lean
variables [ring U] [module R U]
variables [normed_ring V] [normed_space K V]
```
but once again, typing `[normed_ring W] [inner_product_space K W]` gives us two unrelated `+` operators.
This prevents us generalizing over `real`, `complex`, and `quaternion`.
We could work around this by defining variants of `inner_product_space` for `normed_ring A`, `normed_comm_ring A`, `normed_division_ring A`, `normed_field A`, but this doesn't scale well. If we do things "the module way" then we only need one new typeclass instead of four,
```lean
class inner_product_algebra (K A) [is_R_or_C K] [normed_ring A]
extends normed_algebra K A, inner_product_space K A
```
5. The "`is_R_or_C` makes it OK" argument stops working if we generalize to [quaternionic inner product spaces](https://link.springer.com/chapter/10.1007/978-94-009-3713-0_13)
The majority of this PR is adding `[normed_add_comm_group _]` to every `variables` line about `inner_product_space`.
The rest is specifying the scalar manually where previously unification would find it for us.
[This Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/inner_product_space.20and.20normed_algebra/near/341848831) has some initial discussion about this change.1 parent d11893b commit 46b633f
57 files changed
Lines changed: 367 additions & 288 deletions
File tree
- archive
- 100-theorems-list
- imo
- src
- analysis
- calculus
- conformal
- convex/cone
- fourier
- inner_product_space
- von_neumann_algebra
- geometry
- euclidean
- angle
- oriented
- unoriented
- sphere
- manifold/instances
- linear_algebra/matrix
- measure_theory
- function
- conditional_expectation
- special_functions
- strongly_measurable
- integral
- measure
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
| 26 | + | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
309 | | - | |
| 309 | + | |
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
334 | | - | |
| 334 | + | |
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
717 | 717 | | |
718 | 718 | | |
719 | 719 | | |
720 | | - | |
| 720 | + | |
721 | 721 | | |
722 | 722 | | |
723 | 723 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
429 | | - | |
| 429 | + | |
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
206 | 207 | | |
207 | 208 | | |
208 | 209 | | |
209 | | - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
210 | 213 | | |
211 | 214 | | |
212 | 215 | | |
| |||
402 | 405 | | |
403 | 406 | | |
404 | 407 | | |
405 | | - | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
406 | 411 | | |
407 | 412 | | |
408 | 413 | | |
| |||
0 commit comments