2015-02-18 21:42:45 +00:00
|
|
|
|
/-
|
|
|
|
|
Copyright (c) 2014 Robert Lewis. All rights reserved.
|
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
|
|
Module: algebra.field
|
|
|
|
|
Authors: Robert Lewis
|
|
|
|
|
|
2015-02-18 22:33:41 +00:00
|
|
|
|
Structures with multiplicative and additive components, including division rings and fields.
|
2015-02-18 21:42:45 +00:00
|
|
|
|
The development is modeled after Isabelle's library.
|
|
|
|
|
-/
|
2015-02-23 18:05:24 +00:00
|
|
|
|
----------------------------------------------------------------------------------------------------
|
2015-02-18 21:42:45 +00:00
|
|
|
|
import logic.eq logic.connectives data.unit data.sigma data.prod
|
|
|
|
|
import algebra.function algebra.binary algebra.group algebra.ring
|
|
|
|
|
open eq eq.ops
|
|
|
|
|
|
|
|
|
|
namespace algebra
|
|
|
|
|
|
|
|
|
|
variable {A : Type}
|
|
|
|
|
|
2015-03-25 21:08:36 +00:00
|
|
|
|
structure division_ring [class] (A : Type) extends ring A, has_inv A, zero_ne_one_class A :=
|
2015-02-18 21:42:45 +00:00
|
|
|
|
(mul_inv_cancel : ∀{a}, a ≠ zero → mul a (inv a) = one)
|
|
|
|
|
(inv_mul_cancel : ∀{a}, a ≠ zero → mul (inv a) a = one)
|
|
|
|
|
|
|
|
|
|
section division_ring
|
|
|
|
|
variables [s : division_ring A] {a b c : A}
|
|
|
|
|
include s
|
|
|
|
|
|
|
|
|
|
definition divide (a b : A) : A := a * b⁻¹
|
|
|
|
|
infix `/` := divide
|
|
|
|
|
|
2015-02-19 20:17:21 +00:00
|
|
|
|
-- only in this file
|
|
|
|
|
local attribute divide [reducible]
|
|
|
|
|
|
2015-02-18 21:42:45 +00:00
|
|
|
|
theorem mul_inv_cancel (H : a ≠ 0) : a * a⁻¹ = 1 :=
|
|
|
|
|
division_ring.mul_inv_cancel H
|
|
|
|
|
|
|
|
|
|
theorem inv_mul_cancel (H : a ≠ 0) : a⁻¹ * a = 1 :=
|
|
|
|
|
division_ring.inv_mul_cancel H
|
|
|
|
|
|
2015-02-19 20:17:21 +00:00
|
|
|
|
theorem inv_eq_one_div : a⁻¹ = 1 / a := !one_mul⁻¹
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
2015-02-27 20:44:36 +00:00
|
|
|
|
theorem div_eq_mul_one_div : a / b = a * (1 / b) :=
|
2015-03-25 21:08:36 +00:00
|
|
|
|
by rewrite [↑divide, one_mul]
|
2015-02-27 20:44:36 +00:00
|
|
|
|
|
2015-02-18 21:42:45 +00:00
|
|
|
|
theorem mul_one_div_cancel (H : a ≠ 0) : a * (1 / a) = 1 :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
by rewrite [-inv_eq_one_div, (mul_inv_cancel H)]
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
theorem one_div_mul_cancel (H : a ≠ 0) : (1 / a) * a = 1 :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
by rewrite [-inv_eq_one_div, (inv_mul_cancel H)]
|
2015-03-25 21:08:36 +00:00
|
|
|
|
|
2015-02-19 20:17:21 +00:00
|
|
|
|
theorem div_self (H : a ≠ 0) : a / a = 1 := mul_inv_cancel H
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
2015-02-23 18:05:24 +00:00
|
|
|
|
theorem mul_div_assoc : (a * b) / c = a * (b / c) := !mul.assoc
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
theorem one_div_ne_zero (H : a ≠ 0) : 1 / a ≠ 0 :=
|
|
|
|
|
assume H2 : 1 / a = 0,
|
2015-03-25 21:08:36 +00:00
|
|
|
|
have C1 : 0 = 1, from symm (by rewrite [-(mul_one_div_cancel H), H2, mul_zero]),
|
2015-02-27 20:44:36 +00:00
|
|
|
|
absurd C1 zero_ne_one
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
-- the analogue in group is called inv_one
|
|
|
|
|
theorem inv_one_is_one : 1⁻¹ = 1 :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
by rewrite [-mul_one, (inv_mul_cancel (ne.symm zero_ne_one))]
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
theorem div_one : a / 1 = a :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
by rewrite [↑divide, inv_one_is_one, mul_one]
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
2015-02-23 18:05:24 +00:00
|
|
|
|
theorem zero_div : 0 / a = 0 := !zero_mul
|
|
|
|
|
|
|
|
|
|
-- note: integral domain has a "mul_ne_zero". Discrete fields are int domains.
|
2015-02-18 21:42:45 +00:00
|
|
|
|
theorem mul_ne_zero' (Ha : a ≠ 0) (Hb : b ≠ 0) : a * b ≠ 0 :=
|
|
|
|
|
assume H : a * b = 0,
|
2015-02-27 20:44:36 +00:00
|
|
|
|
have C1 : a = 0, by rewrite [-mul_one, -(mul_one_div_cancel Hb), -mul.assoc, H, zero_mul],
|
2015-02-18 21:42:45 +00:00
|
|
|
|
absurd C1 Ha
|
|
|
|
|
|
2015-02-23 18:05:24 +00:00
|
|
|
|
-- this belongs in ring?
|
2015-02-18 21:42:45 +00:00
|
|
|
|
theorem mul_ne_zero_imp_ne_zero (H : a * b ≠ 0) : a ≠ 0 ∧ b ≠ 0 :=
|
|
|
|
|
have Ha : a ≠ 0, from
|
|
|
|
|
(assume Ha1 : a = 0,
|
2015-02-27 20:44:36 +00:00
|
|
|
|
have H1 : a * b = 0, by rewrite [Ha1, zero_mul],
|
2015-02-18 21:42:45 +00:00
|
|
|
|
absurd H1 H),
|
|
|
|
|
have Hb : b ≠ 0, from
|
|
|
|
|
(assume Hb1 : b = 0,
|
2015-02-27 20:44:36 +00:00
|
|
|
|
have H1 : a * b = 0, by rewrite [Hb1, mul_zero],
|
2015-02-18 21:42:45 +00:00
|
|
|
|
absurd H1 H),
|
|
|
|
|
and.intro Ha Hb
|
|
|
|
|
|
|
|
|
|
theorem mul_ne_zero_comm (H : a * b ≠ 0) : b * a ≠ 0 :=
|
|
|
|
|
have H2 : a ≠ 0 ∧ b ≠ 0, from mul_ne_zero_imp_ne_zero H,
|
|
|
|
|
mul_ne_zero' (and.right H2) (and.left H2)
|
|
|
|
|
|
|
|
|
|
-- theorem inv_zero_imp_zero (H : a⁻¹ = 0) : a = 0 :=
|
|
|
|
|
-- classical?
|
|
|
|
|
|
|
|
|
|
-- make "left" and "right" versions?
|
|
|
|
|
theorem eq_one_div_of_mul_eq_one (H : a * b = 1) : b = 1 / a :=
|
2015-03-25 21:08:36 +00:00
|
|
|
|
have H2 : a ≠ 0, from
|
2015-02-18 21:42:45 +00:00
|
|
|
|
(assume A : a = 0,
|
2015-02-27 20:44:36 +00:00
|
|
|
|
have B : 0 = 1, by rewrite [-(zero_mul b), -A, H],
|
2015-02-18 21:42:45 +00:00
|
|
|
|
absurd B zero_ne_one),
|
|
|
|
|
show b = 1 / a, from symm (calc
|
2015-02-27 20:44:36 +00:00
|
|
|
|
1 / a = (1 / a) * 1 : mul_one
|
|
|
|
|
... = (1 / a) * (a * b) : H
|
|
|
|
|
... = (1 / a) * a * b : mul.assoc
|
|
|
|
|
... = 1 * b : one_div_mul_cancel H2
|
|
|
|
|
... = b : one_mul)
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
-- which one is left and which is right?
|
|
|
|
|
theorem eq_one_div_of_mul_eq_one_left (H : b * a = 1) : b = 1 / a :=
|
2015-03-25 21:08:36 +00:00
|
|
|
|
have H2 : a ≠ 0, from
|
2015-02-18 21:42:45 +00:00
|
|
|
|
(assume A : a = 0,
|
|
|
|
|
have B : 0 = 1, from symm (calc
|
|
|
|
|
1 = b * a : symm H
|
|
|
|
|
... = b * 0 : A
|
2015-02-27 20:44:36 +00:00
|
|
|
|
... = 0 : mul_zero),
|
2015-02-18 21:42:45 +00:00
|
|
|
|
absurd B zero_ne_one),
|
|
|
|
|
show b = 1 / a, from symm (calc
|
2015-02-27 20:44:36 +00:00
|
|
|
|
1 / a = 1 * (1 / a) : one_mul
|
|
|
|
|
... = b * a * (1 / a) : H
|
|
|
|
|
... = b * (a * (1 / a)) : mul.assoc
|
|
|
|
|
... = b * 1 : mul_one_div_cancel H2
|
|
|
|
|
... = b : mul_one)
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
theorem one_div_mul_one_div (Ha : a ≠ 0) (Hb : b ≠ 0) : (1 / a) * (1 / b) = 1 / (b * a) :=
|
2015-03-25 21:08:36 +00:00
|
|
|
|
have H : (b * a) * ((1 / a) * (1 / b)) = 1, by
|
2015-02-27 20:44:36 +00:00
|
|
|
|
rewrite [mul.assoc, -(mul.assoc a), (mul_one_div_cancel Ha), one_mul, (mul_one_div_cancel Hb)],
|
2015-03-25 21:08:36 +00:00
|
|
|
|
eq_one_div_of_mul_eq_one H
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
theorem one_div_neg_one_eq_neg_one : 1 / (-1) = -1 :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
have H : (-1) * (-1) = 1, by rewrite [-neg_eq_neg_one_mul, neg_neg],
|
2015-02-18 21:42:45 +00:00
|
|
|
|
symm (eq_one_div_of_mul_eq_one H)
|
|
|
|
|
|
|
|
|
|
-- this should be in ring
|
|
|
|
|
theorem mul_neg_one_eq_neg : a * (-1) = -a :=
|
|
|
|
|
have H : a + a * -1 = 0, from calc
|
|
|
|
|
a + a * -1 = a * 1 + a * -1 : mul_one
|
2015-02-27 20:44:36 +00:00
|
|
|
|
... = a * (1 + -1) : left_distrib
|
|
|
|
|
... = a * 0 : add.right_inv
|
2015-03-25 21:08:36 +00:00
|
|
|
|
... = 0 : mul_zero,
|
2015-02-18 21:42:45 +00:00
|
|
|
|
symm (neg_eq_of_add_eq_zero H)
|
|
|
|
|
|
2015-03-25 21:08:36 +00:00
|
|
|
|
theorem one_div_neg_eq_neg_one_div (H : a ≠ 0) : 1 / (- a) = - (1 / a) :=
|
2015-02-18 21:42:45 +00:00
|
|
|
|
have H1 : -1 ≠ 0, from
|
|
|
|
|
(assume H2 : -1 = 0, absurd (symm (calc
|
2015-02-27 20:44:36 +00:00
|
|
|
|
1 = -(-1) : neg_neg
|
|
|
|
|
... = -0 : H2
|
|
|
|
|
... = 0 : neg_zero)) zero_ne_one),
|
2015-02-18 21:42:45 +00:00
|
|
|
|
calc
|
2015-02-27 20:44:36 +00:00
|
|
|
|
1 / (- a) = 1 / ((-1) * a) : neg_eq_neg_one_mul
|
2015-03-25 21:08:36 +00:00
|
|
|
|
... = (1 / a) * (1 / (- 1)) : one_div_mul_one_div H H1
|
2015-02-27 20:44:36 +00:00
|
|
|
|
... = (1 / a) * (-1) : one_div_neg_one_eq_neg_one
|
|
|
|
|
... = - (1 / a) : mul_neg_one_eq_neg
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
2015-02-23 18:05:24 +00:00
|
|
|
|
theorem div_neg_eq_neg_div (Ha : a ≠ 0) : b / (- a) = - (b / a) :=
|
|
|
|
|
calc
|
|
|
|
|
b / (- a) = b * (1 / (- a)) : inv_eq_one_div
|
2015-02-27 20:44:36 +00:00
|
|
|
|
... = b * -(1 / a) : one_div_neg_eq_neg_one_div Ha
|
|
|
|
|
... = -(b * (1 / a)) : neg_mul_eq_mul_neg
|
|
|
|
|
... = - (b * a⁻¹) : inv_eq_one_div
|
2015-02-23 18:05:24 +00:00
|
|
|
|
|
|
|
|
|
theorem neg_div (Ha : a ≠ 0) : (-b) / a = - (b / a) :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
by rewrite [neg_eq_neg_one_mul, mul_div_assoc, -neg_eq_neg_one_mul]
|
2015-02-23 18:05:24 +00:00
|
|
|
|
|
|
|
|
|
theorem neg_div_neg_eq_div (Hb : b ≠ 0) : (-a) / (-b) = a / b :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
by rewrite [(div_neg_eq_neg_div Hb), (neg_div Hb), neg_neg]
|
2015-02-23 18:05:24 +00:00
|
|
|
|
|
2015-02-18 21:42:45 +00:00
|
|
|
|
theorem div_div (H : a ≠ 0) : 1 / (1 / a) = a :=
|
|
|
|
|
symm (eq_one_div_of_mul_eq_one_left (mul_one_div_cancel H))
|
|
|
|
|
|
|
|
|
|
theorem eq_of_invs_eq (Ha : a ≠ 0) (Hb : b ≠ 0) (H : 1 / a = 1 / b) : a = b :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
by rewrite [-(div_div Ha), H, (div_div Hb)]
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
-- oops, the analogous theorem in group is called inv_mul, but it *should* be called
|
|
|
|
|
-- mul_inv, in which case, we will have to rename this one
|
|
|
|
|
theorem mul_inv (Ha : a ≠ 0) (Hb : b ≠ 0) : (b * a)⁻¹ = a⁻¹ * b⁻¹ :=
|
|
|
|
|
have H1 : b * a ≠ 0, from mul_ne_zero' Hb Ha,
|
|
|
|
|
eq.symm (calc
|
2015-02-19 20:17:21 +00:00
|
|
|
|
a⁻¹ * b⁻¹ = (1 / a) * b⁻¹ : inv_eq_one_div
|
|
|
|
|
... = (1 / a) * (1 / b) : inv_eq_one_div
|
2015-02-18 21:42:45 +00:00
|
|
|
|
... = (1 / (b * a)) : one_div_mul_one_div Ha Hb
|
2015-02-19 20:17:21 +00:00
|
|
|
|
... = (b * a)⁻¹ : inv_eq_one_div)
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
theorem mul_div_cancel (Hb : b ≠ 0) : a * b / b = a :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
by rewrite [↑divide, mul.assoc, (mul_inv_cancel Hb), mul_one]
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
theorem div_mul_cancel (Hb : b ≠ 0) : a / b * b = a :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
by rewrite [↑divide, mul.assoc, (inv_mul_cancel Hb), mul_one]
|
2015-03-25 21:08:36 +00:00
|
|
|
|
|
2015-02-23 18:05:24 +00:00
|
|
|
|
theorem div_add_div_same : a / c + b / c = (a + b) / c := !right_distrib⁻¹
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
2015-02-18 22:33:41 +00:00
|
|
|
|
theorem inv_mul_add_mul_inv_eq_inv_add_inv (Ha : a ≠ 0) (Hb : b ≠ 0) :
|
|
|
|
|
(1 / a) * (a + b) * (1 / b) = 1 / a + 1 / b :=
|
|
|
|
|
by rewrite [(left_distrib (1 / a)), (one_div_mul_cancel Ha), right_distrib, one_mul,
|
|
|
|
|
mul.assoc, (mul_one_div_cancel Hb), mul_one, add.comm]
|
|
|
|
|
|
|
|
|
|
theorem inv_mul_sub_mul_inv_eq_inv_add_inv (Ha : a ≠ 0) (Hb : b ≠ 0) :
|
|
|
|
|
(1 / a) * (b - a) * (1 / b) = 1 / a - 1 / b :=
|
|
|
|
|
by rewrite [(mul_sub_left_distrib (1 / a)), (one_div_mul_cancel Ha), mul_sub_right_distrib,
|
2015-02-27 20:44:36 +00:00
|
|
|
|
one_mul, mul.assoc, (mul_one_div_cancel Hb), mul_one, one_mul]
|
2015-02-18 22:33:41 +00:00
|
|
|
|
|
2015-03-25 21:08:36 +00:00
|
|
|
|
theorem div_eq_one_iff_eq (Hb : b ≠ 0) : a / b = 1 ↔ a = b :=
|
2015-02-18 22:33:41 +00:00
|
|
|
|
iff.intro
|
|
|
|
|
(assume H1 : a / b = 1, symm (calc
|
2015-02-27 20:44:36 +00:00
|
|
|
|
b = 1 * b : one_mul
|
2015-02-18 22:33:41 +00:00
|
|
|
|
... = a / b * b : H1
|
2015-02-27 20:44:36 +00:00
|
|
|
|
... = a : div_mul_cancel Hb))
|
2015-02-18 22:33:41 +00:00
|
|
|
|
(assume H2 : a = b, calc
|
|
|
|
|
a / b = b / b : H2
|
2015-02-27 20:44:36 +00:00
|
|
|
|
... = 1 : div_self Hb)
|
2015-02-18 22:33:41 +00:00
|
|
|
|
|
2015-02-23 18:05:24 +00:00
|
|
|
|
theorem eq_div_iff_mul_eq (Hc : c ≠ 0) : a = b / c ↔ a * c = b :=
|
|
|
|
|
iff.intro
|
2015-02-27 20:44:36 +00:00
|
|
|
|
(assume H : a = b / c, by rewrite [H, (div_mul_cancel Hc)])
|
|
|
|
|
(assume H : a * c = b, by rewrite [-(mul_div_cancel Hc), H])
|
2015-02-23 18:05:24 +00:00
|
|
|
|
|
|
|
|
|
theorem add_div_eq_mul_add_div (Hc : c ≠ 0) : a + b / c = (a * c + b) / c :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
have H : (a + b / c) * c = a * c + b, by rewrite [right_distrib, (div_mul_cancel Hc)],
|
2015-02-23 18:05:24 +00:00
|
|
|
|
(iff.elim_right (eq_div_iff_mul_eq Hc)) H
|
|
|
|
|
|
2015-02-27 20:44:36 +00:00
|
|
|
|
-- There are many similar rules to these last two in the Isabelle library
|
|
|
|
|
-- that haven't been ported yet. Do as necessary.
|
|
|
|
|
|
2015-02-18 21:42:45 +00:00
|
|
|
|
end division_ring
|
|
|
|
|
|
2015-02-19 20:17:21 +00:00
|
|
|
|
structure field [class] (A : Type) extends division_ring A, comm_ring A
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
section field
|
|
|
|
|
variables [s : field A] {a b c d: A}
|
|
|
|
|
include s
|
2015-02-23 18:05:24 +00:00
|
|
|
|
local attribute divide [reducible]
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
2015-02-27 20:44:36 +00:00
|
|
|
|
theorem one_div_mul_one_div' (Ha : a ≠ 0) (Hb : b ≠ 0) : (1 / a) * (1 / b) = 1 / (a * b) :=
|
|
|
|
|
by rewrite [(one_div_mul_one_div Ha Hb), mul.comm b]
|
|
|
|
|
|
2015-02-19 20:17:21 +00:00
|
|
|
|
theorem div_mul_right (Hb : b ≠ 0) (H : a * b ≠ 0) : a / (a * b) = 1 / b :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
let Ha : a ≠ 0 := and.left (mul_ne_zero_imp_ne_zero H) in
|
2015-02-18 21:42:45 +00:00
|
|
|
|
symm (calc
|
2015-02-27 20:44:36 +00:00
|
|
|
|
1 / b = 1 * (1 / b) : one_mul
|
|
|
|
|
... = (a * a⁻¹) * (1 / b) : mul_inv_cancel Ha
|
|
|
|
|
... = a * (a⁻¹ * (1 / b)) : mul.assoc
|
|
|
|
|
... = a * ((1 / a) * (1 / b)) :inv_eq_one_div
|
|
|
|
|
... = a * (1 / (b * a)) : one_div_mul_one_div Ha Hb
|
|
|
|
|
... = a * (1 / (a * b)) : mul.comm
|
|
|
|
|
... = a * (a * b)⁻¹ : inv_eq_one_div)
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
2015-02-19 20:17:21 +00:00
|
|
|
|
theorem div_mul_left (Ha : a ≠ 0) (H : a * b ≠ 0) : b / (a * b) = 1 / a :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
let H1 : b * a ≠ 0 := mul_ne_zero_comm H in
|
|
|
|
|
by rewrite [mul.comm a, (div_mul_right Ha H1)]
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
theorem mul_div_cancel_left (Ha : a ≠ 0) : a * b / a = b :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
by rewrite [mul.comm a, (mul_div_cancel Ha)]
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
theorem mul_div_cancel' (Hb : b ≠ 0) : b * (a / b) = a :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
by rewrite [mul.comm, (div_mul_cancel Hb)]
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
theorem one_div_add_one_div (Ha : a ≠ 0) (Hb : b ≠ 0) : 1 / a + 1 / b = (a + b) / (a * b) :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
have H [visible] : a * b ≠ 0, from (mul_ne_zero' Ha Hb),
|
|
|
|
|
by rewrite [add.comm, -(div_mul_left Ha H), -(div_mul_right Hb H), ↑divide, -right_distrib]
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
theorem div_mul_div (Hb : b ≠ 0) (Hd : d ≠ 0) : (a / b) * (c / d) = (a * c) / (b * d) :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
by rewrite [↑divide, 2 mul.assoc, (mul.comm b⁻¹), mul.assoc, (mul_inv Hd Hb)]
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
theorem mul_div_mul_left (Hb : b ≠ 0) (Hc : c ≠ 0) : (c * a) / (c * b) = a / b :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
have H [visible] : c * b ≠ 0, from mul_ne_zero' Hc Hb,
|
|
|
|
|
by rewrite [-(div_mul_div Hc Hb), (div_self Hc), one_mul]
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
theorem mul_div_mul_right (Hb : b ≠ 0) (Hc : c ≠ 0) : (a * c) / (b * c) = a / b :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
by rewrite [(mul.comm a), (mul.comm b), (mul_div_mul_left Hb Hc)]
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
theorem div_mul_eq_mul_div (Hc : c ≠ 0) : (b / c) * a = (b * a) / c :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
by rewrite [↑divide, mul.assoc, (mul.comm c⁻¹), -mul.assoc]
|
2015-03-25 21:08:36 +00:00
|
|
|
|
|
2015-02-18 21:42:45 +00:00
|
|
|
|
-- this one is odd -- I am not sure what to call it, but again, the prefix is right
|
|
|
|
|
theorem div_mul_eq_mul_div_comm (Hc : c ≠ 0) : (b / c) * a = b * (a / c) :=
|
2015-03-25 21:08:36 +00:00
|
|
|
|
by rewrite [(div_mul_eq_mul_div Hc), -(one_mul c), -(div_mul_div (ne.symm zero_ne_one) Hc), div_one, one_mul]
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
theorem div_add_div (Hb : b ≠ 0) (Hd : d ≠ 0) :
|
|
|
|
|
(a / b) + (c / d) = ((a * d) + (b * c)) / (b * d) :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
have H [visible] : b * d ≠ 0, from mul_ne_zero' Hb Hd,
|
|
|
|
|
by rewrite [-(mul_div_mul_right Hb Hd), -(mul_div_mul_left Hd Hb), div_add_div_same]
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
theorem div_sub_div (Hb : b ≠ 0) (Hd : d ≠ 0) :
|
|
|
|
|
(a / b) - (c / d) = ((a * d) - (b * c)) / (b * d) :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
by rewrite [↑sub, neg_eq_neg_one_mul, -mul_div_assoc, (div_add_div Hb Hd),
|
|
|
|
|
-mul.assoc, (mul.comm b), mul.assoc, -neg_eq_neg_one_mul]
|
2015-03-25 21:08:36 +00:00
|
|
|
|
|
2015-02-18 21:42:45 +00:00
|
|
|
|
theorem mul_eq_mul_of_div_eq_div (Hb : b ≠ 0) (Hd : d ≠ 0) (H : a / b = c / d) : a * d = c * b :=
|
2015-02-27 20:44:36 +00:00
|
|
|
|
by rewrite [-mul_one, mul.assoc, (mul.comm d), -mul.assoc, -(div_self Hb),
|
|
|
|
|
-(div_mul_eq_mul_div_comm Hb), H, (div_mul_eq_mul_div Hd), (div_mul_cancel Hd)]
|
|
|
|
|
|
|
|
|
|
theorem one_div_div (Ha : a ≠ 0) (Hb : b ≠ 0) : 1 / (a / b) = b / a :=
|
|
|
|
|
have H : (a / b) * (b / a) = 1, from calc
|
|
|
|
|
(a / b) * (b / a) = (a * b) / (b * a) : div_mul_div Hb Ha
|
|
|
|
|
... = (a * b) / (a * b) : mul.comm
|
|
|
|
|
... = 1 : div_self (mul_ne_zero' Ha Hb),
|
|
|
|
|
symm (eq_one_div_of_mul_eq_one H)
|
|
|
|
|
|
|
|
|
|
theorem div_div_eq_mul_div (Hb : b ≠ 0) (Hc : c ≠ 0) : a / (b / c) = (a * c) / b :=
|
|
|
|
|
by rewrite [div_eq_mul_one_div, (one_div_div Hb Hc), -mul_div_assoc]
|
|
|
|
|
|
|
|
|
|
theorem div_div_eq_div_mul (Hb : b ≠ 0) (Hc : c ≠ 0) : (a / b) / c = a / (b * c) :=
|
|
|
|
|
by rewrite [div_eq_mul_one_div, (div_mul_div Hb Hc), mul_one]
|
|
|
|
|
|
|
|
|
|
theorem div_div_div_div (Hb : b ≠ 0) (Hc : c ≠ 0) (Hd : d ≠ 0) : (a / b) / (c / d) = (a * d) / (b * c) :=
|
|
|
|
|
by rewrite [(div_div_eq_mul_div Hc Hd), (div_mul_eq_mul_div Hb), (div_div_eq_div_mul Hb Hc)]
|
|
|
|
|
|
|
|
|
|
-- remaining to transfer from Isabelle fields: ordered fields
|
2015-02-18 21:42:45 +00:00
|
|
|
|
|
|
|
|
|
end field
|
|
|
|
|
|
2015-02-19 20:17:21 +00:00
|
|
|
|
structure discrete_field [class] (A : Type) extends field A :=
|
|
|
|
|
(decidable_equality : ∀x y : A, decidable (x = y))
|
|
|
|
|
|
|
|
|
|
section discrete_field
|
|
|
|
|
variable [s : discrete_field A]
|
|
|
|
|
include s
|
|
|
|
|
variables {a b c : A}
|
|
|
|
|
|
2015-03-03 15:39:36 +00:00
|
|
|
|
-- name clash with order
|
|
|
|
|
definition decidable_eq' [instance] (a b : A) : decidable (a = b) :=
|
|
|
|
|
@discrete_field.decidable_equality A s a b
|
2015-02-19 20:17:21 +00:00
|
|
|
|
|
|
|
|
|
theorem discrete_field.eq_zero_or_eq_zero_of_mul_eq_zero
|
|
|
|
|
(x y : A) (H : x * y = 0) : x = 0 ∨ y = 0 :=
|
|
|
|
|
decidable.by_cases
|
|
|
|
|
(assume H : x = 0, or.inl H)
|
|
|
|
|
(assume H1 : x ≠ 0,
|
2015-03-25 21:08:36 +00:00
|
|
|
|
or.inr (by rewrite [-one_mul, -(inv_mul_cancel H1), mul.assoc, H, mul_zero]))
|
2015-02-19 20:17:21 +00:00
|
|
|
|
|
2015-03-25 21:08:36 +00:00
|
|
|
|
definition discrete_field.to_integral_domain [instance] [reducible] [coercion] :
|
2015-02-19 20:17:21 +00:00
|
|
|
|
integral_domain A :=
|
|
|
|
|
⦃ integral_domain, s,
|
|
|
|
|
eq_zero_or_eq_zero_of_mul_eq_zero := discrete_field.eq_zero_or_eq_zero_of_mul_eq_zero⦄
|
|
|
|
|
|
|
|
|
|
example (H1 : a ≠ 0) (H2 : b ≠ 0) : a * b ≠ 0 :=
|
|
|
|
|
@mul_ne_zero A s a b H1 H2
|
|
|
|
|
|
2015-02-27 20:44:36 +00:00
|
|
|
|
theorem inv_zero_imp_zero (H : 1 / a = 0) : a = 0 :=
|
|
|
|
|
decidable.by_cases
|
|
|
|
|
(assume Ha : a = 0, Ha)
|
|
|
|
|
(assume Ha: a ≠ 0, false.elim ((one_div_ne_zero Ha) H))
|
|
|
|
|
|
2015-02-19 20:17:21 +00:00
|
|
|
|
end discrete_field
|
|
|
|
|
|
2015-02-18 21:42:45 +00:00
|
|
|
|
end algebra
|