|
| 1 | +/- |
| 2 | +Copyright (c) 2014 Jeremy Avigad. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Jeremy Avigad, Leonardo de Moura |
| 5 | +
|
| 6 | +Various multiplicative and additive structures. |
| 7 | +-/ |
| 8 | +import pending |
| 9 | + |
| 10 | +universe variable uu |
| 11 | +variable {A : Type uu} |
| 12 | + |
| 13 | +section group |
| 14 | + variable [group A] |
| 15 | + |
| 16 | + variable (A) |
| 17 | + theorem left_inverse_inv : function.left_inverse (λ a : A, a⁻¹) (λ a, a⁻¹) := |
| 18 | + assume a, inv_inv a |
| 19 | + variable {A} |
| 20 | + |
| 21 | + theorem inv_eq_inv_iff_eq (a b : A) : a⁻¹ = b⁻¹ ↔ a = b := |
| 22 | + iff.intro inv_inj (begin intro h, simp [h] end) |
| 23 | + |
| 24 | + theorem inv_eq_one_iff_eq_one (a : A) : a⁻¹ = 1 ↔ a = 1 := |
| 25 | + have a⁻¹ = 1⁻¹ ↔ a = 1, from inv_eq_inv_iff_eq a 1, |
| 26 | + begin rewrite this^.symm, simp end |
| 27 | + |
| 28 | + theorem eq_one_of_inv_eq_one (a : A) : a⁻¹ = 1 → a = 1 := |
| 29 | + iff.mp (inv_eq_one_iff_eq_one a) |
| 30 | + |
| 31 | + theorem eq_inv_iff_eq_inv (a b : A) : a = b⁻¹ ↔ b = a⁻¹ := |
| 32 | + iff.intro eq_inv_of_eq_inv eq_inv_of_eq_inv |
| 33 | + |
| 34 | + theorem eq_of_mul_inv_eq_one {a b : A} (H : a * b⁻¹ = 1) : a = b := |
| 35 | + calc |
| 36 | + a = a * b⁻¹ * b : by simp |
| 37 | + ... = b : begin rewrite H, simp end |
| 38 | + |
| 39 | + theorem mul_eq_iff_eq_inv_mul (a b c : A) : a * b = c ↔ b = a⁻¹ * c := |
| 40 | + iff.intro eq_inv_mul_of_mul_eq mul_eq_of_eq_inv_mul |
| 41 | + |
| 42 | + theorem mul_eq_iff_eq_mul_inv (a b c : A) : a * b = c ↔ a = c * b⁻¹ := |
| 43 | + iff.intro eq_mul_inv_of_mul_eq mul_eq_of_eq_mul_inv |
| 44 | +end group |
| 45 | + |
| 46 | +/- transport versions to additive -/ |
| 47 | +run_cmd transport_multiplicative_to_additive' |
| 48 | + [ (`left_inverse_inv, `left_inverse_neg), |
| 49 | + (`inv_eq_inv_iff_eq, `neg_eq_neg_iff_eq), |
| 50 | + (`inv_eq_one_iff_eq_one, `neg_eq_zero_iff_eq_zero), |
| 51 | + (`eq_one_of_inv_eq_one, `eq_zero_of_neg_eq_zero), |
| 52 | + (`eq_inv_iff_eq_inv, `eq_neg_iff_eq_neg), |
| 53 | + (`mul_right_inv, `add_right_inv), |
| 54 | + (`eq_of_mul_inv_eq_one, `eq_of_add_neg_eq_zero), |
| 55 | + (`mul_eq_iff_eq_inv_mul, `add_eq_iff_eq_neg_add), |
| 56 | + (`mul_eq_iff_eq_mul_inv, `add_eq_iff_eq_add_neg) |
| 57 | + -- (`mul_eq_one_of_mul_eq_one, `add_eq_zero_of_add_eq_zero) not needed for commutative groups |
| 58 | + -- (`muleq_one_iff_mul_eq_one, `add_eq_zero_iff_add_eq_zero) |
| 59 | + ] |
| 60 | + |
| 61 | +section add_group |
| 62 | + variable [add_group A] |
| 63 | + |
| 64 | + local attribute [simp] sub_eq_add_neg |
| 65 | + |
| 66 | + theorem eq_iff_sub_eq_zero (a b : A) : a = b ↔ a - b = 0 := |
| 67 | + iff.intro (assume h, by simp [h]) (assume h, eq_of_sub_eq_zero h) |
| 68 | + |
| 69 | + theorem sub_eq_iff_eq_add (a b c : A) : a - b = c ↔ a = c + b := |
| 70 | + iff.intro (assume H, eq_add_of_add_neg_eq H) (assume H, add_neg_eq_of_eq_add H) |
| 71 | + |
| 72 | + theorem eq_sub_iff_add_eq (a b c : A) : a = b - c ↔ a + c = b := |
| 73 | + iff.intro (assume H, add_eq_of_eq_add_neg H) (assume H, eq_add_neg_of_add_eq H) |
| 74 | + |
| 75 | + theorem eq_iff_eq_of_sub_eq_sub {a b c d : A} (H : a - b = c - d) : a = b ↔ c = d := |
| 76 | + calc |
| 77 | + a = b ↔ a - b = 0 : eq_iff_sub_eq_zero a b |
| 78 | + ... = (c - d = 0) : by rewrite H |
| 79 | + ... ↔ c = d : iff.symm (eq_iff_sub_eq_zero c d) |
| 80 | + |
| 81 | + theorem left_inverse_sub_add_left (c : A) : function.left_inverse (λ x, x - c) (λ x, x + c) := |
| 82 | + assume x, add_sub_cancel x c |
| 83 | + |
| 84 | + theorem left_inverse_add_left_sub (c : A) : function.left_inverse (λ x, x + c) (λ x, x - c) := |
| 85 | + assume x, sub_add_cancel x c |
| 86 | + |
| 87 | + theorem left_inverse_add_right_neg_add (c : A) : |
| 88 | + function.left_inverse (λ x, c + x) (λ x, - c + x) := |
| 89 | + assume x, add_neg_cancel_left c x |
| 90 | + |
| 91 | + theorem left_inverse_neg_add_add_right (c : A) : |
| 92 | + function.left_inverse (λ x, - c + x) (λ x, c + x) := |
| 93 | + assume x, neg_add_cancel_left c x |
| 94 | +end add_group |
| 95 | + |
| 96 | + |
| 97 | +/- |
| 98 | +namespace norm_num |
| 99 | +reveal add.assoc |
| 100 | +
|
| 101 | +def add1 [has_add A] [has_one A] (a : A) : A := add a one |
| 102 | +
|
| 103 | +local attribute add1 bit0 bit1 [reducible] |
| 104 | +
|
| 105 | +theorem add_comm_four [add_comm_semigroup A] (a b : A) : a + a + (b + b) = (a + b) + (a + b) := |
| 106 | +sorry -- by simp |
| 107 | +
|
| 108 | +theorem add_comm_middle [add_comm_semigroup A] (a b c : A) : a + b + c = a + c + b := |
| 109 | +sorry -- by simp |
| 110 | +
|
| 111 | +theorem bit0_add_bit0 [add_comm_semigroup A] (a b : A) : bit0 a + bit0 b = bit0 (a + b) := |
| 112 | +sorry -- by simp |
| 113 | +
|
| 114 | +theorem bit0_add_bit0_helper [add_comm_semigroup A] (a b t : A) (H : a + b = t) : |
| 115 | + bit0 a + bit0 b = bit0 t := |
| 116 | +sorry -- by rewrite -H; simp |
| 117 | +
|
| 118 | +theorem bit1_add_bit0 [add_comm_semigroup A] [has_one A] (a b : A) : |
| 119 | + bit1 a + bit0 b = bit1 (a + b) := |
| 120 | +sorry -- by simp |
| 121 | +
|
| 122 | +theorem bit1_add_bit0_helper [add_comm_semigroup A] [has_one A] (a b t : A) |
| 123 | + (H : a + b = t) : bit1 a + bit0 b = bit1 t := |
| 124 | +sorry -- by rewrite -H; simp |
| 125 | +
|
| 126 | +theorem bit0_add_bit1 [add_comm_semigroup A] [has_one A] (a b : A) : |
| 127 | + bit0 a + bit1 b = bit1 (a + b) := |
| 128 | +sorry -- by simp |
| 129 | +
|
| 130 | +theorem bit0_add_bit1_helper [add_comm_semigroup A] [has_one A] (a b t : A) |
| 131 | + (H : a + b = t) : bit0 a + bit1 b = bit1 t := |
| 132 | +sorry -- by rewrite -H; simp |
| 133 | +
|
| 134 | +theorem bit1_add_bit1 [add_comm_semigroup A] [has_one A] (a b : A) : |
| 135 | + bit1 a + bit1 b = bit0 (add1 (a + b)) := |
| 136 | +sorry -- by simp |
| 137 | +
|
| 138 | +theorem bit1_add_bit1_helper [add_comm_semigroup A] [has_one A] (a b t s: A) |
| 139 | + (H : (a + b) = t) (H2 : add1 t = s) : bit1 a + bit1 b = bit0 s := |
| 140 | +sorry -- by inst_simp |
| 141 | +
|
| 142 | +theorem bin_add_zero [add_monoid A] (a : A) : a + zero = a := |
| 143 | +sorry -- by simp |
| 144 | +
|
| 145 | +theorem bin_zero_add [add_monoid A] (a : A) : zero + a = a := |
| 146 | +sorry -- by simp |
| 147 | +
|
| 148 | +theorem one_add_bit0 [add_comm_semigroup A] [has_one A] (a : A) : one + bit0 a = bit1 a := |
| 149 | +sorry -- by simp |
| 150 | +
|
| 151 | +theorem bit0_add_one [has_add A] [has_one A] (a : A) : bit0 a + one = bit1 a := |
| 152 | +rfl |
| 153 | +
|
| 154 | +theorem bit1_add_one [has_add A] [has_one A] (a : A) : bit1 a + one = add1 (bit1 a) := |
| 155 | +rfl |
| 156 | +
|
| 157 | +theorem bit1_add_one_helper [has_add A] [has_one A] (a t : A) (H : add1 (bit1 a) = t) : |
| 158 | + bit1 a + one = t := |
| 159 | +sorry -- by inst_simp |
| 160 | +
|
| 161 | +theorem one_add_bit1 [add_comm_semigroup A] [has_one A] (a : A) : one + bit1 a = add1 (bit1 a) := |
| 162 | +sorry -- by simp |
| 163 | +
|
| 164 | +theorem one_add_bit1_helper [add_comm_semigroup A] [has_one A] (a t : A) |
| 165 | + (H : add1 (bit1 a) = t) : one + bit1 a = t := |
| 166 | +sorry -- by inst_simp |
| 167 | +
|
| 168 | +theorem add1_bit0 [has_add A] [has_one A] (a : A) : add1 (bit0 a) = bit1 a := |
| 169 | +rfl |
| 170 | +
|
| 171 | +theorem add1_bit1 [add_comm_semigroup A] [has_one A] (a : A) : |
| 172 | + add1 (bit1 a) = bit0 (add1 a) := |
| 173 | +sorry -- by simp |
| 174 | +
|
| 175 | +theorem add1_bit1_helper [add_comm_semigroup A] [has_one A] (a t : A) (H : add1 a = t) : |
| 176 | + add1 (bit1 a) = bit0 t := |
| 177 | +sorry -- by inst_simp |
| 178 | +
|
| 179 | +theorem add1_one [has_add A] [has_one A] : add1 (one : A) = bit0 one := |
| 180 | +rfl |
| 181 | +
|
| 182 | +theorem add1_zero [add_monoid A] [has_one A] : add1 (zero : A) = one := |
| 183 | +sorry -- by simp |
| 184 | +
|
| 185 | +theorem one_add_one [has_add A] [has_one A] : (one : A) + one = bit0 one := |
| 186 | +rfl |
| 187 | +
|
| 188 | +theorem subst_into_sum [has_add A] (l r tl tr t : A) (prl : l = tl) (prr : r = tr) |
| 189 | + (prt : tl + tr = t) : l + r = t := |
| 190 | +sorry -- by simp |
| 191 | +
|
| 192 | +theorem neg_zero_helper [add_group A] (a : A) (H : a = 0) : - a = 0 := |
| 193 | +sorry -- by simp |
| 194 | +
|
| 195 | +end norm_num |
| 196 | +
|
| 197 | +attribute [simp] |
| 198 | + zero_add add_zero one_mul mul_one |
| 199 | +
|
| 200 | +attribute [simp] |
| 201 | + neg_neg sub_eq_add_neg |
| 202 | +
|
| 203 | +attribute [simp] |
| 204 | + add.assoc add.comm add.left_comm |
| 205 | + mul.left_comm mul.comm mul.assoc |
| 206 | +-/ |
0 commit comments