Zulip Chat Archive

Stream: new members

Topic: Working with nested intermediate fields


Michał Staromiejski (Oct 13 2024 at 18:18):

I'm trying to prove things in field theory and arrived at something that I don't yet understand regarding (nested) subtyping.
Here's my mwe:

import Mathlib.FieldTheory.Adjoin
import Mathlib.LinearAlgebra.Dimension.Finrank

open scoped IntermediateField /- `F⟮a⟯` notation -/

def test (F K : Type u) [Field F] [Field K] [Algebra F K] [FiniteDimensional F K]
    (E : IntermediateField F K) (a : E) :  :=
  FiniteDimensional.finrank Fa E

The error is in the last line saying: failed to synthesize Module ↥(IntermediateField.lift F⟮a⟯) ↥E.
As far as I understand, Lean tries to reinterpret F⟮a⟯ as IntermediateField F K (IntermediateField.lift F⟮a⟯) and then it cannot find instances existing in Mathlib for towers of extensions.
How to properly handle such cases?

Michał Staromiejski (Oct 14 2024 at 10:49):

Ok, I was able to workaround by

import Mathlib.FieldTheory.Adjoin
import Mathlib.LinearAlgebra.Dimension.Finrank

open scoped IntermediateField -- `F⟮a⟯` notation

variable (F K : Type u) [Field F] [Field K] [Algebra F K] [FiniteDimensional F K]

noncomputable def codeg (a : K) :  := FiniteDimensional.finrank Fa K

variable (E : IntermediateField F K) (a : E)

noncomputable def test :  := codeg F E a

But I'm still wondering if there is another way to work with such towers...
The following approaches also failed unless I explicitely add typeclass parameter:

import Mathlib.FieldTheory.Adjoin
import Mathlib.LinearAlgebra.Dimension.Finrank

open scoped IntermediateField -- `F⟮a⟯` notation

variable (F K : Type u) [Field F] [Field K] [Algebra F K] [FiniteDimensional F K]
variable (E : IntermediateField F K) (a : E)

-- does not work
noncomputable def test2 (E₁ : IntermediateField F E) :  := FiniteDimensional.finrank E₁ E
noncomputable def test3 (E₁ : IntermediateField F K) (h : E₁  E) :  := FiniteDimensional.finrank E₁ E

-- works but does not work "inline" with `haveI : ... := inferInstance`
noncomputable def test' [Algebra Fa E] :  := FiniteDimensional.finrank Fa E
noncomputable def test2' (E₁ : IntermediateField F E) [Algebra E₁ E] :  := FiniteDimensional.finrank E₁ E
noncomputable def test3' (E₁ : IntermediateField F K) (h : E₁  E) [Algebra E₁ E] :  := FiniteDimensional.finrank E₁ E

Last updated: May 02 2025 at 03:31 UTC