Zulip Chat Archive

Stream: Is there code for X?

Topic: with_zero (multiplicative A) ≃* multiplicative (with_bot A)


Eric Wieser (Feb 23 2022 at 17:20):

Do we have something like this anywhere?

section
local attribute [reducible] with_zero

def with_zero.to_additive {A} [add_monoid A] :
  with_zero (multiplicative A) ≃* multiplicative (with_bot A) :=
by exact mul_equiv.refl _
end

@[simp] lemma with_zero.to_additive_zero {A} [add_monoid A] :
  with_zero.to_additive (0 : with_zero (multiplicative A)) = multiplicative.of_add  := rfl
@[simp] lemma with_zero.to_additive_coe {A} [add_monoid A] (x : multiplicative A) :
  with_zero.to_additive x = multiplicative.of_add (x.to_add : with_bot A) := rfl
@[simp] lemma with_zero.to_additive_symm_bot {A} [add_monoid A] :
  with_zero.to_additive.symm (multiplicative.of_add ( : with_bot A)) = 0 := rfl
@[simp] lemma with_zero.to_additive_coe_of_add {A} [add_monoid A] (x : A) :
  with_zero.to_additive.symm (multiplicative.of_add (x : with_bot A)) =
    multiplicative.of_add x := rfl

Eric Wieser (Feb 23 2022 at 17:23):

I ask because this combined with #8889 gives an if-free definition of #12245's

def infty_valuation_def (r : ratfunc Fq) : with_zero (multiplicative ) :=
with_zero.to_additive.symm $
  multiplicative.of_add (r.num.degree.map coe - r.denom.degree.map coe : with_bot )

(cc @María Inés de Frutos Fernández)

María Inés de Frutos Fernández (Feb 23 2022 at 17:53):

As far as I know this is not in mathlib.
I think it would be nice to have the with_top version of this:

def with_zero.to_additive {A} [add_monoid A] :
  with_zero (multiplicative A) ≃* multiplicative (with_top A) :=
by exact mul_equiv.refl _

It might help to easily relate the valuation infty_valuation with its associated add_valuation (and more generally for other nonarchimedean valuations).

María Inés de Frutos Fernández (Feb 23 2022 at 17:55):

Currently in mathlib we seem to have more API for valuation and with_zero than for add_valuation and with_top, so I just use valuation, but it would be nice if there were a simple way to convert from one to the other.

Eric Wieser (Feb 23 2022 at 18:42):

You're right, with_top is probably the right choice, not with_bot, since that also makes this preserve the ordering relation.

Eric Wieser (Feb 23 2022 at 18:44):

I retract that comment, with_bot is the one that preserves order after all

Kevin Buzzard (Feb 23 2022 at 18:49):

With valuations in particular, Maria's convention is the useful one, because additive valuations like "v(n) = the highest power of p dividing n" have v(0)=+∞ and when converting to a multiplicative valuation you reverse the order.

Kevin Buzzard (Feb 23 2022 at 18:51):

v_mult(n)=e^v_add(n) with 0<e<1 (traditionally e=1/p)

Eric Wieser (Feb 23 2022 at 18:53):

I can't quite make the precise connection between your comment and my isomorphism above, although I can believe it's there

Kevin Buzzard (Feb 23 2022 at 18:54):

If G is a totally ordered abelian group then with_bot G and with_top G are order isomorphic via inv.

Eric Wieser (Feb 23 2022 at 18:55):

Yes, so I think I'd argue you should be chaining the equiv I suggest above with such an inv order isomorphism

Eric Wieser (Feb 23 2022 at 18:55):

I guess we have docs#order_iso.inv but no with_* version?

Eric Wieser (Feb 23 2022 at 18:57):

Hmm, I still think I'm missing something - order_iso.inv : G ≃o order_dual G, so either the total order changes things in a way I can't see, or you mean that with_top G ≃o with_bot (order_dual G) via inv.

