Skip to content

Commit

Permalink
feat(algebra/euclidean_domain): div_zero
Browse files Browse the repository at this point in the history
  • Loading branch information
kckennylau committed Feb 1, 2019
1 parent 89bc63c commit 7c48e5f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/algebra/euclidean_domain.lean
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ universe u

class euclidean_domain (α : Type u) extends nonzero_comm_ring α :=
(quotient : α → α → α)
(quotient_zero : ∀ a, quotient a 0 = 0)
(remainder : α → α → α)
-- This could be changed to the same order as int.mod_add_div.
-- We normally write qb+r rather than r + qb though.
Expand Down Expand Up @@ -98,6 +99,9 @@ mod_eq_zero.2 (dvd_zero _)
@[simp] lemma zero_div {a : α} (a0 : a ≠ 0) : 0 / a = 0 :=
by simpa only [zero_mul] using mul_div_cancel 0 a0

@[simp] lemma div_zero (a : α) : a / 0 = 0 :=
quotient_zero a

@[simp] lemma div_self {a : α} (a0 : a ≠ 0) : a / a = 1 :=
by simpa only [one_mul] using mul_div_cancel 1 a0

Expand Down Expand Up @@ -232,6 +236,7 @@ end gcd

instance : euclidean_domain ℤ :=
{ quotient := (/),
quotient_zero := int.div_zero,
remainder := (%),
quotient_mul_add_remainder_eq := λ a b, by rw add_comm; exact int.mod_add_div _ _,
r := λ a b, a.nat_abs < b.nat_abs,
Expand Down
4 changes: 1 addition & 3 deletions src/data/polynomial.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1678,6 +1678,7 @@ div_by_monic_eq_div p (monic_X_sub_C a) ▸ mul_div_by_monic_eq_iff_is_root

instance : euclidean_domain (polynomial α) :=
{ quotient := (/),
quotient_zero := by simp [div_def],
remainder := (%),
r := _,
r_well_founded := degree_lt_wf,
Expand All @@ -1703,9 +1704,6 @@ lemma div_eq_zero_iff (hq0 : q ≠ 0) : p / q = 0 ↔ degree p < degree q :=
have hm : monic (q * C (leading_coeff q)⁻¹) := monic_mul_leading_coeff_inv hq0,
by rw [div_def, (div_by_monic_eq_zero_iff hm (ne_zero_of_monic hm)).2 hlt, mul_zero]⟩

@[simp] lemma div_zero : p / 0 = 0 :=
by simp [div_def]

lemma degree_add_div (hq0 : q ≠ 0) (hpq : degree q ≤ degree p) :
degree q + degree (p / q) = degree p :=
have degree (p % q) < degree (q * (p / q)) :=
Expand Down

0 comments on commit 7c48e5f

Please sign in to comment.