Library NumAnalysis.FEM.geometry

This file is part of the Rocq Numerical Analysis library
Copyright (C) Boldo, Clément, Martin, Mayero, Mouhcine
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the COPYING file for more details.
This file is about the convex_hull of a set of points in a vector space. It includes the definition and a few lemmas about it.

From NumAnalysis Require Import stdlib_wR ssr_wMC.

From Coquelicot Require Import Hierarchy.
Close Scope R_scope.

From NumAnalysis Require Import Algebra_wDep.

Local Open Scope R_scope. Local Open Scope Monoid_scope.
Local Open Scope Group_scope.
Local Open Scope Ring_scope.

Section Convex_hull.

Context {E : ModuleSpace R_Ring}.

Variant convex_hull {n} (vtx : 'E^n) : E → Prop :=
  | Cvx : ∀ L, (∀ i, 0 ≤ L i) → sum L = 1 →
      convex_hull vtx (barycenter L vtx).

Lemma convex_hull_ex :
  ∀ {n} (vtx : 'E^n) x,
    convex_hull vtx x ↔
    ∃ L, (∀ i, 0 ≤ L i) ∧ sum L = 1 ∧ x = barycenter L vtx.
Proof.
intros; split.
intros [L HL1 HL2]; ∃ L; easy.
intros [L [HL1 [HL2 HL3]]]; subst; easy.
Qed.

Lemma convex_hull_inclF : ∀ {n} (vtx : 'E^n), inclF vtx (convex_hull vtx).
Proof.
intros n vtx i; rewrite -baryc_l_kron_r; apply Cvx;
    [intros; apply kronR_bound | rewrite kron_sum_r; easy].
Qed.

Lemma convex_hull_castF :
  ∀ {n1 n2} (H : n1 = n2) (vtx1 : 'E^n1) (vtx2 : 'E^n2),
    vtx2 = castF H vtx1 → convex_hull vtx1 = convex_hull vtx2.
Proof. intros; subst; rewrite castF_id; easy. Qed.

End Convex_hull.

Section Non_deg.

Context {E : ModuleSpace R_Ring}.

Definition non_deg {n} (vtx : 'E^n.+1) : Prop :=
  ∀ i, convex_hull vtx ≠ convex_hull (skipF i vtx).

Lemma aff_indep_non_deg_aux :
  ∀ {n} {vtx : 'E^n.+1} i,
    aff_indep vtx →
    convex_hull vtx (vtx i) ∧ ¬ convex_hull (skipF i vtx) (vtx i).
Proof.
intros n vtx i Hvtx; split; [apply convex_hull_inclF |].
intros Hi; inversion Hi as [L HL1 HL2 HL3].
assert (H0 : sum (insertF i 0 L) = 1) by now rewrite sum_insertF plus_zero_l.
assert (H1 : insertF i 0 L = kron i).
  apply (aff_indep_decomp_uniq Hvtx); [easy.. | rewrite kron_sum_r; easy |].
  move: HL3; rewrite baryc_l_kron_r -!baryc_ms_correct !baryc_ms_eq//.
  rewrite lc_insertF_l scal_zero_l plus_zero_l; easy.
move: H1 ⇒ /(fun_ext_rev^~ i); rewrite kron_is_1// insertF_correct_l//.
apply not_eq_sym, R1_neq_R0.
Qed.

Lemma aff_indep_non_deg :
  ∀ {n} (vtx : 'E^n.+1), aff_indep vtx → non_deg vtx.
Proof.
intros n vtx Hvtx i; destruct (aff_indep_non_deg_aux i Hvtx) as [H1 H2].
contradict H2; rewrite -H2; easy.
Qed.

End Non_deg.