Kevin Buzzard (Feb 23 2022 at 19:01):

You're rght -- there is an unsolvable "op" problem here. Additive valuations have the axiom v(ab)>= min v(a) v(b) and multiplicative valuations have the axiom v(ab) <= max v(a) v(b) and this is already culturally embedded. This is what's behind Maria's comment.

Eric Wieser (Feb 23 2022 at 19:13):

Right, so there's an order_dual hiding in the difference too

Eric Wieser (Feb 23 2022 at 19:24):

It took me forever, but I think you're describing foo or bar in:

import algebra.order.group
import control.equiv_functor

def order_iso.with_bot_dual {G : Type*} [has_le G] :
  order_dual (with_top G) o with_bot (order_dual G) :=
order_iso.refl _

def order_iso.with_top_dual {G : Type*} [has_le G] :
  order_dual (with_bot G) o with_top (order_dual G) :=
order_iso.refl _

def order_iso.with_top {α β} [partial_order α] [partial_order β] (e : α o β) :
  with_top α o with_top β :=
{ to_equiv := show option α  option β, from equiv_functor.map_equiv _ e,
  map_rel_iff' := λ x y, begin
    cases x; cases y;
      dsimp [equiv_functor.map_equiv, equiv_functor.map];
      dsimp [with_top.none_eq_top, with_top.some_eq_coe];
      try {simp},
    exact e.map_rel_iff,
  end }

variables {G : Type*} [group G] [partial_order G]
  [covariant_class G G (*) ()]
  [covariant_class G G (function.swap (*)) ()]

def bar : with_top G o with_top (order_dual G) :=
order_iso.with_top (order_iso.inv G)

def foo : with_top G o order_dual (with_bot G) :=
bar.trans order_iso.with_top_dual.symm

Kevin Buzzard (Feb 23 2022 at 19:27):

Right! We use foo and then to_additive when translating from mult to add

Yaël Dillies (Feb 23 2022 at 19:29):

Oh duh, did I forget to add the above with_top/with_bot equivalences?

Eric Wieser (Feb 23 2022 at 19:29):

The other important one we're missing is:

def order_iso.with_top {α β} [has_le α] [has_le β] (e : α o β) :
  with_top α o with_top β :=

Yaël Dillies (Feb 23 2022 at 19:31):

Have a look at #11677 :wink:

Yaël Dillies (Feb 23 2022 at 19:31):

I needed those for docs#lattice_hom in order to construct the free functor from Lattice to BoundedLattice.

Eric Wieser (Feb 23 2022 at 19:32):

I don't see the order_iso version there

Yaël Dillies (Feb 23 2022 at 19:33):

No, it's not there, but I was about to add it

Eric Wieser (Feb 23 2022 at 19:39):

I edited it above

Eric Wieser (Feb 23 2022 at 19:40):

The proof is gross, we should probably have an equiv_functor instance for with_top

Eric Wieser (Feb 24 2022 at 01:03):

Eric Wieser said:

It took me forever, but I think you're describing foo or bar in:
<snip>

I PR'd these three isos in #12264

Eric Wieser (Feb 24 2022 at 16:58):

The last pieces are in #12275. I'm not sure exactly how useful these are, but I think with all of them together you can push the type tags around while preserving structure.

Yaël Dillies (Feb 24 2022 at 17:01):

You should definitely have a look at branch#GroupWithZero

Eric Wieser (Feb 24 2022 at 17:15):

Is there any overlap? I don't see it

Yaël Dillies (Feb 24 2022 at 17:30):

My monoid_hom.with_zero is very close to your mul_equiv.with_zero_congr.

Eric Wieser (Feb 24 2022 at 17:58):

It's also very close to the docs#with_zero.map we already have, right?

Yaël Dillies (Feb 24 2022 at 20:01):

Yeah


Last updated: Dec 20 2023 at 11:08 UTC