(*VUONG ANH QUYEN *)
(* DEFINITIONS OF AFFINE HULL. *)
(* ==================================================================== *)
(* -------------------------------------------------------------------- *)
(* Two ways to define affine set & affine hull. *)
(* -------------------------------------------------------------------- *)
(* Define as in convex.ml *)
(* -------------------------------------------------------------------- *)
(* Define using affine combination *)
(* -------------------------------------------------------------------- *)
let affine_comb = new_definition `!(s:real^N->bool). affine_comb s = ! (n:num) (t:num->real) (v:num->real^N).
( sum (1..n) (\i. t i) = &1)/\(!i. ((1..n) i) ==>(s (v i)))
==> (s (vsum (1..n) (\i. (t i) % (v i))))`;;
let aff_comb = new_definition `! (S:real^N -> bool) (w:real^N). aff_comb S w =(
? (n:num) (t:num->real) (v:num->real^N).
( sum (1..n) (\i. t i) = &1 ) /\
(w = vsum (1..n) (\i. (t i) % (v i)))/\ (!i. ((1..n) i) ==> (S (v i))) )`;;
(* Some simple properties of affine, aff, affine_comb, aff_comb, hull *)
(* -------------------------------------------------------------------- *)
(* Some lemmas need using *)
(* --------------------------------------------------------------- *)
(* VSUM_2 -> hull_error.ml *)
let VMUL_CASES = prove
(`!(P:A->bool) (t:A->
real) (t':A->
real) (v:A->real^N) (v':A->real^N). (if P i then t i else t' i) % (if P i then v i else v' i) = (if P i then ( t i % v i) else (t' i % v' i))`,
REPEAT GEN_TAC THEN REPEAT COND_CASES_TAC THEN ASM_MESON_TAC[]);;
(* Relation between affine and affine_comb *)
(* --------------------------------------------------------------- *)
(* affcomb_imp_aff -> hull_error.ml *)
let comb_trans = prove (
`! (n:num) (t:num->
real) (v:num->real^N).
~(n=0)/\(
sum (1..n+1) (\i. t i) = &1)==>
(
vsum (1..n+1) (\i. (t i) % (v i)) =
vsum (1..n) (\i. (&1 / &n) % ((&n * (t i)) % (v i) + (&1 - &n * (t i)) % (v (n+1)))))`,
(* aff_imp_affcomb -> hull_error.ml *)
(* The equality between two ways of defining, aff & aff_comb *)
(* ------------------------------------------------------------------*)
(* affine_affcomb -> hull_error.ml *)
(* aff_eq_affcomb -> hull_error.ml *)
(* convex, added by thales *)