@@ -25,6 +25,8 @@ variables (R : Type*) {V V' P P' : Type*}
2525
2626open affine_equiv affine_map
2727
28+ open_locale big_operators
29+
2830section ordered_ring
2931
3032variables [ordered_ring R] [add_comm_group V] [module R V] [add_torsor V P]
@@ -452,6 +454,39 @@ lemma sbtw.trans_wbtw_right_ne [no_zero_smul_divisors R V] {w x y z : P} (h₁ :
452454 (h₂ : wbtw R x y z) : w ≠ y :=
453455h₁.wbtw.trans_right_ne h₂ h₁.left_ne
454456
457+ /- Calls to `affine_combination` are slow to elaborate (generally, not just for this lemma), and
458+ without the use of `@finset.affine_combination R V _ _ _ _ _ _` for at least three of the six
459+ calls in this lemma statement, elaboration of the statement times out (even if the proof is
460+ replaced by `sorry`). -/
461+ lemma sbtw.affine_combination_of_mem_affine_span_pair [no_zero_divisors R]
462+ [no_zero_smul_divisors R V] {ι : Type *} {p : ι → P} (ha : affine_independent R p)
463+ {w w₁ w₂ : ι → R} {s : finset ι} (hw : ∑ i in s, w i = 1 ) (hw₁ : ∑ i in s, w₁ i = 1 )
464+ (hw₂ : ∑ i in s, w₂ i = 1 )
465+ (h : s.affine_combination p w ∈
466+ line[R, s.affine_combination p w₁, s.affine_combination p w₂]) {i : ι} (his : i ∈ s)
467+ (hs : sbtw R (w₁ i) (w i) (w₂ i)) :
468+ sbtw R (@finset.affine_combination R V _ _ _ _ _ _ s p w₁)
469+ (@finset.affine_combination R V _ _ _ _ _ _ s p w)
470+ (@finset.affine_combination R V _ _ _ _ _ _ s p w₂) :=
471+ begin
472+ rw affine_combination_mem_affine_span_pair ha hw hw₁ hw₂ at h,
473+ rcases h with ⟨r, hr⟩,
474+ dsimp only at hr,
475+ rw [hr i his, sbtw_mul_sub_add_iff] at hs,
476+ change ∀ i ∈ s, w i = ((r • (w₂ - w₁) + w₁) i) at hr,
477+ rw s.affine_combination_congr hr (λ _ _, rfl),
478+ dsimp only,
479+ rw [←s.weighted_vsub_vadd_affine_combination, s.weighted_vsub_const_smul,
480+ ←s.affine_combination_vsub, ←line_map_apply, sbtw_line_map_iff, and_iff_left hs.2 ,
481+ ←@vsub_ne_zero V, s.affine_combination_vsub],
482+ intro hz,
483+ have hw₁w₂ : ∑ i in s, (w₁ - w₂) i = 0 ,
484+ { simp_rw [pi.sub_apply, finset.sum_sub_distrib, hw₁, hw₂, sub_self] },
485+ refine hs.1 _,
486+ have ha' := ha s (w₁ - w₂) hw₁w₂ hz i his,
487+ rwa [pi.sub_apply, sub_eq_zero] at ha'
488+ end
489+
455490end ordered_ring
456491
457492section strict_ordered_comm_ring
487522
488523end strict_ordered_comm_ring
489524
525+ section linear_ordered_ring
526+
527+ variables [linear_ordered_ring R] [add_comm_group V] [module R V] [add_torsor V P]
528+
529+ include V
530+
531+ variables {R}
532+
533+ /-- Suppose lines from two vertices of a triangle to interior points of the opposite side meet at
534+ `p`. Then `p` lies in the interior of the first (and by symmetry the other) segment from a
535+ vertex to the point on the opposite side. -/
536+ lemma sbtw_of_sbtw_of_sbtw_of_mem_affine_span_pair [no_zero_smul_divisors R V]
537+ {t : affine.triangle R P} {i₁ i₂ i₃ : fin 3 } (h₁₂ : i₁ ≠ i₂) {p₁ p₂ p : P}
538+ (h₁ : sbtw R (t.points i₂) p₁ (t.points i₃)) (h₂ : sbtw R (t.points i₁) p₂ (t.points i₃))
539+ (h₁' : p ∈ line[R, t.points i₁, p₁]) (h₂' : p ∈ line[R, t.points i₂, p₂]) :
540+ sbtw R (t.points i₁) p p₁ :=
541+ begin
542+ -- Should not be needed; see comments on local instances in `data.sign`.
543+ letI : decidable_rel ((<) : R → R → Prop ) := linear_ordered_ring.decidable_lt,
544+ have h₁₃ : i₁ ≠ i₃, { rintro rfl, simpa using h₂ },
545+ have h₂₃ : i₂ ≠ i₃, { rintro rfl, simpa using h₁ },
546+ have h3 : ∀ i : fin 3 , i = i₁ ∨ i = i₂ ∨ i = i₃, { clear h₁ h₂ h₁' h₂', dec_trivial! },
547+ have hu : (finset.univ : finset (fin 3 )) = {i₁, i₂, i₃}, { clear h₁ h₂ h₁' h₂', dec_trivial! },
548+ have hp : p ∈ affine_span R (set.range t.points),
549+ { have hle : line[R, t.points i₁, p₁] ≤ affine_span R (set.range t.points),
550+ { refine affine_span_pair_le_of_mem_of_mem (mem_affine_span _ (set.mem_range_self _)) _,
551+ have hle : line[R, t.points i₂, t.points i₃] ≤ affine_span R (set.range t.points),
552+ { refine affine_span_mono _ _, simp [set.insert_subset] },
553+ rw affine_subspace.le_def' at hle,
554+ exact hle _ h₁.wbtw.mem_affine_span },
555+ rw affine_subspace.le_def' at hle,
556+ exact hle _ h₁' },
557+ have h₁i := h₁.mem_image_Ioo,
558+ have h₂i := h₂.mem_image_Ioo,
559+ rw set.mem_image at h₁i h₂i,
560+ rcases h₁i with ⟨r₁, ⟨hr₁0 , hr₁1 ⟩, rfl⟩,
561+ rcases h₂i with ⟨r₂, ⟨hr₂0 , hr₂1 ⟩, rfl⟩,
562+ rcases eq_affine_combination_of_mem_affine_span_of_fintype hp with ⟨w, hw, rfl⟩,
563+ have h₁s := sign_eq_of_affine_combination_mem_affine_span_single_line_map t.independent hw
564+ (finset.mem_univ _) (finset.mem_univ _) (finset.mem_univ _) h₁₂ h₁₃ h₂₃ hr₁0 hr₁1 h₁',
565+ have h₂s := sign_eq_of_affine_combination_mem_affine_span_single_line_map t.independent hw
566+ (finset.mem_univ _) (finset.mem_univ _) (finset.mem_univ _) h₁₂.symm h₂₃ h₁₃ hr₂0 hr₂1 h₂',
567+ dsimp only at h₁s h₂s,
568+ rw [←finset.univ.affine_combination_affine_combination_single_weights R t.points
569+ (finset.mem_univ i₁),
570+ ←finset.univ.affine_combination_affine_combination_line_map_weights t.points
571+ (finset.mem_univ _) (finset.mem_univ _)] at ⊢ h₁',
572+ refine sbtw.affine_combination_of_mem_affine_span_pair t.independent hw
573+ (finset.univ.sum_affine_combination_single_weights R (finset.mem_univ _))
574+ (finset.univ.sum_affine_combination_line_map_weights (finset.mem_univ _) (finset.mem_univ _) _)
575+ h₁' (finset.mem_univ i₁) _,
576+ rw [finset.affine_combination_single_weights_apply_self,
577+ finset.affine_combination_line_map_weights_apply_of_ne h₁₂ h₁₃, sbtw_one_zero_iff],
578+ have hs : ∀ i : fin 3 , sign (w i) = sign (w i₃),
579+ { intro i,
580+ rcases h3 i with rfl | rfl | rfl,
581+ { exact h₂s },
582+ { exact h₁s },
583+ { refl } },
584+ have hss : sign (∑ i, w i) = 1 , { simp [hw] },
585+ have hs' := sign_sum (finset.univ_nonempty) (sign (w i₃)) (λ i _, hs i),
586+ rw hs' at hss,
587+ simp_rw [hss, sign_eq_one_iff] at hs,
588+ refine ⟨hs i₁, _⟩,
589+ rw hu at hw,
590+ rw [finset.sum_insert, finset.sum_insert, finset.sum_singleton] at hw,
591+ { by_contra hle,
592+ rw not_lt at hle,
593+ exact (hle.trans_lt (lt_add_of_pos_right _ (left.add_pos (hs i₂) (hs i₃)))).ne' hw },
594+ { simp [h₂₃] },
595+ { simp [h₁₂, h₁₃] }
596+ end
597+
598+ end linear_ordered_ring
599+
490600section linear_ordered_field
491601
492602variables [linear_ordered_field R] [add_comm_group V] [module R V] [add_torsor V P]
0 commit comments