@@ -7,6 +7,7 @@ import algebra.order.invertible
7
7
import algebra.order.module
8
8
import linear_algebra.affine_space.midpoint
9
9
import linear_algebra.affine_space.affine_subspace
10
+ import linear_algebra.ray
10
11
11
12
/-!
12
13
# Convex sets and functions in vector spaces
@@ -58,6 +59,15 @@ def open_segment (x y : E) : set E :=
58
59
59
60
localized " notation `[` x ` -[` 𝕜 `] ` y `]` := segment 𝕜 x y" in convex
60
61
62
+ lemma segment_eq_image₂ (x y : E) :
63
+ [x -[𝕜] y] = (λ p : 𝕜 × 𝕜, p.1 • x + p.2 • y) '' {p | 0 ≤ p.1 ∧ 0 ≤ p.2 ∧ p.1 + p.2 = 1 } :=
64
+ by simp only [segment, image, prod.exists, mem_set_of_eq, exists_prop, and_assoc]
65
+
66
+ lemma open_segment_eq_image₂ (x y : E) :
67
+ open_segment 𝕜 x y =
68
+ (λ p : 𝕜 × 𝕜, p.1 • x + p.2 • y) '' {p | 0 < p.1 ∧ 0 < p.2 ∧ p.1 + p.2 = 1 } :=
69
+ by simp only [open_segment, image, prod.exists, mem_set_of_eq, exists_prop, and_assoc]
70
+
61
71
lemma segment_symm (x y : E) : [x -[𝕜] y] = [y -[𝕜] x] :=
62
72
set.ext $ λ z,
63
73
⟨λ ⟨a, b, ha, hb, hab, H⟩, ⟨b, a, hb, ha, (add_comm _ _).trans hab, (add_comm _ _).trans H⟩,
@@ -101,7 +111,7 @@ end mul_action_with_zero
101
111
section module
102
112
variables (𝕜) [module 𝕜 E]
103
113
104
- lemma segment_same (x : E) : [x -[𝕜] x] = {x} :=
114
+ @[simp] lemma segment_same (x : E) : [x -[𝕜] x] = {x} :=
105
115
set.ext $ λ z, ⟨λ ⟨a, b, ha, hb, hab, hz⟩,
106
116
by simpa only [(add_smul _ _ _).symm, mem_singleton_iff, hab, one_smul, eq_comm] using hz,
107
117
λ h, mem_singleton_iff.1 h ▸ left_mem_segment 𝕜 z z⟩
@@ -177,15 +187,6 @@ set.ext $ λ z,
177
187
⟨b, ⟨hb, hab ▸ lt_add_of_pos_left _ ha⟩, hab ▸ hz ▸ by simp only [add_sub_cancel]⟩,
178
188
λ ⟨θ, ⟨hθ₀, hθ₁⟩, hz⟩, ⟨1 - θ, θ, sub_pos.2 hθ₁, hθ₀, sub_add_cancel _ _, hz⟩⟩
179
189
180
- lemma segment_eq_image₂ (x y : E) :
181
- [x -[𝕜] y] = (λ p : 𝕜 × 𝕜, p.1 • x + p.2 • y) '' {p | 0 ≤ p.1 ∧ 0 ≤ p.2 ∧ p.1 + p.2 = 1 } :=
182
- by simp only [segment, image, prod.exists, mem_set_of_eq, exists_prop, and_assoc]
183
-
184
- lemma open_segment_eq_image₂ (x y : E) :
185
- open_segment 𝕜 x y =
186
- (λ p : 𝕜 × 𝕜, p.1 • x + p.2 • y) '' {p | 0 < p.1 ∧ 0 < p.2 ∧ p.1 + p.2 = 1 } :=
187
- by simp only [open_segment, image, prod.exists, mem_set_of_eq, exists_prop, and_assoc]
188
-
189
190
lemma segment_eq_image' (x y : E) :
190
191
[x -[𝕜] y] = (λ (θ : 𝕜), x + θ • (y - x)) '' Icc (0 : 𝕜) 1 :=
191
192
by { convert segment_eq_image 𝕜 x y, ext θ, simp only [smul_sub, sub_smul, one_smul], abel }
@@ -242,6 +243,15 @@ open_segment_translate_preimage 𝕜 a b c ▸ image_preimage_eq _ $ add_left_su
242
243
end add_comm_group
243
244
end ordered_ring
244
245
246
+ lemma same_ray_of_mem_segment [ordered_comm_ring 𝕜] [add_comm_group E] [module 𝕜 E]
247
+ {x y z : E} (h : x ∈ [y -[𝕜] z]) : same_ray 𝕜 (x - y) (z - x) :=
248
+ begin
249
+ rw segment_eq_image' at h,
250
+ rcases h with ⟨θ, ⟨hθ₀, hθ₁⟩, rfl⟩,
251
+ simpa only [add_sub_cancel', ← sub_sub, sub_smul, one_smul]
252
+ using (same_ray_nonneg_smul_left (z - y) hθ₀).nonneg_smul_right (sub_nonneg.2 hθ₁)
253
+ end
254
+
245
255
section linear_ordered_ring
246
256
variables [linear_ordered_ring 𝕜]
247
257
@@ -278,6 +288,17 @@ variables [linear_ordered_field 𝕜]
278
288
section add_comm_group
279
289
variables [add_comm_group E] [add_comm_group F] [module 𝕜 E] [module 𝕜 F]
280
290
291
+ lemma mem_segment_iff_same_ray {x y z : E} :
292
+ x ∈ [y -[𝕜] z] ↔ same_ray 𝕜 (x - y) (z - x) :=
293
+ begin
294
+ refine ⟨same_ray_of_mem_segment, λ h, _⟩,
295
+ rcases h.exists_eq_smul_add with ⟨a, b, ha, hb, hab, hxy, hzx⟩,
296
+ rw [add_comm, sub_add_sub_cancel] at hxy hzx,
297
+ rw [← mem_segment_translate _ (-x), neg_add_self],
298
+ refine ⟨b, a, hb, ha, add_comm a b ▸ hab, _⟩,
299
+ rw [← sub_eq_neg_add, ← neg_sub, hxy, ← sub_eq_neg_add, hzx, smul_neg, smul_comm, neg_add_self]
300
+ end
301
+
281
302
lemma mem_segment_iff_div {x y z : E} : x ∈ [y -[𝕜] z] ↔
282
303
∃ a b : 𝕜, 0 ≤ a ∧ 0 ≤ b ∧ 0 < a + b ∧ (a / (a + b)) • y + (b / (a + b)) • z = x :=
283
304
begin
0 commit comments