l3lab/ntp-mathlib huggingface dataset:
protected theorem Commute.inv_sub_inv (hab : Commute a b) (ha : a ≠ 0) (hb : b ≠ 0) :
    a⁻¹ - b⁻¹ = (b - a) / (a * b) := by
  

Proof state:
α : Type u_1
β : Type u_2
K : Type u_3
inst✝ : DivisionRing K
a b c d : K
hab : Commute a b
ha : a ≠ 0
hb : b ≠ 0
⊢ a⁻¹ - b⁻¹ = (b - a) / (a * b)

Next tactic:
simp only [inv_eq_one_div, (Commute.one_right a).div_sub_div hab ha hb, one_mul, mul_one]
theorem inv_sub_inv {a b : K} (ha : a ≠ 0) (hb : b ≠ 0) : a⁻¹ - b⁻¹ = (b - a) / (a * b) := by
  

Proof state:
α : Type u_1
β : Type u_2
K : Type u_3
inst✝ : Field K
a b : K
ha : a ≠ 0
hb : b ≠ 0
⊢ a⁻¹ - b⁻¹ = (b - a) / (a * b)

Next tactic:
rw [inv_eq_one_div, inv_eq_one_div, div_sub_div _ _ ha hb, one_mul, mul_one]
@[field_simps]
theorem sub_div' (a b c : K) (hc : c ≠ 0) : b - a / c = (b * c - a) / c := by
  

Proof state:
α : Type u_1
β : Type u_2
K : Type u_3
inst✝ : Field K
a b c : K
hc : c ≠ 0
⊢ b - a / c = (b * c - a) / c

Next tactic:
simpa using div_sub_div b a one_ne_zero hc
@[field_simps]
theorem div_sub' (a b c : K) (hc : c ≠ 0) : a / c - b = (a - c * b) / c := by
  

Proof state:
α : Type u_1
β : Type u_2
K : Type u_3
inst✝ : Field K
a b c : K
hc : c ≠ 0
⊢ a / c - b = (a - c * b) / c

