Skip to content

Commit 3830035

Browse files
committed
feat: CommSemiring (NonemptyInterval ℚ≥0) (leanprover-community#20783)
For rings with negation we need a total rewrite of `Mul`, which is a problem for a later PR. Co-authored-by: Eric Wieser <efw@google.com>
1 parent 1912962 commit 3830035

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Mathlib/Algebra/Order/Interval/Basic.lean

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Yaël Dillies
55
-/
66
import Mathlib.Algebra.Group.Pointwise.Set.Basic
7+
import Mathlib.Algebra.Ring.Prod
78
import Mathlib.Algebra.Order.BigOperators.Group.Finset
9+
import Mathlib.Algebra.Order.Ring.Canonical
810
import Mathlib.Order.Interval.Basic
911
import Mathlib.Tactic.Positivity.Core
1012

@@ -263,6 +265,40 @@ theorem bot_pow : ∀ {n : ℕ}, n ≠ 0 → (⊥ : Interval α) ^ n = ⊥
263265

264266
end Interval
265267

268+
/-!
269+
### Semiring structure
270+
271+
When `α` is a canonically `OrderedCommSemiring`, the previous `+` and `*` on `NonemptyInterval α`
272+
form a `CommSemiring`.
273+
-/
274+
275+
section NatCast
276+
variable [Preorder α] [NatCast α]
277+
278+
namespace NonemptyInterval
279+
280+
instance : NatCast (NonemptyInterval α) where
281+
natCast n := pure <| Nat.cast n
282+
283+
theorem fst_natCast (n : ℕ) : (n : NonemptyInterval α).fst = n := rfl
284+
285+
theorem snd_natCast (n : ℕ) : (n : NonemptyInterval α).snd = n := rfl
286+
287+
@[simp]
288+
theorem pure_natCast (n : ℕ) : pure (n : α) = n := rfl
289+
290+
end NonemptyInterval
291+
292+
end NatCast
293+
294+
namespace NonemptyInterval
295+
296+
instance [OrderedCommSemiring α] [CanonicallyOrderedAdd α] : CommSemiring (NonemptyInterval α) :=
297+
NonemptyInterval.toProd_injective.commSemiring _
298+
toProd_zero toProd_one toProd_add toProd_mul (swap toProd_nsmul) toProd_pow (fun _ => rfl)
299+
300+
end NonemptyInterval
301+
266302
/-!
267303
### Subtraction
268304

0 commit comments

Comments
 (0)