Zulip Chat Archive

Stream: Is there code for X?

Topic: The infinite place(s) of Q


Kevin Buzzard (Nov 26 2024 at 14:05):

I was going to prove a theorem about adeles of a number field by reducing to Q but I was unexpectedly thrown by a lack of API for infinite places for Q. I got this far:

import Mathlib

open NumberField

-- do we not have this?
def Rat.realAbsoluteValue : AbsoluteValue   where
  toFun q := |q|
  map_mul' x y := by simp only [cast_mul, abs_mul]
  nonneg' x := by simp only [abs_nonneg]
  eq_zero' x := by simp only [abs_eq_zero, cast_eq_zero]
  add_le' x y := by simp only [cast_add, abs_add_le]

-- one possibility for def of unique infinite place
def Rat.infinitePlace : InfinitePlace  := Rat.realAbsoluteValue, Rat.castHom , by
  ext; simp [Rat.realAbsoluteValue]

-- another one
noncomputable def Rat.infinitePlace' : InfinitePlace  := .mk (Rat.castHom _)

-- there's only one anyway
instance : Subsingleton (InfinitePlace ) where
  allEq a b := Subtype.ext <| by
    obtain ⟨_, _, rfl := a
    obtain ⟨_, _, rfl := b
    ext
    simp

-- this is true for all of them
lemma Rat.infinitePlace_apply (v : InfinitePlace ) (x : ) : v x = |x| := by
  obtain ⟨_, _, rfl := v
  change place _ _ = _
  simp

-- stuck on this
lemma foo (v : InfinitePlace ) (x : ) : (x : v.completion) = |x| := by
  sorry

There are three possibilities for trying to prove foo -- either cases on v, or use Subsingleton.elim to reduce to either infinitePlace or infinitePlace', but I couldn't get any of them to work :-) I'm only just learning all the API for this stuff, I've not really thought about real-valued norms before.

Riccardo Brasca (Nov 26 2024 at 14:06):

Cc @Xavier Roblot

Andrew Yang (Nov 26 2024 at 15:07):

lemma foo (v : InfinitePlace ) (x : ) : (x : v.completion) = |x| := by
  convert UniformSpace.Completion.norm_coe (E := WithAbs v.1) x using 1
  · congr 1
    show _ = UniformSpace.Completion.coeRingHom (α := WithAbs v.1) x
    exact (eq_ratCast _ _).symm
  · show _ = v.1 x
    obtain ⟨_, v, rfl := v
    simp

Adam Topaz (Nov 26 2024 at 15:33):

That's a lot of borderline defeq abuse, which probably suggests some missing API

Andrew Yang (Nov 26 2024 at 15:38):

We definitely need the rewrite lemmas instead of the show.

Kevin Buzzard (Nov 30 2024 at 17:23):

After many hours of trying to understand @Andrew Yang 's proof, I've come up with this, which I propose PRing. Any comments before I do?

import Mathlib

-- uniform space completion API
lemma UniformSpace.Completion.coeRingHom_apply {α : Type*} [Ring α] [UniformSpace α]
    [TopologicalRing α] [UniformAddGroup α] (x : α) : coeRingHom x = x := rfl

-- WithAbs.equiv API
lemma WithAbs.abv_equiv {R : Type*} [Ring R] (a : AbsoluteValue R )
    (x : WithAbs a) : a ((WithAbs.equiv a) x) = x := rfl

lemma WithAbs.norm_equiv_symm {R : Type*} [Ring R] (a : AbsoluteValue R ) (x : R) :
    (WithAbs.equiv a).symm x = a x := rfl

def WithAbs.equivRingHom {R : Type*} [Semiring R] (a : AbsoluteValue R ) :
    WithAbs a ≃+* R where
  toFun := WithAbs.equiv a
  invFun := (WithAbs.equiv a).symm
  left_inv _ := rfl
  right_inv _ := rfl
  map_mul' _ _ := rfl
  map_add' _ _ := rfl

-- Infinite place API
lemma NumberField.InfinitePlace.apply_def {K : Type*} [Field K] (v : InfinitePlace K) (x : K) :
  v x = v.1 x := rfl

-- Infinite place of ℚ API
open NumberField

noncomputable def Rat.infinitePlace : InfinitePlace  := .mk (Rat.castHom _)

instance : Subsingleton (InfinitePlace ) where
  allEq a b := Subtype.ext <| by
    obtain ⟨_, _, rfl := a
    obtain ⟨_, _, rfl := b
    ext
    simp

lemma Rat.infinitePlace_apply (v : InfinitePlace ) (x : ) : v x = |x| := by
  rw [NumberField.InfinitePlace.apply_def]
  obtain ⟨_, _, rfl := v
  simp

-- no defeq abuse
lemma Rat.norm_infinitePlace_completion (v : InfinitePlace ) (x : ) :
    (x : v.completion) = |x| := by
  rw [ eq_ratCast (UniformSpace.Completion.coeRingHom.comp (WithAbs.equivRingHom v.1).symm)]
  have := UniformSpace.Completion.norm_coe ((WithAbs.equiv v.1).symm x)
  rw [WithAbs.norm_equiv_symm] at this
  obtain a, φ, rfl := v
  simp [WithAbs.equivRingHom, this, UniformSpace.Completion.coeRingHom_apply]

Andrew Yang (Nov 30 2024 at 17:37):

I would suggest to also add the following two lemmas

lemma NumberField.InfinitePlace.completion.norm_coe {K : Type*} [Field K]
    (v : InfinitePlace K) (x : WithAbs v.1) :
    (x : v.completion) = v (WithAbs.equiv v.1 x) :=
  UniformSpace.Completion.norm_coe x

lemma WithAbs.ratCast_equiv (v : InfinitePlace ) (x : WithAbs v.1) :
    Rat.cast (WithAbs.equiv _ x) = (x : v.completion) :=
  (eq_ratCast (UniformSpace.Completion.coeRingHom.comp (WithAbs.equivRingHom v.1).symm.toRingHom) x).symm

-- no defeq abuse
lemma Rat.norm_infinitePlace_completion (v : InfinitePlace ) (x : ) :
    (x : v.completion) = |x| := by
  rw [ (WithAbs.equiv v.1).apply_symm_apply x, WithAbs.ratCast_equiv,
    NumberField.InfinitePlace.completion.norm_coe, (WithAbs.equiv v.1).apply_symm_apply,
    Rat.infinitePlace_apply]

Kevin Buzzard (Nov 30 2024 at 21:51):

#19644

Jz Pan (Dec 01 2024 at 14:20):

Maybe you can write

def WithAbs.equivRingHom {R : Type*} [Semiring R] (a : AbsoluteValue R ) :
    WithAbs a ≃+* R where
  __ := WithAbs.equiv a
  map_mul' _ _ := rfl
  map_add' _ _ := rfl

(untested)

Kevin Buzzard (Dec 01 2024 at 14:54):

During the PR process I discovered we already had it: docs#WithAbs.ringEquiv (and this is what I use in #19644)


Last updated: May 02 2025 at 03:31 UTC