l3lab/ntp-mathlib huggingface dataset:
theorem _root_.Real.toNNReal_sum_of_nonneg {α} {s : Finset α} {f : α → ℝ}
    (hf : ∀ a, a ∈ s → 0 ≤ f a) :
    Real.toNNReal (∑ a in s, f a) = ∑ a in s, Real.toNNReal (f a) := by
  rw [← NNReal.coe_eq, NNReal.coe_sum, Real.coe_toNNReal _ (Finset.sum_nonneg hf)]
  exact Finset.sum_congr rfl fun x hxs => by 

Proof state:
α : Type u_1
s : Finset α
f : α → ℝ
hf : ∀ a ∈ s, 0 ≤ f a
x : α
hxs : x ∈ s
⊢ f x = ↑(Real.toNNReal (f x))

Next tactic:
rw [Real.coe_toNNReal _ (hf x hxs)]
theorem _root_.Real.toNNReal_prod_of_nonneg {α} {s : Finset α} {f : α → ℝ}
    (hf : ∀ a, a ∈ s → 0 ≤ f a) :
    Real.toNNReal (∏ a in s, f a) = ∏ a in s, Real.toNNReal (f a) := by
  

Proof state:
α : Type u_1
s : Finset α
f : α → ℝ
hf : ∀ a ∈ s, 0 ≤ f a
⊢ Real.toNNReal (∏ a in s, f a) = ∏ a in s, Real.toNNReal (f a)

Next tactic:
rw [← NNReal.coe_eq, NNReal.coe_prod, Real.coe_toNNReal _ (Finset.prod_nonneg hf)]
theorem _root_.Real.toNNReal_prod_of_nonneg {α} {s : Finset α} {f : α → ℝ}
    (hf : ∀ a, a ∈ s → 0 ≤ f a) :
    Real.toNNReal (∏ a in s, f a) = ∏ a in s, Real.toNNReal (f a) := by
  rw [← NNReal.coe_eq, NNReal.coe_prod, Real.coe_toNNReal _ (Finset.prod_nonneg hf)]
  

Proof state:
α : Type u_1
s : Finset α
f : α → ℝ
hf : ∀ a ∈ s, 0 ≤ f a
⊢ ∏ i in s, f i = ∏ a in s, ↑(Real.toNNReal (f a))

Next tactic:
exact Finset.prod_congr rfl fun x hxs => by rw [Real.coe_toNNReal _ (hf x hxs)]
theorem _root_.Real.toNNReal_prod_of_nonneg {α} {s : Finset α} {f : α → ℝ}
    (hf : ∀ a, a ∈ s → 0 ≤ f a) :
    Real.toNNReal (∏ a in s, f a) = ∏ a in s, Real.toNNReal (f a) := by
  rw [← NNReal.coe_eq, NNReal.coe_prod, Real.coe_toNNReal _ (Finset.prod_nonneg hf)]
  exact Finset.prod_congr rfl fun x hxs => by 

Proof state:
α : Type u_1
s : Finset α
f : α → ℝ
hf : ∀ a ∈ s, 0 ≤ f a
x : α
hxs : x ∈ s
⊢ f x = ↑(Real.toNNReal (f x))

Next tactic:
rw [Real.coe_toNNReal _ (hf x hxs)]
noncomputable example : LinearOrder ℝ≥0 := by 

Proof state:
⊢ LinearOrder ℝ≥0

Next tactic:
infer_instance
@[simp]
theorem toNNReal_coe_nat (n : ℕ) : Real.toNNReal n = n :=
  NNReal.eq <| by 

Proof state:
n : ℕ
⊢ ↑(Real.toNNReal ↑n) = ↑↑n

Next tactic:
simp [Real.coe_toNNReal]
example : OrderBot ℝ≥0 := by 

Proof state:
⊢ OrderBot ℝ≥0

Next tactic:
infer_instance
example : PartialOrder ℝ≥0 := by 

Proof state:
⊢ PartialOrder ℝ≥0

Next tactic:
infer_instance
noncomputable example : CanonicallyLinearOrderedAddCommMonoid ℝ≥0 := by 

Proof state:
⊢ CanonicallyLinearOrderedAddCommMonoid ℝ≥0

Next tactic:
infer_instance
noncomputable example : LinearOrderedAddCommMonoid ℝ≥0 := by 

Proof state:
⊢ LinearOrderedAddCommMonoid ℝ≥0

Next tactic:
infer_instance
example : DistribLattice ℝ≥0 := by 

Proof state:
⊢ DistribLattice ℝ≥0

Next tactic:
infer_instance
example : SemilatticeInf ℝ≥0 := by 

Proof state:
⊢ SemilatticeInf ℝ≥0

Next tactic:
infer_instance
example : SemilatticeSup ℝ≥0 := by 

Proof state:
⊢ SemilatticeSup ℝ≥0

Next tactic:
infer_instance
noncomputable example : LinearOrderedSemiring ℝ≥0 := by 

Proof state:
⊢ LinearOrderedSemiring ℝ≥0

Next tactic:
infer_instance
example : OrderedCommSemiring ℝ≥0 := by 

Proof state:
⊢ OrderedCommSemiring ℝ≥0

Next tactic:
infer_instance
noncomputable example : LinearOrderedCommMonoid ℝ≥0 := by 

Proof state:
⊢ LinearOrderedCommMonoid ℝ≥0

