l3lab/ntp-mathlib huggingface dataset:
theorem smul_eq_C_smul (x : RatFunc K) (r : K) : r • x = Polynomial.C r • x := by
  cases' x with x
  -- Porting note: had to specify the induction principle manually
  induction x using Localization.induction_on
  

Proof state:
case ofFractionRing.H
K : Type u
inst✝ : CommRing K
R : Type u_1
r : K
y✝ : K[X] × ↥K[X]⁰
⊢ r • { toFractionRing := Localization.mk y✝.1 y✝.2 } = Polynomial.C r • { toFractionRing := Localization.mk y✝.1 y✝.2 }

Next tactic:
rw [← ofFractionRing_smul, ← ofFractionRing_smul, Localization.smul_mk,
    Localization.smul_mk, smul_eq_mul, Polynomial.smul_eq_C_mul]
theorem mk_smul (c : R) (p q : K[X]) : RatFunc.mk (c • p) q = c • RatFunc.mk p q := by
  

Proof state:
K : Type u
inst✝⁴ : CommRing K
R : Type u_1
inst✝³ : IsDomain K
inst✝² : Monoid R
inst✝¹ : DistribMulAction R K[X]
inst✝ : IsScalarTower R K[X] K[X]
c : R
p q : K[X]
⊢ RatFunc.mk (c • p) q = c • RatFunc.mk p q

Next tactic:
by_cases hq : q = 0
theorem mk_smul (c : R) (p q : K[X]) : RatFunc.mk (c • p) q = c • RatFunc.mk p q := by
  by_cases hq : q = 0
  · 

Proof state:
case pos
K : Type u
inst✝⁴ : CommRing K
R : Type u_1
inst✝³ : IsDomain K
inst✝² : Monoid R
inst✝¹ : DistribMulAction R K[X]
inst✝ : IsScalarTower R K[X] K[X]
c : R
p q : K[X]
hq : q = 0
⊢ RatFunc.mk (c • p) q = c • RatFunc.mk p q

Next tactic:
rw [hq, mk_zero, mk_zero, ← ofFractionRing_smul, smul_zero]
theorem mk_smul (c : R) (p q : K[X]) : RatFunc.mk (c • p) q = c • RatFunc.mk p q := by
  by_cases hq : q = 0
  · rw [hq, mk_zero, mk_zero, ← ofFractionRing_smul, smul_zero]
  · 

Proof state:
case neg
K : Type u
inst✝⁴ : CommRing K
R : Type u_1
inst✝³ : IsDomain K
inst✝² : Monoid R
inst✝¹ : DistribMulAction R K[X]
inst✝ : IsScalarTower R K[X] K[X]
c : R
p q : K[X]
hq : ¬q = 0
⊢ RatFunc.mk (c • p) q = c • RatFunc.mk p q

Next tactic:
rw [mk_eq_localization_mk _ hq, mk_eq_localization_mk _ hq, ← Localization.smul_mk, ←
      ofFractionRing_smul]
instance : IsScalarTower R K[X] (RatFunc K) :=
  ⟨fun c p q => q.induction_on' fun q r _ => by 

Proof state:
K : Type u
inst✝⁴ : CommRing K
R : Type u_1
inst✝³ : IsDomain K
inst✝² : Monoid R
inst✝¹ : DistribMulAction R K[X]
inst✝ : IsScalarTower R K[X] K[X]
c : R
p : K[X]
q✝ : RatFunc K
q r : K[X]
x✝ : r ≠ 0
⊢ (c • p) • RatFunc.mk q r = c • p • RatFunc.mk q r

Next tactic:
rw [← mk_smul, smul_assoc, mk_smul, mk_smul]
/-- `RatFunc K` is isomorphic to the field of fractions of `K[X]`, as rings.

This is an auxiliary definition; `simp`-normal form is `IsLocalization.algEquiv`.
-/
@[simps apply]
def toFractionRingRingEquiv : RatFunc K ≃+* FractionRing K[X] where
  toFun := toFractionRing
  invFun := ofFractionRing
  left_inv := fun ⟨_⟩ => rfl
  right_inv _ := rfl
  map_add' := fun ⟨_⟩ ⟨_⟩ => by simp [← ofFractionRing_add]
  map_mul' := fun ⟨_⟩ ⟨_⟩ => by 

