Zulip Chat Archive

Stream: mathlib4

Topic: !4#5159 FieldTheory.PolynomialGaloisGroup


Xavier Roblot (Jun 21 2023 at 09:00):

There seems to be a diamond for IsScalarTower ℚ ℝ ℂ. Here is a #mwe coming from the port of #5159

import Mathlib.Algebra.Algebra.Tower
import Mathlib.Data.Complex.Module

example := AlgEquiv.restrictScalars  Complex.conjAe  -- failed to synthesize instance  IsScalarTower ℚ ℝ ℂ

Lean wants

@IsScalarTower    Algebra.toSMul Algebra.toSMul Algebra.toSMul

but the inferred instances are either docs#Complex.instIsScalarTowerComplexInstSMulComplexInstSMulComplex giving

@IsScalarTower    Algebra.toSMul Complex.instSMulComplex Complex.instSMulComplex

or docs#IsScalarTower.rat giving

@IsScalarTower    SMulZeroClass.toSMul SMulZeroClass.toSMul SMulZeroClass.toSMul

I tried to find out which instance was giving the term

@IsScalarTower    Algebra.toSMul Algebra.toSMul Algebra.toSMul

but I was unsuccessful.

Riccardo Brasca (Jun 21 2023 at 09:15):

I think docs#instIsScalarTowerComplexInstSMulComplexInstSMulComplex and docs#IsScalarTower.rat give exactly the same term

Riccardo Brasca (Jun 21 2023 at 09:16):

I mean, syntactically

Riccardo Brasca (Jun 21 2023 at 09:16):

That is

@IsScalarTower   
  (@Algebra.toSMul   Rat.commSemiring Real.semiring
    (@algebraRat  Real.instDivisionRingReal
      (_ :
        @CharZero 
          (@AddCommMonoidWithOne.toAddMonoidWithOne 
            (@NonAssocSemiring.toAddCommMonoidWithOne 
              (@Semiring.toNonAssocSemiring  (@StrictOrderedSemiring.toSemiring  Real.strictOrderedSemiring)))))))
  (@Complex.instSMulComplex 
    (@Algebra.toSMul   Real.instCommSemiringReal Real.semiring (@Algebra.id  Real.instCommSemiringReal)))
  (@Complex.instSMulComplex 
    (@Algebra.toSMul   Rat.commSemiring Real.semiring
      (@algebraRat  Real.instDivisionRingReal
        (_ :
          @CharZero 
            (@AddCommMonoidWithOne.toAddMonoidWithOne 
              (@NonAssocSemiring.toAddCommMonoidWithOne 
                (@Semiring.toNonAssocSemiring  (@StrictOrderedSemiring.toSemiring  Real.strictOrderedSemiring))))))))

Riccardo Brasca (Jun 21 2023 at 09:17):

Lean wants

@IsScalarTower   
  (@Algebra.toSMul   Rat.commSemiring (@CommSemiring.toSemiring  Real.instCommSemiringReal)
    (@algebraRat  Real.instDivisionRingReal
      (_ :
        @CharZero 
          (@AddCommMonoidWithOne.toAddMonoidWithOne 
            (@NonAssocSemiring.toAddCommMonoidWithOne 
              (@Semiring.toNonAssocSemiring  (@StrictOrderedSemiring.toSemiring  Real.strictOrderedSemiring)))))))
  (@Algebra.toSMul   Real.instCommSemiringReal Complex.instSemiringComplex
    (@Complex.instAlgebraComplexInstSemiringComplex  Real.instCommSemiringReal
      (@Algebra.id  Real.instCommSemiringReal)))
  (@Algebra.toSMul   Rat.commSemiring Complex.instSemiringComplex
    (@algebraRat  (@Field.toDivisionRing  Complex.instFieldComplex) Complex.charZero))

Riccardo Brasca (Jun 21 2023 at 09:17):

It looks like again the CharZero diamond, if I convert the instance the goal is

@Eq (SMul  )
  (@Algebra.toSMul   Rat.commSemiring Complex.instSemiringComplex
    (@algebraRat  (@Field.toDivisionRing  Complex.instFieldComplex) Complex.charZero))
  (@Complex.instSMulComplex 
    (@Algebra.toSMul   Rat.commSemiring Real.semiring
      (@algebraRat  Real.instDivisionRingReal
        (_ :
          @CharZero 
            (@AddCommMonoidWithOne.toAddMonoidWithOne 
              (@NonAssocSemiring.toAddCommMonoidWithOne 
                (@Semiring.toNonAssocSemiring  (@StrictOrderedSemiring.toSemiring  Real.strictOrderedSemiring))))))))

Riccardo Brasca (Jun 21 2023 at 09:33):

No sorry, it's not exactly that one. In any case this is the diamond

import Mathlib.Data.Complex.Module

example : (Complex.instSMulComplex : SMul  ) = (Algebra.toSMul : SMul  ) := rfl --fails

Anne Baanen (Jun 21 2023 at 09:46):

The CharZero diamond should be fixable by giving the right qsmul field to docs#Complex.instFieldComplex.

Riccardo Brasca (Jun 21 2023 at 10:05):

Let me try this

Chris Hughes (Jun 21 2023 at 10:06):

I'm just about to open a PR myself

Riccardo Brasca (Jun 21 2023 at 10:08):

OK, I can review it then :D

Xavier Roblot (Jun 21 2023 at 10:50):

But why is it working in mathlib3 but not in mathlib4?

Chris Hughes (Jun 21 2023 at 11:33):

It doesn't work in mathlib3 either

Chris Hughes (Jun 21 2023 at 11:36):

I guess the file field_theory.polynomial_galois_group works because of some accident about which instance it finds first somewhere.

Xavier Roblot (Jun 21 2023 at 11:38):

I don't understand. This works:

import data.complex.module

example : (complex.has_smul : has_smul  ) = (algebra.to_has_smul : has_smul  ) := rfl

Am I missing something?

Chris Hughes (Jun 21 2023 at 11:42):

It works at the end of the file data.complex.module, but not if you put that line directly after the has_smul instance.

Chris Hughes (Jun 21 2023 at 11:43):

It works before the algebra instance on line 95 in that file, but not after, to be precise.


Last updated: Dec 20 2023 at 11:08 UTC