Next tactic:
infer_instance
noncomputable example : LinearOrderedCommMonoidWithZero ℝ≥0 := by 

Proof state:
⊢ LinearOrderedCommMonoidWithZero ℝ≥0

Next tactic:
infer_instance
noncomputable example : LinearOrderedCommGroupWithZero ℝ≥0 := by 

Proof state:
⊢ LinearOrderedCommGroupWithZero ℝ≥0

Next tactic:
infer_instance
example : CanonicallyOrderedCommSemiring ℝ≥0 := by 

Proof state:
⊢ CanonicallyOrderedCommSemiring ℝ≥0

Next tactic:
infer_instance
example : DenselyOrdered ℝ≥0 := by 

Proof state:
⊢ DenselyOrdered ℝ≥0

Next tactic:
infer_instance
example : NoMaxOrder ℝ≥0 := by 

Proof state:
⊢ NoMaxOrder ℝ≥0

Next tactic:
infer_instance
@[norm_cast]
theorem coe_sSup (s : Set ℝ≥0) : (↑(sSup s) : ℝ) = sSup (((↑) : ℝ≥0 → ℝ) '' s) := by
  

Proof state:
s : Set ℝ≥0
⊢ ↑(sSup s) = sSup (toReal '' s)

Next tactic:
rcases Set.eq_empty_or_nonempty s with rfl|hs
@[norm_cast]
theorem coe_sSup (s : Set ℝ≥0) : (↑(sSup s) : ℝ) = sSup (((↑) : ℝ≥0 → ℝ) '' s) := by
  rcases Set.eq_empty_or_nonempty s with rfl|hs
  · 

Proof state:
case inl
⊢ ↑(sSup ∅) = sSup (toReal '' ∅)

Next tactic:
simp
@[norm_cast]
theorem coe_sSup (s : Set ℝ≥0) : (↑(sSup s) : ℝ) = sSup (((↑) : ℝ≥0 → ℝ) '' s) := by
  rcases Set.eq_empty_or_nonempty s with rfl|hs
  · simp
  

Proof state:
case inr
s : Set ℝ≥0
hs : Set.Nonempty s
⊢ ↑(sSup s) = sSup (toReal '' s)

Next tactic:
by_cases H : BddAbove s
@[norm_cast]
theorem coe_sSup (s : Set ℝ≥0) : (↑(sSup s) : ℝ) = sSup (((↑) : ℝ≥0 → ℝ) '' s) := by
  rcases Set.eq_empty_or_nonempty s with rfl|hs
  · simp
  by_cases H : BddAbove s
  · 

Proof state:
case pos
s : Set ℝ≥0
hs : Set.Nonempty s
H : BddAbove s
⊢ ↑(sSup s) = sSup (toReal '' s)

Next tactic:
have A : sSup (Subtype.val '' s) ∈ Set.Ici 0 := by
      apply Real.sSup_nonneg
      rintro - ⟨y, -, rfl⟩
      exact y.2
@[norm_cast]
theorem coe_sSup (s : Set ℝ≥0) : (↑(sSup s) : ℝ) = sSup (((↑) : ℝ≥0 → ℝ) '' s) := by
  rcases Set.eq_empty_or_nonempty s with rfl|hs
  · simp
  by_cases H : BddAbove s
  · have A : sSup (Subtype.val '' s) ∈ Set.Ici 0 := by
      

Proof state:
s : Set ℝ≥0
hs : Set.Nonempty s
H : BddAbove s
⊢ sSup (Subtype.val '' s) ∈ Set.Ici 0

Next tactic:
apply Real.sSup_nonneg
@[norm_cast]
theorem coe_sSup (s : Set ℝ≥0) : (↑(sSup s) : ℝ) = sSup (((↑) : ℝ≥0 → ℝ) '' s) := by
  rcases Set.eq_empty_or_nonempty s with rfl|hs
  · simp
  by_cases H : BddAbove s
  · have A : sSup (Subtype.val '' s) ∈ Set.Ici 0 := by
      apply Real.sSup_nonneg
      

Proof state:
case hS
s : Set ℝ≥0
hs : Set.Nonempty s
H : BddAbove s
⊢ ∀ x ∈ Subtype.val '' s, 0 ≤ x

Next tactic:
rintro - ⟨y, -, rfl⟩
@[norm_cast]
theorem coe_sSup (s : Set ℝ≥0) : (↑(sSup s) : ℝ) = sSup (((↑) : ℝ≥0 → ℝ) '' s) := by
  rcases Set.eq_empty_or_nonempty s with rfl|hs
  · simp
  by_cases H : BddAbove s
  · have A : sSup (Subtype.val '' s) ∈ Set.Ici 0 := by
      apply Real.sSup_nonneg
      rintro - ⟨y, -, rfl⟩
      