Next tactic:
simpa using div_sub_div a b hc one_ne_zero
/-- Pullback a `DivisionSemiring` along an injective function.
See note [reducible non-instances]. -/
@[reducible]
protected def Function.Injective.divisionRing [DivisionRing K] {K'} [Zero K'] [One K'] [Add K']
    [Mul K'] [Neg K'] [Sub K'] [Inv K'] [Div K'] [SMul ℕ K'] [SMul ℤ K'] [SMul ℚ K']
    [Pow K' ℕ] [Pow K' ℤ] [NatCast K'] [IntCast K'] [RatCast K'] (f : K' → K) (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) (neg : ∀ x, f (-x) = -f x)
    (sub : ∀ x y, f (x - y) = f x - f y) (inv : ∀ x, f x⁻¹ = (f x)⁻¹)
    (div : ∀ x y, f (x / y) = f x / f y) (nsmul : ∀ (x) (n : ℕ), f (n • x) = n • f x)
    (zsmul : ∀ (x) (n : ℤ), f (n • x) = n • f x) (qsmul : ∀ (x) (n : ℚ), f (n • x) = n • f x)
    (npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n) (zpow : ∀ (x) (n : ℤ), f (x ^ n) = f x ^ n)
    (nat_cast : ∀ n : ℕ, f n = n) (int_cast : ∀ n : ℤ, f n = n) (rat_cast : ∀ n : ℚ, f n = n) :
    DivisionRing K' :=
  { hf.groupWithZero f zero one mul inv div npow zpow,
    hf.ring f zero one add mul neg sub nsmul zsmul npow nat_cast int_cast with
    ratCast := Rat.cast,
    ratCast_mk := fun a b h1 h2 ↦
      hf
        (by
          

Proof state:
α : Type u_1
β : Type u_2
K : Type u_3
inst✝¹⁶ : DivisionRing K
K' : Type ?u.49586
inst✝¹⁵ : Zero K'
inst✝¹⁴ : One K'
inst✝¹³ : Add K'
inst✝¹² : Mul K'
inst✝¹¹ : Neg K'
inst✝¹⁰ : Sub K'
inst✝⁹ : Inv K'
inst✝⁸ : Div K'
inst✝⁷ : SMul ℕ K'
inst✝⁶ : SMul ℤ K'
inst✝⁵ : SMul ℚ K'
inst✝⁴ : Pow K' ℕ
inst✝³ : Pow K' ℤ
inst✝² : NatCast K'
inst✝¹ : IntCast K'
inst✝ : RatCast K'
f : K' → K
hf : Injective f
zero : f 0 = 0
one : f 1 = 1
add : ∀ (x y : K'), f (x + y) = f x + f y
mul : ∀ (x y : K'), f (x * y) = f x * f y
neg : ∀ (x : K'), f (-x) = -f x
sub : ∀ (x y : K'), f (x - y) = f x - f y
inv : ∀ (x : K'), f x⁻¹ = (f x)⁻¹
div : ∀ (x y : K'), f (x / y) = f x / f y
nsmul : ∀ (x : K') (n : ℕ), f (n • x) = n • f x
zsmul : ∀ (x : K') (n : ℤ), f (n • x) = n • f x
qsmul : ∀ (x : K') (n : ℚ), f (n • x) = n • f x
npow : ∀ (x : K') (n : ℕ), f (x ^ n) = f x ^ n
zpow : ∀ (x : K') (n : ℤ), f (x ^ n) = f x ^ n
nat_cast : ∀ (n : ℕ), f ↑n = ↑n
int_cast : ∀ (n : ℤ), f ↑n = ↑n
rat_cast : ∀ (n : ℚ), f ↑n = ↑n
src✝¹ : GroupWithZero K' := Injective.groupWithZero f hf zero one mul inv div npow zpow
src✝ : Ring K' := Injective.ring f hf zero one add mul neg sub nsmul zsmul npow nat_cast int_cast
a : ℤ
b : ℕ
h1 : b ≠ 0
h2 : Nat.Coprime (Int.natAbs a) b
⊢ f ↑(Rat.mk' a b) = f (↑a * (↑b)⁻¹)

Next tactic:
erw [rat_cast, mul, inv, int_cast, nat_cast]
/-- Pullback a `DivisionSemiring` along an injective function.
See note [reducible non-instances]. -/
@[reducible]
protected def Function.Injective.divisionRing [DivisionRing K] {K'} [Zero K'] [One K'] [Add K']
    [Mul K'] [Neg K'] [Sub K'] [Inv K'] [Div K'] [SMul ℕ K'] [SMul ℤ K'] [SMul ℚ K']
    [Pow K' ℕ] [Pow K' ℤ] [NatCast K'] [IntCast K'] [RatCast K'] (f : K' → K) (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) (neg : ∀ x, f (-x) = -f x)
    (sub : ∀ x y, f (x - y) = f x - f y) (inv : ∀ x, f x⁻¹ = (f x)⁻¹)
    (div : ∀ x y, f (x / y) = f x / f y) (nsmul : ∀ (x) (n : ℕ), f (n • x) = n • f x)
    (zsmul : ∀ (x) (n : ℤ), f (n • x) = n • f x) (qsmul : ∀ (x) (n : ℚ), f (n • x) = n • f x)
    (npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n) (zpow : ∀ (x) (n : ℤ), f (x ^ n) = f x ^ n)
    (nat_cast : ∀ n : ℕ, f n = n) (int_cast : ∀ n : ℤ, f n = n) (rat_cast : ∀ n : ℚ, f n = n) :
    DivisionRing K' :=
  { hf.groupWithZero f zero one mul inv div npow zpow,
    hf.ring f zero one add mul neg sub nsmul zsmul npow nat_cast int_cast with
    ratCast := Rat.cast,
    ratCast_mk := fun a b h1 h2 ↦
      hf
        (by
          erw [rat_cast, mul, inv, int_cast, nat_cast]
          

Proof state:
α : Type u_1
β : Type u_2
K : Type u_3
inst✝¹⁶ : DivisionRing K
K' : Type ?u.49586
inst✝¹⁵ : Zero K'
inst✝¹⁴ : One K'
inst✝¹³ : Add K'
inst✝¹² : Mul K'
inst✝¹¹ : Neg K'
inst✝¹⁰ : Sub K'
inst✝⁹ : Inv K'
inst✝⁸ : Div K'
inst✝⁷ : SMul ℕ K'
inst✝⁶ : SMul ℤ K'
inst✝⁵ : SMul ℚ K'
inst✝⁴ : Pow K' ℕ
inst✝³ : Pow K' ℤ
inst✝² : NatCast K'
inst✝¹ : IntCast K'
inst✝ : RatCast K'
f : K' → K
hf : Injective f
zero : f 0 = 0
one : f 1 = 1
add : ∀ (x y : K'), f (x + y) = f x + f y
mul : ∀ (x y : K'), f (x * y) = f x * f y
neg : ∀ (x : K'), f (-x) = -f x
sub : ∀ (x y : K'), f (x - y) = f x - f y
inv : ∀ (x : K'), f x⁻¹ = (f x)⁻¹
div : ∀ (x y : K'), f (x / y) = f x / f y
nsmul : ∀ (x : K') (n : ℕ), f (n • x) = n • f x
zsmul : ∀ (x : K') (n : ℤ), f (n • x) = n • f x
qsmul : ∀ (x : K') (n : ℚ), f (n • x) = n • f x
npow : ∀ (x : K') (n : ℕ), f (x ^ n) = f x ^ n
zpow : ∀ (x : K') (n : ℤ), f (x ^ n) = f x ^ n
nat_cast : ∀ (n : ℕ), f ↑n = ↑n
int_cast : ∀ (n : ℤ), f ↑n = ↑n
rat_cast : ∀ (n : ℚ), f ↑n = ↑n
src✝¹ : GroupWithZero K' := Injective.groupWithZero f hf zero one mul inv div npow zpow
src✝ : Ring K' := Injective.ring f hf zero one add mul neg sub nsmul zsmul npow nat_cast int_cast
a : ℤ
b : ℕ
h1 : b ≠ 0
h2 : Nat.Coprime (Int.natAbs a) b
⊢ ↑(Rat.mk' a b) = ↑a * (↑b)⁻¹

Next tactic:
exact DivisionRing.ratCast_mk a b h1 h2
/-- Pullback a `DivisionSemiring` along an injective function.
See note [reducible non-instances]. -/
@[reducible]
protected def Function.Injective.divisionRing [DivisionRing K] {K'} [Zero K'] [One K'] [Add K']
    [Mul K'] [Neg K'] [Sub K'] [Inv K'] [Div K'] [SMul ℕ K'] [SMul ℤ K'] [SMul ℚ K']
    [Pow K' ℕ] [Pow K' ℤ] [NatCast K'] [IntCast K'] [RatCast K'] (f : K' → K) (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) (neg : ∀ x, f (-x) = -f x)
    (sub : ∀ x y, f (x - y) = f x - f y) (inv : ∀ x, f x⁻¹ = (f x)⁻¹)
    (div : ∀ x y, f (x / y) = f x / f y) (nsmul : ∀ (x) (n : ℕ), f (n • x) = n • f x)
    (zsmul : ∀ (x) (n : ℤ), f (n • x) = n • f x) (qsmul : ∀ (x) (n : ℚ), f (n • x) = n • f x)
    (npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n) (zpow : ∀ (x) (n : ℤ), f (x ^ n) = f x ^ n)
    (nat_cast : ∀ n : ℕ, f n = n) (int_cast : ∀ n : ℤ, f n = n) (rat_cast : ∀ n : ℚ, f n = n) :
    DivisionRing K' :=
  { hf.groupWithZero f zero one mul inv div npow zpow,
    hf.ring f zero one add mul neg sub nsmul zsmul npow nat_cast int_cast with
    ratCast := Rat.cast,
    ratCast_mk := fun a b h1 h2 ↦
      hf
        (by
          erw [rat_cast, mul, inv, int_cast, nat_cast]
          exact DivisionRing.ratCast_mk a b h1 h2),
    qsmul := (· • ·), qsmul_eq_mul' := fun a x ↦ hf (by 

Proof state:
α : Type u_1
β : Type u_2
K : Type u_3
inst✝¹⁶ : DivisionRing K
K' : Type ?u.49586
inst✝¹⁵ : Zero K'
inst✝¹⁴ : One K'
inst✝¹³ : Add K'
inst✝¹² : Mul K'
inst✝¹¹ : Neg K'
inst✝¹⁰ : Sub K'
inst✝⁹ : Inv K'
inst✝⁸ : Div K'
inst✝⁷ : SMul ℕ K'
inst✝⁶ : SMul ℤ K'
inst✝⁵ : SMul ℚ K'
inst✝⁴ : Pow K' ℕ
inst✝³ : Pow K' ℤ
inst✝² : NatCast K'
inst✝¹ : IntCast K'
inst✝ : RatCast K'
f : K' → K
hf : Injective f
zero : f 0 = 0
one : f 1 = 1
add : ∀ (x y : K'), f (x + y) = f x + f y
mul : ∀ (x y : K'), f (x * y) = f x * f y
neg : ∀ (x : K'), f (-x) = -f x
sub : ∀ (x y : K'), f (x - y) = f x - f y
inv : ∀ (x : K'), f x⁻¹ = (f x)⁻¹
div : ∀ (x y : K'), f (x / y) = f x / f y
nsmul : ∀ (x : K') (n : ℕ), f (n • x) = n • f x
zsmul : ∀ (x : K') (n : ℤ), f (n • x) = n • f x
qsmul : ∀ (x : K') (n : ℚ), f (n • x) = n • f x
npow : ∀ (x : K') (n : ℕ), f (x ^ n) = f x ^ n
zpow : ∀ (x : K') (n : ℤ), f (x ^ n) = f x ^ n
nat_cast : ∀ (n : ℕ), f ↑n = ↑n
int_cast : ∀ (n : ℤ), f ↑n = ↑n
rat_cast : ∀ (n : ℚ), f ↑n = ↑n
src✝¹ : GroupWithZero K' := Injective.groupWithZero f hf zero one mul inv div npow zpow
src✝ : Ring K' := Injective.ring f hf zero one add mul neg sub nsmul zsmul npow nat_cast int_cast
a : ℚ
x : K'
⊢ f ((fun x x_1 => x • x_1) a x) = f (↑a * x)

Next tactic:
erw [qsmul, mul, Rat.smul_def, rat_cast]
/-- Pullback a `Field` along an injective function.
See note [reducible non-instances]. -/
@[reducible]
protected def Function.Injective.field [Field K] {K'} [Zero K'] [Mul K'] [Add K'] [Neg K'] [Sub K']
    [One K'] [Inv K'] [Div K'] [SMul ℕ K'] [SMul ℤ K'] [SMul ℚ K'] [Pow K' ℕ] [Pow K' ℤ]
    [NatCast K'] [IntCast K'] [RatCast K'] (f : K' → K) (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)
    (neg : ∀ x, f (-x) = -f x) (sub : ∀ x y, f (x - y) = f x - f y) (inv : ∀ x, f x⁻¹ = (f x)⁻¹)
    (div : ∀ x y, f (x / y) = f x / f y) (nsmul : ∀ (x) (n : ℕ), f (n • x) = n • f x)
    (zsmul : ∀ (x) (n : ℤ), f (n • x) = n • f x) (qsmul : ∀ (x) (n : ℚ), f (n • x) = n • f x)
    (npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n) (zpow : ∀ (x) (n : ℤ), f (x ^ n) = f x ^ n)
    (nat_cast : ∀ n : ℕ, f n = n) (int_cast : ∀ n : ℤ, f n = n) (rat_cast : ∀ n : ℚ, f n = n) :
    Field K' :=
  { hf.commGroupWithZero f zero one mul inv div npow zpow,
    hf.commRing f zero one add mul neg sub nsmul zsmul npow nat_cast int_cast with
    ratCast := Rat.cast,
    ratCast_mk := fun a b h1 h2 ↦
      hf
        (by
          

Proof state:
α : Type u_1
β : Type u_2
K : Type u_3
inst✝¹⁶ : Field K
K' : Type ?u.56341
inst✝¹⁵ : Zero K'
inst✝¹⁴ : Mul K'
inst✝¹³ : Add K'
inst✝¹² : Neg K'
inst✝¹¹ : Sub K'
inst✝¹⁰ : One K'
inst✝⁹ : Inv K'
inst✝⁸ : Div K'
inst✝⁷ : SMul ℕ K'
inst✝⁶ : SMul ℤ K'
inst✝⁵ : SMul ℚ K'
inst✝⁴ : Pow K' ℕ
inst✝³ : Pow K' ℤ
inst✝² : NatCast K'
inst✝¹ : IntCast K'
inst✝ : RatCast K'
f : K' → K
hf : Injective f
zero : f 0 = 0
one : f 1 = 1
add : ∀ (x y : K'), f (x + y) = f x + f y
mul : ∀ (x y : K'), f (x * y) = f x * f y
neg : ∀ (x : K'), f (-x) = -f x
sub : ∀ (x y : K'), f (x - y) = f x - f y
inv : ∀ (x : K'), f x⁻¹ = (f x)⁻¹
div : ∀ (x y : K'), f (x / y) = f x / f y
nsmul : ∀ (x : K') (n : ℕ), f (n • x) = n • f x
zsmul : ∀ (x : K') (n : ℤ), f (n • x) = n • f x
qsmul : ∀ (x : K') (n : ℚ), f (n • x) = n • f x
npow : ∀ (x : K') (n : ℕ), f (x ^ n) = f x ^ n
zpow : ∀ (x : K') (n : ℤ), f (x ^ n) = f x ^ n
nat_cast : ∀ (n : ℕ), f ↑n = ↑n
int_cast : ∀ (n : ℤ), f ↑n = ↑n
rat_cast : ∀ (n : ℚ), f ↑n = ↑n
src✝¹ : CommGroupWithZero K' := Injective.commGroupWithZero f hf zero one mul inv div npow zpow
src✝ : CommRing K' := Injective.commRing f hf zero one add mul neg sub nsmul zsmul npow nat_cast int_cast
a : ℤ
b : ℕ
h1 : b ≠ 0
h2 : Nat.Coprime (Int.natAbs a) b
⊢ f ↑(Rat.mk' a b) = f (↑a * (↑b)⁻¹)

Next tactic:
erw [rat_cast, mul, inv, int_cast, nat_cast]
/-- Pullback a `Field` along an injective function.
See note [reducible non-instances]. -/
@[reducible]
protected def Function.Injective.field [Field K] {K'} [Zero K'] [Mul K'] [Add K'] [Neg K'] [Sub K']
    [One K'] [Inv K'] [Div K'] [SMul ℕ K'] [SMul ℤ K'] [SMul ℚ K'] [Pow K' ℕ] [Pow K' ℤ]
    [NatCast K'] [IntCast K'] [RatCast K'] (f : K' → K) (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)
    (neg : ∀ x, f (-x) = -f x) (sub : ∀ x y, f (x - y) = f x - f y) (inv : ∀ x, f x⁻¹ = (f x)⁻¹)
    (div : ∀ x y, f (x / y) = f x / f y) (nsmul : ∀ (x) (n : ℕ), f (n • x) = n • f x)
    (zsmul : ∀ (x) (n : ℤ), f (n • x) = n • f x) (qsmul : ∀ (x) (n : ℚ), f (n • x) = n • f x)
    (npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n) (zpow : ∀ (x) (n : ℤ), f (x ^ n) = f x ^ n)
    (nat_cast : ∀ n : ℕ, f n = n) (int_cast : ∀ n : ℤ, f n = n) (rat_cast : ∀ n : ℚ, f n = n) :
    Field K' :=
  { hf.commGroupWithZero f zero one mul inv div npow zpow,
    hf.commRing f zero one add mul neg sub nsmul zsmul npow nat_cast int_cast with
    ratCast := Rat.cast,
    ratCast_mk := fun a b h1 h2 ↦
      hf
        (by
          erw [rat_cast, mul, inv, int_cast, nat_cast]
          

Proof state:
α : Type u_1
β : Type u_2
K : Type u_3
inst✝¹⁶ : Field K
K' : Type ?u.56341
inst✝¹⁵ : Zero K'
inst✝¹⁴ : Mul K'
inst✝¹³ : Add K'
inst✝¹² : Neg K'
inst✝¹¹ : Sub K'
inst✝¹⁰ : One K'
inst✝⁹ : Inv K'
inst✝⁸ : Div K'
inst✝⁷ : SMul ℕ K'
inst✝⁶ : SMul ℤ K'
inst✝⁵ : SMul ℚ K'
inst✝⁴ : Pow K' ℕ
inst✝³ : Pow K' ℤ
inst✝² : NatCast K'
inst✝¹ : IntCast K'
inst✝ : RatCast K'
f : K' → K
hf : Injective f
zero : f 0 = 0
one : f 1 = 1
add : ∀ (x y : K'), f (x + y) = f x + f y
mul : ∀ (x y : K'), f (x * y) = f x * f y
neg : ∀ (x : K'), f (-x) = -f x
sub : ∀ (x y : K'), f (x - y) = f x - f y
inv : ∀ (x : K'), f x⁻¹ = (f x)⁻¹
div : ∀ (x y : K'), f (x / y) = f x / f y
nsmul : ∀ (x : K') (n : ℕ), f (n • x) = n • f x
zsmul : ∀ (x : K') (n : ℤ), f (n • x) = n • f x
qsmul : ∀ (x : K') (n : ℚ), f (n • x) = n • f x
npow : ∀ (x : K') (n : ℕ), f (x ^ n) = f x ^ n
zpow : ∀ (x : K') (n : ℤ), f (x ^ n) = f x ^ n
nat_cast : ∀ (n : ℕ), f ↑n = ↑n
int_cast : ∀ (n : ℤ), f ↑n = ↑n
rat_cast : ∀ (n : ℚ), f ↑n = ↑n
src✝¹ : CommGroupWithZero K' := Injective.commGroupWithZero f hf zero one mul inv div npow zpow
src✝ : CommRing K' := Injective.commRing f hf zero one add mul neg sub nsmul zsmul npow nat_cast int_cast
a : ℤ
b : ℕ
h1 : b ≠ 0
h2 : Nat.Coprime (Int.natAbs a) b
⊢ ↑(Rat.mk' a b) = ↑a * (↑b)⁻¹

Next tactic:
exact DivisionRing.ratCast_mk a b h1 h2
/-- Pullback a `Field` along an injective function.
See note [reducible non-instances]. -/
@[reducible]
protected def Function.Injective.field [Field K] {K'} [Zero K'] [Mul K'] [Add K'] [Neg K'] [Sub K']
    [One K'] [Inv K'] [Div K'] [SMul ℕ K'] [SMul ℤ K'] [SMul ℚ K'] [Pow K' ℕ] [Pow K' ℤ]
    [NatCast K'] [IntCast K'] [RatCast K'] (f : K' → K) (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)
    (neg : ∀ x, f (-x) = -f x) (sub : ∀ x y, f (x - y) = f x - f y) (inv : ∀ x, f x⁻¹ = (f x)⁻¹)
    (div : ∀ x y, f (x / y) = f x / f y) (nsmul : ∀ (x) (n : ℕ), f (n • x) = n • f x)
    (zsmul : ∀ (x) (n : ℤ), f (n • x) = n • f x) (qsmul : ∀ (x) (n : ℚ), f (n • x) = n • f x)
    (npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n) (zpow : ∀ (x) (n : ℤ), f (x ^ n) = f x ^ n)
    (nat_cast : ∀ n : ℕ, f n = n) (int_cast : ∀ n : ℤ, f n = n) (rat_cast : ∀ n : ℚ, f n = n) :
    Field K' :=
  { hf.commGroupWithZero f zero one mul inv div npow zpow,
    hf.commRing f zero one add mul neg sub nsmul zsmul npow nat_cast int_cast with
    ratCast := Rat.cast,
    ratCast_mk := fun a b h1 h2 ↦
      hf
        (by
          erw [rat_cast, mul, inv, int_cast, nat_cast]
          exact DivisionRing.ratCast_mk a b h1 h2),
    qsmul := (· • ·), qsmul_eq_mul' := fun a x ↦ hf (by 

Proof state:
α : Type u_1
β : Type u_2
K : Type u_3
inst✝¹⁶ : Field K
K' : Type ?u.56341
inst✝¹⁵ : Zero K'
inst✝¹⁴ : Mul K'
inst✝¹³ : Add K'
inst✝¹² : Neg K'
inst✝¹¹ : Sub K'
inst✝¹⁰ : One K'
inst✝⁹ : Inv K'
inst✝⁸ : Div K'
inst✝⁷ : SMul ℕ K'
inst✝⁶ : SMul ℤ K'
inst✝⁵ : SMul ℚ K'
inst✝⁴ : Pow K' ℕ
inst✝³ : Pow K' ℤ
inst✝² : NatCast K'
inst✝¹ : IntCast K'
inst✝ : RatCast K'
f : K' → K
hf : Injective f
zero : f 0 = 0
one : f 1 = 1
add : ∀ (x y : K'), f (x + y) = f x + f y
mul : ∀ (x y : K'), f (x * y) = f x * f y
neg : ∀ (x : K'), f (-x) = -f x
sub : ∀ (x y : K'), f (x - y) = f x - f y
inv : ∀ (x : K'), f x⁻¹ = (f x)⁻¹
div : ∀ (x y : K'), f (x / y) = f x / f y
nsmul : ∀ (x : K') (n : ℕ), f (n • x) = n • f x
zsmul : ∀ (x : K') (n : ℤ), f (n • x) = n • f x
qsmul : ∀ (x : K') (n : ℚ), f (n • x) = n • f x
npow : ∀ (x : K') (n : ℕ), f (x ^ n) = f x ^ n
zpow : ∀ (x : K') (n : ℤ), f (x ^ n) = f x ^ n
nat_cast : ∀ (n : ℕ), f ↑n = ↑n
int_cast : ∀ (n : ℤ), f ↑n = ↑n
rat_cast : ∀ (n : ℚ), f ↑n = ↑n
src✝¹ : CommGroupWithZero K' := Injective.commGroupWithZero f hf zero one mul inv div npow zpow
src✝ : CommRing K' := Injective.commRing f hf zero one add mul neg sub nsmul zsmul npow nat_cast int_cast
a : ℚ
x : K'
⊢ f ((fun x x_1 => x • x_1) a x) = f (↑a * x)

Next tactic:
erw [qsmul, mul, Rat.smul_def, rat_cast]
/-- The pigeonhole principle for finitely many pigeons counted by weight, strict inequality version:
if the total weight of a finite set of pigeons is greater than `n • b`, and they are sorted into
`n` pigeonholes, then for some pigeonhole, the total weight of the pigeons in this pigeonhole is
greater than `b`. -/
theorem exists_lt_sum_fiber_of_maps_to_of_nsmul_lt_sum (hf : ∀ a ∈ s, f a ∈ t)
    (hb : t.card • b < ∑ x in s, w x) : ∃ y ∈ t, b < ∑ x in s.filter fun x => f x = y, w x :=
  exists_lt_of_sum_lt <| by 

Proof state:
α : Type u
β : Type v
M : Type w
inst✝¹ : DecidableEq β
s : Finset α
t : Finset β
f : α → β
w : α → M
b : M
n : ℕ
inst✝ : LinearOrderedCancelAddCommMonoid M
hf : ∀ a ∈ s, f a ∈ t
hb : card t • b < ∑ x in s, w x
⊢ ∑ i in t, b < ∑ i in t, ∑ x in filter (fun x => f x = i) s, w x

Next tactic:
simpa only [sum_fiberwise_of_maps_to hf, sum_const]
/-- The pigeonhole principle for finitely many pigeons counted by weight, strict inequality version:
if the total weight of a finite set of pigeons is greater than `n • b`, they are sorted into some
pigeonholes, and for all but `n` pigeonholes the total weight of the pigeons there is nonpositive,
then for at least one of these `n` pigeonholes, the total weight of the pigeons in this pigeonhole
is greater than `b`. -/
theorem exists_lt_sum_fiber_of_sum_fiber_nonpos_of_nsmul_lt_sum
    (ht : ∀ y ∉ t, ∑ x in s.filter fun x => f x = y, w x ≤ 0)
    (hb : t.card • b < ∑ x in s, w x) : ∃ y ∈ t, b < ∑ x in s.filter fun x => f x = y, w x :=
  exists_lt_of_sum_lt <|
    calc
      ∑ _y in t, b < ∑ x in s, w x := by 

Proof state:
α : Type u
β : Type v
M : Type w
inst✝¹ : DecidableEq β
s : Finset α
t : Finset β
f : α → β
w : α → M
b : M
n : ℕ
inst✝ : LinearOrderedCancelAddCommMonoid M
ht : ∀ y ∉ t, ∑ x in filter (fun x => f x = y) s, w x ≤ 0
hb : card t • b < ∑ x in s, w x
⊢ ∑ _y in t, b < ∑ x in s, w x

Next tactic:
simpa
/-- The pigeonhole principle for finitely many pigeons counted by weight, non-strict inequality
version: if the total weight of a finite set of pigeons is greater than or equal to `n • b`, and
they are sorted into `n > 0` pigeonholes, then for some pigeonhole, the total weight of the pigeons
in this pigeonhole is greater than or equal to `b`. -/
theorem exists_le_sum_fiber_of_maps_to_of_nsmul_le_sum (hf : ∀ a ∈ s, f a ∈ t) (ht : t.Nonempty)
    (hb : t.card • b ≤ ∑ x in s, w x) : ∃ y ∈ t, b ≤ ∑ x in s.filter fun x => f x = y, w x :=
  exists_le_of_sum_le ht <| by 

Proof state:
α : Type u
β : Type v
M : Type w
inst✝¹ : DecidableEq β
s : Finset α
t : Finset β
f : α → β
w : α → M
b : M
n : ℕ
inst✝ : LinearOrderedCancelAddCommMonoid M
hf : ∀ a ∈ s, f a ∈ t
ht : Finset.Nonempty t
hb : card t • b ≤ ∑ x in s, w x
⊢ ∑ i in t, b ≤ ∑ i in t, ∑ x in filter (fun x => f x = i) s, w x

Next tactic:
simpa only [sum_fiberwise_of_maps_to hf, sum_const]
/-- The pigeonhole principle for finitely many pigeons counted by weight, non-strict inequality
version: if the total weight of a finite set of pigeons is greater than or equal to `n • b`, they
are sorted into some pigeonholes, and for all but `n > 0` pigeonholes the total weight of the
pigeons there is nonpositive, then for at least one of these `n` pigeonholes, the total weight of
the pigeons in this pigeonhole is greater than or equal to `b`. -/
theorem exists_le_sum_fiber_of_sum_fiber_nonpos_of_nsmul_le_sum
    (hf : ∀ y ∉ t, ∑ x in s.filter fun x => f x = y, w x ≤ 0) (ht : t.Nonempty)
    (hb : t.card • b ≤ ∑ x in s, w x) : ∃ y ∈ t, b ≤ ∑ x in s.filter fun x => f x = y, w x :=
  exists_le_of_sum_le ht <|
    calc
      ∑ _y in t, b ≤ ∑ x in s, w x := by 

Proof state:
α : Type u
β : Type v
M : Type w
inst✝¹ : DecidableEq β
s : Finset α
t : Finset β
f : α → β
w : α → M
b : M
n : ℕ
inst✝ : LinearOrderedCancelAddCommMonoid M
hf : ∀ y ∉ t, ∑ x in filter (fun x => f x = y) s, w x ≤ 0
ht : Finset.Nonempty t
hb : card t • b ≤ ∑ x in s, w x
⊢ ∑ _y in t, b ≤ ∑ x in s, w x

Next tactic:
simpa
/-- The pigeonhole principle for finitely many pigeons counted by heads: there is a pigeonhole with
at least as many pigeons as the ceiling of the average number of pigeons across all pigeonholes. -/
theorem exists_lt_card_fiber_of_nsmul_lt_card_of_maps_to (hf : ∀ a ∈ s, f a ∈ t)
    (ht : t.card • b < s.card) : ∃ y ∈ t, b < (s.filter fun x => f x = y).card := by
  

Proof state:
α : Type u
β : Type v
M : Type w
inst✝¹ : DecidableEq β
s : Finset α
t : Finset β
f : α → β
w : α → M
b : M
n : ℕ
inst✝ : LinearOrderedCommSemiring M
hf : ∀ a ∈ s, f a ∈ t
ht : card t • b < ↑(card s)
⊢ ∃ y ∈ t, b < ↑(card (filter (fun x => f x = y) s))

Next tactic:
simp_rw [cast_card] at ht ⊢
/-- The pigeonhole principle for finitely many pigeons counted by heads: there is a pigeonhole with
at least as many pigeons as the ceiling of the average number of pigeons across all pigeonholes. -/
theorem exists_lt_card_fiber_of_nsmul_lt_card_of_maps_to (hf : ∀ a ∈ s, f a ∈ t)
    (ht : t.card • b < s.card) : ∃ y ∈ t, b < (s.filter fun x => f x = y).card := by
  simp_rw [cast_card] at ht ⊢
  

Proof state:
α : Type u
β : Type v
M : Type w
inst✝¹ : DecidableEq β
s : Finset α
t : Finset β
f : α → β
w : α → M
b : M
n : ℕ
inst✝ : LinearOrderedCommSemiring M
hf : ∀ a ∈ s, f a ∈ t
ht : card t • b < ∑ a in s, 1
⊢ ∃ y ∈ t, b < ∑ a in filter (fun x => f x = y) s, 1

Next tactic:
exact exists_lt_sum_fiber_of_maps_to_of_nsmul_lt_sum hf ht
/-- The pigeonhole principle for finitely many pigeons counted by heads: there is a pigeonhole with
at most as many pigeons as the floor of the average number of pigeons across all pigeonholes. -/
theorem exists_card_fiber_lt_of_card_lt_nsmul (ht : ↑s.card < t.card • b) :
    ∃ y ∈ t, ↑(s.filter fun x => f x = y).card < b := by
  

Proof state:
α : Type u
β : Type v
M : Type w
inst✝¹ : DecidableEq β
s : Finset α
t : Finset β
f : α → β
w : α → M
b : M
n : ℕ
inst✝ : LinearOrderedCommSemiring M
ht : ↑(card s) < card t • b
⊢ ∃ y ∈ t, ↑(card (filter (fun x => f x = y) s)) < b

Next tactic:
simp_rw [cast_card] at ht ⊢
/-- The pigeonhole principle for finitely many pigeons counted by heads: there is a pigeonhole with
at most as many pigeons as the floor of the average number of pigeons across all pigeonholes. -/
theorem exists_card_fiber_lt_of_card_lt_nsmul (ht : ↑s.card < t.card • b) :
    ∃ y ∈ t, ↑(s.filter fun x => f x = y).card < b := by
  simp_rw [cast_card] at ht ⊢
  

Proof state:
α : Type u
β : Type v
M : Type w
inst✝¹ : DecidableEq β
s : Finset α
t : Finset β
f : α → β
w : α → M
b : M
n : ℕ
inst✝ : LinearOrderedCommSemiring M
ht : ∑ a in s, 1 < card t • b
⊢ ∃ y ∈ t, ∑ a in filter (fun x => f x = y) s, 1 < b

Next tactic:
exact
    exists_sum_fiber_lt_of_sum_fiber_nonneg_of_sum_lt_nsmul
      (fun _ _ => sum_nonneg fun _ _ => zero_le_one) ht