Proof state:
K : Type u
inst✝ : CommRing K
x✝¹ x✝ : RatFunc K
toFractionRing✝¹ toFractionRing✝ : FractionRing K[X]
⊢ Equiv.toFun
      { toFun := toFractionRing, invFun := ofFractionRing,
        left_inv := (_ : ∀ (x : RatFunc K), { toFractionRing := x.toFractionRing } = x),
        right_inv :=
          (_ :
            ∀ (x : FractionRing K[X]),
              { toFractionRing := x }.toFractionRing = { toFractionRing := x }.toFractionRing) }
      ({ toFractionRing := toFractionRing✝¹ } * { toFractionRing := toFractionRing✝ }) =
    Equiv.toFun
        { toFun := toFractionRing, invFun := ofFractionRing,
          left_inv := (_ : ∀ (x : RatFunc K), { toFractionRing := x.toFractionRing } = x),
          right_inv :=
            (_ :
              ∀ (x : FractionRing K[X]),
                { toFractionRing := x }.toFractionRing = { toFractionRing := x }.toFractionRing) }
        { toFractionRing := toFractionRing✝¹ } *
      Equiv.toFun
        { toFun := toFractionRing, invFun := ofFractionRing,
          left_inv := (_ : ∀ (x : RatFunc K), { toFractionRing := x.toFractionRing } = x),
          right_inv :=
            (_ :
              ∀ (x : FractionRing K[X]),
                { toFractionRing := x }.toFractionRing = { toFractionRing := x }.toFractionRing) }
        { toFractionRing := toFractionRing✝ }

Next tactic:
simp [← ofFractionRing_mul]
/-- `RatFunc K` is isomorphic to the field of fractions of `K[X]`, as rings.

This is an auxiliary definition; `simp`-normal form is `IsLocalization.algEquiv`.
-/
@[simps apply]
def toFractionRingRingEquiv : RatFunc K ≃+* FractionRing K[X] where
  toFun := toFractionRing
  invFun := ofFractionRing
  left_inv := fun ⟨_⟩ => rfl
  right_inv _ := rfl
  map_add' := fun ⟨_⟩ ⟨_⟩ => by 

Proof state:
K : Type u
inst✝ : CommRing K
x✝¹ x✝ : RatFunc K
toFractionRing✝¹ toFractionRing✝ : FractionRing K[X]
⊢ Equiv.toFun
      { toFun := toFractionRing, invFun := ofFractionRing,
        left_inv := (_ : ∀ (x : RatFunc K), { toFractionRing := x.toFractionRing } = x),
        right_inv :=
          (_ :
            ∀ (x : FractionRing K[X]),
              { toFractionRing := x }.toFractionRing = { toFractionRing := x }.toFractionRing) }
      ({ toFractionRing := toFractionRing✝¹ } + { toFractionRing := toFractionRing✝ }) =
    Equiv.toFun
        { toFun := toFractionRing, invFun := ofFractionRing,
          left_inv := (_ : ∀ (x : RatFunc K), { toFractionRing := x.toFractionRing } = x),
          right_inv :=
            (_ :
              ∀ (x : FractionRing K[X]),
                { toFractionRing := x }.toFractionRing = { toFractionRing := x }.toFractionRing) }
        { toFractionRing := toFractionRing✝¹ } +
      Equiv.toFun
        { toFun := toFractionRing, invFun := ofFractionRing,
          left_inv := (_ : ∀ (x : RatFunc K), { toFractionRing := x.toFractionRing } = x),
          right_inv :=
            (_ :
              ∀ (x : FractionRing K[X]),
                { toFractionRing := x }.toFractionRing = { toFractionRing := x }.toFractionRing) }
        { toFractionRing := toFractionRing✝ }

Next tactic:
simp [← ofFractionRing_add]
/-- `RatFunc K` is a commutative monoid.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instCommMonoid : CommMonoid (RatFunc K) where
  mul := (· * ·)
  mul_assoc := by 

Proof state:
K : Type u
inst✝ : CommRing K
⊢ ∀ (a b c : RatFunc K), a * b * c = a * (b * c)

