Zulip Chat Archive

Stream: mathlib4

Topic: phantom declaration


Patrick Massot (Oct 25 2023 at 01:54):

The following code contains a phantom theorem. It looks declared (and sorried) but then the #check commands doesn't know about it. Replacing the sorry by the commented "proof" results in this tactic is never executed [linter.unreachableTactic] over the whole proof.

import Mathlib

noncomputable section

open Set Equiv Bundle ContinuousLinearMap

open scoped Manifold Bundle Topology

universe u v

variable {๐•œ : Type*} [NontriviallyNormedField ๐•œ] {E : Type u} [NormedAddCommGroup E]
  [NormedSpace ๐•œ E] {H : Type*} [TopologicalSpace H] (I : ModelWithCorners ๐•œ E H) (M : Type*)
  [TopologicalSpace M] [ChartedSpace H M] [SmoothManifoldWithCorners I M] {F : Type*}
  [NormedAddCommGroup F] [NormedSpace ๐•œ F] {G : Type*} [TopologicalSpace G]
  {J : ModelWithCorners ๐•œ F G} {N : Type*} [TopologicalSpace N] [ChartedSpace G N]
  [SmoothManifoldWithCorners J N] (V : Type*) [NormedAddCommGroup V] [NormedSpace ๐•œ V]

local notation "FJยนMV" =>
  Bundle.ContinuousLinearMap (RingHom.id ๐•œ) (TangentSpace I : M โ†’ Type*) (Bundle.Trivial M V)

local notation "JยนMV" => TotalSpace (E โ†’L[๐•œ] V) FJยนMV

section Smoothness

variable {I M V} {f : N โ†’ JยนMV}

theorem smoothAt_one_jet_eucl_bundle' {xโ‚€ : N} :
    SmoothAt J (I.prod ๐“˜(๐•œ, E โ†’L[๐•œ] V)) f xโ‚€ โ†” SmoothAt J I (fun x => (f x).1) xโ‚€ โˆง
    SmoothAt J ๐“˜(๐•œ, E โ†’L[๐•œ] V)
      (fun x => show E โ†’L[๐•œ] V from (f x).2 โˆ˜L (trivializationAt E (TangentSpace I : M โ†’ Type u) (f xโ‚€).1).symmL ๐•œ (f x).1) xโ‚€ := sorry
      /- by
  simp_rw [smoothAt_hom_bundle, in_coordinates, trivial.trivialization_at,
    trivial.trivialization_continuous_linear_map_at]
  dsimp only [Bundle.Trivial]
  simp_rw [ContinuousLinearMap.id_comp] -/

#check smoothAt_one_jet_eucl_bundle'

Any idea?

Patrick Massot (Oct 25 2023 at 01:54):

@Heather Macbeth, this is mathported from code you wrote.

Adam Topaz (Oct 25 2023 at 02:06):

Just for the sake of minimization, the first prop in the conjunction can be removed while preserving the issue (with the sorry):

theorem foo {xโ‚€ : N} :
    (SmoothAt J ๐“˜(๐•œ, E โ†’L[๐•œ] V)
      (fun x => show E โ†’L[๐•œ] V from (f x).2 โˆ˜L
        (trivializationAt E (TangentSpace I : M โ†’ Type u) (f xโ‚€).1).symmL ๐•œ (f x).1) xโ‚€) := sorry

#check foo

Mario Carneiro (Oct 25 2023 at 02:40):

