@@ -36,15 +36,36 @@ instance : mul_zero_class (with_top α) :=
36
36
37
37
lemma mul_def {a b : with_top α} : a * b = if a = 0 ∨ b = 0 then 0 else option.map₂ (*) a b := rfl
38
38
39
- @[simp] lemma mul_top {a : with_top α} (h : a ≠ 0 ) : a * ⊤ = ⊤ :=
40
- by cases a ; simp [mul_def, h ]; refl
39
+ lemma mul_top' {a : with_top α} : a * ⊤ = if a = 0 then 0 else ⊤ :=
40
+ by induction a using with_top.rec_top_coe ; simp [mul_def]; refl
41
41
42
- @[simp] lemma top_mul {a : with_top α} (h : a ≠ 0 ) : ⊤ * a = ⊤ :=
43
- by cases a; simp [mul_def, h]; refl
42
+ @[simp] lemma mul_top {a : with_top α} (h : a ≠ 0 ) : a * ⊤ = ⊤ := by rw [mul_top', if_neg h]
43
+
44
+ lemma top_mul' {a : with_top α} : ⊤ * a = if a = 0 then 0 else ⊤ :=
45
+ by induction a using with_top.rec_top_coe; simp [mul_def]; refl
46
+
47
+ @[simp] lemma top_mul {a : with_top α} (h : a ≠ 0 ) : ⊤ * a = ⊤ := by rw [top_mul', if_neg h]
44
48
45
49
@[simp] lemma top_mul_top : (⊤ * ⊤ : with_top α) = ⊤ :=
46
50
top_mul top_ne_zero
47
51
52
+ theorem mul_eq_top_iff {a b : with_top α} : a * b = ⊤ ↔ a ≠ 0 ∧ b = ⊤ ∨ a = ⊤ ∧ b ≠ 0 :=
53
+ begin
54
+ rw [mul_def, ite_eq_iff, ← none_eq_top, option.map₂_eq_none_iff],
55
+ have ha : a = 0 → a ≠ none := λ h, h.symm ▸ zero_ne_top,
56
+ have hb : b = 0 → b ≠ none := λ h, h.symm ▸ zero_ne_top,
57
+ tauto
58
+ end
59
+
60
+ theorem mul_lt_top' [has_lt α] {a b : with_top α} (ha : a < ⊤) (hb : b < ⊤) : a * b < ⊤ :=
61
+ begin
62
+ rw [with_top.lt_top_iff_ne_top] at *,
63
+ simp only [ne.def, mul_eq_top_iff, *, and_false, false_and, false_or, not_false_iff]
64
+ end
65
+
66
+ theorem mul_lt_top [has_lt α] {a b : with_top α} (ha : a ≠ ⊤) (hb : b ≠ ⊤) : a * b < ⊤ :=
67
+ mul_lt_top' (with_top.lt_top_iff_ne_top.2 ha) (with_top.lt_top_iff_ne_top.2 hb)
68
+
48
69
instance [no_zero_divisors α] : no_zero_divisors (with_top α) :=
49
70
begin
50
71
refine ⟨λ a b h₁, decidable.by_contradiction $ λ h₂, _⟩,
@@ -59,7 +80,7 @@ section mul_zero_class
59
80
60
81
variables [mul_zero_class α]
61
82
62
- @[norm_cast] lemma coe_mul {a b : α} : (↑(a * b) : with_top α) = a * b :=
83
+ @[simp, norm_cast] lemma coe_mul {a b : α} : (↑(a * b) : with_top α) = a * b :=
63
84
decidable.by_cases (assume : a = 0 , by simp [this ]) $ assume ha,
64
85
decidable.by_cases (assume : b = 0 , by simp [this ]) $ assume hb,
65
86
by { simp [*, mul_def] }
@@ -69,22 +90,6 @@ lemma mul_coe {b : α} (hb : b ≠ 0) : ∀{a : with_top α}, a * b = a.bind (λ
69
90
by simp [hb]
70
91
| (some a) := show ↑a * ↑b = ↑(a * b), from coe_mul.symm
71
92
72
- @[simp] lemma mul_eq_top_iff {a b : with_top α} : a * b = ⊤ ↔ (a ≠ 0 ∧ b = ⊤) ∨ (a = ⊤ ∧ b ≠ 0 ) :=
73
- begin
74
- cases a; cases b; simp only [none_eq_top, some_eq_coe],
75
- { simp [← coe_mul] },
76
- { by_cases hb : b = 0 ; simp [hb] },
77
- { by_cases ha : a = 0 ; simp [ha] },
78
- { simp [← coe_mul] }
79
- end
80
-
81
- lemma mul_lt_top [preorder α] {a b : with_top α} (ha : a ≠ ⊤) (hb : b ≠ ⊤) : a * b < ⊤ :=
82
- begin
83
- lift a to α using ha,
84
- lift b to α using hb,
85
- simp only [← coe_mul, coe_lt_top]
86
- end
87
-
88
93
@[simp] lemma untop'_zero_mul (a b : with_top α) : (a * b).untop' 0 = a.untop' 0 * b.untop' 0 :=
89
94
begin
90
95
by_cases ha : a = 0 , { rw [ha, zero_mul, ← coe_zero, untop'_coe, zero_mul] },
@@ -127,7 +132,7 @@ instance [mul_zero_one_class α] [nontrivial α] : mul_zero_one_class (with_top
127
132
induction y using with_top.rec_top_coe,
128
133
{ have : (f x : with_top S) ≠ 0 , by simpa [hf.eq_iff' (map_zero f)] using hx,
129
134
simp [hx, this ] },
130
- simp [← coe_mul]
135
+ simp only [← coe_mul, map_coe, map_mul ]
131
136
end ,
132
137
.. f.to_zero_hom.with_top_map, .. f.to_monoid_hom.to_one_hom.with_top_map }
133
138
@@ -163,7 +168,7 @@ begin
163
168
induction c using with_top.rec_top_coe,
164
169
{ by_cases ha : a = 0 ; simp [ha] },
165
170
{ by_cases hc : c = 0 , { simp [hc] },
166
- simp [mul_coe hc], cases a; cases b,
171
+ simp only [mul_coe hc], cases a; cases b,
167
172
repeat { refl <|> exact congr_arg some (add_mul _ _ _) } }
168
173
end
169
174
@@ -216,6 +221,15 @@ with_top.top_mul h
216
221
@[simp] lemma bot_mul_bot : (⊥ * ⊥ : with_bot α) = ⊥ :=
217
222
with_top.top_mul_top
218
223
224
+ theorem mul_eq_bot_iff {a b : with_bot α} : a * b = ⊥ ↔ a ≠ 0 ∧ b = ⊥ ∨ a = ⊥ ∧ b ≠ 0 :=
225
+ with_top.mul_eq_top_iff
226
+
227
+ theorem bot_lt_mul' [has_lt α] {a b : with_bot α} (ha : ⊥ < a) (hb : ⊥ < b) : ⊥ < a * b :=
228
+ @with_top.mul_lt_top' αᵒᵈ _ _ _ _ _ _ ha hb
229
+
230
+ theorem bot_lt_mul [has_lt α] {a b : with_bot α} (ha : a ≠ ⊥) (hb : b ≠ ⊥) : ⊥ < a * b :=
231
+ @with_top.mul_lt_top αᵒᵈ _ _ _ _ _ _ ha hb
232
+
219
233
end has_mul
220
234
221
235
section mul_zero_class
@@ -228,16 +242,6 @@ with_top.coe_mul
228
242
lemma mul_coe {b : α} (hb : b ≠ 0 ) {a : with_bot α} : a * b = a.bind (λa:α, ↑(a * b)) :=
229
243
with_top.mul_coe hb
230
244
231
- @[simp] lemma mul_eq_bot_iff {a b : with_bot α} : a * b = ⊥ ↔ (a ≠ 0 ∧ b = ⊥) ∨ (a = ⊥ ∧ b ≠ 0 ) :=
232
- with_top.mul_eq_top_iff
233
-
234
- lemma bot_lt_mul [preorder α] {a b : with_bot α} (ha : ⊥ < a) (hb : ⊥ < b) : ⊥ < a * b :=
235
- begin
236
- lift a to α using ne_bot_of_gt ha,
237
- lift b to α using ne_bot_of_gt hb,
238
- simp only [← coe_mul, bot_lt_coe],
239
- end
240
-
241
245
end mul_zero_class
242
246
243
247
/-- `nontrivial α` is needed here as otherwise we have `1 * ⊥ = ⊥` but also `= 0 * ⊥ = 0`. -/
0 commit comments