# Documentation

Mathlib.Algebra.Tropical.Basic

# Tropical algebraic structures #

This file defines algebraic structures of the (min-)tropical numbers, up to the tropical semiring. Some basic lemmas about conversion from the base type R to tropical R are provided, as well as the expected implementations of tropical addition and tropical multiplication.

## Main declarations #

• Tropical R: The type synonym of the tropical interpretation of R. If [LinearOrder R], then addition on R is via min.
• Semiring (Tropical R): A LinearOrderedAddCommMonoidWithTop R induces a Semiring (Tropical R). If one solely has [LinearOrderedAddCommMonoid R], then the "tropicalization of R" would be Tropical (WithTop R).

## Implementation notes #

The tropical structure relies on Top and min. For the max-tropical numbers, use OrderDual R.

Inspiration was drawn from the implementation of Additive/Multiplicative/Opposite, where a type synonym is created with some barebones API, and quickly made irreducible.

Algebraic structures are provided with as few typeclass assumptions as possible, even though most references rely on Semiring (Tropical R) for building up the whole theory.

## References followed #

• https://arxiv.org/pdf/math/0408099.pdf
• https://www.mathenjeans.fr/sites/default/files/sujets/tropical_geometry_-_casagrande.pdf
def Tropical (R : Type u) :

The tropicalization of a type R.

Equations
def Tropical.trop {R : Type u} :
R

Reinterpret x : R as an element of Tropical R. See Tropical.tropEquiv for the equivalence.

Equations
• Tropical.trop = id
def Tropical.untrop {R : Type u} :
R

Reinterpret x : Tropical R as an element of R. See Tropical.tropEquiv for the equivalence.

Equations
• Tropical.untrop = id
@[simp]
theorem Tropical.trop_inj_iff {R : Type u} (x : R) (y : R) :
x = y
@[simp]
theorem Tropical.untrop_inj_iff {R : Type u} (x : ) (y : ) :
x = y
@[simp]
theorem Tropical.trop_untrop {R : Type u} (x : ) :
@[simp]
theorem Tropical.untrop_trop {R : Type u} (x : R) :
theorem Tropical.leftInverse_trop {R : Type u} :
Function.LeftInverse Tropical.trop Tropical.untrop
theorem Tropical.rightInverse_trop {R : Type u} :
Function.RightInverse Tropical.trop Tropical.untrop
def Tropical.tropEquiv {R : Type u} :
R

Reinterpret x : R as an element of Tropical R. See Tropical.tropOrderIso for the order-preserving equivalence.

Equations
• One or more equations did not get rendered due to their size.
@[simp]
theorem Tropical.tropEquiv_coe_fn {R : Type u} :
Tropical.tropEquiv = Tropical.trop
@[simp]
theorem Tropical.tropEquiv_symm_coe_fn {R : Type u} :
↑(Equiv.symm Tropical.tropEquiv) = Tropical.untrop
theorem Tropical.trop_eq_iff_eq_untrop {R : Type u} {x : R} {y : } :
theorem Tropical.untrop_eq_iff_eq_trop {R : Type u} {x : } {y : R} :
instance Tropical.instInhabitedTropical {R : Type u} [inst : ] :
Equations
def Tropical.tropRec {R : Type u} {F : Sort v} (h : (X : R) → F ()) (X : ) :
F X

Recursing on a x' : Tropical R is the same as recursing on an x : R reinterpreted as a term of Tropical R via trop x.

Equations
• = h ()
instance Tropical.instDecidableEqTropical {R : Type u} [inst : ] :
Equations
instance Tropical.instLETropical {R : Type u} [inst : LE R] :
LE ()
Equations
• Tropical.instLETropical = { le := fun x y => }
@[simp]
theorem Tropical.untrop_le_iff {R : Type u} [inst : LE R] {x : } {y : } :
x y
instance Tropical.decidableLE {R : Type u} [inst : LE R] [inst : DecidableRel fun x x_1 => x x_1] :
DecidableRel fun x x_1 => x x_1
Equations
• = inst () ()
instance Tropical.instLTTropical {R : Type u} [inst : LT R] :
LT ()
Equations
• Tropical.instLTTropical = { lt := fun x y => }
@[simp]
theorem Tropical.untrop_lt_iff {R : Type u} [inst : LT R] {x : } {y : } :
x < y
instance Tropical.decidableLT {R : Type u} [inst : LT R] [inst : DecidableRel fun x x_1 => x < x_1] :
DecidableRel fun x x_1 => x < x_1
Equations
• = inst () ()
instance Tropical.instPreorderTropical {R : Type u} [inst : ] :
Equations
• One or more equations did not get rendered due to their size.
def Tropical.tropOrderIso {R : Type u} [inst : ] :
R ≃o