Next tactic:
frac_tac
/-- `RatFunc K` is a commutative monoid.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instCommMonoid : CommMonoid (RatFunc K) where
  mul := (· * ·)
  mul_assoc := by frac_tac
  mul_comm := by frac_tac
  one := 1
  one_mul := by 

Proof state:
K : Type u
inst✝ : CommRing K
⊢ ∀ (a : RatFunc K), 1 * a = a

Next tactic:
frac_tac
/-- `RatFunc K` is a commutative monoid.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instCommMonoid : CommMonoid (RatFunc K) where
  mul := (· * ·)
  mul_assoc := by frac_tac
  mul_comm := by frac_tac
  one := 1
  one_mul := by frac_tac
  mul_one := by 

Proof state:
K : Type u
inst✝ : CommRing K
⊢ ∀ (a : RatFunc K), a * 1 = a

Next tactic:
frac_tac
/-- `RatFunc K` is a commutative monoid.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instCommMonoid : CommMonoid (RatFunc K) where
  mul := (· * ·)
  mul_assoc := by frac_tac
  mul_comm := by 

Proof state:
K : Type u
inst✝ : CommRing K
⊢ ∀ (a b : RatFunc K), a * b = b * a

Next tactic:
frac_tac
/-- `RatFunc K` is an additive commutative group.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instAddCommGroup : AddCommGroup (RatFunc K) where
  add := (· + ·)
  add_assoc := by 

Proof state:
K : Type u
inst✝ : CommRing K
⊢ ∀ (a b c : RatFunc K), a + b + c = a + (b + c)

Next tactic:
frac_tac
/-- `RatFunc K` is an additive commutative group.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instAddCommGroup : AddCommGroup (RatFunc K) where
  add := (· + ·)
  add_assoc := by frac_tac
 -- porting note: `by frac_tac` didn't work:
  add_comm := by repeat rintro (⟨⟩ : RatFunc _) <;> simp only [← ofFractionRing_add, add_comm]
  zero := 0
  zero_add := by 

Proof state:
K : Type u
inst✝ : CommRing K
⊢ ∀ (a : RatFunc K), 0 + a = a

Next tactic:
frac_tac
/-- `RatFunc K` is an additive commutative group.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instAddCommGroup : AddCommGroup (RatFunc K) where
  add := (· + ·)
  add_assoc := by frac_tac
 -- porting note: `by frac_tac` didn't work:
  add_comm := by repeat rintro (⟨⟩ : RatFunc _) <;> simp only [← ofFractionRing_add, add_comm]
  zero := 0
  zero_add := by frac_tac
  add_zero := by 

Proof state:
K : Type u
inst✝ : CommRing K
⊢ ∀ (a : RatFunc K), a + 0 = a

Next tactic:
frac_tac
/-- `RatFunc K` is an additive commutative group.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instAddCommGroup : AddCommGroup (RatFunc K) where
  add := (· + ·)
  add_assoc := by frac_tac
 -- porting note: `by frac_tac` didn't work:
  add_comm := by repeat rintro (⟨⟩ : RatFunc _) <;> simp only [← ofFractionRing_add, add_comm]
  zero := 0
  zero_add := by frac_tac
  add_zero := by frac_tac
  neg := Neg.neg
  add_left_neg := by frac_tac
  sub := Sub.sub
  sub_eq_add_neg := by frac_tac
  nsmul := (· • ·)
  nsmul_zero := by 

Proof state:
K : Type u
inst✝ : CommRing K
⊢ ∀ (x : RatFunc K), (fun x x_1 => x • x_1) 0 x = 0

Next tactic:
smul_tac
/-- `RatFunc K` is an additive commutative group.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instAddCommGroup : AddCommGroup (RatFunc K) where
  add := (· + ·)
  add_assoc := by frac_tac
 -- porting note: `by frac_tac` didn't work:
  add_comm := by repeat rintro (⟨⟩ : RatFunc _) <;> simp only [← ofFractionRing_add, add_comm]
  zero := 0
  zero_add := by frac_tac
  add_zero := by frac_tac
  neg := Neg.neg
  add_left_neg := by frac_tac
  sub := Sub.sub
  sub_eq_add_neg := by frac_tac
  nsmul := (· • ·)
  nsmul_zero := by smul_tac
  nsmul_succ _ := by 

