algebra.field.defs
⟷
Mathlib.Algebra.Field.IsField
The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(last sync)
There is many generalisations around these areas too, but I am specifically not doing them as it will be easier done after the port. I am only doing what I need for merging in the splitting field diamond fix.
Co-authored-by: Eric Rodriguez <37984851+ericrbg@users.noreply.github.com>
@@ -143,6 +143,10 @@ instance smul_division_ring : has_smul ℚ K :=
lemma smul_def (a : ℚ) (x : K) : a • x = ↑a * x := division_ring.qsmul_eq_mul' a x
+@[simp] lemma smul_one_eq_coe (A : Type*) [division_ring A] (m : ℚ) :
+ m • (1 : A) = ↑m :=
+by rw [rat.smul_def, mul_one]
+
end rat
end division_ring
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(first ported)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -72,7 +72,6 @@ class HasRatCast (K : Type u) where
ratCast : ℚ → K
#align has_rat_cast HasRatCast
-#print qsmulRec /-
/-- The default definition of the scalar multiplication `(a : ℚ) • (x : K)` for a division ring `K`
is given by `a • x = (↑ a) * x`.
Use `(a : ℚ) • (x : K)` instead of `qsmul_rec` for better definitional behaviour.
@@ -80,7 +79,6 @@ Use `(a : ℚ) • (x : K)` instead of `qsmul_rec` for better definitional behav
def qsmulRec (coe : ℚ → K) [Mul K] (a : ℚ) (x : K) : K :=
coe a * x
#align qsmul_rec qsmulRec
--/
#print DivisionSemiring /-
/-- A `division_semiring` is a `semiring` with multiplicative inverses for nonzero elements. -/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -105,7 +105,7 @@ class DivisionRing (K : Type u) extends Ring K, DivInvMonoid K, Nontrivial K, Ha
mul_inv_cancel : ∀ {a : K}, a ≠ 0 → a * a⁻¹ = 1
inv_zero : (0 : K)⁻¹ = 0
ratCast := Rat.castRec
- ratCast_mk : ∀ (a : ℤ) (b : ℕ) (h1 h2), rat_cast ⟨a, b, h1, h2⟩ = a * b⁻¹ := by intros; rfl
+ ratCast_def : ∀ (a : ℤ) (b : ℕ) (h1 h2), rat_cast ⟨a, b, h1, h2⟩ = a * b⁻¹ := by intros; rfl
qsmul : ℚ → K → K := qsmulRec rat_cast
qsmul_eq_mul' : ∀ (a : ℚ) (x : K), qsmul a x = rat_cast a * x := by intros; rfl
#align division_ring DivisionRing
@@ -158,7 +158,7 @@ instance (priority := 900) castCoe {K : Type _} [HasRatCast K] : CoeTC ℚ K :=
#print Rat.cast_mk' /-
theorem cast_mk' (a b h1 h2) : ((⟨a, b, h1, h2⟩ : ℚ) : K) = a * b⁻¹ :=
- DivisionRing.ratCast_mk _ _ _ _
+ DivisionRing.ratCast_def _ _ _ _
#align rat.cast_mk' Rat.cast_mk'
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,8 +3,8 @@ Copyright (c) 2014 Robert Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Lewis, Leonardo de Moura, Johannes Hölzl, Mario Carneiro
-/
-import Mathbin.Data.Rat.Init
-import Mathbin.Algebra.Ring.Defs
+import Data.Rat.Init
+import Algebra.Ring.Defs
#align_import algebra.field.defs from "leanprover-community/mathlib"@"2651125b48fc5c170ab1111afd0817c903b1fc6c"
mathlib commit https://github.com/leanprover-community/mathlib/commit/32a7e535287f9c73f2e4d2aef306a39190f0b504
@@ -257,11 +257,11 @@ open scoped Classical
noncomputable def IsField.toSemifield {R : Type u} [Semiring R] (h : IsField R) : Semifield R :=
{ ‹Semiring R›,
h with
- inv := fun a => if ha : a = 0 then 0 else Classical.choose (IsField.mul_inv_cancel h ha)
+ inv := fun a => if ha : a = 0 then 0 else Classical.choose (IsField.hMul_inv_cancel h ha)
inv_zero := dif_pos rfl
mul_inv_cancel := fun a ha =>
by
- convert Classical.choose_spec (IsField.mul_inv_cancel h ha)
+ convert Classical.choose_spec (IsField.hMul_inv_cancel h ha)
exact dif_neg ha }
#align is_field.to_semifield IsField.toSemifield
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,15 +2,12 @@
Copyright (c) 2014 Robert Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Lewis, Leonardo de Moura, Johannes Hölzl, Mario Carneiro
-
-! This file was ported from Lean 3 source module algebra.field.defs
-! leanprover-community/mathlib commit 2651125b48fc5c170ab1111afd0817c903b1fc6c
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Data.Rat.Init
import Mathbin.Algebra.Ring.Defs
+#align_import algebra.field.defs from "leanprover-community/mathlib"@"2651125b48fc5c170ab1111afd0817c903b1fc6c"
+
/-!
# Division (semi)rings and (semi)fields
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -58,6 +58,7 @@ universe u
variable {α β K : Type _}
+#print Rat.castRec /-
/-- The default definition of the coercion `(↑(a : ℚ) : K)` for a division ring `K`
is defined as `(a / b : K) = (a : K) * (b : K)⁻¹`.
Use `coe` instead of `rat.cast_rec` for better definitional behaviour.
@@ -65,6 +66,7 @@ Use `coe` instead of `rat.cast_rec` for better definitional behaviour.
def Rat.castRec [HasLiftT ℕ K] [HasLiftT ℤ K] [Mul K] [Inv K] : ℚ → K
| ⟨a, b, _, _⟩ => ↑a * (↑b)⁻¹
#align rat.cast_rec Rat.castRec
+-/
/-- Type class for the canonical homomorphism `ℚ → K`.
-/
@@ -157,13 +159,17 @@ instance (priority := 900) castCoe {K : Type _} [HasRatCast K] : CoeTC ℚ K :=
⟨HasRatCast.ratCast⟩
#align rat.cast_coe Rat.castCoe
+#print Rat.cast_mk' /-
theorem cast_mk' (a b h1 h2) : ((⟨a, b, h1, h2⟩ : ℚ) : K) = a * b⁻¹ :=
DivisionRing.ratCast_mk _ _ _ _
#align rat.cast_mk' Rat.cast_mk'
+-/
+#print Rat.cast_def /-
theorem cast_def : ∀ r : ℚ, (r : K) = r.num / r.den
| ⟨a, b, h1, h2⟩ => (cast_mk' _ _ _ _).trans (div_eq_mul_inv _ _).symm
#align rat.cast_def Rat.cast_def
+-/
#print Rat.smulDivisionRing /-
instance (priority := 100) smulDivisionRing : SMul ℚ K :=
@@ -171,14 +177,18 @@ instance (priority := 100) smulDivisionRing : SMul ℚ K :=
#align rat.smul_division_ring Rat.smulDivisionRing
-/
+#print Rat.smul_def /-
theorem smul_def (a : ℚ) (x : K) : a • x = ↑a * x :=
DivisionRing.qsmul_eq_mul' a x
#align rat.smul_def Rat.smul_def
+-/
+#print Rat.smul_one_eq_coe /-
@[simp]
theorem smul_one_eq_coe (A : Type _) [DivisionRing A] (m : ℚ) : m • (1 : A) = ↑m := by
rw [Rat.smul_def, mul_one]
#align rat.smul_one_eq_coe Rat.smul_one_eq_coe
+-/
end Rat
@@ -266,6 +276,7 @@ noncomputable def IsField.toField {R : Type u} [Ring R] (h : IsField R) : Field
#align is_field.to_field IsField.toField
-/
+#print uniq_inv_of_isField /-
/-- For each field, and for each nonzero element of said field, there is a unique inverse.
Since `is_field` doesn't remember the data of an `inv` function and as such,
a lemma that there is a unique inverse could be useful.
@@ -281,6 +292,7 @@ theorem uniq_inv_of_isField (R : Type u) [Ring R] (hf : IsField R) :
_ = x * y * z := by rw [← mul_assoc, hf.mul_comm y x]
_ = z := by rw [hxy, one_mul]
#align uniq_inv_of_is_field uniq_inv_of_isField
+-/
end IsField
mathlib commit https://github.com/leanprover-community/mathlib/commit/7e5137f579de09a059a5ce98f364a04e221aabf0
@@ -280,7 +280,6 @@ theorem uniq_inv_of_isField (R : Type u) [Ring R] (hf : IsField R) :
y = y * (x * z) := by rw [hxz, mul_one]
_ = x * y * z := by rw [← mul_assoc, hf.mul_comm y x]
_ = z := by rw [hxy, one_mul]
-
#align uniq_inv_of_is_field uniq_inv_of_isField
end IsField
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -106,9 +106,9 @@ class DivisionRing (K : Type u) extends Ring K, DivInvMonoid K, Nontrivial K, Ha
mul_inv_cancel : ∀ {a : K}, a ≠ 0 → a * a⁻¹ = 1
inv_zero : (0 : K)⁻¹ = 0
ratCast := Rat.castRec
- ratCast_mk : ∀ (a : ℤ) (b : ℕ) (h1 h2), rat_cast ⟨a, b, h1, h2⟩ = a * b⁻¹ := by intros ; rfl
+ ratCast_mk : ∀ (a : ℤ) (b : ℕ) (h1 h2), rat_cast ⟨a, b, h1, h2⟩ = a * b⁻¹ := by intros; rfl
qsmul : ℚ → K → K := qsmulRec rat_cast
- qsmul_eq_mul' : ∀ (a : ℚ) (x : K), qsmul a x = rat_cast a * x := by intros ; rfl
+ qsmul_eq_mul' : ∀ (a : ℚ) (x : K), qsmul a x = rat_cast a * x := by intros; rfl
#align division_ring DivisionRing
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -243,7 +243,7 @@ theorem not_isField_of_subsingleton (R : Type u) [Semiring R] [Subsingleton R] :
#align not_is_field_of_subsingleton not_isField_of_subsingleton
-/
-open Classical
+open scoped Classical
#print IsField.toSemifield /-
/-- Transferring from `is_field` to `semifield`. -/
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -58,12 +58,6 @@ universe u
variable {α β K : Type _}
-/- warning: rat.cast_rec -> Rat.castRec is a dubious translation:
-lean 3 declaration is
- forall {K : Type.{u1}} [_inst_1 : HasLiftT.{1, succ u1} Nat K] [_inst_2 : HasLiftT.{1, succ u1} Int K] [_inst_3 : Mul.{u1} K] [_inst_4 : Inv.{u1} K], Rat -> K
-but is expected to have type
- forall {K : Type.{u1}} [_inst_1 : NatCast.{u1} K] [_inst_2 : IntCast.{u1} K] [_inst_3 : Mul.{u1} K] [_inst_4 : Inv.{u1} K], Rat -> K
-Case conversion may be inaccurate. Consider using '#align rat.cast_rec Rat.castRecₓ'. -/
/-- The default definition of the coercion `(↑(a : ℚ) : K)` for a division ring `K`
is defined as `(a / b : K) = (a : K) * (b : K)⁻¹`.
Use `coe` instead of `rat.cast_rec` for better definitional behaviour.
@@ -163,22 +157,10 @@ instance (priority := 900) castCoe {K : Type _} [HasRatCast K] : CoeTC ℚ K :=
⟨HasRatCast.ratCast⟩
#align rat.cast_coe Rat.castCoe
-/- warning: rat.cast_mk' -> Rat.cast_mk' is a dubious translation:
-lean 3 declaration is
- forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (a : Int) (b : Nat) (h1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) b) (h2 : Nat.coprime (Int.natAbs a) b), Eq.{succ u1} K ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat K (HasLiftT.mk.{1, succ u1} Rat K (CoeTCₓ.coe.{1, succ u1} Rat K (Rat.castCoe.{u1} K (DivisionRing.toHasRatCast.{u1} K _inst_1)))) (Rat.mk' a b h1 h2)) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (Distrib.toHasMul.{u1} K (Ring.toDistrib.{u1} K (DivisionRing.toRing.{u1} K _inst_1)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int K (HasLiftT.mk.{1, succ u1} Int K (CoeTCₓ.coe.{1, succ u1} Int K (Int.castCoe.{u1} K (AddGroupWithOne.toHasIntCast.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))))) a) (Inv.inv.{u1} K (DivInvMonoid.toHasInv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K _inst_1)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat K (HasLiftT.mk.{1, succ u1} Nat K (CoeTCₓ.coe.{1, succ u1} Nat K (Nat.castCoe.{u1} K (AddMonoidWithOne.toNatCast.{u1} K (AddGroupWithOne.toAddMonoidWithOne.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K _inst_1)))))))) b)))
-but is expected to have type
- forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (a : Int) (b : Nat) (h1 : Ne.{1} Nat b (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) (h2 : Nat.coprime (Int.natAbs a) b), Eq.{succ u1} K (Rat.cast.{u1} K (DivisionRing.toRatCast.{u1} K _inst_1) (Rat.mk' a b h1 h2)) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (NonUnitalNonAssocRing.toMul.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))) (Int.cast.{u1} K (Ring.toIntCast.{u1} K (DivisionRing.toRing.{u1} K _inst_1)) a) (Inv.inv.{u1} K (DivisionRing.toInv.{u1} K _inst_1) (Nat.cast.{u1} K (Semiring.toNatCast.{u1} K (DivisionSemiring.toSemiring.{u1} K (DivisionRing.toDivisionSemiring.{u1} K _inst_1))) b)))
-Case conversion may be inaccurate. Consider using '#align rat.cast_mk' Rat.cast_mk'ₓ'. -/
theorem cast_mk' (a b h1 h2) : ((⟨a, b, h1, h2⟩ : ℚ) : K) = a * b⁻¹ :=
DivisionRing.ratCast_mk _ _ _ _
#align rat.cast_mk' Rat.cast_mk'
-/- warning: rat.cast_def -> Rat.cast_def is a dubious translation:
-lean 3 declaration is
- forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (r : Rat), Eq.{succ u1} K ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat K (HasLiftT.mk.{1, succ u1} Rat K (CoeTCₓ.coe.{1, succ u1} Rat K (Rat.castCoe.{u1} K (DivisionRing.toHasRatCast.{u1} K _inst_1)))) r) (HDiv.hDiv.{u1, u1, u1} K K K (instHDiv.{u1} K (DivInvMonoid.toHasDiv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K _inst_1))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int K (HasLiftT.mk.{1, succ u1} Int K (CoeTCₓ.coe.{1, succ u1} Int K (Int.castCoe.{u1} K (AddGroupWithOne.toHasIntCast.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))))) (Rat.num r)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat K (HasLiftT.mk.{1, succ u1} Nat K (CoeTCₓ.coe.{1, succ u1} Nat K (Nat.castCoe.{u1} K (AddMonoidWithOne.toNatCast.{u1} K (AddGroupWithOne.toAddMonoidWithOne.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K _inst_1)))))))) (Rat.den r)))
-but is expected to have type
- forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (r : Rat), Eq.{succ u1} K (Rat.cast.{u1} K (DivisionRing.toRatCast.{u1} K _inst_1) r) (HDiv.hDiv.{u1, u1, u1} K K K (instHDiv.{u1} K (DivisionRing.toDiv.{u1} K _inst_1)) (Int.cast.{u1} K (Ring.toIntCast.{u1} K (DivisionRing.toRing.{u1} K _inst_1)) (Rat.num r)) (Nat.cast.{u1} K (Semiring.toNatCast.{u1} K (DivisionSemiring.toSemiring.{u1} K (DivisionRing.toDivisionSemiring.{u1} K _inst_1))) (Rat.den r)))
-Case conversion may be inaccurate. Consider using '#align rat.cast_def Rat.cast_defₓ'. -/
theorem cast_def : ∀ r : ℚ, (r : K) = r.num / r.den
| ⟨a, b, h1, h2⟩ => (cast_mk' _ _ _ _).trans (div_eq_mul_inv _ _).symm
#align rat.cast_def Rat.cast_def
@@ -189,22 +171,10 @@ instance (priority := 100) smulDivisionRing : SMul ℚ K :=
#align rat.smul_division_ring Rat.smulDivisionRing
-/
-/- warning: rat.smul_def -> Rat.smul_def is a dubious translation:
-lean 3 declaration is
- forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (a : Rat) (x : K), Eq.{succ u1} K (SMul.smul.{0, u1} Rat K (Rat.smulDivisionRing.{u1} K _inst_1) a x) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (Distrib.toHasMul.{u1} K (Ring.toDistrib.{u1} K (DivisionRing.toRing.{u1} K _inst_1)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat K (HasLiftT.mk.{1, succ u1} Rat K (CoeTCₓ.coe.{1, succ u1} Rat K (Rat.castCoe.{u1} K (DivisionRing.toHasRatCast.{u1} K _inst_1)))) a) x)
-but is expected to have type
- forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (a : Rat) (x : K), Eq.{succ u1} K (HSMul.hSMul.{0, u1, u1} Rat K K (instHSMul.{0, u1} Rat K (Rat.smulDivisionRing.{u1} K _inst_1)) a x) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (NonUnitalNonAssocRing.toMul.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))) (Rat.cast.{u1} K (DivisionRing.toRatCast.{u1} K _inst_1) a) x)
-Case conversion may be inaccurate. Consider using '#align rat.smul_def Rat.smul_defₓ'. -/
theorem smul_def (a : ℚ) (x : K) : a • x = ↑a * x :=
DivisionRing.qsmul_eq_mul' a x
#align rat.smul_def Rat.smul_def
-/- warning: rat.smul_one_eq_coe -> Rat.smul_one_eq_coe is a dubious translation:
-lean 3 declaration is
- forall (A : Type.{u1}) [_inst_2 : DivisionRing.{u1} A] (m : Rat), Eq.{succ u1} A (SMul.smul.{0, u1} Rat A (Rat.smulDivisionRing.{u1} A _inst_2) m (OfNat.ofNat.{u1} A 1 (OfNat.mk.{u1} A 1 (One.one.{u1} A (AddMonoidWithOne.toOne.{u1} A (AddGroupWithOne.toAddMonoidWithOne.{u1} A (AddCommGroupWithOne.toAddGroupWithOne.{u1} A (Ring.toAddCommGroupWithOne.{u1} A (DivisionRing.toRing.{u1} A _inst_2))))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat A (HasLiftT.mk.{1, succ u1} Rat A (CoeTCₓ.coe.{1, succ u1} Rat A (Rat.castCoe.{u1} A (DivisionRing.toHasRatCast.{u1} A _inst_2)))) m)
-but is expected to have type
- forall (A : Type.{u1}) [_inst_2 : DivisionRing.{u1} A] (m : Rat), Eq.{succ u1} A (HSMul.hSMul.{0, u1, u1} Rat A A (instHSMul.{0, u1} Rat A (Rat.smulDivisionRing.{u1} A _inst_2)) m (OfNat.ofNat.{u1} A 1 (One.toOfNat1.{u1} A (Semiring.toOne.{u1} A (DivisionSemiring.toSemiring.{u1} A (DivisionRing.toDivisionSemiring.{u1} A _inst_2)))))) (Rat.cast.{u1} A (DivisionRing.toRatCast.{u1} A _inst_2) m)
-Case conversion may be inaccurate. Consider using '#align rat.smul_one_eq_coe Rat.smul_one_eq_coeₓ'. -/
@[simp]
theorem smul_one_eq_coe (A : Type _) [DivisionRing A] (m : ℚ) : m • (1 : A) = ↑m := by
rw [Rat.smul_def, mul_one]
@@ -296,12 +266,6 @@ noncomputable def IsField.toField {R : Type u} [Ring R] (h : IsField R) : Field
#align is_field.to_field IsField.toField
-/
-/- warning: uniq_inv_of_is_field -> uniq_inv_of_isField is a dubious translation:
-lean 3 declaration is
- forall (R : Type.{u1}) [_inst_1 : Ring.{u1} R], (IsField.{u1} R (Ring.toSemiring.{u1} R _inst_1)) -> (forall (x : R), (Ne.{succ u1} R x (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))))))) -> (ExistsUnique.{succ u1} R (fun (y : R) => Eq.{succ u1} R (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R _inst_1))) x y) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1))))))))))
-but is expected to have type
- forall (R : Type.{u1}) [_inst_1 : Ring.{u1} R], (IsField.{u1} R (Ring.toSemiring.{u1} R _inst_1)) -> (forall (x : R), (Ne.{succ u1} R x (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))) -> (ExistsUnique.{succ u1} R (fun (y : R) => Eq.{succ u1} R (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) x y) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))))
-Case conversion may be inaccurate. Consider using '#align uniq_inv_of_is_field uniq_inv_of_isFieldₓ'. -/
/-- For each field, and for each nonzero element of said field, there is a unique inverse.
Since `is_field` doesn't remember the data of an `inv` function and as such,
a lemma that there is a unique inverse could be useful.
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -112,17 +112,9 @@ class DivisionRing (K : Type u) extends Ring K, DivInvMonoid K, Nontrivial K, Ha
mul_inv_cancel : ∀ {a : K}, a ≠ 0 → a * a⁻¹ = 1
inv_zero : (0 : K)⁻¹ = 0
ratCast := Rat.castRec
- ratCast_mk :
- ∀ (a : ℤ) (b : ℕ) (h1 h2),
- rat_cast ⟨a, b, h1, h2⟩ = a * b⁻¹ := by
- intros
- rfl
+ ratCast_mk : ∀ (a : ℤ) (b : ℕ) (h1 h2), rat_cast ⟨a, b, h1, h2⟩ = a * b⁻¹ := by intros ; rfl
qsmul : ℚ → K → K := qsmulRec rat_cast
- qsmul_eq_mul' :
- ∀ (a : ℚ) (x : K), qsmul a x = rat_cast a *
- x := by
- intros
- rfl
+ qsmul_eq_mul' : ∀ (a : ℚ) (x : K), qsmul a x = rat_cast a * x := by intros ; rfl
#align division_ring DivisionRing
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/08e1d8d4d989df3a6df86f385e9053ec8a372cc1
@@ -175,7 +175,7 @@ instance (priority := 900) castCoe {K : Type _} [HasRatCast K] : CoeTC ℚ K :=
lean 3 declaration is
forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (a : Int) (b : Nat) (h1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) b) (h2 : Nat.coprime (Int.natAbs a) b), Eq.{succ u1} K ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat K (HasLiftT.mk.{1, succ u1} Rat K (CoeTCₓ.coe.{1, succ u1} Rat K (Rat.castCoe.{u1} K (DivisionRing.toHasRatCast.{u1} K _inst_1)))) (Rat.mk' a b h1 h2)) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (Distrib.toHasMul.{u1} K (Ring.toDistrib.{u1} K (DivisionRing.toRing.{u1} K _inst_1)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int K (HasLiftT.mk.{1, succ u1} Int K (CoeTCₓ.coe.{1, succ u1} Int K (Int.castCoe.{u1} K (AddGroupWithOne.toHasIntCast.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))))) a) (Inv.inv.{u1} K (DivInvMonoid.toHasInv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K _inst_1)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat K (HasLiftT.mk.{1, succ u1} Nat K (CoeTCₓ.coe.{1, succ u1} Nat K (Nat.castCoe.{u1} K (AddMonoidWithOne.toNatCast.{u1} K (AddGroupWithOne.toAddMonoidWithOne.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K _inst_1)))))))) b)))
but is expected to have type
- forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (a : Int) (b : Nat) (h1 : Ne.{1} Nat b (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) (h2 : Nat.coprime (Int.natAbs a) b), Eq.{succ u1} K (Rat.cast.{u1} K (DivisionRing.toRatCast.{u1} K _inst_1) (Rat.mk' a b h1 h2)) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (NonUnitalNonAssocRing.toMul.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))) (Int.cast.{u1} K (Ring.toIntCast.{u1} K (DivisionRing.toRing.{u1} K _inst_1)) a) (Inv.inv.{u1} K (DivisionRing.toInv.{u1} K _inst_1) (Nat.cast.{u1} K (NonAssocRing.toNatCast.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))) b)))
+ forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (a : Int) (b : Nat) (h1 : Ne.{1} Nat b (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) (h2 : Nat.coprime (Int.natAbs a) b), Eq.{succ u1} K (Rat.cast.{u1} K (DivisionRing.toRatCast.{u1} K _inst_1) (Rat.mk' a b h1 h2)) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (NonUnitalNonAssocRing.toMul.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))) (Int.cast.{u1} K (Ring.toIntCast.{u1} K (DivisionRing.toRing.{u1} K _inst_1)) a) (Inv.inv.{u1} K (DivisionRing.toInv.{u1} K _inst_1) (Nat.cast.{u1} K (Semiring.toNatCast.{u1} K (DivisionSemiring.toSemiring.{u1} K (DivisionRing.toDivisionSemiring.{u1} K _inst_1))) b)))
Case conversion may be inaccurate. Consider using '#align rat.cast_mk' Rat.cast_mk'ₓ'. -/
theorem cast_mk' (a b h1 h2) : ((⟨a, b, h1, h2⟩ : ℚ) : K) = a * b⁻¹ :=
DivisionRing.ratCast_mk _ _ _ _
@@ -185,7 +185,7 @@ theorem cast_mk' (a b h1 h2) : ((⟨a, b, h1, h2⟩ : ℚ) : K) = a * b⁻¹ :=
lean 3 declaration is
forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (r : Rat), Eq.{succ u1} K ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat K (HasLiftT.mk.{1, succ u1} Rat K (CoeTCₓ.coe.{1, succ u1} Rat K (Rat.castCoe.{u1} K (DivisionRing.toHasRatCast.{u1} K _inst_1)))) r) (HDiv.hDiv.{u1, u1, u1} K K K (instHDiv.{u1} K (DivInvMonoid.toHasDiv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K _inst_1))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int K (HasLiftT.mk.{1, succ u1} Int K (CoeTCₓ.coe.{1, succ u1} Int K (Int.castCoe.{u1} K (AddGroupWithOne.toHasIntCast.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))))) (Rat.num r)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat K (HasLiftT.mk.{1, succ u1} Nat K (CoeTCₓ.coe.{1, succ u1} Nat K (Nat.castCoe.{u1} K (AddMonoidWithOne.toNatCast.{u1} K (AddGroupWithOne.toAddMonoidWithOne.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K _inst_1)))))))) (Rat.den r)))
but is expected to have type
- forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (r : Rat), Eq.{succ u1} K (Rat.cast.{u1} K (DivisionRing.toRatCast.{u1} K _inst_1) r) (HDiv.hDiv.{u1, u1, u1} K K K (instHDiv.{u1} K (DivisionRing.toDiv.{u1} K _inst_1)) (Int.cast.{u1} K (Ring.toIntCast.{u1} K (DivisionRing.toRing.{u1} K _inst_1)) (Rat.num r)) (Nat.cast.{u1} K (NonAssocRing.toNatCast.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))) (Rat.den r)))
+ forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (r : Rat), Eq.{succ u1} K (Rat.cast.{u1} K (DivisionRing.toRatCast.{u1} K _inst_1) r) (HDiv.hDiv.{u1, u1, u1} K K K (instHDiv.{u1} K (DivisionRing.toDiv.{u1} K _inst_1)) (Int.cast.{u1} K (Ring.toIntCast.{u1} K (DivisionRing.toRing.{u1} K _inst_1)) (Rat.num r)) (Nat.cast.{u1} K (Semiring.toNatCast.{u1} K (DivisionSemiring.toSemiring.{u1} K (DivisionRing.toDivisionSemiring.{u1} K _inst_1))) (Rat.den r)))
Case conversion may be inaccurate. Consider using '#align rat.cast_def Rat.cast_defₓ'. -/
theorem cast_def : ∀ r : ℚ, (r : K) = r.num / r.den
| ⟨a, b, h1, h2⟩ => (cast_mk' _ _ _ _).trans (div_eq_mul_inv _ _).symm
@@ -211,7 +211,7 @@ theorem smul_def (a : ℚ) (x : K) : a • x = ↑a * x :=
lean 3 declaration is
forall (A : Type.{u1}) [_inst_2 : DivisionRing.{u1} A] (m : Rat), Eq.{succ u1} A (SMul.smul.{0, u1} Rat A (Rat.smulDivisionRing.{u1} A _inst_2) m (OfNat.ofNat.{u1} A 1 (OfNat.mk.{u1} A 1 (One.one.{u1} A (AddMonoidWithOne.toOne.{u1} A (AddGroupWithOne.toAddMonoidWithOne.{u1} A (AddCommGroupWithOne.toAddGroupWithOne.{u1} A (Ring.toAddCommGroupWithOne.{u1} A (DivisionRing.toRing.{u1} A _inst_2))))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat A (HasLiftT.mk.{1, succ u1} Rat A (CoeTCₓ.coe.{1, succ u1} Rat A (Rat.castCoe.{u1} A (DivisionRing.toHasRatCast.{u1} A _inst_2)))) m)
but is expected to have type
- forall (A : Type.{u1}) [_inst_2 : DivisionRing.{u1} A] (m : Rat), Eq.{succ u1} A (HSMul.hSMul.{0, u1, u1} Rat A A (instHSMul.{0, u1} Rat A (Rat.smulDivisionRing.{u1} A _inst_2)) m (OfNat.ofNat.{u1} A 1 (One.toOfNat1.{u1} A (NonAssocRing.toOne.{u1} A (Ring.toNonAssocRing.{u1} A (DivisionRing.toRing.{u1} A _inst_2)))))) (Rat.cast.{u1} A (DivisionRing.toRatCast.{u1} A _inst_2) m)
+ forall (A : Type.{u1}) [_inst_2 : DivisionRing.{u1} A] (m : Rat), Eq.{succ u1} A (HSMul.hSMul.{0, u1, u1} Rat A A (instHSMul.{0, u1} Rat A (Rat.smulDivisionRing.{u1} A _inst_2)) m (OfNat.ofNat.{u1} A 1 (One.toOfNat1.{u1} A (Semiring.toOne.{u1} A (DivisionSemiring.toSemiring.{u1} A (DivisionRing.toDivisionSemiring.{u1} A _inst_2)))))) (Rat.cast.{u1} A (DivisionRing.toRatCast.{u1} A _inst_2) m)
Case conversion may be inaccurate. Consider using '#align rat.smul_one_eq_coe Rat.smul_one_eq_coeₓ'. -/
@[simp]
theorem smul_one_eq_coe (A : Type _) [DivisionRing A] (m : ℚ) : m • (1 : A) = ↑m := by
@@ -308,7 +308,7 @@ noncomputable def IsField.toField {R : Type u} [Ring R] (h : IsField R) : Field
lean 3 declaration is
forall (R : Type.{u1}) [_inst_1 : Ring.{u1} R], (IsField.{u1} R (Ring.toSemiring.{u1} R _inst_1)) -> (forall (x : R), (Ne.{succ u1} R x (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))))))) -> (ExistsUnique.{succ u1} R (fun (y : R) => Eq.{succ u1} R (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R _inst_1))) x y) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1))))))))))
but is expected to have type
- forall (R : Type.{u1}) [_inst_1 : Ring.{u1} R], (IsField.{u1} R (Ring.toSemiring.{u1} R _inst_1)) -> (forall (x : R), (Ne.{succ u1} R x (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))) -> (ExistsUnique.{succ u1} R (fun (y : R) => Eq.{succ u1} R (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) x y) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))))))
+ forall (R : Type.{u1}) [_inst_1 : Ring.{u1} R], (IsField.{u1} R (Ring.toSemiring.{u1} R _inst_1)) -> (forall (x : R), (Ne.{succ u1} R x (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))) -> (ExistsUnique.{succ u1} R (fun (y : R) => Eq.{succ u1} R (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) x y) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))))
Case conversion may be inaccurate. Consider using '#align uniq_inv_of_is_field uniq_inv_of_isFieldₓ'. -/
/-- For each field, and for each nonzero element of said field, there is a unique inverse.
Since `is_field` doesn't remember the data of an `inv` function and as such,
mathlib commit https://github.com/leanprover-community/mathlib/commit/d2d964c64f8ddcccd6704a731c41f95d13e72f5c
@@ -211,7 +211,7 @@ theorem smul_def (a : ℚ) (x : K) : a • x = ↑a * x :=
lean 3 declaration is
forall (A : Type.{u1}) [_inst_2 : DivisionRing.{u1} A] (m : Rat), Eq.{succ u1} A (SMul.smul.{0, u1} Rat A (Rat.smulDivisionRing.{u1} A _inst_2) m (OfNat.ofNat.{u1} A 1 (OfNat.mk.{u1} A 1 (One.one.{u1} A (AddMonoidWithOne.toOne.{u1} A (AddGroupWithOne.toAddMonoidWithOne.{u1} A (AddCommGroupWithOne.toAddGroupWithOne.{u1} A (Ring.toAddCommGroupWithOne.{u1} A (DivisionRing.toRing.{u1} A _inst_2))))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat A (HasLiftT.mk.{1, succ u1} Rat A (CoeTCₓ.coe.{1, succ u1} Rat A (Rat.castCoe.{u1} A (DivisionRing.toHasRatCast.{u1} A _inst_2)))) m)
but is expected to have type
- forall {A : Type.{u1}} [_inst_2 : DivisionRing.{u1} A] [m : Algebra.{0, u1} Rat A Rat.commSemiring (DivisionSemiring.toSemiring.{u1} A (DivisionRing.toDivisionSemiring.{u1} A _inst_2))] (m_1 : Rat), Eq.{succ u1} A (SMul.smul.{0, u1} Rat A (Algebra.toSMul.{0, u1} Rat A Rat.commSemiring (DivisionSemiring.toSemiring.{u1} A (DivisionRing.toDivisionSemiring.{u1} A _inst_2)) m) m_1 (OfNat.ofNat.{u1} A 1 (One.toOfNat1.{u1} A (NonAssocRing.toOne.{u1} A (Ring.toNonAssocRing.{u1} A (DivisionRing.toRing.{u1} A _inst_2)))))) (Rat.cast.{u1} A (DivisionRing.toRatCast.{u1} A _inst_2) m_1)
+ forall (A : Type.{u1}) [_inst_2 : DivisionRing.{u1} A] (m : Rat), Eq.{succ u1} A (HSMul.hSMul.{0, u1, u1} Rat A A (instHSMul.{0, u1} Rat A (Rat.smulDivisionRing.{u1} A _inst_2)) m (OfNat.ofNat.{u1} A 1 (One.toOfNat1.{u1} A (NonAssocRing.toOne.{u1} A (Ring.toNonAssocRing.{u1} A (DivisionRing.toRing.{u1} A _inst_2)))))) (Rat.cast.{u1} A (DivisionRing.toRatCast.{u1} A _inst_2) m)
Case conversion may be inaccurate. Consider using '#align rat.smul_one_eq_coe Rat.smul_one_eq_coeₓ'. -/
@[simp]
theorem smul_one_eq_coe (A : Type _) [DivisionRing A] (m : ℚ) : m • (1 : A) = ↑m := by
mathlib commit https://github.com/leanprover-community/mathlib/commit/2651125b48fc5c170ab1111afd0817c903b1fc6c
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Lewis, Leonardo de Moura, Johannes Hölzl, Mario Carneiro
! This file was ported from Lean 3 source module algebra.field.defs
-! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7
+! leanprover-community/mathlib commit 2651125b48fc5c170ab1111afd0817c903b1fc6c
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -207,6 +207,17 @@ theorem smul_def (a : ℚ) (x : K) : a • x = ↑a * x :=
DivisionRing.qsmul_eq_mul' a x
#align rat.smul_def Rat.smul_def
+/- warning: rat.smul_one_eq_coe -> Rat.smul_one_eq_coe is a dubious translation:
+lean 3 declaration is
+ forall (A : Type.{u1}) [_inst_2 : DivisionRing.{u1} A] (m : Rat), Eq.{succ u1} A (SMul.smul.{0, u1} Rat A (Rat.smulDivisionRing.{u1} A _inst_2) m (OfNat.ofNat.{u1} A 1 (OfNat.mk.{u1} A 1 (One.one.{u1} A (AddMonoidWithOne.toOne.{u1} A (AddGroupWithOne.toAddMonoidWithOne.{u1} A (AddCommGroupWithOne.toAddGroupWithOne.{u1} A (Ring.toAddCommGroupWithOne.{u1} A (DivisionRing.toRing.{u1} A _inst_2))))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat A (HasLiftT.mk.{1, succ u1} Rat A (CoeTCₓ.coe.{1, succ u1} Rat A (Rat.castCoe.{u1} A (DivisionRing.toHasRatCast.{u1} A _inst_2)))) m)
+but is expected to have type
+ forall {A : Type.{u1}} [_inst_2 : DivisionRing.{u1} A] [m : Algebra.{0, u1} Rat A Rat.commSemiring (DivisionSemiring.toSemiring.{u1} A (DivisionRing.toDivisionSemiring.{u1} A _inst_2))] (m_1 : Rat), Eq.{succ u1} A (SMul.smul.{0, u1} Rat A (Algebra.toSMul.{0, u1} Rat A Rat.commSemiring (DivisionSemiring.toSemiring.{u1} A (DivisionRing.toDivisionSemiring.{u1} A _inst_2)) m) m_1 (OfNat.ofNat.{u1} A 1 (One.toOfNat1.{u1} A (NonAssocRing.toOne.{u1} A (Ring.toNonAssocRing.{u1} A (DivisionRing.toRing.{u1} A _inst_2)))))) (Rat.cast.{u1} A (DivisionRing.toRatCast.{u1} A _inst_2) m_1)
+Case conversion may be inaccurate. Consider using '#align rat.smul_one_eq_coe Rat.smul_one_eq_coeₓ'. -/
+@[simp]
+theorem smul_one_eq_coe (A : Type _) [DivisionRing A] (m : ℚ) : m • (1 : A) = ↑m := by
+ rw [Rat.smul_def, mul_one]
+#align rat.smul_one_eq_coe Rat.smul_one_eq_coe
+
end Rat
end DivisionRing
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce86f4e05e9a9b8da5e316b22c76ce76440c56a1
@@ -173,7 +173,7 @@ instance (priority := 900) castCoe {K : Type _} [HasRatCast K] : CoeTC ℚ K :=
/- warning: rat.cast_mk' -> Rat.cast_mk' is a dubious translation:
lean 3 declaration is
- forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (a : Int) (b : Nat) (h1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) b) (h2 : Nat.coprime (Int.natAbs a) b), Eq.{succ u1} K ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat K (HasLiftT.mk.{1, succ u1} Rat K (CoeTCₓ.coe.{1, succ u1} Rat K (Rat.castCoe.{u1} K (DivisionRing.toHasRatCast.{u1} K _inst_1)))) (Rat.mk' a b h1 h2)) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (Distrib.toHasMul.{u1} K (Ring.toDistrib.{u1} K (DivisionRing.toRing.{u1} K _inst_1)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int K (HasLiftT.mk.{1, succ u1} Int K (CoeTCₓ.coe.{1, succ u1} Int K (Int.castCoe.{u1} K (AddGroupWithOne.toHasIntCast.{u1} K (NonAssocRing.toAddGroupWithOne.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))))) a) (Inv.inv.{u1} K (DivInvMonoid.toHasInv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K _inst_1)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat K (HasLiftT.mk.{1, succ u1} Nat K (CoeTCₓ.coe.{1, succ u1} Nat K (Nat.castCoe.{u1} K (AddMonoidWithOne.toNatCast.{u1} K (AddGroupWithOne.toAddMonoidWithOne.{u1} K (NonAssocRing.toAddGroupWithOne.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1)))))))) b)))
+ forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (a : Int) (b : Nat) (h1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) b) (h2 : Nat.coprime (Int.natAbs a) b), Eq.{succ u1} K ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat K (HasLiftT.mk.{1, succ u1} Rat K (CoeTCₓ.coe.{1, succ u1} Rat K (Rat.castCoe.{u1} K (DivisionRing.toHasRatCast.{u1} K _inst_1)))) (Rat.mk' a b h1 h2)) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (Distrib.toHasMul.{u1} K (Ring.toDistrib.{u1} K (DivisionRing.toRing.{u1} K _inst_1)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int K (HasLiftT.mk.{1, succ u1} Int K (CoeTCₓ.coe.{1, succ u1} Int K (Int.castCoe.{u1} K (AddGroupWithOne.toHasIntCast.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))))) a) (Inv.inv.{u1} K (DivInvMonoid.toHasInv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K _inst_1)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat K (HasLiftT.mk.{1, succ u1} Nat K (CoeTCₓ.coe.{1, succ u1} Nat K (Nat.castCoe.{u1} K (AddMonoidWithOne.toNatCast.{u1} K (AddGroupWithOne.toAddMonoidWithOne.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K _inst_1)))))))) b)))
but is expected to have type
forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (a : Int) (b : Nat) (h1 : Ne.{1} Nat b (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) (h2 : Nat.coprime (Int.natAbs a) b), Eq.{succ u1} K (Rat.cast.{u1} K (DivisionRing.toRatCast.{u1} K _inst_1) (Rat.mk' a b h1 h2)) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (NonUnitalNonAssocRing.toMul.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))) (Int.cast.{u1} K (Ring.toIntCast.{u1} K (DivisionRing.toRing.{u1} K _inst_1)) a) (Inv.inv.{u1} K (DivisionRing.toInv.{u1} K _inst_1) (Nat.cast.{u1} K (NonAssocRing.toNatCast.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))) b)))
Case conversion may be inaccurate. Consider using '#align rat.cast_mk' Rat.cast_mk'ₓ'. -/
@@ -183,7 +183,7 @@ theorem cast_mk' (a b h1 h2) : ((⟨a, b, h1, h2⟩ : ℚ) : K) = a * b⁻¹ :=
/- warning: rat.cast_def -> Rat.cast_def is a dubious translation:
lean 3 declaration is
- forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (r : Rat), Eq.{succ u1} K ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat K (HasLiftT.mk.{1, succ u1} Rat K (CoeTCₓ.coe.{1, succ u1} Rat K (Rat.castCoe.{u1} K (DivisionRing.toHasRatCast.{u1} K _inst_1)))) r) (HDiv.hDiv.{u1, u1, u1} K K K (instHDiv.{u1} K (DivInvMonoid.toHasDiv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K _inst_1))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int K (HasLiftT.mk.{1, succ u1} Int K (CoeTCₓ.coe.{1, succ u1} Int K (Int.castCoe.{u1} K (AddGroupWithOne.toHasIntCast.{u1} K (NonAssocRing.toAddGroupWithOne.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))))) (Rat.num r)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat K (HasLiftT.mk.{1, succ u1} Nat K (CoeTCₓ.coe.{1, succ u1} Nat K (Nat.castCoe.{u1} K (AddMonoidWithOne.toNatCast.{u1} K (AddGroupWithOne.toAddMonoidWithOne.{u1} K (NonAssocRing.toAddGroupWithOne.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1)))))))) (Rat.den r)))
+ forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (r : Rat), Eq.{succ u1} K ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat K (HasLiftT.mk.{1, succ u1} Rat K (CoeTCₓ.coe.{1, succ u1} Rat K (Rat.castCoe.{u1} K (DivisionRing.toHasRatCast.{u1} K _inst_1)))) r) (HDiv.hDiv.{u1, u1, u1} K K K (instHDiv.{u1} K (DivInvMonoid.toHasDiv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K _inst_1))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int K (HasLiftT.mk.{1, succ u1} Int K (CoeTCₓ.coe.{1, succ u1} Int K (Int.castCoe.{u1} K (AddGroupWithOne.toHasIntCast.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))))) (Rat.num r)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat K (HasLiftT.mk.{1, succ u1} Nat K (CoeTCₓ.coe.{1, succ u1} Nat K (Nat.castCoe.{u1} K (AddMonoidWithOne.toNatCast.{u1} K (AddGroupWithOne.toAddMonoidWithOne.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K _inst_1)))))))) (Rat.den r)))
but is expected to have type
forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (r : Rat), Eq.{succ u1} K (Rat.cast.{u1} K (DivisionRing.toRatCast.{u1} K _inst_1) r) (HDiv.hDiv.{u1, u1, u1} K K K (instHDiv.{u1} K (DivisionRing.toDiv.{u1} K _inst_1)) (Int.cast.{u1} K (Ring.toIntCast.{u1} K (DivisionRing.toRing.{u1} K _inst_1)) (Rat.num r)) (Nat.cast.{u1} K (NonAssocRing.toNatCast.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))) (Rat.den r)))
Case conversion may be inaccurate. Consider using '#align rat.cast_def Rat.cast_defₓ'. -/
@@ -295,7 +295,7 @@ noncomputable def IsField.toField {R : Type u} [Ring R] (h : IsField R) : Field
/- warning: uniq_inv_of_is_field -> uniq_inv_of_isField is a dubious translation:
lean 3 declaration is
- forall (R : Type.{u1}) [_inst_1 : Ring.{u1} R], (IsField.{u1} R (Ring.toSemiring.{u1} R _inst_1)) -> (forall (x : R), (Ne.{succ u1} R x (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))))))) -> (ExistsUnique.{succ u1} R (fun (y : R) => Eq.{succ u1} R (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R _inst_1))) x y) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (NonAssocRing.toAddGroupWithOne.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))))))))
+ forall (R : Type.{u1}) [_inst_1 : Ring.{u1} R], (IsField.{u1} R (Ring.toSemiring.{u1} R _inst_1)) -> (forall (x : R), (Ne.{succ u1} R x (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))))))) -> (ExistsUnique.{succ u1} R (fun (y : R) => Eq.{succ u1} R (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R _inst_1))) x y) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1))))))))))
but is expected to have type
forall (R : Type.{u1}) [_inst_1 : Ring.{u1} R], (IsField.{u1} R (Ring.toSemiring.{u1} R _inst_1)) -> (forall (x : R), (Ne.{succ u1} R x (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))) -> (ExistsUnique.{succ u1} R (fun (y : R) => Eq.{succ u1} R (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) x y) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))))))
Case conversion may be inaccurate. Consider using '#align uniq_inv_of_is_field uniq_inv_of_isFieldₓ'. -/
mathlib commit https://github.com/leanprover-community/mathlib/commit/3180fab693e2cee3bff62675571264cb8778b212
@@ -72,14 +72,12 @@ def Rat.castRec [HasLiftT ℕ K] [HasLiftT ℤ K] [Mul K] [Inv K] : ℚ → K
| ⟨a, b, _, _⟩ => ↑a * (↑b)⁻¹
#align rat.cast_rec Rat.castRec
-#print RatCast /-
/-- Type class for the canonical homomorphism `ℚ → K`.
-/
@[protect_proj]
-class RatCast (K : Type u) where
+class HasRatCast (K : Type u) where
ratCast : ℚ → K
-#align has_rat_cast RatCast
--/
+#align has_rat_cast HasRatCast
#print qsmulRec /-
/-- The default definition of the scalar multiplication `(a : ℚ) • (x : K)` for a division ring `K`
@@ -110,7 +108,7 @@ definitions for some special cases of `K` (in particular `K = ℚ` itself).
See also Note [forgetful inheritance].
-/
@[protect_proj]
-class DivisionRing (K : Type u) extends Ring K, DivInvMonoid K, Nontrivial K, RatCast K where
+class DivisionRing (K : Type u) extends Ring K, DivInvMonoid K, Nontrivial K, HasRatCast K where
mul_inv_cancel : ∀ {a : K}, a ≠ 0 → a * a⁻¹ = 1
inv_zero : (0 : K)⁻¹ = 0
ratCast := Rat.castRec
@@ -164,26 +162,20 @@ variable [DivisionRing K] {a b : K}
namespace Rat
-/- warning: rat.cast_coe -> Rat.castCoe is a dubious translation:
-lean 3 declaration is
- forall {K : Type.{u1}} [_inst_2 : RatCast.{u1} K], CoeTCₓ.{1, succ u1} Rat K
-but is expected to have type
- forall {K : Type.{u1}} [_inst_2 : RatCast.{u1} K], CoeTC.{1, succ u1} Rat K
-Case conversion may be inaccurate. Consider using '#align rat.cast_coe Rat.castCoeₓ'. -/
-- see Note [coercion into rings]
/-- Construct the canonical injection from `ℚ` into an arbitrary
division ring. If the field has positive characteristic `p`,
we define `1 / p = 1 / 0 = 0` for consistency with our
division by zero convention. -/
-instance (priority := 900) castCoe {K : Type _} [RatCast K] : CoeTC ℚ K :=
- ⟨RatCast.ratCast⟩
+instance (priority := 900) castCoe {K : Type _} [HasRatCast K] : CoeTC ℚ K :=
+ ⟨HasRatCast.ratCast⟩
#align rat.cast_coe Rat.castCoe
/- warning: rat.cast_mk' -> Rat.cast_mk' is a dubious translation:
lean 3 declaration is
forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (a : Int) (b : Nat) (h1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) b) (h2 : Nat.coprime (Int.natAbs a) b), Eq.{succ u1} K ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat K (HasLiftT.mk.{1, succ u1} Rat K (CoeTCₓ.coe.{1, succ u1} Rat K (Rat.castCoe.{u1} K (DivisionRing.toHasRatCast.{u1} K _inst_1)))) (Rat.mk' a b h1 h2)) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (Distrib.toHasMul.{u1} K (Ring.toDistrib.{u1} K (DivisionRing.toRing.{u1} K _inst_1)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int K (HasLiftT.mk.{1, succ u1} Int K (CoeTCₓ.coe.{1, succ u1} Int K (Int.castCoe.{u1} K (AddGroupWithOne.toHasIntCast.{u1} K (NonAssocRing.toAddGroupWithOne.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))))) a) (Inv.inv.{u1} K (DivInvMonoid.toHasInv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K _inst_1)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat K (HasLiftT.mk.{1, succ u1} Nat K (CoeTCₓ.coe.{1, succ u1} Nat K (Nat.castCoe.{u1} K (AddMonoidWithOne.toNatCast.{u1} K (AddGroupWithOne.toAddMonoidWithOne.{u1} K (NonAssocRing.toAddGroupWithOne.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1)))))))) b)))
but is expected to have type
- forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (a : Int) (b : Nat) (h1 : Ne.{1} Nat b (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) (h2 : Nat.coprime (Int.natAbs a) b), Eq.{succ u1} K (RatCast.ratCast.{u1} K (DivisionRing.toRatCast.{u1} K _inst_1) (Rat.mk' a b h1 h2)) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (NonUnitalNonAssocRing.toMul.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))) (Int.cast.{u1} K (Ring.toIntCast.{u1} K (DivisionRing.toRing.{u1} K _inst_1)) a) (Inv.inv.{u1} K (DivisionRing.toInv.{u1} K _inst_1) (Nat.cast.{u1} K (NonAssocRing.toNatCast.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))) b)))
+ forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (a : Int) (b : Nat) (h1 : Ne.{1} Nat b (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) (h2 : Nat.coprime (Int.natAbs a) b), Eq.{succ u1} K (Rat.cast.{u1} K (DivisionRing.toRatCast.{u1} K _inst_1) (Rat.mk' a b h1 h2)) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (NonUnitalNonAssocRing.toMul.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))) (Int.cast.{u1} K (Ring.toIntCast.{u1} K (DivisionRing.toRing.{u1} K _inst_1)) a) (Inv.inv.{u1} K (DivisionRing.toInv.{u1} K _inst_1) (Nat.cast.{u1} K (NonAssocRing.toNatCast.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))) b)))
Case conversion may be inaccurate. Consider using '#align rat.cast_mk' Rat.cast_mk'ₓ'. -/
theorem cast_mk' (a b h1 h2) : ((⟨a, b, h1, h2⟩ : ℚ) : K) = a * b⁻¹ :=
DivisionRing.ratCast_mk _ _ _ _
@@ -193,7 +185,7 @@ theorem cast_mk' (a b h1 h2) : ((⟨a, b, h1, h2⟩ : ℚ) : K) = a * b⁻¹ :=
lean 3 declaration is
forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (r : Rat), Eq.{succ u1} K ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat K (HasLiftT.mk.{1, succ u1} Rat K (CoeTCₓ.coe.{1, succ u1} Rat K (Rat.castCoe.{u1} K (DivisionRing.toHasRatCast.{u1} K _inst_1)))) r) (HDiv.hDiv.{u1, u1, u1} K K K (instHDiv.{u1} K (DivInvMonoid.toHasDiv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K _inst_1))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int K (HasLiftT.mk.{1, succ u1} Int K (CoeTCₓ.coe.{1, succ u1} Int K (Int.castCoe.{u1} K (AddGroupWithOne.toHasIntCast.{u1} K (NonAssocRing.toAddGroupWithOne.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))))) (Rat.num r)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat K (HasLiftT.mk.{1, succ u1} Nat K (CoeTCₓ.coe.{1, succ u1} Nat K (Nat.castCoe.{u1} K (AddMonoidWithOne.toNatCast.{u1} K (AddGroupWithOne.toAddMonoidWithOne.{u1} K (NonAssocRing.toAddGroupWithOne.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1)))))))) (Rat.den r)))
but is expected to have type
- forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (r : Rat), Eq.{succ u1} K (RatCast.ratCast.{u1} K (DivisionRing.toRatCast.{u1} K _inst_1) r) (HDiv.hDiv.{u1, u1, u1} K K K (instHDiv.{u1} K (DivisionRing.toDiv.{u1} K _inst_1)) (Int.cast.{u1} K (Ring.toIntCast.{u1} K (DivisionRing.toRing.{u1} K _inst_1)) (Rat.num r)) (Nat.cast.{u1} K (NonAssocRing.toNatCast.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))) (Rat.den r)))
+ forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (r : Rat), Eq.{succ u1} K (Rat.cast.{u1} K (DivisionRing.toRatCast.{u1} K _inst_1) r) (HDiv.hDiv.{u1, u1, u1} K K K (instHDiv.{u1} K (DivisionRing.toDiv.{u1} K _inst_1)) (Int.cast.{u1} K (Ring.toIntCast.{u1} K (DivisionRing.toRing.{u1} K _inst_1)) (Rat.num r)) (Nat.cast.{u1} K (NonAssocRing.toNatCast.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))) (Rat.den r)))
Case conversion may be inaccurate. Consider using '#align rat.cast_def Rat.cast_defₓ'. -/
theorem cast_def : ∀ r : ℚ, (r : K) = r.num / r.den
| ⟨a, b, h1, h2⟩ => (cast_mk' _ _ _ _).trans (div_eq_mul_inv _ _).symm
@@ -209,7 +201,7 @@ instance (priority := 100) smulDivisionRing : SMul ℚ K :=
lean 3 declaration is
forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (a : Rat) (x : K), Eq.{succ u1} K (SMul.smul.{0, u1} Rat K (Rat.smulDivisionRing.{u1} K _inst_1) a x) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (Distrib.toHasMul.{u1} K (Ring.toDistrib.{u1} K (DivisionRing.toRing.{u1} K _inst_1)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat K (HasLiftT.mk.{1, succ u1} Rat K (CoeTCₓ.coe.{1, succ u1} Rat K (Rat.castCoe.{u1} K (DivisionRing.toHasRatCast.{u1} K _inst_1)))) a) x)
but is expected to have type
- forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (a : Rat) (x : K), Eq.{succ u1} K (HSMul.hSMul.{0, u1, u1} Rat K K (instHSMul.{0, u1} Rat K (Rat.smulDivisionRing.{u1} K _inst_1)) a x) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (NonUnitalNonAssocRing.toMul.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))) (RatCast.ratCast.{u1} K (DivisionRing.toRatCast.{u1} K _inst_1) a) x)
+ forall {K : Type.{u1}} [_inst_1 : DivisionRing.{u1} K] (a : Rat) (x : K), Eq.{succ u1} K (HSMul.hSMul.{0, u1, u1} Rat K K (instHSMul.{0, u1} Rat K (Rat.smulDivisionRing.{u1} K _inst_1)) a x) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (NonUnitalNonAssocRing.toMul.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K _inst_1))))) (Rat.cast.{u1} K (DivisionRing.toRatCast.{u1} K _inst_1) a) x)
Case conversion may be inaccurate. Consider using '#align rat.smul_def Rat.smul_defₓ'. -/
theorem smul_def (a : ℚ) (x : K) : a • x = ↑a * x :=
DivisionRing.qsmul_eq_mul' a x
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
OfScientific
instance for NNRat
and NNReal
(#12485)
The existing RatCast.toOfScientific
instance has to be removed since it forms a non-defeq diamond (there is nothing enforcing that nnratCast
and ratCast
are defeq).
The norm_num
extension also needs some fixes, though the old design didn't make much sense anyway, as it synthesize the instances separately, thus losing important defeqs.
@@ -227,5 +227,7 @@ theorem smul_one_eq_coe (A : Type*) [DivisionRing A] (m : ℚ) : m • (1 : A) =
end Rat
-instance RatCast.toOfScientific [RatCast K] : OfScientific K where
- ofScientific (m : ℕ) (b : Bool) (d : ℕ) := Rat.ofScientific m b d
+/-- `OfScientific.ofScientific` is the simp-normal form. -/
+@[simp]
+theorem Rat.ofScientific_eq_ofScientific :
+ Rat.ofScientific = OfScientific.ofScientific := rfl
b ≠ 0 → a * b / b = a
(#12424)
This lets us unify a few lemmas between GroupWithZero
and EuclideanDomain
and two lemmas that were previously proved separately for Nat
, Int
, Polynomial
.
@@ -38,9 +38,9 @@ structure IsField (R : Type u) [Semiring R] : Prop where
#align is_field IsField
/-- Transferring from `Semifield` to `IsField`. -/
-theorem Semifield.toIsField (R : Type u) [Semifield R] : IsField R :=
- { ‹Semifield R› with
- mul_inv_cancel := @fun a ha => ⟨a⁻¹, mul_inv_cancel a ha⟩ }
+theorem Semifield.toIsField (R : Type u) [Semifield R] : IsField R where
+ __ := ‹Semifield R›
+ mul_inv_cancel {a} ha := ⟨a⁻¹, mul_inv_cancel ha⟩
#align semifield.to_is_field Semifield.toIsField
/-- Transferring from `Field` to `IsField`. -/
NNRat.cast
(#11203)
Define the canonical coercion from the nonnegative rationals to any division semiring.
From LeanAPAP
@@ -69,6 +69,7 @@ noncomputable def IsField.toSemifield {R : Type u} [Semiring R] (h : IsField R)
inv a := if ha : a = 0 then 0 else Classical.choose (h.mul_inv_cancel ha)
inv_zero := dif_pos rfl
mul_inv_cancel a ha := by convert Classical.choose_spec (h.mul_inv_cancel ha); exact dif_neg ha
+ nnqsmul := _
#align is_field.to_semifield IsField.toSemifield
/-- Transferring from `IsField` to `Field`. -/
NNRat.cast
(#11203)
Define the canonical coercion from the nonnegative rationals to any division semiring.
From LeanAPAP
@@ -1,7 +1,7 @@
/-
Copyright (c) 2014 Robert Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
-Authors: Robert Lewis, Leonardo de Moura, Johannes Hölzl, Mario Carneiro
+Authors: Robert Lewis, Leonardo de Moura, Johannes Hölzl, Mario Carneiro, Yaël Dillies
-/
import Mathlib.Algebra.Ring.Defs
import Mathlib.Data.Rat.Init
@@ -59,6 +59,14 @@ universe u
variable {α β K : Type*}
+/-- The default definition of the coercion `ℚ≥0 → K` for a division semiring `K`.
+
+`↑q : K` is defined as `(q.num : K) / (q.den : K)`.
+
+Do not use this directly (instances of `DivisionSemiring` are allowed to override that default for
+better definitional properties). Instead, use the coercion. -/
+def NNRat.castRec [NatCast K] [Div K] (q : ℚ≥0) : K := q.num / q.den
+
/-- The default definition of the coercion `ℚ → K` for a division ring `K`.
`↑q : K` is defined as `(q.num : K) / (q.den : K)`.
@@ -79,7 +87,23 @@ itself). See also note [forgetful inheritance].
If the division semiring has positive characteristic `p`, our division by zero convention forces
`nnratCast (1 / p) = 1 / 0 = 0`. -/
-class DivisionSemiring (α : Type*) extends Semiring α, GroupWithZero α where
+class DivisionSemiring (α : Type*) extends Semiring α, GroupWithZero α, NNRatCast α where
+ protected nnratCast := NNRat.castRec
+ /-- However `NNRat.cast` is defined, it must be propositionally equal to `a / b`.
+
+ Do not use this lemma directly. Use `NNRat.cast_def` instead. -/
+ protected nnratCast_def (q : ℚ≥0) : (NNRat.cast q : α) = q.num / q.den := by intros; rfl
+ /-- Scalar multiplication by a nonnegative rational number.
+
+ Unless there is a risk of a `Module ℚ≥0 _` instance diamond, write `nnqsmul := _`. This will set
+ `nnqsmul` to `(NNRat.cast · * ·)` thanks to unification in the default proof of `nnqsmul_def`.
+
+ Do not use directly. Instead use the `•` notation. -/
+ protected nnqsmul : ℚ≥0 → α → α
+ /-- However `qsmul` is defined, it must be propositionally equal to multiplication by `Rat.cast`.
+
+ Do not use this lemma directly. Use `NNRat.smul_def` instead. -/
+ protected nnqsmul_def (q : ℚ≥0) (a : α) : nnqsmul q a = NNRat.cast q * a := by intros; rfl
#align division_semiring DivisionSemiring
/-- A `DivisionRing` is a `Ring` with multiplicative inverses for nonzero elements.
@@ -93,11 +117,27 @@ See also note [forgetful inheritance]. Similarly, there are maps `nnratCast ℚ
If the division ring has positive characteristic `p`, our division by zero convention forces
`ratCast (1 / p) = 1 / 0 = 0`. -/
class DivisionRing (α : Type*)
- extends Ring α, DivInvMonoid α, Nontrivial α, RatCast α where
+ extends Ring α, DivInvMonoid α, Nontrivial α, NNRatCast α, RatCast α where
/-- For a nonzero `a`, `a⁻¹` is a right multiplicative inverse. -/
protected mul_inv_cancel : ∀ (a : α), a ≠ 0 → a * a⁻¹ = 1
/-- The inverse of `0` is `0` by convention. -/
protected inv_zero : (0 : α)⁻¹ = 0
+ protected nnratCast := NNRat.castRec
+ /-- However `NNRat.cast` is defined, it must be equal to `a / b`.
+
+ Do not use this lemma directly. Use `NNRat.cast_def` instead. -/
+ protected nnratCast_def (q : ℚ≥0) : (NNRat.cast q : α) = q.num / q.den := by intros; rfl
+ /-- Scalar multiplication by a nonnegative rational number.
+
+ Unless there is a risk of a `Module ℚ≥0 _` instance diamond, write `nnqsmul := _`. This will set
+ `nnqsmul` to `(NNRat.cast · * ·)` thanks to unification in the default proof of `nnqsmul_def`.
+
+ Do not use directly. Instead use the `•` notation. -/
+ protected nnqsmul : ℚ≥0 → α → α
+ /-- However `qsmul` is defined, it must be propositionally equal to multiplication by `Rat.cast`.
+
+ Do not use this lemma directly. Use `NNRat.smul_def` instead. -/
+ protected nnqsmul_def (q : ℚ≥0) (a : α) : nnqsmul q a = NNRat.cast q * a := by intros; rfl
protected ratCast := Rat.castRec
/-- However `Rat.cast q` is defined, it must be propositionally equal to `q.num / q.den`.
@@ -150,6 +190,20 @@ class Field (K : Type u) extends CommRing K, DivisionRing K
instance (priority := 100) Field.toSemifield [Field α] : Semifield α := { ‹Field α› with }
#align field.to_semifield Field.toSemifield
+namespace NNRat
+variable [DivisionSemiring α]
+
+instance (priority := 100) smulDivisionSemiring : SMul ℚ≥0 α := ⟨DivisionSemiring.nnqsmul⟩
+
+lemma cast_def (q : ℚ≥0) : (q : α) = q.num / q.den := DivisionSemiring.nnratCast_def _
+lemma smul_def (q : ℚ≥0) (a : α) : q • a = q * a := DivisionSemiring.nnqsmul_def q a
+
+variable (α)
+
+@[simp] lemma smul_one_eq_coe (q : ℚ≥0) : q • (1 : α) = q := by rw [NNRat.smul_def, mul_one]
+
+end NNRat
+
namespace Rat
variable [DivisionRing K] {a b : K}
NNRat.cast
(#12360)
This is the parts of the diff of #11203 which don't mention NNRat.cast
.
where
notation.qsmul := _
instead of qsmul := qsmulRec _
to make the instances more robust to definition changes.qsmulRec
.qsmul
before ratCast_def
in instance declarations.rat_smul
to qsmul
.@@ -63,18 +63,17 @@ theorem not_isField_of_subsingleton (R : Type u) [Semiring R] [Subsingleton R] :
open scoped Classical
/-- Transferring from `IsField` to `Semifield`. -/
-noncomputable def IsField.toSemifield {R : Type u} [Semiring R] (h : IsField R) : Semifield R :=
- { ‹Semiring R›, h with
- inv := fun a => if ha : a = 0 then 0 else Classical.choose (IsField.mul_inv_cancel h ha),
- inv_zero := dif_pos rfl,
- mul_inv_cancel := fun a ha => by
- convert Classical.choose_spec (IsField.mul_inv_cancel h ha)
- exact dif_neg ha }
+noncomputable def IsField.toSemifield {R : Type u} [Semiring R] (h : IsField R) : Semifield R where
+ __ := ‹Semiring R›
+ __ := h
+ inv a := if ha : a = 0 then 0 else Classical.choose (h.mul_inv_cancel ha)
+ inv_zero := dif_pos rfl
+ mul_inv_cancel a ha := by convert Classical.choose_spec (h.mul_inv_cancel ha); exact dif_neg ha
#align is_field.to_semifield IsField.toSemifield
/-- Transferring from `IsField` to `Field`. -/
noncomputable def IsField.toField {R : Type u} [Ring R] (h : IsField R) : Field R :=
- { ‹Ring R›, IsField.toSemifield h with qsmul := qsmulRec _ }
+ { ‹Ring R›, IsField.toSemifield h with qsmul := _ }
#align is_field.to_field IsField.toField
/-- For each field, and for each nonzero element of said field, there is a unique inverse.
NNRat.cast
(#12360)
This is the parts of the diff of #11203 which don't mention NNRat.cast
.
where
notation.qsmul := _
instead of qsmul := qsmulRec _
to make the instances more robust to definition changes.qsmulRec
.qsmul
before ratCast_def
in instance declarations.rat_smul
to qsmul
.@@ -68,15 +68,7 @@ better definitional properties). Instead, use the coercion. -/
def Rat.castRec [NatCast K] [IntCast K] [Div K] (q : ℚ) : K := q.num / q.den
#align rat.cast_rec Rat.castRec
-/-- The default definition of the scalar multiplication by `ℚ` on a division ring `K`.
-
-`q • x` is defined as `↑q * x`.
-
-Do not use directly (instances of `DivisionRing` are allowed to override that default for
-better definitional properties). Instead use the `•` notation. -/
-def qsmulRec (coe : ℚ → K) [Mul K] (a : ℚ) (x : K) : K :=
- coe a * x
-#align qsmul_rec qsmulRec
+#noalign qsmul_rec
/-- A `DivisionSemiring` is a `Semiring` with multiplicative inverses for nonzero elements.
@@ -113,7 +105,8 @@ class DivisionRing (α : Type*)
protected ratCast_def (q : ℚ) : (Rat.cast q : α) = q.num / q.den := by intros; rfl
/-- Scalar multiplication by a rational number.
- Set this to `qsmulRec _` unless there is a risk of a `Module ℚ _` instance diamond.
+ Unless there is a risk of a `Module ℚ _` instance diamond, write `qsmul := _`. This will set
+ `qsmul` to `(Rat.cast · * ·)` thanks to unification in the default proof of `qsmul_def`.
Do not use directly. Instead use the `•` notation. -/
protected qsmul : ℚ → α → α
Rat
internals in the definition of Field
(#11639)
Soon, there will be NNRat
analogs of the Rat
fields in the definition of Field
. NNRat
is less nicely a structure than Rat
, hence there is a need to reduce the dependency of Field
on the internals of Rat
.
This PR achieves this by restating Field.ratCast_mk'
in terms of Rat.num
, Rat.den
. This requires fixing a few downstream instances.
Reduce the diff of #11203.
Co-authored-by: Floris van Doorn <fpvdoorn@gmail.com>
@@ -61,11 +61,11 @@ variable {α β K : Type*}
/-- The default definition of the coercion `ℚ → K` for a division ring `K`.
-`↑q : K` is defined as `(q.num : K) * (q.den : K)⁻¹`.
+`↑q : K` is defined as `(q.num : K) / (q.den : K)`.
Do not use this directly (instances of `DivisionRing` are allowed to override that default for
better definitional properties). Instead, use the coercion. -/
-def Rat.castRec [NatCast K] [IntCast K] [Mul K] [Inv K] (q : ℚ) : K := q.num * (q.den : K)⁻¹
+def Rat.castRec [NatCast K] [IntCast K] [Div K] (q : ℚ) : K := q.num / q.den
#align rat.cast_rec Rat.castRec
/-- The default definition of the scalar multiplication by `ℚ` on a division ring `K`.
@@ -107,12 +107,10 @@ class DivisionRing (α : Type*)
/-- The inverse of `0` is `0` by convention. -/
protected inv_zero : (0 : α)⁻¹ = 0
protected ratCast := Rat.castRec
- /-- However `Rat.cast` is defined, it must be propositionally equal to `a * b⁻¹`.
+ /-- However `Rat.cast q` is defined, it must be propositionally equal to `q.num / q.den`.
Do not use this lemma directly. Use `Rat.cast_def` instead. -/
- protected ratCast_mk : ∀ (a : ℤ) (b : ℕ) (h1 h2), Rat.cast ⟨a, b, h1, h2⟩ = a * (b : α)⁻¹ := by
- intros
- rfl
+ protected ratCast_def (q : ℚ) : (Rat.cast q : α) = q.num / q.den := by intros; rfl
/-- Scalar multiplication by a rational number.
Set this to `qsmulRec _` unless there is a risk of a `Module ℚ _` instance diamond.
@@ -122,9 +120,9 @@ class DivisionRing (α : Type*)
/-- However `qsmul` is defined, it must be propositionally equal to multiplication by `Rat.cast`.
Do not use this lemma directly. Use `Rat.cast_def` instead. -/
- protected qsmul_eq_mul' (a : ℚ) (x : α) : qsmul a x = Rat.cast a * x := by intros; rfl
+ protected qsmul_def (a : ℚ) (x : α) : qsmul a x = Rat.cast a * x := by intros; rfl
#align division_ring DivisionRing
-#align division_ring.rat_cast_mk DivisionRing.ratCast_mk
+#align division_ring.rat_cast_mk DivisionRing.ratCast_def
-- see Note [lower instance priority]
instance (priority := 100) DivisionRing.toDivisionSemiring [DivisionRing α] : DivisionSemiring α :=
@@ -162,19 +160,17 @@ instance (priority := 100) Field.toSemifield [Field α] : Semifield α := { ‹F
namespace Rat
variable [DivisionRing K] {a b : K}
-theorem cast_mk' (a b h1 h2) : ((⟨a, b, h1, h2⟩ : ℚ) : K) = a * (b : K)⁻¹ :=
- DivisionRing.ratCast_mk _ _ _ _
-#align rat.cast_mk' Rat.cast_mk'
-
-theorem cast_def : ∀ r : ℚ, (r : K) = r.num / r.den
- | ⟨_, _, _, _⟩ => (cast_mk' _ _ _ _).trans (div_eq_mul_inv _ _).symm
+lemma cast_def (q : ℚ) : (q : K) = q.num / q.den := DivisionRing.ratCast_def _
#align rat.cast_def Rat.cast_def
+lemma cast_mk' (a b h1 h2) : ((⟨a, b, h1, h2⟩ : ℚ) : K) = a / b := cast_def _
+#align rat.cast_mk' Rat.cast_mk'
+
instance (priority := 100) smulDivisionRing : SMul ℚ K :=
⟨DivisionRing.qsmul⟩
#align rat.smul_division_ring Rat.smulDivisionRing
-theorem smul_def (a : ℚ) (x : K) : a • x = ↑a * x := DivisionRing.qsmul_eq_mul' a x
+theorem smul_def (a : ℚ) (x : K) : a • x = ↑a * x := DivisionRing.qsmul_def a x
#align rat.smul_def Rat.smul_def
@[simp]
@@ -3,9 +3,7 @@ Copyright (c) 2014 Robert Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Lewis, Leonardo de Moura, Johannes Hölzl, Mario Carneiro
-/
-
import Mathlib.Algebra.Ring.Defs
-import Std.Data.Rat.Basic
import Mathlib.Data.Rat.Init
#align_import algebra.field.defs from "leanprover-community/mathlib"@"2651125b48fc5c170ab1111afd0817c903b1fc6c"
@@ -47,6 +45,13 @@ a `GroupWithZero` lemma instead.
field, division ring, skew field, skew-field, skewfield
-/
+-- `NeZero` should not be needed in the basic algebraic hierarchy.
+assert_not_exists NeZero
+
+-- Check that we have not imported `Mathlib.Tactic.Common` yet.
+assert_not_exists Mathlib.Tactic.LibrarySearch.librarySearch
+
+assert_not_exists MonoidHom
open Function Set
@@ -54,54 +59,70 @@ universe u
variable {α β K : Type*}
-/-- The default definition of the coercion `(↑(a : ℚ) : K)` for a division ring `K`
-is defined as `(a / b : K) = (a : K) * (b : K)⁻¹`.
-Use `coe` instead of `Rat.castRec` for better definitional behaviour.
--/
-def Rat.castRec [NatCast K] [IntCast K] [Mul K] [Inv K] : ℚ → K
- | ⟨a, b, _, _⟩ => ↑a * (↑b)⁻¹
+/-- The default definition of the coercion `ℚ → K` for a division ring `K`.
+
+`↑q : K` is defined as `(q.num : K) * (q.den : K)⁻¹`.
+
+Do not use this directly (instances of `DivisionRing` are allowed to override that default for
+better definitional properties). Instead, use the coercion. -/
+def Rat.castRec [NatCast K] [IntCast K] [Mul K] [Inv K] (q : ℚ) : K := q.num * (q.den : K)⁻¹
#align rat.cast_rec Rat.castRec
-/-- The default definition of the scalar multiplication `(a : ℚ) • (x : K)` for a division ring `K`
-is given by `a • x = (↑ a) * x`.
-Use `(a : ℚ) • (x : K)` instead of `qsmulRec` for better definitional behaviour.
--/
+/-- The default definition of the scalar multiplication by `ℚ` on a division ring `K`.
+
+`q • x` is defined as `↑q * x`.
+
+Do not use directly (instances of `DivisionRing` are allowed to override that default for
+better definitional properties). Instead use the `•` notation. -/
def qsmulRec (coe : ℚ → K) [Mul K] (a : ℚ) (x : K) : K :=
coe a * x
#align qsmul_rec qsmulRec
-/-- A `DivisionSemiring` is a `Semiring` with multiplicative inverses for nonzero elements. -/
-class DivisionSemiring (α : Type*) extends Semiring α, GroupWithZero α
+/-- A `DivisionSemiring` is a `Semiring` with multiplicative inverses for nonzero elements.
+
+An instance of `DivisionSemiring K` includes maps `nnratCast : ℚ≥0 → K` and `nnqsmul : ℚ≥0 → K → K`.
+Those two fields are needed to implement the `DivisionSemiring K → Algebra ℚ≥0 K` instance since we
+need to control the specific definitions for some special cases of `K` (in particular `K = ℚ≥0`
+itself). See also note [forgetful inheritance].
+
+If the division semiring has positive characteristic `p`, our division by zero convention forces
+`nnratCast (1 / p) = 1 / 0 = 0`. -/
+class DivisionSemiring (α : Type*) extends Semiring α, GroupWithZero α where
#align division_semiring DivisionSemiring
/-- A `DivisionRing` is a `Ring` with multiplicative inverses for nonzero elements.
An instance of `DivisionRing K` includes maps `ratCast : ℚ → K` and `qsmul : ℚ → K → K`.
-If the division ring has positive characteristic p, we define `ratCast (1 / p) = 1 / 0 = 0`
-for consistency with our division by zero convention.
-The fields `ratCast` and `qsmul` are needed to implement the
-`algebraRat [DivisionRing K] : Algebra ℚ K` instance, since we need to control the specific
-definitions for some special cases of `K` (in particular `K = ℚ` itself).
-See also Note [forgetful inheritance].
--/
-class DivisionRing (K : Type u) extends Ring K, DivInvMonoid K, Nontrivial K, RatCast K where
+Those two fields are needed to implement the `DivisionRing K → Algebra ℚ K` instance since we need
+to control the specific definitions for some special cases of `K` (in particular `K = ℚ` itself).
+See also note [forgetful inheritance]. Similarly, there are maps `nnratCast ℚ≥0 → K` and
+`nnqsmul : ℚ≥0 → K → K` to implement the `DivisionSemiring K → Algebra ℚ≥0 K` instance.
+
+If the division ring has positive characteristic `p`, our division by zero convention forces
+`ratCast (1 / p) = 1 / 0 = 0`. -/
+class DivisionRing (α : Type*)
+ extends Ring α, DivInvMonoid α, Nontrivial α, RatCast α where
/-- For a nonzero `a`, `a⁻¹` is a right multiplicative inverse. -/
- protected mul_inv_cancel : ∀ (a : K), a ≠ 0 → a * a⁻¹ = 1
- /-- We define the inverse of `0` to be `0`. -/
- protected inv_zero : (0 : K)⁻¹ = 0
+ protected mul_inv_cancel : ∀ (a : α), a ≠ 0 → a * a⁻¹ = 1
+ /-- The inverse of `0` is `0` by convention. -/
+ protected inv_zero : (0 : α)⁻¹ = 0
protected ratCast := Rat.castRec
- /-- However `ratCast` is defined, propositionally it must be equal to `a * b⁻¹`. -/
- protected ratCast_mk : ∀ (a : ℤ) (b : ℕ) (h1 h2), Rat.cast ⟨a, b, h1, h2⟩ = a * (b : K)⁻¹ := by
- intros
- rfl
- /-- Multiplication by a rational number.
- Set this to `qsmulRec _` unless there is a risk of a `Module ℚ _` instance diamond. -/
- protected qsmul : ℚ → K → K
- /-- However `qsmul` is defined,
- propositionally it must be equal to multiplication by `ratCast`. -/
- protected qsmul_eq_mul' : ∀ (a : ℚ) (x : K), qsmul a x = Rat.cast a * x := by
+ /-- However `Rat.cast` is defined, it must be propositionally equal to `a * b⁻¹`.
+
+ Do not use this lemma directly. Use `Rat.cast_def` instead. -/
+ protected ratCast_mk : ∀ (a : ℤ) (b : ℕ) (h1 h2), Rat.cast ⟨a, b, h1, h2⟩ = a * (b : α)⁻¹ := by
intros
rfl
+ /-- Scalar multiplication by a rational number.
+
+ Set this to `qsmulRec _` unless there is a risk of a `Module ℚ _` instance diamond.
+
+ Do not use directly. Instead use the `•` notation. -/
+ protected qsmul : ℚ → α → α
+ /-- However `qsmul` is defined, it must be propositionally equal to multiplication by `Rat.cast`.
+
+ Do not use this lemma directly. Use `Rat.cast_def` instead. -/
+ protected qsmul_eq_mul' (a : ℚ) (x : α) : qsmul a x = Rat.cast a * x := by intros; rfl
#align division_ring DivisionRing
#align division_ring.rat_cast_mk DivisionRing.ratCast_mk
@@ -110,28 +131,36 @@ instance (priority := 100) DivisionRing.toDivisionSemiring [DivisionRing α] : D
{ ‹DivisionRing α› with }
#align division_ring.to_division_semiring DivisionRing.toDivisionSemiring
-/-- A `Semifield` is a `CommSemiring` with multiplicative inverses for nonzero elements. -/
+/-- A `Semifield` is a `CommSemiring` with multiplicative inverses for nonzero elements.
+
+An instance of `Semifield K` includes maps `nnratCast : ℚ≥0 → K` and `nnqsmul : ℚ≥0 → K → K`.
+Those two fields are needed to implement the `DivisionSemiring K → Algebra ℚ≥0 K` instance since we
+need to control the specific definitions for some special cases of `K` (in particular `K = ℚ≥0`
+itself). See also note [forgetful inheritance].
+
+If the semifield has positive characteristic `p`, our division by zero convention forces
+`nnratCast (1 / p) = 1 / 0 = 0`. -/
class Semifield (α : Type*) extends CommSemiring α, DivisionSemiring α, CommGroupWithZero α
#align semifield Semifield
/-- A `Field` is a `CommRing` with multiplicative inverses for nonzero elements.
An instance of `Field K` includes maps `ratCast : ℚ → K` and `qsmul : ℚ → K → K`.
-If the field has positive characteristic p, we define `ratCast (1 / p) = 1 / 0 = 0`
-for consistency with our division by zero convention.
-The fields `ratCast` and `qsmul` are needed to implement the
-`algebraRat [DivisionRing K] : Algebra ℚ K` instance, since we need to control the specific
-definitions for some special cases of `K` (in particular `K = ℚ` itself).
-See also Note [forgetful inheritance].
--/
+Those two fields are needed to implement the `DivisionRing K → Algebra ℚ K` instance since we need
+to control the specific definitions for some special cases of `K` (in particular `K = ℚ` itself).
+See also note [forgetful inheritance].
+
+If the field has positive characteristic `p`, our division by zero convention forces
+`ratCast (1 / p) = 1 / 0 = 0`. -/
class Field (K : Type u) extends CommRing K, DivisionRing K
#align field Field
-section DivisionRing
-
-variable [DivisionRing K] {a b : K}
+-- see Note [lower instance priority]
+instance (priority := 100) Field.toSemifield [Field α] : Semifield α := { ‹Field α› with }
+#align field.to_semifield Field.toSemifield
namespace Rat
+variable [DivisionRing K] {a b : K}
theorem cast_mk' (a b h1 h2) : ((⟨a, b, h1, h2⟩ : ℚ) : K) = a * (b : K)⁻¹ :=
DivisionRing.ratCast_mk _ _ _ _
@@ -145,8 +174,7 @@ instance (priority := 100) smulDivisionRing : SMul ℚ K :=
⟨DivisionRing.qsmul⟩
#align rat.smul_division_ring Rat.smulDivisionRing
-theorem smul_def (a : ℚ) (x : K) : a • x = ↑a * x :=
- DivisionRing.qsmul_eq_mul' a x
+theorem smul_def (a : ℚ) (x : K) : a • x = ↑a * x := DivisionRing.qsmul_eq_mul' a x
#align rat.smul_def Rat.smul_def
@[simp]
@@ -156,32 +184,5 @@ theorem smul_one_eq_coe (A : Type*) [DivisionRing A] (m : ℚ) : m • (1 : A) =
end Rat
-end DivisionRing
-
-section OfScientific
-
instance RatCast.toOfScientific [RatCast K] : OfScientific K where
ofScientific (m : ℕ) (b : Bool) (d : ℕ) := Rat.ofScientific m b d
-
-end OfScientific
-
-section Field
-
-variable [Field K]
-
--- see Note [lower instance priority]
-instance (priority := 100) Field.toSemifield : Semifield K :=
- { ‹Field K› with }
-#align field.to_semifield Field.toSemifield
-
-end Field
-
-/-
-`NeZero` should not be needed in the basic algebraic hierarchy.
--/
-assert_not_exists NeZero
-
-/-
-Check that we have not imported `Mathlib.Tactic.Common` yet.
--/
-assert_not_exists Mathlib.Tactic.LibrarySearch.librarySearch
@@ -74,7 +74,7 @@ noncomputable def IsField.toSemifield {R : Type u} [Semiring R] (h : IsField R)
/-- Transferring from `IsField` to `Field`. -/
noncomputable def IsField.toField {R : Type u} [Ring R] (h : IsField R) : Field R :=
- { ‹Ring R›, IsField.toSemifield h with }
+ { ‹Ring R›, IsField.toSemifield h with qsmul := qsmulRec _ }
#align is_field.to_field IsField.toField
/-- For each field, and for each nonzero element of said field, there is a unique inverse.
@@ -94,8 +94,9 @@ class DivisionRing (K : Type u) extends Ring K, DivInvMonoid K, Nontrivial K, Ra
protected ratCast_mk : ∀ (a : ℤ) (b : ℕ) (h1 h2), Rat.cast ⟨a, b, h1, h2⟩ = a * (b : K)⁻¹ := by
intros
rfl
- /-- Multiplication by a rational number. -/
- protected qsmul : ℚ → K → K := qsmulRec Rat.cast
+ /-- Multiplication by a rational number.
+ Set this to `qsmulRec _` unless there is a risk of a `Module ℚ _` instance diamond. -/
+ protected qsmul : ℚ → K → K
/-- However `qsmul` is defined,
propositionally it must be equal to multiplication by `ratCast`. -/
protected qsmul_eq_mul' : ∀ (a : ℚ) (x : K), qsmul a x = Rat.cast a * x := by
open Classical
(#11199)
We remove all but one open Classical
s, instead preferring to use open scoped Classical
. The only real side-effect this led to is moving a couple declarations to use Exists.choose
instead of Classical.choose
.
The first few commits are explicitly labelled regex replaces for ease of review.
@@ -60,7 +60,7 @@ theorem not_isField_of_subsingleton (R : Type u) [Semiring R] [Subsingleton R] :
h (Subsingleton.elim _ _)
#align not_is_field_of_subsingleton not_isField_of_subsingleton
-open Classical
+open scoped Classical
/-- Transferring from `IsField` to `Semifield`. -/
noncomputable def IsField.toSemifield {R : Type u} [Semiring R] (h : IsField R) : Semifield R :=
If you can cast a rat to a type, then we probably want decimal notation to work there too.
This has the benefit of making the instance computable even in cases where some parts of the division ring structure are not. It also means that this could apply to matrices of rational numbers, which are not a division ring, but could have a rat cast.
@@ -159,7 +159,7 @@ end DivisionRing
section OfScientific
-instance DivisionRing.toOfScientific [DivisionRing K] : OfScientific K where
+instance RatCast.toOfScientific [RatCast K] : OfScientific K where
ofScientific (m : ℕ) (b : Bool) (d : ℕ) := Rat.ofScientific m b d
end OfScientific
@@ -5,7 +5,7 @@ Authors: Robert Lewis, Leonardo de Moura, Johannes Hölzl, Mario Carneiro
-/
import Mathlib.Algebra.Ring.Defs
-import Std.Data.Rat
+import Std.Data.Rat.Basic
import Mathlib.Data.Rat.Init
#align_import algebra.field.defs from "leanprover-community/mathlib"@"2651125b48fc5c170ab1111afd0817c903b1fc6c"
@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Lewis, Leonardo de Moura, Johannes Hölzl, Mario Carneiro
-/
import Mathlib.Algebra.Field.Defs
+import Mathlib.Tactic.Common
#align_import algebra.field.defs from "leanprover-community/mathlib"@"2651125b48fc5c170ab1111afd0817c903b1fc6c"
@@ -179,3 +179,8 @@ end Field
`NeZero` should not be needed in the basic algebraic hierarchy.
-/
assert_not_exists NeZero
+
+/-
+Check that we have not imported `Mathlib.Tactic.Common` yet.
+-/
+assert_not_exists Mathlib.Tactic.LibrarySearch.librarySearch
@@ -174,3 +174,8 @@ instance (priority := 100) Field.toSemifield : Semifield K :=
#align field.to_semifield Field.toSemifield
end Field
+
+/-
+`NeZero` should not be needed in the basic algebraic hierarchy.
+-/
+assert_not_exists NeZero
@@ -174,78 +174,3 @@ instance (priority := 100) Field.toSemifield : Semifield K :=
#align field.to_semifield Field.toSemifield
end Field
-
-section IsField
-
-/-- A predicate to express that a (semi)ring is a (semi)field.
-
-This is mainly useful because such a predicate does not contain data,
-and can therefore be easily transported along ring isomorphisms.
-Additionally, this is useful when trying to prove that
-a particular ring structure extends to a (semi)field. -/
-structure IsField (R : Type u) [Semiring R] : Prop where
- /-- For a semiring to be a field, it must have two distinct elements. -/
- exists_pair_ne : ∃ x y : R, x ≠ y
- /-- Fields are commutative. -/
- mul_comm : ∀ x y : R, x * y = y * x
- /-- Nonzero elements have multiplicative inverses. -/
- mul_inv_cancel : ∀ {a : R}, a ≠ 0 → ∃ b, a * b = 1
-#align is_field IsField
-
-/-- Transferring from `Semifield` to `IsField`. -/
-theorem Semifield.toIsField (R : Type u) [Semifield R] : IsField R :=
- { ‹Semifield R› with
- mul_inv_cancel := @fun a ha => ⟨a⁻¹, mul_inv_cancel a ha⟩ }
-#align semifield.to_is_field Semifield.toIsField
-
-/-- Transferring from `Field` to `IsField`. -/
-theorem Field.toIsField (R : Type u) [Field R] : IsField R :=
- Semifield.toIsField _
-#align field.to_is_field Field.toIsField
-
-@[simp]
-theorem IsField.nontrivial {R : Type u} [Semiring R] (h : IsField R) : Nontrivial R :=
- ⟨h.exists_pair_ne⟩
-#align is_field.nontrivial IsField.nontrivial
-
-@[simp]
-theorem not_isField_of_subsingleton (R : Type u) [Semiring R] [Subsingleton R] : ¬IsField R :=
- fun h =>
- let ⟨_, _, h⟩ := h.exists_pair_ne
- h (Subsingleton.elim _ _)
-#align not_is_field_of_subsingleton not_isField_of_subsingleton
-
-open Classical
-
-/-- Transferring from `IsField` to `Semifield`. -/
-noncomputable def IsField.toSemifield {R : Type u} [Semiring R] (h : IsField R) : Semifield R :=
- { ‹Semiring R›, h with
- inv := fun a => if ha : a = 0 then 0 else Classical.choose (IsField.mul_inv_cancel h ha),
- inv_zero := dif_pos rfl,
- mul_inv_cancel := fun a ha => by
- convert Classical.choose_spec (IsField.mul_inv_cancel h ha)
- exact dif_neg ha }
-#align is_field.to_semifield IsField.toSemifield
-
-/-- Transferring from `IsField` to `Field`. -/
-noncomputable def IsField.toField {R : Type u} [Ring R] (h : IsField R) : Field R :=
- { ‹Ring R›, IsField.toSemifield h with }
-#align is_field.to_field IsField.toField
-
-/-- For each field, and for each nonzero element of said field, there is a unique inverse.
-Since `IsField` doesn't remember the data of an `inv` function and as such,
-a lemma that there is a unique inverse could be useful.
--/
-theorem uniq_inv_of_isField (R : Type u) [Ring R] (hf : IsField R) :
- ∀ x : R, x ≠ 0 → ∃! y : R, x * y = 1 := by
- intro x hx
- apply exists_unique_of_exists_of_unique
- · exact hf.mul_inv_cancel hx
- · intro y z hxy hxz
- calc
- y = y * (x * z) := by rw [hxz, mul_one]
- _ = x * y * z := by rw [← mul_assoc, hf.mul_comm y x]
- _ = z := by rw [hxy, one_mul]
-#align uniq_inv_of_is_field uniq_inv_of_isField
-
-end IsField
In both Division.toDivisionSemiring
and Field.toSemiField
, an extra unused Semiring
instance is provided to construct the instance. This removes them.
@@ -106,7 +106,7 @@ class DivisionRing (K : Type u) extends Ring K, DivInvMonoid K, Nontrivial K, Ra
-- see Note [lower instance priority]
instance (priority := 100) DivisionRing.toDivisionSemiring [DivisionRing α] : DivisionSemiring α :=
- { ‹DivisionRing α›, (inferInstance : Semiring α) with }
+ { ‹DivisionRing α› with }
#align division_ring.to_division_semiring DivisionRing.toDivisionSemiring
/-- A `Semifield` is a `CommSemiring` with multiplicative inverses for nonzero elements. -/
@@ -170,7 +170,7 @@ variable [Field K]
-- see Note [lower instance priority]
instance (priority := 100) Field.toSemifield : Semifield K :=
- { ‹Field K›, (inferInstance : Semiring K) with }
+ { ‹Field K› with }
#align field.to_semifield Field.toSemifield
end Field
Type _
and Sort _
(#6499)
We remove all possible occurences of Type _
and Sort _
in favor of Type*
and Sort*
.
This has nice performance benefits.
@@ -52,7 +52,7 @@ open Function Set
universe u
-variable {α β K : Type _}
+variable {α β K : Type*}
/-- The default definition of the coercion `(↑(a : ℚ) : K)` for a division ring `K`
is defined as `(a / b : K) = (a : K) * (b : K)⁻¹`.
@@ -71,7 +71,7 @@ def qsmulRec (coe : ℚ → K) [Mul K] (a : ℚ) (x : K) : K :=
#align qsmul_rec qsmulRec
/-- A `DivisionSemiring` is a `Semiring` with multiplicative inverses for nonzero elements. -/
-class DivisionSemiring (α : Type _) extends Semiring α, GroupWithZero α
+class DivisionSemiring (α : Type*) extends Semiring α, GroupWithZero α
#align division_semiring DivisionSemiring
/-- A `DivisionRing` is a `Ring` with multiplicative inverses for nonzero elements.
@@ -110,7 +110,7 @@ instance (priority := 100) DivisionRing.toDivisionSemiring [DivisionRing α] : D
#align division_ring.to_division_semiring DivisionRing.toDivisionSemiring
/-- A `Semifield` is a `CommSemiring` with multiplicative inverses for nonzero elements. -/
-class Semifield (α : Type _) extends CommSemiring α, DivisionSemiring α, CommGroupWithZero α
+class Semifield (α : Type*) extends CommSemiring α, DivisionSemiring α, CommGroupWithZero α
#align semifield Semifield
/-- A `Field` is a `CommRing` with multiplicative inverses for nonzero elements.
@@ -149,7 +149,7 @@ theorem smul_def (a : ℚ) (x : K) : a • x = ↑a * x :=
#align rat.smul_def Rat.smul_def
@[simp]
-theorem smul_one_eq_coe (A : Type _) [DivisionRing A] (m : ℚ) : m • (1 : A) = ↑m := by
+theorem smul_one_eq_coe (A : Type*) [DivisionRing A] (m : ℚ) : m • (1 : A) = ↑m := by
rw [Rat.smul_def, mul_one]
#align rat.smul_one_eq_coe Rat.smul_one_eq_coe
@@ -2,17 +2,14 @@
Copyright (c) 2014 Robert Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Lewis, Leonardo de Moura, Johannes Hölzl, Mario Carneiro
-
-! This file was ported from Lean 3 source module algebra.field.defs
-! leanprover-community/mathlib commit 2651125b48fc5c170ab1111afd0817c903b1fc6c
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Algebra.Ring.Defs
import Std.Data.Rat
import Mathlib.Data.Rat.Init
+#align_import algebra.field.defs from "leanprover-community/mathlib"@"2651125b48fc5c170ab1111afd0817c903b1fc6c"
+
/-!
# Division (semi)rings and (semi)fields
I ran codespell Mathlib
and got tired halfway through the suggestions.
@@ -184,7 +184,7 @@ section IsField
This is mainly useful because such a predicate does not contain data,
and can therefore be easily transported along ring isomorphisms.
-Additionaly, this is useful when trying to prove that
+Additionally, this is useful when trying to prove that
a particular ring structure extends to a (semi)field. -/
structure IsField (R : Type u) [Semiring R] : Prop where
/-- For a semiring to be a field, it must have two distinct elements. -/
This makes a mathlib4 version of mathlib3's tactic.basic
, now called Mathlib.Tactic.Common
, which imports all tactics which do not have significant theory requirements, and then is imported all across the base of the hierarchy.
This ensures that all common tactics are available nearly everywhere in the library, rather than having to be imported one-by-one as you need them.
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@@ -10,7 +10,6 @@ Authors: Robert Lewis, Leonardo de Moura, Johannes Hölzl, Mario Carneiro
-/
import Mathlib.Algebra.Ring.Defs
-import Mathlib.Tactic.Convert
import Std.Data.Rat
import Mathlib.Data.Rat.Init
This additionally makes a further small generalization to some of the finsupp instances (labelled with porting notes) which should be backported.
The new statement of Rat.smul_one_eq_coe
fixes a proof in Mathlib/Analysis/NormedSpace/Basic.lean
that was mangled during porting.
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Lewis, Leonardo de Moura, Johannes Hölzl, Mario Carneiro
! This file was ported from Lean 3 source module algebra.field.defs
-! leanprover-community/mathlib commit 70d50ecfd4900dd6d328da39ab7ebd516abe4025
+! leanprover-community/mathlib commit 2651125b48fc5c170ab1111afd0817c903b1fc6c
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -152,6 +152,11 @@ theorem smul_def (a : ℚ) (x : K) : a • x = ↑a * x :=
DivisionRing.qsmul_eq_mul' a x
#align rat.smul_def Rat.smul_def
+@[simp]
+theorem smul_one_eq_coe (A : Type _) [DivisionRing A] (m : ℚ) : m • (1 : A) = ↑m := by
+ rw [Rat.smul_def, mul_one]
+#align rat.smul_one_eq_coe Rat.smul_one_eq_coe
+
end Rat
end DivisionRing
This PR fixes two things:
align
statements for definitions and theorems and instances that are separated by two newlines from the relevant declaration (s/\n\n#align/\n#align
). This is often seen in the mathport output after ending calc
blocks.#align
statements. (This was needed for a script I wrote for #3630.)@@ -240,13 +240,11 @@ theorem uniq_inv_of_isField (R : Type u) [Ring R] (hf : IsField R) :
intro x hx
apply exists_unique_of_exists_of_unique
· exact hf.mul_inv_cancel hx
-
· intro y z hxy hxz
calc
y = y * (x * z) := by rw [hxz, mul_one]
_ = x * y * z := by rw [← mul_assoc, hf.mul_comm y x]
_ = z := by rw [hxy, one_mul]
-
#align uniq_inv_of_is_field uniq_inv_of_isField
end IsField
norm_num
(#1707)
We implement #1706.
In addition to a norm_num
extension for OfScientific.ofScientific
, we implement extensions for
Int.ofNat
mkRat
Rat.cast
/RatCast.ratCast
which made implementation more convenient. We also patch up the other two *.cast
evaluators consistently while we're at it.
We create an instance of OfScientific K
for any division ring K
.
See Zulip discussion here for the original discussion, and this Zulip discussion for the more recent one.
@@ -156,6 +156,13 @@ end Rat
end DivisionRing
+section OfScientific
+
+instance DivisionRing.toOfScientific [DivisionRing K] : OfScientific K where
+ ofScientific (m : ℕ) (b : Bool) (d : ℕ) := Rat.ofScientific m b d
+
+end OfScientific
+
section Field
variable [Field K]
@@ -66,15 +66,6 @@ def Rat.castRec [NatCast K] [IntCast K] [Mul K] [Inv K] : ℚ → K
| ⟨a, b, _, _⟩ => ↑a * (↑b)⁻¹
#align rat.cast_rec Rat.castRec
-/-- Type class for the canonical homomorphism `ℚ → K`.
--/
-class RatCast (K : Type u) where
- /-- The canonical homomorphism `ℚ → K`. -/
- protected ratCast : ℚ → K
-#align has_rat_cast RatCast
-
-attribute [coe] RatCast.ratCast
-
/-- The default definition of the scalar multiplication `(a : ℚ) • (x : K)` for a division ring `K`
is given by `a • x = (↑ a) * x`.
Use `(a : ℚ) • (x : K)` instead of `qsmulRec` for better definitional behaviour.
@@ -104,14 +95,14 @@ class DivisionRing (K : Type u) extends Ring K, DivInvMonoid K, Nontrivial K, Ra
protected inv_zero : (0 : K)⁻¹ = 0
protected ratCast := Rat.castRec
/-- However `ratCast` is defined, propositionally it must be equal to `a * b⁻¹`. -/
- protected ratCast_mk : ∀ (a : ℤ) (b : ℕ) (h1 h2), ratCast ⟨a, b, h1, h2⟩ = a * (b : K)⁻¹ := by
+ protected ratCast_mk : ∀ (a : ℤ) (b : ℕ) (h1 h2), Rat.cast ⟨a, b, h1, h2⟩ = a * (b : K)⁻¹ := by
intros
rfl
/-- Multiplication by a rational number. -/
- protected qsmul : ℚ → K → K := qsmulRec ratCast
+ protected qsmul : ℚ → K → K := qsmulRec Rat.cast
/-- However `qsmul` is defined,
propositionally it must be equal to multiplication by `ratCast`. -/
- protected qsmul_eq_mul' : ∀ (a : ℚ) (x : K), qsmul a x = ratCast a * x := by
+ protected qsmul_eq_mul' : ∀ (a : ℚ) (x : K), qsmul a x = Rat.cast a * x := by
intros
rfl
#align division_ring DivisionRing
@@ -145,15 +136,6 @@ variable [DivisionRing K] {a b : K}
namespace Rat
--- see Note [coercion into rings]
-/-- Construct the canonical injection from `ℚ` into an arbitrary
- division ring. If the field has positive characteristic `p`,
- we define `1 / p = 1 / 0 = 0` for consistency with our
- division by zero convention. -/
-instance (priority := 900) castCoe {K : Type _} [RatCast K] : CoeTC ℚ K :=
- ⟨RatCast.ratCast⟩
-#align rat.cast_coe Rat.castCoe
-
theorem cast_mk' (a b h1 h2) : ((⟨a, b, h1, h2⟩ : ℚ) : K) = a * (b : K)⁻¹ :=
DivisionRing.ratCast_mk _ _ _ _
#align rat.cast_mk' Rat.cast_mk'
@@ -68,12 +68,12 @@ def Rat.castRec [NatCast K] [IntCast K] [Mul K] [Inv K] : ℚ → K
/-- Type class for the canonical homomorphism `ℚ → K`.
-/
-class HasRatCast (K : Type u) where
+class RatCast (K : Type u) where
/-- The canonical homomorphism `ℚ → K`. -/
protected ratCast : ℚ → K
-#align has_rat_cast HasRatCast
+#align has_rat_cast RatCast
-attribute [coe] HasRatCast.ratCast
+attribute [coe] RatCast.ratCast
/-- The default definition of the scalar multiplication `(a : ℚ) • (x : K)` for a division ring `K`
is given by `a • x = (↑ a) * x`.
@@ -97,7 +97,7 @@ The fields `ratCast` and `qsmul` are needed to implement the
definitions for some special cases of `K` (in particular `K = ℚ` itself).
See also Note [forgetful inheritance].
-/
-class DivisionRing (K : Type u) extends Ring K, DivInvMonoid K, Nontrivial K, HasRatCast K where
+class DivisionRing (K : Type u) extends Ring K, DivInvMonoid K, Nontrivial K, RatCast K where
/-- For a nonzero `a`, `a⁻¹` is a right multiplicative inverse. -/
protected mul_inv_cancel : ∀ (a : K), a ≠ 0 → a * a⁻¹ = 1
/-- We define the inverse of `0` to be `0`. -/
@@ -150,8 +150,8 @@ namespace Rat
division ring. If the field has positive characteristic `p`,
we define `1 / p = 1 / 0 = 0` for consistency with our
division by zero convention. -/
-instance (priority := 900) castCoe {K : Type _} [HasRatCast K] : CoeTC ℚ K :=
- ⟨HasRatCast.ratCast⟩
+instance (priority := 900) castCoe {K : Type _} [RatCast K] : CoeTC ℚ K :=
+ ⟨RatCast.ratCast⟩
#align rat.cast_coe Rat.castCoe
theorem cast_mk' (a b h1 h2) : ((⟨a, b, h1, h2⟩ : ℚ) : K) = a * (b : K)⁻¹ :=
@@ -73,6 +73,8 @@ class HasRatCast (K : Type u) where
protected ratCast : ℚ → K
#align has_rat_cast HasRatCast
+attribute [coe] HasRatCast.ratCast
+
/-- The default definition of the scalar multiplication `(a : ℚ) • (x : K)` for a division ring `K`
is given by `a • x = (↑ a) * x`.
Use `(a : ℚ) • (x : K)` instead of `qsmulRec` for better definitional behaviour.
@@ -60,7 +60,7 @@ variable {α β K : Type _}
/-- The default definition of the coercion `(↑(a : ℚ) : K)` for a division ring `K`
is defined as `(a / b : K) = (a : K) * (b : K)⁻¹`.
-Use `coe` instead of `rat.castRec` for better definitional behaviour.
+Use `coe` instead of `Rat.castRec` for better definitional behaviour.
-/
def Rat.castRec [NatCast K] [IntCast K] [Mul K] [Inv K] : ℚ → K
| ⟨a, b, _, _⟩ => ↑a * (↑b)⁻¹
@@ -200,13 +200,13 @@ structure IsField (R : Type u) [Semiring R] : Prop where
mul_inv_cancel : ∀ {a : R}, a ≠ 0 → ∃ b, a * b = 1
#align is_field IsField
-/-- Transferring from `semifield` to `is_field`. -/
+/-- Transferring from `Semifield` to `IsField`. -/
theorem Semifield.toIsField (R : Type u) [Semifield R] : IsField R :=
{ ‹Semifield R› with
mul_inv_cancel := @fun a ha => ⟨a⁻¹, mul_inv_cancel a ha⟩ }
#align semifield.to_is_field Semifield.toIsField
-/-- Transferring from `field` to `is_field`. -/
+/-- Transferring from `Field` to `IsField`. -/
theorem Field.toIsField (R : Type u) [Field R] : IsField R :=
Semifield.toIsField _
#align field.to_is_field Field.toIsField
@@ -225,7 +225,7 @@ theorem not_isField_of_subsingleton (R : Type u) [Semiring R] [Subsingleton R] :
open Classical
-/-- Transferring from `is_field` to `semifield`. -/
+/-- Transferring from `IsField` to `Semifield`. -/
noncomputable def IsField.toSemifield {R : Type u} [Semiring R] (h : IsField R) : Semifield R :=
{ ‹Semiring R›, h with
inv := fun a => if ha : a = 0 then 0 else Classical.choose (IsField.mul_inv_cancel h ha),
@@ -235,7 +235,7 @@ noncomputable def IsField.toSemifield {R : Type u} [Semiring R] (h : IsField R)
exact dif_neg ha }
#align is_field.to_semifield IsField.toSemifield
-/-- Transferring from `is_field` to `field`. -/
+/-- Transferring from `IsField` to `Field`. -/
noncomputable def IsField.toField {R : Type u} [Ring R] (h : IsField R) : Field R :=
{ ‹Ring R›, IsField.toSemifield h with }
#align is_field.to_field IsField.toField
@@ -244,7 +244,7 @@ noncomputable def IsField.toField {R : Type u} [Ring R] (h : IsField R) : Field
Since `IsField` doesn't remember the data of an `inv` function and as such,
a lemma that there is a unique inverse could be useful.
-/
-theorem uniq_inv_of_is_field (R : Type u) [Ring R] (hf : IsField R) :
+theorem uniq_inv_of_isField (R : Type u) [Ring R] (hf : IsField R) :
∀ x : R, x ≠ 0 → ∃! y : R, x * y = 1 := by
intro x hx
apply exists_unique_of_exists_of_unique
@@ -256,7 +256,6 @@ theorem uniq_inv_of_is_field (R : Type u) [Ring R] (hf : IsField R) :
_ = x * y * z := by rw [← mul_assoc, hf.mul_comm y x]
_ = z := by rw [hxy, one_mul]
-
-#align uniq_inv_of_is_field uniq_inv_of_is_field
+#align uniq_inv_of_is_field uniq_inv_of_isField
end IsField
@@ -62,7 +62,7 @@ variable {α β K : Type _}
is defined as `(a / b : K) = (a : K) * (b : K)⁻¹`.
Use `coe` instead of `rat.castRec` for better definitional behaviour.
-/
-def Rat.castRec [CoeTail ℕ K] [CoeTail ℤ K] [Mul K] [Inv K] : ℚ → K
+def Rat.castRec [NatCast K] [IntCast K] [Mul K] [Inv K] : ℚ → K
| ⟨a, b, _, _⟩ => ↑a * (↑b)⁻¹
#align rat.cast_rec Rat.castRec
The script used to do this is included. The yaml file was obtained from https://raw.githubusercontent.com/wiki/leanprover-community/mathlib/mathlib4-port-status.md
@@ -2,6 +2,11 @@
Copyright (c) 2014 Robert Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Lewis, Leonardo de Moura, Johannes Hölzl, Mario Carneiro
+
+! This file was ported from Lean 3 source module algebra.field.defs
+! leanprover-community/mathlib commit 70d50ecfd4900dd6d328da39ab7ebd516abe4025
+! Please do not edit these lines, except to modify the commit id
+! if you have ported upstream changes.
-/
import Mathlib.Algebra.Ring.Defs
All dependencies are ported!