feat(library): replace same 'calc' proofs with 'rewrite'

This commit is contained in:
Leonardo de Moura 2015-02-05 10:39:25 -08:00
parent b6dd1269b9
commit 2ffdbba8b0
2 changed files with 5 additions and 20 deletions

View file

@ -151,32 +151,20 @@ section group
theorem mul.left_inv (a : A) : a⁻¹ * a = 1 := !group.mul_left_inv theorem mul.left_inv (a : A) : a⁻¹ * a = 1 := !group.mul_left_inv
theorem inv_mul_cancel_left (a b : A) : a⁻¹ * (a * b) = b := theorem inv_mul_cancel_left (a b : A) : a⁻¹ * (a * b) = b :=
calc by rewrite ⟨-mul.assoc, mul.left_inv, one_mul⟩
a⁻¹ * (a * b) = a⁻¹ * a * b : !mul.assoc⁻¹
... = 1 * b : mul.left_inv
... = b : one_mul
theorem inv_mul_cancel_right (a b : A) : a * b⁻¹ * b = a := theorem inv_mul_cancel_right (a b : A) : a * b⁻¹ * b = a :=
calc by rewrite ⟨mul.assoc, mul.left_inv, mul_one⟩
a * b⁻¹ * b = a * (b⁻¹ * b) : mul.assoc
... = a * 1 : mul.left_inv
... = a : mul_one
theorem inv_eq_of_mul_eq_one {a b : A} (H : a * b = 1) : a⁻¹ = b := theorem inv_eq_of_mul_eq_one {a b : A} (H : a * b = 1) : a⁻¹ = b :=
calc by rewrite ⟨-(mul_one a⁻¹), -H, inv_mul_cancel_left⟩
a⁻¹ = a⁻¹ * 1 : !mul_one⁻¹
... = a⁻¹ * (a * b) : H
... = b : inv_mul_cancel_left
theorem inv_one : 1⁻¹ = 1 := inv_eq_of_mul_eq_one (one_mul 1) theorem inv_one : 1⁻¹ = 1 := inv_eq_of_mul_eq_one (one_mul 1)
theorem inv_inv (a : A) : (a⁻¹)⁻¹ = a := inv_eq_of_mul_eq_one (mul.left_inv a) theorem inv_inv (a : A) : (a⁻¹)⁻¹ = a := inv_eq_of_mul_eq_one (mul.left_inv a)
theorem inv.inj {a b : A} (H : a⁻¹ = b⁻¹) : a = b := theorem inv.inj {a b : A} (H : a⁻¹ = b⁻¹) : a = b :=
calc by rewrite ⟨-inv_inv, H, inv_inv⟩
a = (a⁻¹)⁻¹ : !inv_inv⁻¹
... = (b⁻¹)⁻¹ : H
... = b : inv_inv
theorem inv_eq_inv_iff_eq (a b : A) : a⁻¹ = b⁻¹ ↔ a = b := theorem inv_eq_inv_iff_eq (a b : A) : a⁻¹ = b⁻¹ ↔ a = b :=
iff.intro (assume H, inv.inj H) (assume H, congr_arg _ H) iff.intro (assume H, inv.inj H) (assume H, congr_arg _ H)

View file

@ -105,10 +105,7 @@ theorem lt_add_of_pos_right {n k : } (H : k > 0) : n < n + k :=
theorem mul_le_mul_left {n m : } (H : n ≤ m) (k : ) : k * n ≤ k * m := theorem mul_le_mul_left {n m : } (H : n ≤ m) (k : ) : k * n ≤ k * m :=
obtain (l : ) (Hl : n + l = m), from le.elim H, obtain (l : ) (Hl : n + l = m), from le.elim H,
have H2 : k * n + k * l = k * m, from have H2 : k * n + k * l = k * m, by rewrite ⟨-mul.left_distrib, Hl⟩,
calc
k * n + k * l = k * (n + l) : mul.left_distrib
... = k * m : {Hl},
le.intro H2 le.intro H2
theorem mul_le_mul_right {n m : } (H : n ≤ m) (k : ) : n * k ≤ m * k := theorem mul_le_mul_right {n m : } (H : n ≤ m) (k : ) : n * k ≤ m * k :=