Proof state:
K : Type u
inst✝ : CommRing K
x✝ : ℕ
⊢ ∀ (x : RatFunc K), (fun x x_1 => x • x_1) (x✝ + 1) x = x + (fun x x_1 => x • x_1) x✝ x

Next tactic:
smul_tac
/-- `RatFunc K` is an additive commutative group.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instAddCommGroup : AddCommGroup (RatFunc K) where
  add := (· + ·)
  add_assoc := by frac_tac
 -- porting note: `by frac_tac` didn't work:
  add_comm := by repeat rintro (⟨⟩ : RatFunc _) <;> simp only [← ofFractionRing_add, add_comm]
  zero := 0
  zero_add := by frac_tac
  add_zero := by frac_tac
  neg := Neg.neg
  add_left_neg := by frac_tac
  sub := Sub.sub
  sub_eq_add_neg := by 

Proof state:
K : Type u
inst✝ : CommRing K
⊢ ∀ (a b : RatFunc K), a - b = a + -b

Next tactic:
frac_tac
/-- `RatFunc K` is an additive commutative group.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instAddCommGroup : AddCommGroup (RatFunc K) where
  add := (· + ·)
  add_assoc := by frac_tac
 -- porting note: `by frac_tac` didn't work:
  add_comm := by repeat rintro (⟨⟩ : RatFunc _) <;> simp only [← ofFractionRing_add, add_comm]
  zero := 0
  zero_add := by frac_tac
  add_zero := by frac_tac
  neg := Neg.neg
  add_left_neg := by frac_tac
  sub := Sub.sub
  sub_eq_add_neg := by frac_tac
  nsmul := (· • ·)
  nsmul_zero := by smul_tac
  nsmul_succ _ := by smul_tac
  zsmul := (· • ·)
  zsmul_zero' := by 

Proof state:
K : Type u
inst✝ : CommRing K
⊢ ∀ (a : RatFunc K), (fun x x_1 => x • x_1) 0 a = 0

Next tactic:
smul_tac
/-- `RatFunc K` is an additive commutative group.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instAddCommGroup : AddCommGroup (RatFunc K) where
  add := (· + ·)
  add_assoc := by frac_tac
 -- porting note: `by frac_tac` didn't work:
  add_comm := by repeat rintro (⟨⟩ : RatFunc _) <;> simp only [← ofFractionRing_add, add_comm]
  zero := 0
  zero_add := by frac_tac
  add_zero := by frac_tac
  neg := Neg.neg
  add_left_neg := by frac_tac
  sub := Sub.sub
  sub_eq_add_neg := by frac_tac
  nsmul := (· • ·)
  nsmul_zero := by smul_tac
  nsmul_succ _ := by smul_tac
  zsmul := (· • ·)
  zsmul_zero' := by smul_tac
  zsmul_succ' _ := by 

Proof state:
K : Type u
inst✝ : CommRing K
x✝ : ℕ
⊢ ∀ (a : RatFunc K), (fun x x_1 => x • x_1) (Int.ofNat (Nat.succ x✝)) a = a + (fun x x_1 => x • x_1) (Int.ofNat x✝) a

Next tactic:
smul_tac
/-- `RatFunc K` is an additive commutative group.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instAddCommGroup : AddCommGroup (RatFunc K) where
  add := (· + ·)
  add_assoc := by frac_tac
 -- porting note: `by frac_tac` didn't work:
  add_comm := by repeat rintro (⟨⟩ : RatFunc _) <;> simp only [← ofFractionRing_add, add_comm]
  zero := 0
  zero_add := by frac_tac
  add_zero := by frac_tac
  neg := Neg.neg
  add_left_neg := by frac_tac
  sub := Sub.sub
  sub_eq_add_neg := by frac_tac
  nsmul := (· • ·)
  nsmul_zero := by smul_tac
  nsmul_succ _ := by smul_tac
  zsmul := (· • ·)
  zsmul_zero' := by smul_tac
  zsmul_succ' _ := by smul_tac
  zsmul_neg' _ := by 

Proof state:
K : Type u
inst✝ : CommRing K
x✝ : ℕ
⊢ ∀ (a : RatFunc K), (fun x x_1 => x • x_1) (Int.negSucc x✝) a = -(fun x x_1 => x • x_1) (↑(Nat.succ x✝)) a