Proof state:
case hS.intro.intro
s : Set ℝ≥0
hs : Set.Nonempty s
H : BddAbove s
y : { r // 0 ≤ r }
⊢ 0 ≤ ↑y

Next tactic:
exact y.2
@[norm_cast]
theorem coe_sSup (s : Set ℝ≥0) : (↑(sSup s) : ℝ) = sSup (((↑) : ℝ≥0 → ℝ) '' s) := by
  rcases Set.eq_empty_or_nonempty s with rfl|hs
  · simp
  by_cases H : BddAbove s
  · have A : sSup (Subtype.val '' s) ∈ Set.Ici 0 := by
      apply Real.sSup_nonneg
      rintro - ⟨y, -, rfl⟩
      exact y.2
    

Proof state:
case pos
s : Set ℝ≥0
hs : Set.Nonempty s
H : BddAbove s
A : sSup (Subtype.val '' s) ∈ Set.Ici 0
⊢ ↑(sSup s) = sSup (toReal '' s)

Next tactic:
exact (@subset_sSup_of_within ℝ (Set.Ici (0 : ℝ)) _ _ (_) s hs H A).symm
@[norm_cast]
theorem coe_sSup (s : Set ℝ≥0) : (↑(sSup s) : ℝ) = sSup (((↑) : ℝ≥0 → ℝ) '' s) := by
  rcases Set.eq_empty_or_nonempty s with rfl|hs
  · simp
  by_cases H : BddAbove s
  · have A : sSup (Subtype.val '' s) ∈ Set.Ici 0 := by
      apply Real.sSup_nonneg
      rintro - ⟨y, -, rfl⟩
      exact y.2
    exact (@subset_sSup_of_within ℝ (Set.Ici (0 : ℝ)) _ _ (_) s hs H A).symm
  · 

Proof state:
case neg
s : Set ℝ≥0
hs : Set.Nonempty s
H : ¬BddAbove s
⊢ ↑(sSup s) = sSup (toReal '' s)

Next tactic:
simp only [csSup_of_not_bddAbove H, csSup_empty, bot_eq_zero', NNReal.coe_zero]
@[norm_cast]
theorem coe_sSup (s : Set ℝ≥0) : (↑(sSup s) : ℝ) = sSup (((↑) : ℝ≥0 → ℝ) '' s) := by
  rcases Set.eq_empty_or_nonempty s with rfl|hs
  · simp
  by_cases H : BddAbove s
  · have A : sSup (Subtype.val '' s) ∈ Set.Ici 0 := by
      apply Real.sSup_nonneg
      rintro - ⟨y, -, rfl⟩
      exact y.2
    exact (@subset_sSup_of_within ℝ (Set.Ici (0 : ℝ)) _ _ (_) s hs H A).symm
  · simp only [csSup_of_not_bddAbove H, csSup_empty, bot_eq_zero', NNReal.coe_zero]
    

Proof state:
case neg
s : Set ℝ≥0
hs : Set.Nonempty s
H : ¬BddAbove s
⊢ 0 = sSup (toReal '' s)

Next tactic:
apply (Real.sSup_of_not_bddAbove ?_).symm
@[norm_cast]
theorem coe_sSup (s : Set ℝ≥0) : (↑(sSup s) : ℝ) = sSup (((↑) : ℝ≥0 → ℝ) '' s) := by
  rcases Set.eq_empty_or_nonempty s with rfl|hs
  · simp
  by_cases H : BddAbove s
  · have A : sSup (Subtype.val '' s) ∈ Set.Ici 0 := by
      apply Real.sSup_nonneg
      rintro - ⟨y, -, rfl⟩
      exact y.2
    exact (@subset_sSup_of_within ℝ (Set.Ici (0 : ℝ)) _ _ (_) s hs H A).symm
  · simp only [csSup_of_not_bddAbove H, csSup_empty, bot_eq_zero', NNReal.coe_zero]
    apply (Real.sSup_of_not_bddAbove ?_).symm
    

Proof state:
s : Set ℝ≥0
hs : Set.Nonempty s
H : ¬BddAbove s
⊢ ¬BddAbove (toReal '' s)

Next tactic:
contrapose! H
@[norm_cast]
theorem coe_sSup (s : Set ℝ≥0) : (↑(sSup s) : ℝ) = sSup (((↑) : ℝ≥0 → ℝ) '' s) := by
  rcases Set.eq_empty_or_nonempty s with rfl|hs
  · simp
  by_cases H : BddAbove s
  · have A : sSup (Subtype.val '' s) ∈ Set.Ici 0 := by
      apply Real.sSup_nonneg
      rintro - ⟨y, -, rfl⟩
      exact y.2
    exact (@subset_sSup_of_within ℝ (Set.Ici (0 : ℝ)) _ _ (_) s hs H A).symm
  · simp only [csSup_of_not_bddAbove H, csSup_empty, bot_eq_zero', NNReal.coe_zero]
    apply (Real.sSup_of_not_bddAbove ?_).symm
    contrapose! H
    

Proof state:
s : Set ℝ≥0
hs : Set.Nonempty s
H : BddAbove (toReal '' s)
⊢ BddAbove s

Next tactic:
exact bddAbove_coe.1 H
@[simp, norm_cast] -- porting note: add `simp`
theorem coe_iSup {ι : Sort*} (s : ι → ℝ≥0) : (↑(⨆ i, s i) : ℝ) = ⨆ i, ↑(s i) := by
  

Proof state:
ι : Sort u_1
s : ι → ℝ≥0
⊢ ↑(⨆ i, s i) = ⨆ i, ↑(s i)

Next tactic:
rw [iSup, iSup, coe_sSup, ← Set.range_comp]
@[simp, norm_cast] -- porting note: add `simp`
theorem coe_iSup {ι : Sort*} (s : ι → ℝ≥0) : (↑(⨆ i, s i) : ℝ) = ⨆ i, ↑(s i) := by
  rw [iSup, iSup, coe_sSup, ← Set.range_comp]; 

Proof state:
ι : Sort u_1
s : ι → ℝ≥0
⊢ sSup (Set.range (toReal ∘ fun i => s i)) = sSup (Set.range fun i => ↑(s i))

Next tactic:
rfl
@[norm_cast]
theorem coe_sInf (s : Set ℝ≥0) : (↑(sInf s) : ℝ) = sInf (((↑) : ℝ≥0 → ℝ) '' s) := by
  

Proof state:
s : Set ℝ≥0
⊢ ↑(sInf s) = sInf (toReal '' s)

Next tactic:
rcases Set.eq_empty_or_nonempty s with rfl|hs
@[norm_cast]
theorem coe_sInf (s : Set ℝ≥0) : (↑(sInf s) : ℝ) = sInf (((↑) : ℝ≥0 → ℝ) '' s) := by
  rcases Set.eq_empty_or_nonempty s with rfl|hs
  · 

Proof state:
case inl
⊢ ↑(sInf ∅) = sInf (toReal '' ∅)

Next tactic:
simp only [Set.image_empty, Real.sInf_empty, NNReal.coe_eq_zero]
@[norm_cast]
theorem coe_sInf (s : Set ℝ≥0) : (↑(sInf s) : ℝ) = sInf (((↑) : ℝ≥0 → ℝ) '' s) := by
  rcases Set.eq_empty_or_nonempty s with rfl|hs
  · simp only [Set.image_empty, Real.sInf_empty, NNReal.coe_eq_zero]
    

Proof state:
case inl
⊢ sInf ∅ = 0

Next tactic:
exact @subset_sInf_emptyset ℝ (Set.Ici (0 : ℝ)) _ _ (_)
@[norm_cast]
theorem coe_sInf (s : Set ℝ≥0) : (↑(sInf s) : ℝ) = sInf (((↑) : ℝ≥0 → ℝ) '' s) := by
  rcases Set.eq_empty_or_nonempty s with rfl|hs
  · simp only [Set.image_empty, Real.sInf_empty, NNReal.coe_eq_zero]
    exact @subset_sInf_emptyset ℝ (Set.Ici (0 : ℝ)) _ _ (_)
  

Proof state:
case inr
s : Set ℝ≥0
hs : Set.Nonempty s
⊢ ↑(sInf s) = sInf (toReal '' s)

Next tactic:
have A : sInf (Subtype.val '' s) ∈ Set.Ici 0 := by
    apply Real.sInf_nonneg
    rintro - ⟨y, -, rfl⟩
    exact y.2
@[norm_cast]
theorem coe_sInf (s : Set ℝ≥0) : (↑(sInf s) : ℝ) = sInf (((↑) : ℝ≥0 → ℝ) '' s) := by
  rcases Set.eq_empty_or_nonempty s with rfl|hs
  · simp only [Set.image_empty, Real.sInf_empty, NNReal.coe_eq_zero]
    exact @subset_sInf_emptyset ℝ (Set.Ici (0 : ℝ)) _ _ (_)
  have A : sInf (Subtype.val '' s) ∈ Set.Ici 0 := by
    

Proof state:
s : Set ℝ≥0
hs : Set.Nonempty s
⊢ sInf (Subtype.val '' s) ∈ Set.Ici 0

Next tactic:
apply Real.sInf_nonneg
@[norm_cast]
theorem coe_sInf (s : Set ℝ≥0) : (↑(sInf s) : ℝ) = sInf (((↑) : ℝ≥0 → ℝ) '' s) := by
  rcases Set.eq_empty_or_nonempty s with rfl|hs
  · simp only [Set.image_empty, Real.sInf_empty, NNReal.coe_eq_zero]
    exact @subset_sInf_emptyset ℝ (Set.Ici (0 : ℝ)) _ _ (_)
  have A : sInf (Subtype.val '' s) ∈ Set.Ici 0 := by
    apply Real.sInf_nonneg
    

Proof state:
case hS
s : Set ℝ≥0
hs : Set.Nonempty s
⊢ ∀ x ∈ Subtype.val '' s, 0 ≤ x

Next tactic:
rintro - ⟨y, -, rfl⟩
@[norm_cast]
theorem coe_sInf (s : Set ℝ≥0) : (↑(sInf s) : ℝ) = sInf (((↑) : ℝ≥0 → ℝ) '' s) := by
  rcases Set.eq_empty_or_nonempty s with rfl|hs
  · simp only [Set.image_empty, Real.sInf_empty, NNReal.coe_eq_zero]
    exact @subset_sInf_emptyset ℝ (Set.Ici (0 : ℝ)) _ _ (_)
  have A : sInf (Subtype.val '' s) ∈ Set.Ici 0 := by
    apply Real.sInf_nonneg
    rintro - ⟨y, -, rfl⟩
    

Proof state:
case hS.intro.intro
s : Set ℝ≥0
hs : Set.Nonempty s
y : { r // 0 ≤ r }
⊢ 0 ≤ ↑y

Next tactic:
exact y.2
@[norm_cast]
theorem coe_sInf (s : Set ℝ≥0) : (↑(sInf s) : ℝ) = sInf (((↑) : ℝ≥0 → ℝ) '' s) := by
  rcases Set.eq_empty_or_nonempty s with rfl|hs
  · simp only [Set.image_empty, Real.sInf_empty, NNReal.coe_eq_zero]
    exact @subset_sInf_emptyset ℝ (Set.Ici (0 : ℝ)) _ _ (_)
  have A : sInf (Subtype.val '' s) ∈ Set.Ici 0 := by
    apply Real.sInf_nonneg
    rintro - ⟨y, -, rfl⟩
    exact y.2
  

Proof state:
case inr
s : Set ℝ≥0
hs : Set.Nonempty s
A : sInf (Subtype.val '' s) ∈ Set.Ici 0
⊢ ↑(sInf s) = sInf (toReal '' s)

Next tactic:
exact (@subset_sInf_of_within ℝ (Set.Ici (0 : ℝ)) _ _ (_) s hs (OrderBot.bddBelow s) A).symm
@[simp]
theorem sInf_empty : sInf (∅ : Set ℝ≥0) = 0 := by
  

Proof state:
⊢ sInf ∅ = 0

Next tactic:
rw [← NNReal.coe_eq_zero, coe_sInf, Set.image_empty, Real.sInf_empty]
@[norm_cast]
theorem coe_iInf {ι : Sort*} (s : ι → ℝ≥0) : (↑(⨅ i, s i) : ℝ) = ⨅ i, ↑(s i) := by
  

Proof state:
ι : Sort u_1
s : ι → ℝ≥0
⊢ ↑(⨅ i, s i) = ⨅ i, ↑(s i)

Next tactic:
rw [iInf, iInf, coe_sInf, ← Set.range_comp]
@[norm_cast]
theorem coe_iInf {ι : Sort*} (s : ι → ℝ≥0) : (↑(⨅ i, s i) : ℝ) = ⨅ i, ↑(s i) := by
  rw [iInf, iInf, coe_sInf, ← Set.range_comp]; 

Proof state:
ι : Sort u_1
s : ι → ℝ≥0
⊢ sInf (Set.range (toReal ∘ fun i => s i)) = sInf (Set.range fun i => ↑(s i))

Next tactic:
rfl
theorem le_iInf_add_iInf {ι ι' : Sort*} [Nonempty ι] [Nonempty ι'] {f : ι → ℝ≥0} {g : ι' → ℝ≥0}
    {a : ℝ≥0} (h : ∀ i j, a ≤ f i + g j) : a ≤ (⨅ i, f i) + ⨅ j, g j := by
  

Proof state:
ι : Sort u_1
ι' : Sort u_2
inst✝¹ : Nonempty ι
inst✝ : Nonempty ι'
f : ι → ℝ≥0
g : ι' → ℝ≥0
a : ℝ≥0
h : ∀ (i : ι) (j : ι'), a ≤ f i + g j
⊢ a ≤ (⨅ i, f i) + ⨅ j, g j

Next tactic:
rw [← NNReal.coe_le_coe, NNReal.coe_add, coe_iInf, coe_iInf]
theorem le_iInf_add_iInf {ι ι' : Sort*} [Nonempty ι] [Nonempty ι'] {f : ι → ℝ≥0} {g : ι' → ℝ≥0}
    {a : ℝ≥0} (h : ∀ i j, a ≤ f i + g j) : a ≤ (⨅ i, f i) + ⨅ j, g j := by
  rw [← NNReal.coe_le_coe, NNReal.coe_add, coe_iInf, coe_iInf]
  

Proof state:
ι : Sort u_1
ι' : Sort u_2
inst✝¹ : Nonempty ι
inst✝ : Nonempty ι'
f : ι → ℝ≥0
g : ι' → ℝ≥0
a : ℝ≥0
h : ∀ (i : ι) (j : ι'), a ≤ f i + g j
⊢ ↑a ≤ (⨅ i, ↑(f i)) + ⨅ i, ↑(g i)

Next tactic:
exact le_ciInf_add_ciInf h
example : Archimedean ℝ≥0 := by 

Proof state:
⊢ Archimedean ℝ≥0

Next tactic:
infer_instance
theorem lt_iff_exists_rat_btwn (a b : ℝ≥0) :
    a < b ↔ ∃ q : ℚ, 0 ≤ q ∧ a < Real.toNNReal q ∧ Real.toNNReal q < b :=
  Iff.intro
    (fun h : (↑a : ℝ) < (↑b : ℝ) =>
      let ⟨q, haq, hqb⟩ := exists_rat_btwn h
      have : 0 ≤ (q : ℝ) := le_trans a.2 <| le_of_lt haq
      ⟨q, Rat.cast_nonneg.1 this, by
        

Proof state:
a b : ℝ≥0
h : ↑a < ↑b
q : ℚ
haq : ↑a < ↑q
hqb : ↑q < ↑b
this : 0 ≤ ↑q
⊢ a < Real.toNNReal ↑q ∧ Real.toNNReal ↑q < b

Next tactic:
simp [Real.coe_toNNReal _ this, NNReal.coe_lt_coe.symm, haq, hqb]
theorem finset_sup_div {α} {f : α → ℝ≥0} {s : Finset α} (r : ℝ≥0) :
    s.sup f / r = s.sup fun a => f a / r := by 

Proof state:
α : Type u_1
f : α → ℝ≥0
s : Finset α
r : ℝ≥0
⊢ Finset.sup s f / r = Finset.sup s fun a => f a / r

Next tactic:
simp only [div_eq_inv_mul, mul_finset_sup]
@[simp]
theorem toNNReal_pos {r : ℝ} : 0 < Real.toNNReal r ↔ 0 < r := by
  

Proof state:
r : ℝ
⊢ 0 < toNNReal r ↔ 0 < r

Next tactic:
simp [← NNReal.coe_lt_coe, lt_irrefl]
@[simp]
theorem toNNReal_eq_zero {r : ℝ} : Real.toNNReal r = 0 ↔ r ≤ 0 := by
  

Proof state:
r : ℝ
⊢ toNNReal r = 0 ↔ r ≤ 0

Next tactic:
simpa [-toNNReal_pos] using not_iff_not.2 (@toNNReal_pos r)
@[simp]
theorem toNNReal_le_toNNReal_iff {r p : ℝ} (hp : 0 ≤ p) :
    toNNReal r ≤ toNNReal p ↔ r ≤ p := by 

Proof state:
r p : ℝ
hp : 0 ≤ p
⊢ toNNReal r ≤ toNNReal p ↔ r ≤ p

Next tactic:
simp [← NNReal.coe_le_coe, hp]
@[simp]
lemma toNNReal_le_one {r : ℝ} : r.toNNReal ≤ 1 ↔ r ≤ 1 := by
  

Proof state:
r : ℝ
⊢ toNNReal r ≤ 1 ↔ r ≤ 1

Next tactic:
simpa using toNNReal_le_toNNReal_iff zero_le_one
@[simp]
lemma one_lt_toNNReal {r : ℝ} : 1 < r.toNNReal ↔ 1 < r := by
  

Proof state:
r : ℝ
⊢ 1 < toNNReal r ↔ 1 < r

Next tactic:
simpa only [not_le] using toNNReal_le_one.not
@[simp]
lemma toNNReal_le_nat_cast {r : ℝ} {n : ℕ} : r.toNNReal ≤ n ↔ r ≤ n := by
  

Proof state:
r : ℝ
n : ℕ
⊢ toNNReal r ≤ ↑n ↔ r ≤ ↑n

Next tactic:
simpa using toNNReal_le_toNNReal_iff n.cast_nonneg
@[simp]
lemma nat_cast_lt_toNNReal {r : ℝ} {n : ℕ} : n < r.toNNReal ↔ n < r := by
  

Proof state:
r : ℝ
n : ℕ
⊢ ↑n < toNNReal r ↔ ↑n < r

Next tactic:
simpa only [not_le] using toNNReal_le_nat_cast.not
@[simp]
theorem toNNReal_eq_toNNReal_iff {r p : ℝ} (hr : 0 ≤ r) (hp : 0 ≤ p) :
    toNNReal r = toNNReal p ↔ r = p := by 

Proof state:
r p : ℝ
hr : 0 ≤ r
hp : 0 ≤ p
⊢ toNNReal r = toNNReal p ↔ r = p

Next tactic:
simp [← NNReal.coe_eq, coe_toNNReal, hr, hp]
lemma toNNReal_le_toNNReal_iff' {r p : ℝ} : r.toNNReal ≤ p.toNNReal ↔ r ≤ p ∨ r ≤ 0 := by
  

Proof state:
r p : ℝ
⊢ toNNReal r ≤ toNNReal p ↔ r ≤ p ∨ r ≤ 0

Next tactic:
simp_rw [← not_lt, toNNReal_lt_toNNReal_iff', not_and_or]
lemma toNNReal_le_toNNReal_iff_of_pos {r p : ℝ} (hr : 0 < r) : r.toNNReal ≤ p.toNNReal ↔ r ≤ p := by
  

Proof state:
r p : ℝ
hr : 0 < r
⊢ toNNReal r ≤ toNNReal p ↔ r ≤ p

Next tactic:
simp [toNNReal_le_toNNReal_iff', hr.not_le]
@[simp]
lemma one_le_toNNReal {r : ℝ} : 1 ≤ r.toNNReal ↔ 1 ≤ r := by
  

Proof state:
r : ℝ
⊢ 1 ≤ toNNReal r ↔ 1 ≤ r

Next tactic:
simpa using toNNReal_le_toNNReal_iff_of_pos one_pos
@[simp]
lemma toNNReal_lt_one {r : ℝ} : r.toNNReal < 1 ↔ r < 1 := by 

Proof state:
r : ℝ
⊢ toNNReal r < 1 ↔ r < 1

Next tactic:
simp only [← not_le, one_le_toNNReal]
@[simp]
lemma nat_cast_le_toNNReal' {n : ℕ} {r : ℝ} : ↑n ≤ r.toNNReal ↔ n ≤ r ∨ n = 0 := by
  

Proof state:
n : ℕ
r : ℝ
⊢ ↑n ≤ toNNReal r ↔ ↑n ≤ r ∨ n = 0

Next tactic:
simpa [n.cast_nonneg.le_iff_eq] using toNNReal_le_toNNReal_iff' (r := n)
@[simp]
lemma toNNReal_lt_nat_cast' {n : ℕ} {r : ℝ} : r.toNNReal < n ↔ r < n ∧ n ≠ 0 := by
  

Proof state:
n : ℕ
r : ℝ
⊢ toNNReal r < ↑n ↔ r < ↑n ∧ n ≠ 0

Next tactic:
simpa [pos_iff_ne_zero] using toNNReal_lt_toNNReal_iff' (r := r) (p := n)
lemma nat_cast_le_toNNReal {n : ℕ} {r : ℝ} (hn : n ≠ 0) : ↑n ≤ r.toNNReal ↔ n ≤ r := by 

Proof state:
n : ℕ
r : ℝ
hn : n ≠ 0
⊢ ↑n ≤ toNNReal r ↔ ↑n ≤ r

Next tactic:
simp [hn]
lemma toNNReal_lt_nat_cast {r : ℝ} {n : ℕ} (hn : n ≠ 0) : r.toNNReal < n ↔ r < n := by 

Proof state:
r : ℝ
n : ℕ
hn : n ≠ 0
⊢ toNNReal r < ↑n ↔ r < ↑n

Next tactic:
simp [hn]
@[simp]
theorem toNNReal_add {r p : ℝ} (hr : 0 ≤ r) (hp : 0 ≤ p) :
    Real.toNNReal (r + p) = Real.toNNReal r + Real.toNNReal p :=
  NNReal.eq <| by 

Proof state:
r p : ℝ
hr : 0 ≤ r
hp : 0 ≤ p
⊢ ↑(toNNReal (r + p)) = ↑(toNNReal r + toNNReal p)

Next tactic:
simp [hr, hp, add_nonneg]
theorem le_toNNReal_iff_coe_le {r : ℝ≥0} {p : ℝ} (hp : 0 ≤ p) : r ≤ Real.toNNReal p ↔ ↑r ≤ p := by
  

Proof state:
r : ℝ≥0
p : ℝ
hp : 0 ≤ p
⊢ r ≤ toNNReal p ↔ ↑r ≤ p

Next tactic:
rw [← NNReal.coe_le_coe, Real.coe_toNNReal p hp]
theorem le_toNNReal_iff_coe_le' {r : ℝ≥0} {p : ℝ} (hr : 0 < r) : r ≤ Real.toNNReal p ↔ ↑r ≤ p :=
  (le_or_lt 0 p).elim le_toNNReal_iff_coe_le fun hp => by
    

Proof state:
r : ℝ≥0
p : ℝ
hr : 0 < r
hp : p < 0
⊢ r ≤ toNNReal p ↔ ↑r ≤ p

Next tactic:
simp only [(hp.trans_le r.coe_nonneg).not_le, toNNReal_eq_zero.2 hp.le, hr.not_le]
theorem toNNReal_lt_iff_lt_coe {r : ℝ} {p : ℝ≥0} (ha : 0 ≤ r) : Real.toNNReal r < p ↔ r < ↑p := by
  

Proof state:
r : ℝ
p : ℝ≥0
ha : 0 ≤ r
⊢ toNNReal r < p ↔ r < ↑p

Next tactic:
rw [← NNReal.coe_lt_coe, Real.coe_toNNReal r ha]
theorem toNNReal_pow {x : ℝ} (hx : 0 ≤ x) (n : ℕ) : (x ^ n).toNNReal = x.toNNReal ^ n := by
  

Proof state:
x : ℝ
hx : 0 ≤ x
n : ℕ
⊢ toNNReal (x ^ n) = toNNReal x ^ n

Next tactic:
rw [← NNReal.coe_eq, NNReal.coe_pow, Real.coe_toNNReal _ (pow_nonneg hx _),
    Real.coe_toNNReal x hx]
theorem toNNReal_mul {p q : ℝ} (hp : 0 ≤ p) :
    Real.toNNReal (p * q) = Real.toNNReal p * Real.toNNReal q :=
  NNReal.eq <| by 

Proof state:
p q : ℝ
hp : 0 ≤ p
⊢ ↑(toNNReal (p * q)) = ↑(toNNReal p * toNNReal q)

Next tactic:
simp [mul_max_of_nonneg, hp]
theorem mul_eq_mul_left {a b c : ℝ≥0} (h : a ≠ 0) : a * b = a * c ↔ b = c := by
  

Proof state:
a b c : ℝ≥0
h : a ≠ 0
⊢ a * b = a * c ↔ b = c

Next tactic:
rw [mul_eq_mul_left_iff, or_iff_left h]
nonrec theorem exists_pow_lt_of_lt_one {a b : ℝ≥0} (ha : 0 < a) (hb : b < 1) :
    ∃ n : ℕ, b ^ n < a := by
  

Proof state:
a b : ℝ≥0
ha : 0 < a
hb : b < 1
⊢ ∃ n, b ^ n < a

Next tactic:
simpa only [← coe_pow, NNReal.coe_lt_coe] using
    exists_pow_lt_of_lt_one (NNReal.coe_pos.2 ha) (NNReal.coe_lt_coe.2 hb)
example : OrderedSub ℝ≥0 := by 

Proof state:
⊢ OrderedSub ℝ≥0

Next tactic:
infer_instance
@[simp]
theorem inv_le {r p : ℝ≥0} (h : r ≠ 0) : r⁻¹ ≤ p ↔ 1 ≤ r * p := by
  

Proof state:
r p : ℝ≥0
h : r ≠ 0
⊢ r⁻¹ ≤ p ↔ 1 ≤ r * p

Next tactic:
rw [← mul_le_mul_left (pos_iff_ne_zero.2 h), mul_inv_cancel h]
theorem inv_le_of_le_mul {r p : ℝ≥0} (h : 1 ≤ r * p) : r⁻¹ ≤ p := by
  

Proof state:
r p : ℝ≥0
h : 1 ≤ r * p
⊢ r⁻¹ ≤ p

Next tactic:
by_cases r = 0
theorem inv_le_of_le_mul {r p : ℝ≥0} (h : 1 ≤ r * p) : r⁻¹ ≤ p := by
  by_cases r = 0 <;> 

Proof state:
case pos
r p : ℝ≥0
h : 1 ≤ r * p
h✝ : r = 0
⊢ r⁻¹ ≤ p

Next tactic:
simp [*, inv_le]
theorem inv_le_of_le_mul {r p : ℝ≥0} (h : 1 ≤ r * p) : r⁻¹ ≤ p := by
  by_cases r = 0 <;> 

Proof state:
case neg
r p : ℝ≥0
h : 1 ≤ r * p
h✝ : ¬r = 0
⊢ r⁻¹ ≤ p

Next tactic:
simp [*, inv_le]
@[simp]
theorem le_inv_iff_mul_le {r p : ℝ≥0} (h : p ≠ 0) : r ≤ p⁻¹ ↔ r * p ≤ 1 := by
  

Proof state:
r p : ℝ≥0
h : p ≠ 0
⊢ r ≤ p⁻¹ ↔ r * p ≤ 1

Next tactic:
rw [← mul_le_mul_left (pos_iff_ne_zero.2 h), mul_inv_cancel h, mul_comm]
@[simp]
theorem lt_inv_iff_mul_lt {r p : ℝ≥0} (h : p ≠ 0) : r < p⁻¹ ↔ r * p < 1 := by
  

Proof state:
r p : ℝ≥0
h : p ≠ 0
⊢ r < p⁻¹ ↔ r * p < 1

Next tactic:
rw [← mul_lt_mul_left (pos_iff_ne_zero.2 h), mul_inv_cancel h, mul_comm]
theorem mul_le_iff_le_inv {a b r : ℝ≥0} (hr : r ≠ 0) : r * a ≤ b ↔ a ≤ r⁻¹ * b := by
  

Proof state:
a b r : ℝ≥0
hr : r ≠ 0
⊢ r * a ≤ b ↔ a ≤ r⁻¹ * b

Next tactic:
have : 0 < r := lt_of_le_of_ne (zero_le r) hr.symm
theorem mul_le_iff_le_inv {a b r : ℝ≥0} (hr : r ≠ 0) : r * a ≤ b ↔ a ≤ r⁻¹ * b := by
  have : 0 < r := lt_of_le_of_ne (zero_le r) hr.symm
  

Proof state:
a b r : ℝ≥0
hr : r ≠ 0
this : 0 < r
⊢ r * a ≤ b ↔ a ≤ r⁻¹ * b

Next tactic:
rw [← mul_le_mul_left (inv_pos.mpr this), ← mul_assoc, inv_mul_cancel hr, one_mul]
theorem div_le_of_le_mul {a b c : ℝ≥0} (h : a ≤ b * c) : a / c ≤ b :=
  if h0 : c = 0 then by 

Proof state:
a b c : ℝ≥0
h : a ≤ b * c
h0 : c = 0
⊢ a / c ≤ b

Next tactic:
simp [h0]
theorem mul_lt_of_lt_div {a b r : ℝ≥0} (h : a < b / r) : a * r < b :=
  (lt_div_iff fun hr => False.elim <| by 

Proof state:
a b r : ℝ≥0
h : a < b / r
hr : r = 0
⊢ False

Next tactic:
simp [hr] at h
theorem le_of_forall_lt_one_mul_le {x y : ℝ≥0} (h : ∀ a < 1, a * x ≤ y) : x ≤ y :=
  le_of_forall_ge_of_dense fun a ha => by
    

Proof state:
x y : ℝ≥0
h : ∀ a < 1, a * x ≤ y
a : ℝ≥0
ha : a < x
⊢ a ≤ y

Next tactic:
have hx : x ≠ 0 := pos_iff_ne_zero.1 (lt_of_le_of_lt (zero_le _) ha)
theorem le_of_forall_lt_one_mul_le {x y : ℝ≥0} (h : ∀ a < 1, a * x ≤ y) : x ≤ y :=
  le_of_forall_ge_of_dense fun a ha => by
    have hx : x ≠ 0 := pos_iff_ne_zero.1 (lt_of_le_of_lt (zero_le _) ha)
    

Proof state:
x y : ℝ≥0
h : ∀ a < 1, a * x ≤ y
a : ℝ≥0
ha : a < x
hx : x ≠ 0
⊢ a ≤ y

Next tactic:
have hx' : x⁻¹ ≠ 0 := by rwa [Ne.def, inv_eq_zero]
theorem le_of_forall_lt_one_mul_le {x y : ℝ≥0} (h : ∀ a < 1, a * x ≤ y) : x ≤ y :=
  le_of_forall_ge_of_dense fun a ha => by
    have hx : x ≠ 0 := pos_iff_ne_zero.1 (lt_of_le_of_lt (zero_le _) ha)
    have hx' : x⁻¹ ≠ 0 := by 

Proof state:
x y : ℝ≥0
h : ∀ a < 1, a * x ≤ y
a : ℝ≥0
ha : a < x
hx : x ≠ 0
⊢ x⁻¹ ≠ 0

Next tactic:
rwa [Ne.def, inv_eq_zero]