Zulip Chat Archive

Stream: Is there code for X?

Topic: Localization of ℤ at p as a subring of ℚ with hom. to ℤ/pℤ?


Michael Stoll (Mar 22 2022 at 10:20):

Does mathlib know that {x : ℚ // padic_val_rat p x ≥ 0} is a subring of ℚ and has a canonical homomorphism onto zmod p?

Johan Commelin (Mar 22 2022 at 10:30):

I'm afraid it (mathlib) does not.

Johan Commelin (Mar 22 2022 at 10:31):

But I think you can rather easily construct the map to ℤ_[p].

Michael Stoll (Mar 22 2022 at 10:34):

And then compose with to_zmod? But that would defeat the purpose, since the goal would be to produce a computable definition of to_zmod.

Michael Stoll (Mar 22 2022 at 10:35):

I see that there is ring_theory.localization, but a cursory look gives me the impression that this is much too abstract for my purpose.

Johan Commelin (Mar 22 2022 at 10:37):

Aah, if you want it to be computable, then I guess you'll have to handroll it

Junyan Xu (Apr 16 2022 at 00:43):

This ongoing PR realizes localization as a subring of the field of fractions.

Adam Topaz (Apr 16 2022 at 00:49):

More precisely #13425

Junyan Xu (Apr 16 2022 at 04:06):

It seems easiest to define localization.subring as ring_hom.range of the natural ring_hom from the localization to the fraction ring. Then docs#is_localization.surj will supply us with the desired representation of elements as quotients.

Junyan Xu (Apr 16 2022 at 04:09):

@Adam Topaz Have you reviewed my change of defintion of prime_of_le? I think it's most convenient to just use this new definition. If you want the valuation characterization we should just add a lemma mem_prime_of_le_iff.

Adam Topaz (Apr 16 2022 at 04:19):

@Junyan Xu , yeah that looks like a good approach.

Adam Topaz (Apr 16 2022 at 04:23):

Junyan Xu said:

It seems easiest to define localization.subring as ring_hom.range of the natural ring_hom from the localization to the fraction ring. Then docs#is_localization.surj will supply us with the desired representation of elements as quotients.

Yeah, this will probably make the initial definitions a little shorter. But it's really nice when you can write rintro \<_,a,b,hb,rfl\> to automatically get the presentation of the element of your localization as a fraction

Junyan Xu (Apr 16 2022 at 07:11):

It seems easiest to define localization.subring as ring_hom.range of the natural ring_hom from the localization to the fraction ring.

@Adam Topaz Here's that definition worked out! Not just a bit shorter :) https://github.com/leanprover-community/mathlib/compare/localization_subring...loc_subring_range?expand=1

This would break defeq so valuation_subring_order needs to be fixed, but that shouldn't be hard.

Junyan Xu (Apr 17 2022 at 02:58):

I proceeded with the ring_hom.range definition and generalized as_subring.lean a bit to allow A not a domain / K not a field. However, the inverse is only available in a field, so I can only recover the original definition as lemma mem_iff_of_field in the field case.

Here is what it takes to adapt valuation_subring to use the new definition of localization.subring: it just involves a couple of of erw mem_iff_of_field. If you don't like it we can make a subring.copy in the field case. Everything is in the branch val_subring_order_golf and ready to be merged into #13429.

Adam Topaz (Apr 17 2022 at 03:59):

@Junyan Xu Nice! What do you think about the following:

  1. Make (is_localization.lift (λ s, by apply is_localization.map_units K ⟨s.1, hS s.2⟩) : localization S →+* K) into a def, say map_to_fraction_ring or something.
  2. Make your mem_iff lemma into a lemma about the range of the map from 1.
  3. Define subring K S hS using subring.copy, using mem_iff to make the carrier defeq to the condition given by mem_iff.
    The nice definitional properties of the carrier would be essentially all the same, and I think most (if not all) of the shortened proofs would still remain.

Adam Topaz (Apr 17 2022 at 04:00):

In any case, I won't be able to do anything involving lean until at least Tuesday, so I changed to a WIP tag on #13425

Adam Topaz (Apr 17 2022 at 04:02):

If you want to merge what you wrote to my branch, please do go ahead.

Junyan Xu (Apr 17 2022 at 04:03):

Thanks for taking a look! What you suggest looks like a good plan, but if we do subring.copy in the general (comm_ring) case, do we want another subring.copy to get nicer defeq in the field case?

Junyan Xu (Apr 17 2022 at 04:05):

We won't be able to use rfl in the general case, so it's not as nice as the field case where we can use rintro \<_,a,b,hb,rfl\> .

Adam Topaz (Apr 17 2022 at 04:08):

Naw, I think the carrier in the more general case would be essentially just as good as the condition in the field case.

Adam Topaz (Apr 17 2022 at 04:09):

So I suggest keeping the statement of mem_iff_of_field the same, while making mem_iff true by refl.

Adam Topaz (Apr 17 2022 at 04:15):

Hmm... Maybe we should only define subring in the case of fields? If we name the map as I suggested above, using range in the general case along with your mem_iff is probably as good as it gets. In the field case, we could use subring which is useful for definitional tricks like using rcases/rintro with rfl.

Junyan Xu (Apr 18 2022 at 06:09):

I've made the subring -> subalgebra change, which gets rid of a bunch of instance declarations.

I changed mem_iff to a version using docs#is_localization.mk', which enables rintro rfl and can be converted to the original version using docs#is_localization.mk'_eq_iff_eq_mul, and the proof of mem_iff_of_field simplifies slightly.

https://github.com/leanprover-community/mathlib/compare/valuation_subring_order...val_subring_order_golf?expand=1

I have not done the copy stuff. If you think it needs to be done for future convenience, I suggest we rename the current subalgebra to something like subalgebra_aux, and define subalgebra using copy in the field case.

Adam Topaz (Apr 19 2022 at 01:11):

I'm a bit surprised we don't have a version of is_localization.lift that gives an alg_hom. Maybe I missed it?

Adam Topaz (Apr 19 2022 at 01:24):

@Junyan Xu I merged your branch into branch#valuation_subring_order ... No need to have divergent branches for this! Please feel free to push directly to valuation_subring_order (this is becoming a collaborative PR anyway ;))

Junyan Xu (Apr 19 2022 at 01:52):

@Adam Topaz Yeah that's a bit surprising, I guess maybe the alg_hom API wasn't well developed when most of ring_theory.localization was written? Searching for in ring_theory.localization.basic shows it appears in only 4 declarations.

Thanks! I was working in that branch so it was most convenient to push to it, but now that you merged it I'll work in branch#valuation_subring_order henceforth.

Adam Topaz (Apr 19 2022 at 01:53):

I just pushed a start to the approach using copy.

Adam Topaz (Apr 19 2022 at 01:58):

As you can see, I defined this map_to_fraction_ring algebra hom, and defined subalgebra by copying using the range of that.
There is still one sorry (about bijectivity) and some similar isntances to add for subalgebra_of_field.

I wonder whether it's worthwhile to add some of these localization instances for (map_to_fraction_ring _ _ _).range as well, and use subalgebra.copy_eq and subalgebra.equiv_of_eq to construct the various instances for subalgebra and subalgebra_of_field.

Adam Topaz (Apr 19 2022 at 01:59):

I won't be able to work on this any more tonight, but I'll probably have some more time tomorrow.

Junyan Xu (Apr 19 2022 at 02:02):

is_localization is Prop so we can just use the original proof:

instance is_localization_subalgebra :
  is_localization S (subalgebra K S hS) :=
by { dunfold localization.subalgebra, rw subalgebra.copy_eq, exact
is_localization.is_localization_of_alg_equiv S
{ commutes' := λ x, by { ext, apply is_localization.lift_eq } .. ring_equiv.of_bijective _
   begin
      refine λ a b h, (is_localization.lift_injective_iff _).2 (λ a b, _) (subtype.ext_iff.1 h),
      exact  λ h, congr_arg _ (is_localization.injective _ hS h),
              λ h, congr_arg _ (is_fraction_ring.injective A K h) ⟩,
    end, ring_hom.range_restrict_surjective _  } }

Last updated: Dec 20 2023 at 11:08 UTC