Next tactic:
smul_tac
/-- `RatFunc K` is an additive commutative group.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instAddCommGroup : AddCommGroup (RatFunc K) where
  add := (· + ·)
  add_assoc := by frac_tac
 -- porting note: `by frac_tac` didn't work:
  add_comm := by repeat rintro (⟨⟩ : RatFunc _) <;> simp only [← ofFractionRing_add, add_comm]
  zero := 0
  zero_add := by frac_tac
  add_zero := by frac_tac
  neg := Neg.neg
  add_left_neg := by 

Proof state:
K : Type u
inst✝ : CommRing K
⊢ ∀ (a : RatFunc K), -a + a = 0

Next tactic:
frac_tac
/-- `RatFunc K` is an additive commutative group.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instAddCommGroup : AddCommGroup (RatFunc K) where
  add := (· + ·)
  add_assoc := by frac_tac
 -- porting note: `by frac_tac` didn't work:
  add_comm := by 

Proof state:
K : Type u
inst✝ : CommRing K
⊢ ∀ (a b : RatFunc K), a + b = b + a

Next tactic:
repeat rintro (⟨⟩ : RatFunc _) <;> simp only [← ofFractionRing_add, add_comm]
/-- `RatFunc K` is an additive commutative group.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instAddCommGroup : AddCommGroup (RatFunc K) where
  add := (· + ·)
  add_assoc := by frac_tac
 -- porting note: `by frac_tac` didn't work:
  add_comm := by repeat 

Proof state:
K : Type u
inst✝ : CommRing K
⊢ ∀ (a b : RatFunc K), a + b = b + a

Next tactic:
rintro (⟨⟩ : RatFunc _)
/-- `RatFunc K` is an additive commutative group.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instAddCommGroup : AddCommGroup (RatFunc K) where
  add := (· + ·)
  add_assoc := by frac_tac
 -- porting note: `by frac_tac` didn't work:
  add_comm := by repeat rintro (⟨⟩ : RatFunc _) <;> 

Proof state:
case ofFractionRing
K : Type u
inst✝ : CommRing K
toFractionRing✝ : FractionRing K[X]
⊢ ∀ (b : RatFunc K), { toFractionRing := toFractionRing✝ } + b = b + { toFractionRing := toFractionRing✝ }

Next tactic:
simp only [← ofFractionRing_add, add_comm]
/-- `RatFunc K` is an additive commutative group.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instAddCommGroup : AddCommGroup (RatFunc K) where
  add := (· + ·)
  add_assoc := by frac_tac
 -- porting note: `by frac_tac` didn't work:
  add_comm := by repeat 

Proof state:
case ofFractionRing
K : Type u
inst✝ : CommRing K
toFractionRing✝ : FractionRing K[X]
⊢ ∀ (b : RatFunc K), { toFractionRing := toFractionRing✝ } + b = b + { toFractionRing := toFractionRing✝ }

Next tactic:
rintro (⟨⟩ : RatFunc _)
/-- `RatFunc K` is an additive commutative group.

This is an intermediate step on the way to the full instance `RatFunc.instCommRing`.
-/
def instAddCommGroup : AddCommGroup (RatFunc K) where
  add := (· + ·)
  add_assoc := by frac_tac
 -- porting note: `by frac_tac` didn't work:
  add_comm := by repeat rintro (⟨⟩ : RatFunc _) <;> 

Proof state:
case ofFractionRing.ofFractionRing
K : Type u
inst✝ : CommRing K
toFractionRing✝¹ toFractionRing✝ : FractionRing K[X]
⊢ { toFractionRing := toFractionRing✝¹ } + { toFractionRing := toFractionRing✝ } =
    { toFractionRing := toFractionRing✝ } + { toFractionRing := toFractionRing✝¹ }