Reinterpret x : R as an element of tropical R, preserving the order.

Equations
• One or more equations did not get rendered due to their size.
@[simp]
theorem Tropical.tropOrderIso_coe_fn {R : Type u} [inst : ] :
(RelIso.toRelEmbedding Tropical.tropOrderIso).toEmbedding = Tropical.trop
@[simp]
theorem Tropical.tropOrderIso_symm_coe_fn {R : Type u} [inst : ] :
(RelIso.toRelEmbedding (OrderIso.symm Tropical.tropOrderIso)).toEmbedding = Tropical.untrop
theorem Tropical.trop_monotone {R : Type u} [inst : ] :
Monotone Tropical.trop
theorem Tropical.untrop_monotone {R : Type u} [inst : ] :
Monotone Tropical.untrop
instance Tropical.instPartialOrderTropical {R : Type u} [inst : ] :
Equations
• Tropical.instPartialOrderTropical = let src := Tropical.instPreorderTropical; PartialOrder.mk (_ : ∀ (x x_1 : ), x x_1x_1 xx = x_1)
instance Tropical.instZeroTropical {R : Type u} [inst : Top R] :
Zero ()
Equations
• Tropical.instZeroTropical = { zero := }
instance Tropical.instTopTropical {R : Type u} [inst : Top R] :
Top ()
Equations
• Tropical.instTopTropical = { top := 0 }
@[simp]
theorem Tropical.untrop_zero {R : Type u} [inst : Top R] :
@[simp]
theorem Tropical.trop_top {R : Type u} [inst : Top R] :
@[simp]
theorem Tropical.trop_coe_ne_zero {R : Type u} (x : R) :
0
@[simp]
theorem Tropical.zero_ne_trop_coe {R : Type u} (x : R) :
0
@[simp]
theorem Tropical.le_zero {R : Type u} [inst : LE R] [inst : ] (x : ) :
x 0
instance Tropical.instOrderTopTropicalInstLETropical {R : Type u} [inst : LE R] [inst : ] :
Equations
• Tropical.instOrderTopTropicalInstLETropical = let src := Tropical.instTopTropical; OrderTop.mk (_ : ∀ (x : ), )
instance Tropical.instAddTropical {R : Type u} [inst : ] :

Tropical addition is the minimum of two underlying elements of R.

Equations
instance Tropical.instAddCommSemigroupTropical {R : Type u} [inst : ] :
Equations
@[simp]
theorem Tropical.untrop_add {R : Type u} [inst : ] (x : ) (y : ) :
Tropical.untrop (x + y) = min () ()
@[simp]
theorem Tropical.trop_min {R : Type u} [inst : ] (x : R) (y : R) :
@[simp]
theorem Tropical.trop_inf {R : Type u} [inst : ] (x : R) (y : R) :
theorem Tropical.trop_add_def {R : Type u} [inst : ] (x : ) (y : ) :
x + y = Tropical.trop (min () ())
instance Tropical.instLinearOrderTropical {R : Type u} [inst : ] :
Equations
• One or more equations did not get rendered due to their size.
@[simp]
theorem Tropical.untrop_sup {R : Type u} [inst : ] (x : ) (y : ) :
@[simp]
theorem Tropical.untrop_max {R : Type u} [inst : ] (x : ) (y : ) :
Tropical.untrop (max x y) = max () ()
@[simp]
theorem Tropical.min_eq_add {R : Type u} [inst : ] :
min = fun x x_1 => x + x_1
@[simp]
theorem Tropical.inf_eq_add {R : Type u} [inst : ] :
(fun x x_1 => x x_1) = fun x x_1 => x + x_1
theorem Tropical.trop_max_def {R : Type u} [inst : ] (x : ) (y : ) :
max x y = Tropical.trop (max () ())
theorem Tropical.trop_sup_def {R : Type u} [inst : ] (x : ) (y : ) :
x y =
@[simp]
theorem Tropical.add_eq_left {R : Type u} [inst : ] ⦃x : ⦃y : (h : x y) :
x + y = x
@[simp]
theorem Tropical.add_eq_right {R : Type u} [inst : ] ⦃x : ⦃y : (h : y x) :
x + y = y
theorem Tropical.add_eq_left_iff {R : Type u} [inst : ] {x : } {y : } :
x + y = x x y
theorem Tropical.add_eq_right_iff {R : Type u} [inst : ] {x : } {y : } :
x + y = y y x
theorem Tropical.add_self {R : Type u} [inst : ] (x : ) :
x + x = x
@[simp]
theorem Tropical.bit0 {R : Type u} [inst : ] (x : ) :
bit0 x = x
theorem Tropical.add_eq_iff {R : Type u} [inst : ] {x : } {y : } {z : } :
x + y = z x = z x y y = z y x
@[simp]
theorem Tropical.add_eq_zero_iff {R : Type u} [inst : ] {a : Tropical ()} {b : Tropical ()} :
a + b = 0 a = 0 b = 0
instance Tropical.instAddCommMonoidTropical {R : Type u} [inst : ] [inst : ] :
Equations
• Tropical.instAddCommMonoidTropical = let src := Tropical.instZeroTropical; let src_1 := Tropical.instAddCommSemigroupTropical; AddCommMonoid.mk (_ : ∀ (a b : ), a + b = b + a)
instance Tropical.instMulTropical {R : Type u} [inst : Add R] :
Mul ()

