l3lab/ntp-mathlib huggingface dataset:
theorem condCount_disjoint_union (hs : s.Finite) (ht : t.Finite) (hst : Disjoint s t) :
    condCount s u * condCount (s ∪ t) s + condCount t u * condCount (s ∪ t) t =
      condCount (s ∪ t) u := by
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
ht : Set.Finite t
hst : Disjoint s t
⊢ ↑↑(condCount s) u * ↑↑(condCount (s ∪ t)) s + ↑↑(condCount t) u * ↑↑(condCount (s ∪ t)) t = ↑↑(condCount (s ∪ t)) u

Next tactic:
rcases s.eq_empty_or_nonempty with (rfl | hs')
theorem condCount_disjoint_union (hs : s.Finite) (ht : t.Finite) (hst : Disjoint s t) :
    condCount s u * condCount (s ∪ t) s + condCount t u * condCount (s ∪ t) t =
      condCount (s ∪ t) u := by
  rcases s.eq_empty_or_nonempty with (rfl | hs') <;> 

Proof state:
case inl
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
t u : Set Ω
ht : Set.Finite t
hs : Set.Finite ∅
hst : Disjoint ∅ t
⊢ ↑↑(condCount ∅) u * ↑↑(condCount (∅ ∪ t)) ∅ + ↑↑(condCount t) u * ↑↑(condCount (∅ ∪ t)) t = ↑↑(condCount (∅ ∪ t)) u

Next tactic:
rcases t.eq_empty_or_nonempty with (rfl | ht')
theorem condCount_disjoint_union (hs : s.Finite) (ht : t.Finite) (hst : Disjoint s t) :
    condCount s u * condCount (s ∪ t) s + condCount t u * condCount (s ∪ t) t =
      condCount (s ∪ t) u := by
  rcases s.eq_empty_or_nonempty with (rfl | hs') <;> 

Proof state:
case inr
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
ht : Set.Finite t
hst : Disjoint s t
hs' : Set.Nonempty s
⊢ ↑↑(condCount s) u * ↑↑(condCount (s ∪ t)) s + ↑↑(condCount t) u * ↑↑(condCount (s ∪ t)) t = ↑↑(condCount (s ∪ t)) u

Next tactic:
rcases t.eq_empty_or_nonempty with (rfl | ht')
theorem condCount_disjoint_union (hs : s.Finite) (ht : t.Finite) (hst : Disjoint s t) :
    condCount s u * condCount (s ∪ t) s + condCount t u * condCount (s ∪ t) t =
      condCount (s ∪ t) u := by
  rcases s.eq_empty_or_nonempty with (rfl | hs') <;> rcases t.eq_empty_or_nonempty with (rfl | ht')
  · 

Proof state:
case inl.inl
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
u : Set Ω
hs ht : Set.Finite ∅
hst : Disjoint ∅ ∅
⊢ ↑↑(condCount ∅) u * ↑↑(condCount (∅ ∪ ∅)) ∅ + ↑↑(condCount ∅) u * ↑↑(condCount (∅ ∪ ∅)) ∅ = ↑↑(condCount (∅ ∪ ∅)) u

Next tactic:
simp
theorem condCount_disjoint_union (hs : s.Finite) (ht : t.Finite) (hst : Disjoint s t) :
    condCount s u * condCount (s ∪ t) s + condCount t u * condCount (s ∪ t) t =
      condCount (s ∪ t) u := by
  rcases s.eq_empty_or_nonempty with (rfl | hs') <;> rcases t.eq_empty_or_nonempty with (rfl | ht')
  · simp
  · 

Proof state:
case inl.inr
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
t u : Set Ω
ht : Set.Finite t
hs : Set.Finite ∅
hst : Disjoint ∅ t
ht' : Set.Nonempty t
⊢ ↑↑(condCount ∅) u * ↑↑(condCount (∅ ∪ t)) ∅ + ↑↑(condCount t) u * ↑↑(condCount (∅ ∪ t)) t = ↑↑(condCount (∅ ∪ t)) u

Next tactic:
simp [condCount_self ht ht']
theorem condCount_disjoint_union (hs : s.Finite) (ht : t.Finite) (hst : Disjoint s t) :
    condCount s u * condCount (s ∪ t) s + condCount t u * condCount (s ∪ t) t =
      condCount (s ∪ t) u := by
  rcases s.eq_empty_or_nonempty with (rfl | hs') <;> rcases t.eq_empty_or_nonempty with (rfl | ht')
  · simp
  · simp [condCount_self ht ht']
  · 

Proof state:
case inr.inl
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s u : Set Ω
hs : Set.Finite s
hs' : Set.Nonempty s
ht : Set.Finite ∅
hst : Disjoint s ∅
⊢ ↑↑(condCount s) u * ↑↑(condCount (s ∪ ∅)) s + ↑↑(condCount ∅) u * ↑↑(condCount (s ∪ ∅)) ∅ = ↑↑(condCount (s ∪ ∅)) u

Next tactic:
simp [condCount_self hs hs']
theorem condCount_disjoint_union (hs : s.Finite) (ht : t.Finite) (hst : Disjoint s t) :
    condCount s u * condCount (s ∪ t) s + condCount t u * condCount (s ∪ t) t =
      condCount (s ∪ t) u := by
  rcases s.eq_empty_or_nonempty with (rfl | hs') <;> rcases t.eq_empty_or_nonempty with (rfl | ht')
  · simp
  · simp [condCount_self ht ht']
  · simp [condCount_self hs hs']
  

Proof state:
case inr.inr
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
ht : Set.Finite t
hst : Disjoint s t
hs' : Set.Nonempty s
ht' : Set.Nonempty t
⊢ ↑↑(condCount s) u * ↑↑(condCount (s ∪ t)) s + ↑↑(condCount t) u * ↑↑(condCount (s ∪ t)) t = ↑↑(condCount (s ∪ t)) u

Next tactic:
rw [condCount, condCount, condCount, cond_apply _ hs.measurableSet,
    cond_apply _ ht.measurableSet, cond_apply _ (hs.union ht).measurableSet,
    cond_apply _ (hs.union ht).measurableSet, cond_apply _ (hs.union ht).measurableSet]
theorem condCount_disjoint_union (hs : s.Finite) (ht : t.Finite) (hst : Disjoint s t) :
    condCount s u * condCount (s ∪ t) s + condCount t u * condCount (s ∪ t) t =
      condCount (s ∪ t) u := by
  rcases s.eq_empty_or_nonempty with (rfl | hs') <;> rcases t.eq_empty_or_nonempty with (rfl | ht')
  · simp
  · simp [condCount_self ht ht']
  · simp [condCount_self hs hs']
  rw [condCount, condCount, condCount, cond_apply _ hs.measurableSet,
    cond_apply _ ht.measurableSet, cond_apply _ (hs.union ht).measurableSet,
    cond_apply _ (hs.union ht).measurableSet, cond_apply _ (hs.union ht).measurableSet]
  

Proof state:
case inr.inr
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
ht : Set.Finite t
hst : Disjoint s t
hs' : Set.Nonempty s
ht' : Set.Nonempty t
⊢ (↑↑Measure.count s)⁻¹ * ↑↑Measure.count (s ∩ u) * ((↑↑Measure.count (s ∪ t))⁻¹ * ↑↑Measure.count ((s ∪ t) ∩ s)) +
      (↑↑Measure.count t)⁻¹ * ↑↑Measure.count (t ∩ u) * ((↑↑Measure.count (s ∪ t))⁻¹ * ↑↑Measure.count ((s ∪ t) ∩ t)) =
    (↑↑Measure.count (s ∪ t))⁻¹ * ↑↑Measure.count ((s ∪ t) ∩ u)

Next tactic:
conv_lhs =>
    rw [Set.union_inter_cancel_left, Set.union_inter_cancel_right,
      mul_comm (Measure.count (s ∪ t))⁻¹, mul_comm (Measure.count (s ∪ t))⁻¹, ← mul_assoc,
      ← mul_assoc, mul_comm _ (Measure.count s), mul_comm _ (Measure.count t), ← mul_assoc,
      ← mul_assoc]
theorem condCount_disjoint_union (hs : s.Finite) (ht : t.Finite) (hst : Disjoint s t) :
    condCount s u * condCount (s ∪ t) s + condCount t u * condCount (s ∪ t) t =
      condCount (s ∪ t) u := by
  rcases s.eq_empty_or_nonempty with (rfl | hs') <;> rcases t.eq_empty_or_nonempty with (rfl | ht')
  · simp
  · simp [condCount_self ht ht']
  · simp [condCount_self hs hs']
  rw [condCount, condCount, condCount, cond_apply _ hs.measurableSet,
    cond_apply _ ht.measurableSet, cond_apply _ (hs.union ht).measurableSet,
    cond_apply _ (hs.union ht).measurableSet, cond_apply _ (hs.union ht).measurableSet]
  conv_lhs =>
    

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
ht : Set.Finite t
hst : Disjoint s t
hs' : Set.Nonempty s
ht' : Set.Nonempty t
| (↑↑Measure.count s)⁻¹ * ↑↑Measure.count (s ∩ u) * ((↑↑Measure.count (s ∪ t))⁻¹ * ↑↑Measure.count ((s ∪ t) ∩ s)) +
    (↑↑Measure.count t)⁻¹ * ↑↑Measure.count (t ∩ u) * ((↑↑Measure.count (s ∪ t))⁻¹ * ↑↑Measure.count ((s ∪ t) ∩ t))

Next tactic:
rw [Set.union_inter_cancel_left, Set.union_inter_cancel_right,
      mul_comm (Measure.count (s ∪ t))⁻¹, mul_comm (Measure.count (s ∪ t))⁻¹, ← mul_assoc,
      ← mul_assoc, mul_comm _ (Measure.count s), mul_comm _ (Measure.count t), ← mul_assoc,
      ← mul_assoc]
theorem condCount_disjoint_union (hs : s.Finite) (ht : t.Finite) (hst : Disjoint s t) :
    condCount s u * condCount (s ∪ t) s + condCount t u * condCount (s ∪ t) t =
      condCount (s ∪ t) u := by
  rcases s.eq_empty_or_nonempty with (rfl | hs') <;> rcases t.eq_empty_or_nonempty with (rfl | ht')
  · simp
  · simp [condCount_self ht ht']
  · simp [condCount_self hs hs']
  rw [condCount, condCount, condCount, cond_apply _ hs.measurableSet,
    cond_apply _ ht.measurableSet, cond_apply _ (hs.union ht).measurableSet,
    cond_apply _ (hs.union ht).measurableSet, cond_apply _ (hs.union ht).measurableSet]
  conv_lhs =>
    rw [Set.union_inter_cancel_left, Set.union_inter_cancel_right,
      mul_comm (Measure.count (s ∪ t))⁻¹, mul_comm (Measure.count (s ∪ t))⁻¹, ← mul_assoc,
      ← mul_assoc, mul_comm _ (Measure.count s), mul_comm _ (Measure.count t), ← mul_assoc,
      ← mul_assoc]
  

Proof state:
case inr.inr
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
ht : Set.Finite t
hst : Disjoint s t
hs' : Set.Nonempty s
ht' : Set.Nonempty t
⊢ ↑↑Measure.count s * (↑↑Measure.count s)⁻¹ * ↑↑Measure.count (s ∩ u) * (↑↑Measure.count (s ∪ t))⁻¹ +
      ↑↑Measure.count t * (↑↑Measure.count t)⁻¹ * ↑↑Measure.count (t ∩ u) * (↑↑Measure.count (s ∪ t))⁻¹ =
    (↑↑Measure.count (s ∪ t))⁻¹ * ↑↑Measure.count ((s ∪ t) ∩ u)

Next tactic:
rw [ENNReal.mul_inv_cancel, ENNReal.mul_inv_cancel, one_mul, one_mul, ← add_mul, ← measure_union,
    Set.union_inter_distrib_right, mul_comm]
theorem condCount_disjoint_union (hs : s.Finite) (ht : t.Finite) (hst : Disjoint s t) :
    condCount s u * condCount (s ∪ t) s + condCount t u * condCount (s ∪ t) t =
      condCount (s ∪ t) u := by
  rcases s.eq_empty_or_nonempty with (rfl | hs') <;> rcases t.eq_empty_or_nonempty with (rfl | ht')
  · simp
  · simp [condCount_self ht ht']
  · simp [condCount_self hs hs']
  rw [condCount, condCount, condCount, cond_apply _ hs.measurableSet,
    cond_apply _ ht.measurableSet, cond_apply _ (hs.union ht).measurableSet,
    cond_apply _ (hs.union ht).measurableSet, cond_apply _ (hs.union ht).measurableSet]
  conv_lhs =>
    rw [Set.union_inter_cancel_left, Set.union_inter_cancel_right,
      mul_comm (Measure.count (s ∪ t))⁻¹, mul_comm (Measure.count (s ∪ t))⁻¹, ← mul_assoc,
      ← mul_assoc, mul_comm _ (Measure.count s), mul_comm _ (Measure.count t), ← mul_assoc,
      ← mul_assoc]
  rw [ENNReal.mul_inv_cancel, ENNReal.mul_inv_cancel, one_mul, one_mul, ← add_mul, ← measure_union,
    Set.union_inter_distrib_right, mul_comm]
  

Proof state:
case inr.inr.hd
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
ht : Set.Finite t
hst : Disjoint s t
hs' : Set.Nonempty s
ht' : Set.Nonempty t
⊢ Disjoint (s ∩ u) (t ∩ u)
case inr.inr.h
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
ht : Set.Finite t
hst : Disjoint s t
hs' : Set.Nonempty s
ht' : Set.Nonempty t
⊢ MeasurableSet (t ∩ u)
case inr.inr.h0
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
ht : Set.Finite t
hst : Disjoint s t
hs' : Set.Nonempty s
ht' : Set.Nonempty t
⊢ ↑↑Measure.count t ≠ 0
case inr.inr.ht
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
ht : Set.Finite t
hst : Disjoint s t
hs' : Set.Nonempty s
ht' : Set.Nonempty t
⊢ ↑↑Measure.count t ≠ ⊤
case inr.inr.h0
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
ht : Set.Finite t
hst : Disjoint s t
hs' : Set.Nonempty s
ht' : Set.Nonempty t
⊢ ↑↑Measure.count s ≠ 0
case inr.inr.ht
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
ht : Set.Finite t
hst : Disjoint s t
hs' : Set.Nonempty s
ht' : Set.Nonempty t
⊢ ↑↑Measure.count s ≠ ⊤

Next tactic:
exacts [hst.mono inf_le_left inf_le_left, (ht.inter_of_left _).measurableSet,
    Measure.count_ne_zero ht', (Measure.count_apply_lt_top.2 ht).ne, Measure.count_ne_zero hs',
    (Measure.count_apply_lt_top.2 hs).ne]
/-- A version of the law of total probability for counting probabilities. -/
theorem condCount_add_compl_eq (u t : Set Ω) (hs : s.Finite) :
    condCount (s ∩ u) t * condCount s u + condCount (s ∩ uᶜ) t * condCount s uᶜ =
      condCount s t := by
  -- Porting note: The original proof used `conv_rhs`. However, that tactic timed out.
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t✝ u✝ u t : Set Ω
hs : Set.Finite s
⊢ ↑↑(condCount (s ∩ u)) t * ↑↑(condCount s) u + ↑↑(condCount (s ∩ uᶜ)) t * ↑↑(condCount s) uᶜ = ↑↑(condCount s) t

Next tactic:
have : condCount s t = (condCount (s ∩ u) t * condCount (s ∩ u ∪ s ∩ uᶜ) (s ∩ u) +
      condCount (s ∩ uᶜ) t * condCount (s ∩ u ∪ s ∩ uᶜ) (s ∩ uᶜ)) := by
    rw [condCount_disjoint_union (hs.inter_of_left _) (hs.inter_of_left _)
      (disjoint_compl_right.mono inf_le_right inf_le_right), Set.inter_union_compl]
/-- A version of the law of total probability for counting probabilities. -/
theorem condCount_add_compl_eq (u t : Set Ω) (hs : s.Finite) :
    condCount (s ∩ u) t * condCount s u + condCount (s ∩ uᶜ) t * condCount s uᶜ =
      condCount s t := by
  -- Porting note: The original proof used `conv_rhs`. However, that tactic timed out.
  have : condCount s t = (condCount (s ∩ u) t * condCount (s ∩ u ∪ s ∩ uᶜ) (s ∩ u) +
      condCount (s ∩ uᶜ) t * condCount (s ∩ u ∪ s ∩ uᶜ) (s ∩ uᶜ)) := by
    

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t✝ u✝ u t : Set Ω
hs : Set.Finite s
⊢ ↑↑(condCount s) t =
    ↑↑(condCount (s ∩ u)) t * ↑↑(condCount (s ∩ u ∪ s ∩ uᶜ)) (s ∩ u) +
      ↑↑(condCount (s ∩ uᶜ)) t * ↑↑(condCount (s ∩ u ∪ s ∩ uᶜ)) (s ∩ uᶜ)

Next tactic:
rw [condCount_disjoint_union (hs.inter_of_left _) (hs.inter_of_left _)
      (disjoint_compl_right.mono inf_le_right inf_le_right), Set.inter_union_compl]
/-- A version of the law of total probability for counting probabilities. -/
theorem condCount_add_compl_eq (u t : Set Ω) (hs : s.Finite) :
    condCount (s ∩ u) t * condCount s u + condCount (s ∩ uᶜ) t * condCount s uᶜ =
      condCount s t := by
  -- Porting note: The original proof used `conv_rhs`. However, that tactic timed out.
  have : condCount s t = (condCount (s ∩ u) t * condCount (s ∩ u ∪ s ∩ uᶜ) (s ∩ u) +
      condCount (s ∩ uᶜ) t * condCount (s ∩ u ∪ s ∩ uᶜ) (s ∩ uᶜ)) := by
    rw [condCount_disjoint_union (hs.inter_of_left _) (hs.inter_of_left _)
      (disjoint_compl_right.mono inf_le_right inf_le_right), Set.inter_union_compl]
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t✝ u✝ u t : Set Ω
hs : Set.Finite s
this :
  ↑↑(condCount s) t =
    ↑↑(condCount (s ∩ u)) t * ↑↑(condCount (s ∩ u ∪ s ∩ uᶜ)) (s ∩ u) +
      ↑↑(condCount (s ∩ uᶜ)) t * ↑↑(condCount (s ∩ u ∪ s ∩ uᶜ)) (s ∩ uᶜ)
⊢ ↑↑(condCount (s ∩ u)) t * ↑↑(condCount s) u + ↑↑(condCount (s ∩ uᶜ)) t * ↑↑(condCount s) uᶜ = ↑↑(condCount s) t

Next tactic:
rw [this]
/-- A version of the law of total probability for counting probabilities. -/
theorem condCount_add_compl_eq (u t : Set Ω) (hs : s.Finite) :
    condCount (s ∩ u) t * condCount s u + condCount (s ∩ uᶜ) t * condCount s uᶜ =
      condCount s t := by
  -- Porting note: The original proof used `conv_rhs`. However, that tactic timed out.
  have : condCount s t = (condCount (s ∩ u) t * condCount (s ∩ u ∪ s ∩ uᶜ) (s ∩ u) +
      condCount (s ∩ uᶜ) t * condCount (s ∩ u ∪ s ∩ uᶜ) (s ∩ uᶜ)) := by
    rw [condCount_disjoint_union (hs.inter_of_left _) (hs.inter_of_left _)
      (disjoint_compl_right.mono inf_le_right inf_le_right), Set.inter_union_compl]
  rw [this]
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t✝ u✝ u t : Set Ω
hs : Set.Finite s
this :
  ↑↑(condCount s) t =
    ↑↑(condCount (s ∩ u)) t * ↑↑(condCount (s ∩ u ∪ s ∩ uᶜ)) (s ∩ u) +
      ↑↑(condCount (s ∩ uᶜ)) t * ↑↑(condCount (s ∩ u ∪ s ∩ uᶜ)) (s ∩ uᶜ)
⊢ ↑↑(condCount (s ∩ u)) t * ↑↑(condCount s) u + ↑↑(condCount (s ∩ uᶜ)) t * ↑↑(condCount s) uᶜ =
    ↑↑(condCount (s ∩ u)) t * ↑↑(condCount (s ∩ u ∪ s ∩ uᶜ)) (s ∩ u) +
      ↑↑(condCount (s ∩ uᶜ)) t * ↑↑(condCount (s ∩ u ∪ s ∩ uᶜ)) (s ∩ uᶜ)

Next tactic:
simp [condCount_inter_self hs]
/-- An `EquivFunctor` in fact takes every equiv to an equiv. -/
def mapEquiv : f α ≃ f β where
  toFun := EquivFunctor.map e
  invFun := EquivFunctor.map e.symm
  left_inv x := by
    

Proof state:
f : Type u₀ → Type u₁
inst✝ : EquivFunctor f
α β : Type u₀
e : α ≃ β
x : f α
⊢ map e.symm (map e x) = x

Next tactic:
convert (congr_fun (EquivFunctor.map_trans' e e.symm) x).symm
/-- An `EquivFunctor` in fact takes every equiv to an equiv. -/
def mapEquiv : f α ≃ f β where
  toFun := EquivFunctor.map e
  invFun := EquivFunctor.map e.symm
  left_inv x := by
    convert (congr_fun (EquivFunctor.map_trans' e e.symm) x).symm
    

Proof state:
case h.e'_3
f : Type u₀ → Type u₁
inst✝ : EquivFunctor f
α β : Type u₀
e : α ≃ β
x : f α
⊢ x = map (e.trans e.symm) x

Next tactic:
simp
/-- An `EquivFunctor` in fact takes every equiv to an equiv. -/
def mapEquiv : f α ≃ f β where
  toFun := EquivFunctor.map e
  invFun := EquivFunctor.map e.symm
  left_inv x := by
    convert (congr_fun (EquivFunctor.map_trans' e e.symm) x).symm
    simp
  right_inv y := by
    

Proof state:
f : Type u₀ → Type u₁
inst✝ : EquivFunctor f
α β : Type u₀
e : α ≃ β
y : f β
⊢ map e (map e.symm y) = y

Next tactic:
convert (congr_fun (EquivFunctor.map_trans' e.symm e) y).symm
/-- An `EquivFunctor` in fact takes every equiv to an equiv. -/
def mapEquiv : f α ≃ f β where
  toFun := EquivFunctor.map e
  invFun := EquivFunctor.map e.symm
  left_inv x := by
    convert (congr_fun (EquivFunctor.map_trans' e e.symm) x).symm
    simp
  right_inv y := by
    convert (congr_fun (EquivFunctor.map_trans' e.symm e) y).symm
    

Proof state:
case h.e'_3
f : Type u₀ → Type u₁
inst✝ : EquivFunctor f
α β : Type u₀
e : α ≃ β
y : f β
⊢ y = map (e.symm.trans e) y

Next tactic:
simp
@[simp]
theorem mapEquiv_refl (α) : mapEquiv f (Equiv.refl α) = Equiv.refl (f α) := by
 

Proof state:
f : Type u₀ → Type u₁
inst✝ : EquivFunctor f
α✝ β : Type u₀
e : α✝ ≃ β
α : Type u₀
⊢ mapEquiv f (Equiv.refl α) = Equiv.refl (f α)

Next tactic:
simp [EquivFunctor.mapEquiv]
@[simp]
theorem mapEquiv_refl (α) : mapEquiv f (Equiv.refl α) = Equiv.refl (f α) := by
 simp [EquivFunctor.mapEquiv]; 

Proof state:
f : Type u₀ → Type u₁
inst✝ : EquivFunctor f
α✝ β : Type u₀
e : α✝ ≃ β
α : Type u₀
⊢ { toFun := id, invFun := id, left_inv := (_ : LeftInverse id id), right_inv := (_ : Function.RightInverse id id) } =
    Equiv.refl (f α)

Next tactic:
rfl
/-- The composition of `mapEquiv`s is carried over the `EquivFunctor`.
For plain `Functor`s, this lemma is named `map_map` when applied
or `map_comp_map` when not applied.
-/
@[simp]
theorem mapEquiv_trans {γ : Type u₀} (ab : α ≃ β) (bc : β ≃ γ) :
    (mapEquiv f ab).trans (mapEquiv f bc) = mapEquiv f (ab.trans bc) :=
  Equiv.ext $ fun x => by 

Proof state:
f : Type u₀ → Type u₁
inst✝ : EquivFunctor f
α β : Type u₀
e : α ≃ β
γ : Type u₀
ab : α ≃ β
bc : β ≃ γ
x : f α
⊢ ((mapEquiv f ab).trans (mapEquiv f bc)) x = (mapEquiv f (ab.trans bc)) x

Next tactic:
simp [mapEquiv, map_trans']
instance (priority := 100) ofLawfulFunctor (f : Type u₀ → Type u₁) [Functor f] [LawfulFunctor f] :
    EquivFunctor f where
  map {α β} e := Functor.map e
  map_refl' α := by
    

Proof state:
f : Type u₀ → Type u₁
inst✝¹ : Functor f
inst✝ : LawfulFunctor f
α : Type u₀
⊢ (fun {α β} e => Functor.map ⇑e) (Equiv.refl α) = id

Next tactic:
ext
instance (priority := 100) ofLawfulFunctor (f : Type u₀ → Type u₁) [Functor f] [LawfulFunctor f] :
    EquivFunctor f where
  map {α β} e := Functor.map e
  map_refl' α := by
    ext
    

Proof state:
case h
f : Type u₀ → Type u₁
inst✝¹ : Functor f
inst✝ : LawfulFunctor f
α : Type u₀
x✝ : f α
⊢ (fun {α β} e => Functor.map ⇑e) (Equiv.refl α) x✝ = id x✝

Next tactic:
apply LawfulFunctor.id_map
instance (priority := 100) ofLawfulFunctor (f : Type u₀ → Type u₁) [Functor f] [LawfulFunctor f] :
    EquivFunctor f where
  map {α β} e := Functor.map e
  map_refl' α := by
    ext
    apply LawfulFunctor.id_map
  map_trans' {α β γ} k h := by
    

Proof state:
f : Type u₀ → Type u₁
inst✝¹ : Functor f
inst✝ : LawfulFunctor f
α β γ : Type u₀
k : α ≃ β
h : β ≃ γ
⊢ (fun {α β} e => Functor.map ⇑e) (k.trans h) = (fun {α β} e => Functor.map ⇑e) h ∘ (fun {α β} e => Functor.map ⇑e) k

Next tactic:
ext x
instance (priority := 100) ofLawfulFunctor (f : Type u₀ → Type u₁) [Functor f] [LawfulFunctor f] :
    EquivFunctor f where
  map {α β} e := Functor.map e
  map_refl' α := by
    ext
    apply LawfulFunctor.id_map
  map_trans' {α β γ} k h := by
    ext x
    

Proof state:
case h
f : Type u₀ → Type u₁
inst✝¹ : Functor f
inst✝ : LawfulFunctor f
α β γ : Type u₀
k : α ≃ β
h : β ≃ γ
x : f α
⊢ (fun {α β} e => Functor.map ⇑e) (k.trans h) x =
    ((fun {α β} e => Functor.map ⇑e) h ∘ (fun {α β} e => Functor.map ⇑e) k) x

Next tactic:
apply LawfulFunctor.comp_map k h x
theorem mapEquiv.injective (f : Type u₀ → Type u₁)
    [Applicative f] [LawfulApplicative f] {α β : Type u₀}
    (h : ∀ γ, Function.Injective (pure : γ → f γ)) :
      Function.Injective (@EquivFunctor.mapEquiv f _ α β) :=
  fun e₁ e₂ H =>
    Equiv.ext $ fun x => h β (by 

Proof state:
f : Type u₀ → Type u₁
inst✝¹ : Applicative f
inst✝ : LawfulApplicative f
α β : Type u₀
h : ∀ (γ : Type u₀), Injective pure
e₁ e₂ : α ≃ β
H : mapEquiv f e₁ = mapEquiv f e₂
x : α
⊢ pure (e₁ x) = pure (e₂ x)

Next tactic:
simpa [EquivFunctor.map] using Equiv.congr_fun H (pure x)
instance divisionRing : DivisionRing ℚ := by 

Proof state:
⊢ DivisionRing ℚ

Next tactic:
infer_instance
/-- Pullback an `OrderedSemiring` under an injective map. -/
@[reducible]
protected def orderedSemiring [OrderedSemiring α] [Zero β] [One β] [Add β] [Mul β] [Pow β ℕ]
    [SMul ℕ β] [NatCast β] (f : β → α) (hf : Injective f) (zero : f 0 = 0) (one : f 1 = 1)
    (add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y)
    (nsmul : ∀ (x) (n : ℕ), f (n • x) = n • f x) (npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n)
    (nat_cast : ∀ n : ℕ, f n = n) : OrderedSemiring β :=
  { hf.orderedAddCommMonoid f zero add nsmul,
    hf.semiring f zero one add mul nsmul npow nat_cast with
    zero_le_one := show f 0 ≤ f 1 by 

Proof state:
α : Type u
β : Type u_1
inst✝⁷ : OrderedSemiring α
inst✝⁶ : Zero β
inst✝⁵ : One β
inst✝⁴ : Add β
inst✝³ : Mul β
inst✝² : Pow β ℕ
inst✝¹ : SMul ℕ β
inst✝ : NatCast β
f : β → α
hf : Injective f
zero : f 0 = 0
one : f 1 = 1
add : ∀ (x y : β), f (x + y) = f x + f y
mul : ∀ (x y : β), f (x * y) = f x * f y
nsmul : ∀ (x : β) (n : ℕ), f (n • x) = n • f x
npow : ∀ (x : β) (n : ℕ), f (x ^ n) = f x ^ n
nat_cast : ∀ (n : ℕ), f ↑n = ↑n
src✝¹ : OrderedAddCommMonoid β := orderedAddCommMonoid f hf zero add nsmul
src✝ : Semiring β := Injective.semiring f hf zero one add mul nsmul npow nat_cast
⊢ f 0 ≤ f 1

Next tactic:
simp only [zero, one, zero_le_one]
/-- Pullback an `OrderedSemiring` under an injective map. -/
@[reducible]
protected def orderedSemiring [OrderedSemiring α] [Zero β] [One β] [Add β] [Mul β] [Pow β ℕ]
    [SMul ℕ β] [NatCast β] (f : β → α) (hf : Injective f) (zero : f 0 = 0) (one : f 1 = 1)
    (add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y)
    (nsmul : ∀ (x) (n : ℕ), f (n • x) = n • f x) (npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n)
    (nat_cast : ∀ n : ℕ, f n = n) : OrderedSemiring β :=
  { hf.orderedAddCommMonoid f zero add nsmul,
    hf.semiring f zero one add mul nsmul npow nat_cast with
    zero_le_one := show f 0 ≤ f 1 by simp only [zero, one, zero_le_one],
    mul_le_mul_of_nonneg_left := fun a b c h hc =>
      show f (c * a) ≤ f (c * b) by
        

Proof state:
α : Type u
β : Type u_1
inst✝⁷ : OrderedSemiring α
inst✝⁶ : Zero β
inst✝⁵ : One β
inst✝⁴ : Add β
inst✝³ : Mul β
inst✝² : Pow β ℕ
inst✝¹ : SMul ℕ β
inst✝ : NatCast β
f : β → α
hf : Injective f
zero : f 0 = 0
one : f 1 = 1
add : ∀ (x y : β), f (x + y) = f x + f y
mul : ∀ (x y : β), f (x * y) = f x * f y
nsmul : ∀ (x : β) (n : ℕ), f (n • x) = n • f x
npow : ∀ (x : β) (n : ℕ), f (x ^ n) = f x ^ n
nat_cast : ∀ (n : ℕ), f ↑n = ↑n
src✝¹ : OrderedAddCommMonoid β := orderedAddCommMonoid f hf zero add nsmul
src✝ : Semiring β := Injective.semiring f hf zero one add mul nsmul npow nat_cast
a b c : β
h : a ≤ b
hc : 0 ≤ c
⊢ f (c * a) ≤ f (c * b)

Next tactic:
rw [mul, mul]