Next tactic:
simp only [← ofFractionRing_add, add_comm]
instance instCommRing : CommRing (RatFunc K) :=
  { instCommMonoid K, instAddCommGroup K with
    zero := 0
    sub := Sub.sub
    zero_mul := by frac_tac
    mul_zero := by frac_tac
    left_distrib := by 

Proof state:
K : Type u
inst✝ : CommRing K
src✝¹ : CommMonoid (RatFunc K) := instCommMonoid K
src✝ : AddCommGroup (RatFunc K) := instAddCommGroup K
⊢ ∀ (a b c : RatFunc K), a * (b + c) = a * b + a * c

Next tactic:
frac_tac
instance instCommRing : CommRing (RatFunc K) :=
  { instCommMonoid K, instAddCommGroup K with
    zero := 0
    sub := Sub.sub
    zero_mul := by frac_tac
    mul_zero := by frac_tac
    left_distrib := by frac_tac
    right_distrib := by 

Proof state:
K : Type u
inst✝ : CommRing K
src✝¹ : CommMonoid (RatFunc K) := instCommMonoid K
src✝ : AddCommGroup (RatFunc K) := instAddCommGroup K
⊢ ∀ (a b c : RatFunc K), (a + b) * c = a * c + b * c

Next tactic:
frac_tac
instance instCommRing : CommRing (RatFunc K) :=
  { instCommMonoid K, instAddCommGroup K with
    zero := 0
    sub := Sub.sub
    zero_mul := by 

Proof state:
K : Type u
inst✝ : CommRing K
src✝¹ : CommMonoid (RatFunc K) := instCommMonoid K
src✝ : AddCommGroup (RatFunc K) := instAddCommGroup K
⊢ ∀ (a : RatFunc K), 0 * a = 0

Next tactic:
frac_tac
instance instCommRing : CommRing (RatFunc K) :=
  { instCommMonoid K, instAddCommGroup K with
    zero := 0
    sub := Sub.sub
    zero_mul := by frac_tac
    mul_zero := by 

Proof state:
K : Type u
inst✝ : CommRing K
src✝¹ : CommMonoid (RatFunc K) := instCommMonoid K
src✝ : AddCommGroup (RatFunc K) := instAddCommGroup K
⊢ ∀ (a : RatFunc K), a * 0 = 0

Next tactic:
frac_tac
/-- Lift a monoid homomorphism that maps polynomials `φ : R[X] →* S[X]`
to a `RatFunc R →* RatFunc S`,
on the condition that `φ` maps non zero divisors to non zero divisors,
by mapping both the numerator and denominator and quotienting them. -/
def map [MonoidHomClass F R[X] S[X]] (φ : F) (hφ : R[X]⁰ ≤ S[X]⁰.comap φ) : RatFunc R →* RatFunc S
    where
  toFun f :=
    RatFunc.liftOn f
      (fun n d => if h : φ d ∈ S[X]⁰ then ofFractionRing (Localization.mk (φ n) ⟨φ d, h⟩) else 0)
      fun {p q p' q'} hq hq' h => by
      

Proof state:
K : Type u
inst✝⁵ : CommRing K
G₀ : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
F : Type u_5
inst✝⁴ : CommGroupWithZero G₀
inst✝³ : Field L
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : MonoidHomClass F R[X] S[X]
φ : F
hφ : R[X]⁰ ≤ Submonoid.comap φ S[X]⁰
f : RatFunc R
p q p' q' : R[X]
hq : q ∈ R[X]⁰
hq' : q' ∈ R[X]⁰
h : q' * p = q * p'
⊢ (fun n d => if h : φ d ∈ S[X]⁰ then { toFractionRing := Localization.mk (φ n) { val := φ d, property := h } } else 0)
      p q =
    (fun n d =>
        if h : φ d ∈ S[X]⁰ then { toFractionRing := Localization.mk (φ n) { val := φ d, property := h } } else 0)
      p' q'

Next tactic:
dsimp only
/-- Lift a monoid homomorphism that maps polynomials `φ : R[X] →* S[X]`
to a `RatFunc R →* RatFunc S`,
on the condition that `φ` maps non zero divisors to non zero divisors,
by mapping both the numerator and denominator and quotienting them. -/
def map [MonoidHomClass F R[X] S[X]] (φ : F) (hφ : R[X]⁰ ≤ S[X]⁰.comap φ) : RatFunc R →* RatFunc S
    where
  toFun f :=
    RatFunc.liftOn f
      (fun n d => if h : φ d ∈ S[X]⁰ then ofFractionRing (Localization.mk (φ n) ⟨φ d, h⟩) else 0)
      fun {p q p' q'} hq hq' h => by
      dsimp only -- porting note: force the function to be applied
      

Proof state:
K : Type u
inst✝⁵ : CommRing K
G₀ : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
F : Type u_5
inst✝⁴ : CommGroupWithZero G₀
inst✝³ : Field L
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : MonoidHomClass F R[X] S[X]
φ : F
hφ : R[X]⁰ ≤ Submonoid.comap φ S[X]⁰
f : RatFunc R
p q p' q' : R[X]
hq : q ∈ R[X]⁰
hq' : q' ∈ R[X]⁰
h : q' * p = q * p'
⊢ (if h : φ q ∈ S[X]⁰ then { toFractionRing := Localization.mk (φ p) { val := φ q, property := h } } else 0) =
    if h : φ q' ∈ S[X]⁰ then { toFractionRing := Localization.mk (φ p') { val := φ q', property := h } } else 0

Next tactic:
rw [dif_pos, dif_pos]
/-- Lift a monoid homomorphism that maps polynomials `φ : R[X] →* S[X]`
to a `RatFunc R →* RatFunc S`,
on the condition that `φ` maps non zero divisors to non zero divisors,
by mapping both the numerator and denominator and quotienting them. -/
def map [MonoidHomClass F R[X] S[X]] (φ : F) (hφ : R[X]⁰ ≤ S[X]⁰.comap φ) : RatFunc R →* RatFunc S
    where
  toFun f :=
    RatFunc.liftOn f
      (fun n d => if h : φ d ∈ S[X]⁰ then ofFractionRing (Localization.mk (φ n) ⟨φ d, h⟩) else 0)
      fun {p q p' q'} hq hq' h => by
      dsimp only -- porting note: force the function to be applied
      rw [dif_pos, dif_pos]
      

Proof state:
K : Type u
inst✝⁵ : CommRing K
G₀ : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
F : Type u_5
inst✝⁴ : CommGroupWithZero G₀
inst✝³ : Field L
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : MonoidHomClass F R[X] S[X]
φ : F
hφ : R[X]⁰ ≤ Submonoid.comap φ S[X]⁰
f : RatFunc R
p q p' q' : R[X]
hq : q ∈ R[X]⁰
hq' : q' ∈ R[X]⁰
h : q' * p = q * p'
⊢ { toFractionRing := Localization.mk (φ p) { val := φ q, property := ?hc } } =
    { toFractionRing := Localization.mk (φ p') { val := φ q', property := ?hc } }
case hc
K : Type u
inst✝⁵ : CommRing K
G₀ : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
F : Type u_5
inst✝⁴ : CommGroupWithZero G₀
inst✝³ : Field L
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : MonoidHomClass F R[X] S[X]
φ : F
hφ : R[X]⁰ ≤ Submonoid.comap φ S[X]⁰
f : RatFunc R
p q p' q' : R[X]
hq : q ∈ R[X]⁰
hq' : q' ∈ R[X]⁰
h : q' * p = q * p'
⊢ φ q' ∈ S[X]⁰
case hc
K : Type u
inst✝⁵ : CommRing K
G₀ : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
F : Type u_5
inst✝⁴ : CommGroupWithZero G₀
inst✝³ : Field L
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : MonoidHomClass F R[X] S[X]
φ : F
hφ : R[X]⁰ ≤ Submonoid.comap φ S[X]⁰
f : RatFunc R
p q p' q' : R[X]
hq : q ∈ R[X]⁰
hq' : q' ∈ R[X]⁰
h : q' * p = q * p'
⊢ φ q ∈ S[X]⁰
case hc
K : Type u
inst✝⁵ : CommRing K
G₀ : Type u_1
L : Type u_2
R : Type u_3
S : Type u_4
F : Type u_5
inst✝⁴ : CommGroupWithZero G₀
inst✝³ : Field L
inst✝² : CommRing R
inst✝¹ : CommRing S
inst✝ : MonoidHomClass F R[X] S[X]
φ : F
hφ : R[X]⁰ ≤ Submonoid.comap φ S[X]⁰
f : RatFunc R
p q p' q' : R[X]
hq : q ∈ R[X]⁰
hq' : q' ∈ R[X]⁰
h : q' * p = q * p'
⊢ φ q ∈ S[X]⁰

Next tactic:
congr 1