reserve x,y,X for set,
        r for Real,
        n,k for Nat;
reserve RLS for non empty RLSStruct,
        Kr,K1r,K2r for SimplicialComplexStr of RLS,
        V for RealLinearSpace,
        Kv for non void SimplicialComplex of V;
reserve Ks for simplex-join-closed SimplicialComplex of V,
        As,Bs for Subset of Ks,
        Ka for non void affinely-independent SimplicialComplex of V,
        Kas for non void affinely-independent simplex-join-closed
                 SimplicialComplex of V,
        K for non void affinely-independent simplex-join-closed total
                 SimplicialComplex of V;
reserve Aff for finite affinely-independent Subset of V,
        Af,Bf for finite Subset of V,
        B for Subset of V,
        S,T for finite Subset-Family of V,
        Sf for c=-linear finite finite-membered Subset-Family of V,
        Sk,Tk for finite simplex-like Subset-Family of K,
        Ak for Simplex of K;

theorem Th36:
  Sf is with_non-empty_elements & union Sf c=Aff implies
   ((center_of_mass V).:Sf is Simplex of card union Sf-1,BCS Complex_of {Aff}
iff
   for n st 0 < n & n <= card union Sf ex x st x in Sf & card x = n)
 proof
  reconsider N=0 as Nat;
  set U=union Sf;
  assume that
   A1: Sf is with_non-empty_elements and
   A2: union Sf c=Aff;
  set B=center_of_mass V,C=Complex_of{Aff};
  reconsider s=Sf as c=-linear finite Subset-Family of C;
  A3: the topology of C=bool Aff by SIMPLEX0:4;
  Segm card U c= Segm card Aff by A2,CARD_1:11;
  then card U<=card Aff by NAT_1:39;
  then A4: N-1<=card U-1 & card U-1<=card Aff-1 by XREAL_1:9;
  Sf c=bool U & bool U c=bool Aff by A2,ZFMISC_1:67,82;
  then A5: s c=the topology of C by A3;
  A6: s is simplex-like
  proof
   let a be Subset of C;
   assume a in s;
   hence thesis by A5;
  end;
  then A7: card s=card(B.:Sf) by A1,Th33;
  Segm card Sf c= Segm card U by A1,SIMPLEX0:10;
  then A8: card Sf<=card U by NAT_1:39;
  set BC=BCS C;
  reconsider c =card Aff as ExtReal;
  A9: degree C=c-1 by SIMPLEX0:26
   .=card Aff+-1 by XXREAL_3:def 2;
  A10: |.C.|c=[#]C;
  then A11: BC=subdivision(B,C) by Def5;
  then [#]BC=[#]C by SIMPLEX0:def 20;
  then reconsider BS=B.:Sf as Subset of BC;
  A12: N-1<=card Aff-1 by XREAL_1:9;
  A13: degree BC=degree C by A10,Th31;
  thus(center_of_mass V).:Sf is Simplex of card U-1,BCS Complex_of{Aff} implies
  for n st 0<n & n<=card U ex x st x in Sf & card x=n
  proof
   assume B.:Sf is Simplex of card U-1,BC;
   then reconsider BS=B.:Sf as Simplex of card U-1,BC;
   reconsider c1=card U-1 as ExtReal;
   let n;
   reconsider s=Sf as Subset-Family of U by ZFMISC_1:82;
   defpred P[Nat] means
    $1<card Sf implies ex x be finite set st x in Sf & card x=card Sf-$1;
   assume that
    A14: 0<n and
    A15: n<=card U;
   A16: card Sf-(0 qua Real)>
(card Sf qua Real)-(n qua Real) by A14,XREAL_1:10;
   A17: card BS=c1+1 by A4,A9,A13,SIMPLEX0:def 18
    .=card U-1+1 by XXREAL_3:def 2
    .=card U;
   then A18: Sf is non empty by A14,A15;
   then consider s1 be Subset-Family of U such that
    A19: s c=s1 and
    s1 is with_non-empty_elements c=-linear and
    A20: card U=card s1 and
    A21: for Z be set st Z in s1 & card Z<>1 ex x st x in Z & Z\{x} in s1 by A1
,SIMPLEX0:9,13;
   card U=card Sf by A1,A6,A17,Th33;
   then A22: s=s1 by A19,A20,CARD_2:102;
   A23: for n st P[n] holds P[n+1]
   proof
    let n such that
     A24: P[n];
    assume A25: n+1<card Sf;
    then consider X be finite set such that
     A26: X in Sf and
     A27: card X=card Sf-n by A24,NAT_1:13;
    A28: n+1-n<card Sf-n by A25,XREAL_1:9;
    then consider x such that
     A29: x in X & X\{x} in Sf by A21,A22,A26,A27;
    reconsider C=card X-1 as Element of NAT by A27,A28,NAT_1:20;
    take X\{x};
    card X=C+1;
    hence thesis by A27,A29,STIRL2_1:55;
   end;
   A30: P[0 qua Nat] by A7,A17,A18,SIMPLEX0:9;
   A31: for n holds P[n] from NAT_1:sch 2(A30,A23);
   card Sf-n is Nat by A7,A15,A17,NAT_1:21;
   then ex x be finite set st x in Sf & card x=card Sf-(card Sf-n) by A16,A31;
   hence thesis;
  end;
  assume A32: for n st 0<n & n<=card U ex x st x in Sf & card x=n;
  per cases;
  suppose A33: U is empty;
   reconsider O=-1 as ExtReal;
   A34: O<=degree BC & 0=O+1 by A9,A10,A12,Th31,XXREAL_3:7;
   Sf is empty by A1,A33;
   then A35: BS is empty;
   thus thesis by A33,A34,A35,SIMPLEX0:def 18;
  end;
  suppose A36: U is non empty;
   reconsider c1=card U-1 as ExtReal;
   consider x such that
    A37: x in Sf and
    card x=card U by A32,A36;
   defpred P[object,object] means
     ex D2 being set st D2 = $2 & card D2=$1;
   A38: for x being object st x in Seg card U
   ex y being object st y in Sf & P[x,y]
   proof
    let x being object such that
     A39: x in Seg card U;
    reconsider n=x as Nat by A39;
    0<n & n<=card U by A39,FINSEQ_1:1;
     then ex x st x in Sf & card x=n by A32;
    hence thesis;
   end;
   consider f be Function of Seg card U,Sf such that
A40: for x being object st x in Seg card U holds P[x,f.x]
from FUNCT_2:sch 1(A38);
   now let x1,x2 be object;
    assume that
     A41: x1 in dom f and
     A42: x2 in dom f & f.x1=f.x2;
A43:   P[x2,f.x2] by A40,A42;
      P[x1,f.x1] by A40,A41;
     hence x1=card(f.x1)
     .=x2 by A42,A43;
   end;
   then A44: rng f c=Sf & f is one-to-one by FUNCT_1:def 4;
   dom f=Seg card U by A37,FUNCT_2:def 1;
   then Segm card Seg card U= Segm card U &
    Segm card Seg card U c= Segm card Sf by A44,CARD_1:10
,FINSEQ_1:57;
   then card U<=card Sf by NAT_1:39;
   then A45: card BS=card U by A7,A8,XXREAL_0:1;
   BS is Simplex of BC & c1+1=(card U-1)+1 by A6,A11,SIMPLEX0:def 20
,XXREAL_3:def 2;
   hence thesis by A4,A9,A13,A45,SIMPLEX0:def 18;
  end;
 end;