This sounds related to an old lean4 issue of mine (lean4#2226), where an error would occur during elaboration without reporting any actual info diagnostics

Mario Carneiro (Oct 25 2023 at 02:48):

Yes, it's an instance of the same issue. There is an issue elaborating the variables line and it produces a synthetic sorry without reporting an error about it, which breaks an invariant of the system (synthetic sorries should only appear if errors have been reported), and if you do it right you can get no further error to be reported (because things see the synthetic sorry and think "I guess I don't need to add insult to injury here, we are already in an error state so no need to report more"

Patrick Massot (Oct 25 2023 at 02:48):

And lean4#2226 refers to lean4#2257 which seems very relevant here.

Patrick Massot (Oct 25 2023 at 02:49):

Getting rid of the local notation by copy-paste reveals an error.

Mario Carneiro (Oct 25 2023 at 02:49):

def foo := f will produce a definition, but notice that it has sorry in it caused by typechecking failures and there are no app mismatch errors or the like

Patrick Massot (Oct 25 2023 at 02:51):

New mystery is then

import Mathlib

noncomputable section

open Set Equiv Bundle ContinuousLinearMap

open scoped Manifold Bundle Topology

universe u v

variable {๐•œ : Type*} [NontriviallyNormedField ๐•œ] {E : Type u} [NormedAddCommGroup E]
  [NormedSpace ๐•œ E] {H : Type*} [TopologicalSpace H] (I : ModelWithCorners ๐•œ E H) (M : Type*)
  [TopologicalSpace M] [ChartedSpace H M] [SmoothManifoldWithCorners I M] {F : Type*}
  [NormedAddCommGroup F] [NormedSpace ๐•œ F] {G : Type*} [TopologicalSpace G]
  {J : ModelWithCorners ๐•œ F G} {N : Type*} [TopologicalSpace N] [ChartedSpace G N]
  [SmoothManifoldWithCorners J N] (V : Type*) [NormedAddCommGroup V] [NormedSpace ๐•œ V]

variable {I M V} {f : N โ†’ TotalSpace (E โ†’L[๐•œ] V) (Bundle.ContinuousLinearMap (RingHom.id ๐•œ) (TangentSpace I : M โ†’ Type u) (Bundle.Trivial M V))}

Patrick Massot (Oct 25 2023 at 02:51):

which does features an error message, so this is a great progress.

Mario Carneiro (Oct 25 2023 at 02:51):

you have to separate the two binder groups there or else {I M V} won't be interpreted as a binder update

Mario Carneiro (Oct 25 2023 at 02:52):

and

variable {I M V}
variable {f : N โ†’ TotalSpace (E โ†’L[๐•œ] V) (Bundle.ContinuousLinearMap (RingHom.id ๐•œ) (TangentSpace I : M โ†’ Type*) (Bundle.Trivial M V))}

has yet another error message

Patrick Massot (Oct 25 2023 at 02:53):

I know how to fix that one.

Patrick Massot (Oct 25 2023 at 02:54):

The following works now:

import Mathlib

noncomputable section

open Set Equiv Bundle ContinuousLinearMap

open scoped Manifold Bundle Topology

universe u v

variable {๐•œ : Type*} [NontriviallyNormedField ๐•œ] {E : Type u} [NormedAddCommGroup E]
  [NormedSpace ๐•œ E] {H : Type*} [TopologicalSpace H] (I : ModelWithCorners ๐•œ E H) (M : Type*)
  [TopologicalSpace M] [ChartedSpace H M] [SmoothManifoldWithCorners I M] {F : Type*}
  [NormedAddCommGroup F] [NormedSpace ๐•œ F] {G : Type*} [TopologicalSpace G]
  {J : ModelWithCorners ๐•œ F G} {N : Type*} [TopologicalSpace N] [ChartedSpace G N]
  [SmoothManifoldWithCorners J N] (V : Type*) [NormedAddCommGroup V] [NormedSpace ๐•œ V]

variable {I M V}

variable {f : N โ†’ TotalSpace (E โ†’L[๐•œ] V) (Bundle.ContinuousLinearMap (RingHom.id ๐•œ) (TangentSpace I : M โ†’ Type u) (Bundle.Trivial M V))}

theorem smoothAt_one_jet_eucl_bundle' {xโ‚€ : N} :
    SmoothAt J (I.prod ๐“˜(๐•œ, E โ†’L[๐•œ] V)) f xโ‚€ โ†” SmoothAt J I (fun x => (f x).1) xโ‚€ โˆง
    SmoothAt J ๐“˜(๐•œ, E โ†’L[๐•œ] V)
      (fun x => show E โ†’L[๐•œ] V from (f x).2 โˆ˜L (trivializationAt E (TangentSpace I : M โ†’ Type u) (f xโ‚€).1).symmL ๐•œ (f x).1) xโ‚€ := sorry
      /- by
  simp_rw [smoothAt_hom_bundle, in_coordinates, trivial.trivialization_at,
    trivial.trivialization_continuous_linear_map_at]
  dsimp only [Bundle.Trivial]
  simp_rw [ContinuousLinearMap.id_comp] -/

#check smoothAt_one_jet_eucl_bundle'

Patrick Massot (Oct 25 2023 at 02:54):

So I'm unstuck now.

Patrick Massot (Oct 25 2023 at 02:55):

Thanks a lot Mario! You can continue that impressive series by solving the minimization quest at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Another.20simp.20mystery/near/398356577

Mario Carneiro (Oct 25 2023 at 02:55):

what did you even change? I'm eyeball diffing and I don't see anything

Mario Carneiro (Oct 25 2023 at 02:55):

oh, Type* -> Type u

Mario Carneiro (Oct 25 2023 at 02:56):

what a terrible error message

Patrick Massot (Oct 25 2023 at 03:04):

Do you think there is anyway I could use a notation here? Or should I write TotalSpace (E โ†’L[๐•œ] V) (Bundle.ContinuousLinearMap (RingHom.id ๐•œ) (TangentSpace I : M โ†’ Type u) (Bundle.Trivial M V)) everywhere in this file?

Mario Carneiro (Oct 25 2023 at 03:05):

there's nothing wrong with using a notation, it was just hiding an error

Patrick Massot (Oct 25 2023 at 03:07):

Can you fix the above snippet while keeping a notation?

Patrick Massot (Oct 25 2023 at 03:07):

I think I already met that issue that local notations are no longer really allowed in Lean 4.

Patrick Massot (Oct 25 2023 at 03:08):

I found it https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Notation.20introduces.20sorry/near/390552023

Mario Carneiro (Oct 25 2023 at 03:13):

set_option hygiene false
local notation "FJยนMV" =>
  Bundle.ContinuousLinearMap (RingHom.id ๐•œ) (TangentSpace I : M โ†’ Type u) (Bundle.Trivial M V)
set_option hygiene true

local notation "JยนMV" => TotalSpace (E โ†’L[๐•œ] V) FJยนMV

section Smoothness

variable {I M V}
variable {f : N โ†’ JยนMV}

Patrick Massot (Oct 25 2023 at 03:15):

Thanks, but this introduces a sorry in the statement.


Last updated: Dec 20 2023 at 11:08 UTC