Tropical multiplication is the addition in the underlying R.

Equations
• Tropical.instMulTropical = { mul := fun x y => }
@[simp]
theorem Tropical.trop_add {R : Type u} [inst : Add R] (x : R) (y : R) :
@[simp]
theorem Tropical.untrop_mul {R : Type u} [inst : Add R] (x : ) (y : ) :
theorem Tropical.trop_mul_def {R : Type u} [inst : Add R] (x : ) (y : ) :
x * y =
instance Tropical.instOneTropical {R : Type u} [inst : Zero R] :
One ()
Equations
• Tropical.instOneTropical = { one := }
@[simp]
theorem Tropical.trop_zero {R : Type u} [inst : Zero R] :
@[simp]
theorem Tropical.untrop_one {R : Type u} [inst : Zero R] :
instance Tropical.instAddMonoidWithOneTropical {R : Type u} [inst : ] [inst : ] [inst : Zero R] :
Equations
instance Tropical.instInvTropical {R : Type u} [inst : Neg R] :
Inv ()
Equations
• Tropical.instInvTropical = { inv := fun x => }
@[simp]
theorem Tropical.untrop_inv {R : Type u} [inst : Neg R] (x : ) :
instance Tropical.instDivTropical {R : Type u} [inst : Sub R] :
Div ()
Equations
• Tropical.instDivTropical = { div := fun x y => }
@[simp]
theorem Tropical.untrop_div {R : Type u} [inst : Sub R] (x : ) (y : ) :
instance Tropical.instSemigroupTropical {R : Type u} [inst : ] :
Equations
• Tropical.instSemigroupTropical = Semigroup.mk (_ : ∀ (x x_1 x_2 : ), x * x_1 * x_2 = x * (x_1 * x_2))
instance Tropical.instCommSemigroupTropical {R : Type u} [inst : ] :
Equations
• Tropical.instCommSemigroupTropical = let src := Tropical.instSemigroupTropical; CommSemigroup.mk (_ : ∀ (x x_1 : ), x * x_1 = x_1 * x)
instance Tropical.instPowTropical {R : Type u} {α : Type u_1} [inst : SMul α R] :
Pow () α
Equations
• Tropical.instPowTropical = { pow := fun x n => }
@[simp]
theorem Tropical.untrop_pow {R : Type u} {α : Type u_1} [inst : SMul α R] (x : ) (n : α) :
@[simp]
theorem Tropical.trop_smul {R : Type u} {α : Type u_1} [inst : SMul α R] (x : R) (n : α) :
instance Tropical.instMulOneClassTropical {R : Type u} [inst : ] :
Equations
• Tropical.instMulOneClassTropical = MulOneClass.mk (_ : ∀ (x : ), 1 * x = x) (_ : ∀ (x : ), x * 1 = x)
instance Tropical.instMonoidTropical {R : Type u} [inst : ] :
Equations
• One or more equations did not get rendered due to their size.
@[simp]
theorem Tropical.trop_nsmul {R : Type u} [inst : ] (x : R) (n : ) :
instance Tropical.instCommMonoidTropical {R : Type u} [inst : ] :
Equations
• Tropical.instCommMonoidTropical = let src := Tropical.instMonoidTropical; let src_1 := Tropical.instCommSemigroupTropical; CommMonoid.mk (_ : ∀ (a b : ), a * b = b * a)
instance Tropical.instGroupTropical {R : Type u} [inst : ] :
Equations
• Tropical.instGroupTropical = let src := Tropical.instMonoidTropical; Group.mk (_ : ∀ (x : ), x⁻¹ * x = 1)
instance Tropical.instCommGroupTropical {R : Type u} [inst : ] :
Equations
• Tropical.instCommGroupTropical = let src := Tropical.instGroupTropical; CommGroup.mk (_ : ∀ (x x_1 : ), x * x_1 = x_1 * x)
@[simp]
theorem Tropical.untrop_zpow {R : Type u} [inst : ] (x : ) (n : ) :
@[simp]
theorem Tropical.trop_zsmul {R : Type u} [inst : ] (x : R) (n : ) :
instance Tropical.covariant_mul {R : Type u} [inst : LE R] [inst : Add R] [inst : CovariantClass R R (fun x x_1 => x + x_1) fun x x_1 => x x_1] :
CovariantClass () () (fun x x_1 => x * x_1) fun x x_1 => x x_1
Equations
instance Tropical.covariant_swap_mul {R : Type u} [inst : LE R] [inst : Add R] [inst : CovariantClass R R (Function.swap fun x x_1 => x + x_1) fun x x_1 => x x_1] :
CovariantClass () () (Function.swap fun x x_1 => x * x_1) fun x x_1 => x x_1
Equations
instance Tropical.covariant_add {R : Type u} [inst : ] :
CovariantClass () () (fun x x_1 => x + x_1) fun x x_1 => x x_1
Equations
instance Tropical.covariant_mul_lt {R : Type u} [inst : LT R] [inst : Add R] [inst : CovariantClass R R (fun x x_1 => x + x_1) fun x x_1 => x < x_1] :
CovariantClass () () (fun x x_1 => x * x_1) fun x x_1 => x < x_1
Equations
instance Tropical.covariant_swap_mul_lt {R : Type u} [inst : ] [inst : Add R] [inst : CovariantClass R R (Function.swap fun x x_1 => x + x_1) fun x x_1 => x < x_1] :
CovariantClass () () (Function.swap fun x x_1 => x * x_1) fun x x_1 => x < x_1
Equations
instance Tropical.instDistribTropical {R : Type u} [inst : ] [inst : Add R] [inst : CovariantClass R R (fun x x_1 => x + x_1) fun x x_1 => x x_1] [inst : CovariantClass R R (Function.swap fun x x_1 => x + x_1) fun x x_1 => x x_1] :
Equations
• Tropical.instDistribTropical = Distrib.mk (_ : ∀ (x x_1 x_2 : ), x * (x_1 + x_2) = x * x_1 + x * x_2) (_ : ∀ (x x_1 x_2 : ), (x + x_1) * x_2 = x * x_2 + x_1 * x_2)
@[simp]
theorem Tropical.add_pow {R : Type u} [inst : ] [inst : ] [inst : CovariantClass R R (fun x x_1 => x + x_1) fun x x_1 => x x_1] [inst : CovariantClass R R (Function.swap fun x x_1 => x + x_1) fun x x_1 => x x_1] (x : ) (y : ) (n : ) :
(x + y) ^ n = x ^ n + y ^ n
instance Tropical.instCommSemiringTropical {R : Type u} [inst : ] :
Equations
• One or more equations did not get rendered due to their size.
@[simp]
theorem Tropical.succ_nsmul {R : Type u_1} [inst : ] [inst : ] (x : ) (n : ) :
(n + 1) x = x
theorem Tropical.mul_eq_zero_iff {R : Type u_1} [inst : ] {a : Tropical ()} {b : Tropical ()} :
a * b = 0 a = 0 b = 0
Equations
• One or more equations did not get rendered due to their size.