Zulip Chat Archive
Stream: mathlib4
Topic: Operator norm
Patrick Massot (Jun 03 2023 at 08:21):
The following mystery is blocking calculus in mathlib4:
import Mathlib.Analysis.Calculus.ContDiffDef
import Mathlib.Analysis.Calculus.Deriv.Inverse
import Mathlib.Analysis.Calculus.MeanValue
import Mathlib.Analysis.NormedSpace.FiniteDimension
import Mathlib.Data.Nat.Choose.Cast
variable {๐ : Type _} [NontriviallyNormedField ๐] {Du Eu Fu Gu : Type u}
[NormedAddCommGroup Du] [NormedSpace ๐ Du] [NormedAddCommGroup Eu] [NormedSpace ๐ Eu]
[NormedAddCommGroup Fu] [NormedSpace ๐ Fu] [NormedAddCommGroup Gu] [NormedSpace ๐ Gu]
#check (Eu โL[๐] (Du โL[๐] Fu) โL[๐] Du โL[๐] Gu)
#check (Du โL[๐] Fu) โL[๐] Du โL[๐] Gu
set_option trace.Meta.synthInstance true in
#synth Norm (Du โL[๐] Fu)
#synth Norm ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu)
set_option trace.Meta.synthInstance true in
#synth Norm (Eu โL[๐] ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu))
Ruben Van de Velde (Jun 03 2023 at 08:22):
Not the operator norm again :see_no_evil:
Patrick Massot (Jun 03 2023 at 08:22):
Lean has no trouble finding the operator norm until (Du โL[๐] Fu) โL[๐] Du โL[๐] Gu
but fails with Eu โL[๐] ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu)
Patrick Massot (Jun 03 2023 at 08:22):
This is the first error in !4#4532.
Patrick Massot (Jun 03 2023 at 08:23):
Ruben, you seem to be a specialist in this issue, it would be very nice to have a fix.
Patrick Massot (Jun 03 2023 at 08:24):
This file is the main remaining roadblock to restoring the calculus chapter in MIL.
Ruben Van de Velde (Jun 03 2023 at 08:26):
I'm not sure any such reputation is deserved, but I'll try to find some time later today
Eric Wieser (Jun 03 2023 at 08:57):
Is it able to find this instance if given the expression to construct it explicitly?
Eric Wieser (Jun 03 2023 at 10:47):
Answer: no :fear:
-- type mismatch
example : Norm (Eu โL[๐] ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu)) := ContinuousLinearMap.hasOpNorm
Going through the isDefEq
trace suggests thar the problem is that itfound stuck MVar
.
Eric Wieser (Jun 03 2023 at 10:55):
I think there's some weird universe problem:
set_option pp.universes true in
example : Norm (Eu โL[๐] ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu)) :=
let foo : NormedAddCommGroup ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu) := by infer_instance
ContinuousLinearMap.hasOpNorm
This has an error on both the last two lines, but the error goes away if you replace the last line with sorry
Kevin Buzzard (Jun 03 2023 at 11:01):
I'm assuming it's just a coincidence that mathlib's longest declaration name is about these objects.
Eric Wieser (Jun 03 2023 at 11:02):
Note that that instance is already a porting hack, so probably this is related
Johan Commelin (Jun 03 2023 at 12:17):
@Eric Wieser Why do you think it is related to universes?
Eric Wieser (Jun 03 2023 at 12:18):
Because the metavariable has an unresolved universe argument
Eric Wieser (Jun 03 2023 at 12:18):
And the error in the above code sample complains about unifying max ? ?
with u
Patrick Massot (Jun 03 2023 at 13:05):
I pushed a hack feeding this instance into the first failing proof, but I need to give up on the next proof for now (the issue seems different). But working on this file is almost impossible because everything is so slow. So probably we can't avoid facing that issue for real.
Kevin Buzzard (Jun 03 2023 at 17:12):
[tryResolve] โ RingHomIsometric (RingHom.id ๐) โ RingHomIsometric (RingHom.id ?m.51913)
:-(
I don't really know what a stuck metavariable is but this shows up a few times in the trace:
[synthInstance] โ SeminormedAddCommGroup ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu) โถ
[] โ ContinuousLinearMap.topologicalSpace =?= UniformSpace.toTopologicalSpace โผ
[] โ ContinuousLinearMap.strongTopology (RingHom.id ๐) (Du โL[๐] Gu)
{S | Bornology.IsVonNBounded ๐ S} =?= UniformSpace.toTopologicalSpace โผ
[] โ TopologicalSpace.induced FunLike.coe
(UniformOnFun.topologicalSpace (Du โL[๐] Fu) (Du โL[๐] Gu)
{S | Bornology.IsVonNBounded ๐ S}) =?= UniformSpace.toTopologicalSpace โผ
[] โ { IsOpen := fun s โฆ โ s', IsOpen s' โง FunLike.coe โปยน' s' = s,
isOpen_univ := (_ : โ s', IsOpen s' โง FunLike.coe โปยน' s' = Set.univ),
isOpen_inter :=
(_ :
โ (sโ sโ : Set ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu)),
(โ s', IsOpen s' โง FunLike.coe โปยน' s' = sโ) โ
(โ s', IsOpen s' โง FunLike.coe โปยน' s' = sโ) โ
(fun s โฆ โ s', IsOpen s' โง FunLike.coe โปยน' s' = s) (sโ โฉ sโ)),
isOpen_sUnion :=
(_ :
โ (S : Set (Set ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu))),
(โ (t : Set ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu)),
t โ S โ (fun s โฆ โ s', IsOpen s' โง FunLike.coe โปยน' s' = s) t) โ
โ s', IsOpen s' โง FunLike.coe โปยน' s' = โโ S) } =?= UniformSpace.toTopologicalSpace โผ
[] โ { IsOpen := fun s โฆ โ s', IsOpen s' โง FunLike.coe โปยน' s' = s,
isOpen_univ := (_ : โ s', IsOpen s' โง FunLike.coe โปยน' s' = Set.univ),
isOpen_inter :=
(_ :
โ (sโ sโ : Set ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu)),
(โ s', IsOpen s' โง FunLike.coe โปยน' s' = sโ) โ
(โ s', IsOpen s' โง FunLike.coe โปยน' s' = sโ) โ
(fun s โฆ โ s', IsOpen s' โง FunLike.coe โปยน' s' = s) (sโ โฉ sโ)),
isOpen_sUnion :=
(_ :
โ (S : Set (Set ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu))),
(โ (t : Set ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu)),
t โ S โ (fun s โฆ โ s', IsOpen s' โง FunLike.coe โปยน' s' = s) t) โ
โ s', IsOpen s' โง FunLike.coe โปยน' s' = โโ S) } =?= PseudoMetricSpace.toUniformSpace.1 โผ
[] โ
TopologicalSpace ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu) =?= TopologicalSpace ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu) โถ
[] โ TopologicalSpace.IsOpen =?= fun s โฆ โ s', IsOpen s' โง FunLike.coe โปยน' s' = s โถ
[onFailure] โ { IsOpen := fun s โฆ โ s', IsOpen s' โง FunLike.coe โปยน' s' = s,
isOpen_univ := (_ : โ s', IsOpen s' โง FunLike.coe โปยน' s' = Set.univ),
isOpen_inter :=
(_ :
โ (sโ sโ : Set ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu)),
(โ s', IsOpen s' โง FunLike.coe โปยน' s' = sโ) โ
(โ s', IsOpen s' โง FunLike.coe โปยน' s' = sโ) โ
(fun s โฆ โ s', IsOpen s' โง FunLike.coe โปยน' s' = s) (sโ โฉ sโ)),
isOpen_sUnion :=
(_ :
โ (S : Set (Set ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu))),
(โ (t : Set ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu)),
t โ S โ (fun s โฆ โ s', IsOpen s' โง FunLike.coe โปยน' s' = s) t) โ
โ s', IsOpen s' โง FunLike.coe โปยน' s' = โโ S) } =?= PseudoMetricSpace.toUniformSpace.1 โผ
[stuckMVar] found stuck MVar ?m.51846 : SeminormedAddCommGroup ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu)
Eric Wieser (Jun 03 2023 at 17:19):
I think a lot of these traces would become easier to navigate with set_option pp.proofs false
or whatever the name is
Kevin Buzzard (Jun 03 2023 at 17:20):
Maybe the problem is this:
/-
[tryResolve] โ RingHomIsometric (RingHom.id ๐) โ RingHomIsometric (RingHom.id ?m.52368) โถ
LHS
@RingHomIsometric ๐ ๐ DivisionSemiring.toSemiring DivisionSemiring.toSemiring NormedField.toNorm NormedField.toNorm
(RingHom.id ๐) : Prop
RHS
@RingHomIsometric ?m.52368 ?m.52368 Ring.toSemiring Ring.toSemiring SeminormedRing.toNorm SeminormedRing.toNorm
(RingHom.id ?m.52368) : Prop
-/
Eric Wieser (Jun 03 2023 at 17:21):
Does setting a default instance on RingHomIsometric
for RingHom.id
help at all?
Kevin Buzzard (Jun 03 2023 at 17:22):
(The above issue would align with the general picture of Lean 4 being a bit crap at the way we've set up ring theory and now this problem is leaking over to anything which uses fields :-/)
Kevin Buzzard (Jun 03 2023 at 17:28):
Eric Wieser said:
Does setting a default instance on
RingHomIsometric
forRingHom.id
help at all?
Yes, it changes the issue to
[] โ apply smulCommClass_self to SMulCommClass ๐ ๐ Fu โผ
[tryResolve] โ SMulCommClass ๐ ๐ Fu โ SMulCommClass ?m.53239 ?m.53239 ?m.53240
Eric Wieser (Jun 03 2023 at 17:29):
That failure is expected, that's the wrong instance
Kevin Buzzard (Jun 03 2023 at 17:29):
LHS is @SMulCommClass ๐ ๐ Fu SMulZeroClass.toSMul SMulZeroClass.toSMul : Prop
, RHS is @SMulCommClass ?m.53239 ?m.53239 ?m.53240 MulAction.toSMul MulAction.toSMul : Prop
Eric Wieser (Jun 03 2023 at 17:30):
I assume it's stuck because MulAction.toSMul
on the RHS has more metavariables?
Eric Wieser (Jun 03 2023 at 17:30):
Is the LHS metavariable-free?
Kevin Buzzard (Jun 03 2023 at 17:31):
Sorry I'm finding it a bit hard to read these traces, ultimately Lean seems to reduce it to IsScalarTower ๐ ๐ Fu
. The "goal" of the traces keeps changing and I have to unfold things to find out where we're going
Kevin Buzzard (Jun 03 2023 at 17:36):
And
[] โ apply IsScalarTower.left to IsScalarTower ๐ ๐ Fu โผ
[tryResolve] โ IsScalarTower ๐ ๐ Fu โ IsScalarTower ?m.53455 ?m.53455 ?m.53456
fails because LHS is @IsScalarTower ๐ ๐ Fu Algebra.toSMul SMulZeroClass.toSMul SMulZeroClass.toSMul : Prop
and RHS is @IsScalarTower ?m.53455 ?m.53455 ?m.53456 MulAction.toSMul MulAction.toSMul MulAction.toSMul : Prop
. And at this point it goes back and tries to find another way to make NormedSpace ๐ Fu
other than _inst_2
:-/
Kevin Buzzard (Jun 03 2023 at 18:37):
Eric Wieser said:
I assume it's stuck because
MulAction.toSMul
on the RHS has more metavariables?
It does have more metavariables: @MulAction.toSMul ?m.55677 ?m.55678 CommMonoid.toMonoid ?m.55680 : SMul ?m.55677 ?m.55678
Kevin Buzzard (Jun 03 2023 at 18:40):
OK so here's some kind of solution:
import Mathlib.Analysis.Calculus.ContDiffDef
import Mathlib.Analysis.Calculus.Deriv.Inverse
import Mathlib.Analysis.Calculus.MeanValue
import Mathlib.Analysis.NormedSpace.FiniteDimension
import Mathlib.Data.Nat.Choose.Cast
variable {๐ : Type v} [NontriviallyNormedField ๐] {Du Eu Fu Gu : Type u}
[NormedAddCommGroup Du] [NormedSpace ๐ Du] [NormedAddCommGroup Eu] [NormedSpace ๐ Eu]
[NormedAddCommGroup Fu] [NormedSpace ๐ Fu] [NormedAddCommGroup Gu] [NormedSpace ๐ Gu]
instance : RingHomIsometric (RingHom.id ๐) := inferInstance
instance : SMulCommClass ๐ ๐ Fu := inferInstance
#synth Norm (Eu โL[๐] ((Du โL[๐] Fu) โL[๐] Du โL[๐] Gu)) -- works
If you comment out either instance then #synth
fails. Should that happen? I am only adding instances which typeclass inference can already find. That's a bit weird.
Patrick Massot (Jun 03 2023 at 18:44):
It's not super weird since it probably change the order in which instances are tried.
Kevin Buzzard (Jun 03 2023 at 18:45):
Oh OK. We also do this sort of thing occasionally in Lean 3, e.g. here in data.rat.basic
(and I didn't really understand why we had to do that either)
Patrick Massot (Jun 03 2023 at 18:46):
It doesn't mean this isn't a problem. I only meant that it's not paranormal.
Kevin Buzzard (Jun 03 2023 at 18:47):
"Lean does not do magic" -- Kenny Lau
Ruben Van de Velde (Jun 03 2023 at 19:07):
I seem to have it building, but please don't judge how :)
Last updated: Dec 20 2023 at 11:08 UTC