reserve x,y for set,
        r,s for Real,
        n for Nat,
        V for RealLinearSpace,
        v,u,w,p for VECTOR of V,
        A,B for Subset of V,
        Af for finite Subset of V,
        I for affinely-independent Subset of V,
        If for finite affinely-independent Subset of V,
        F for Subset-Family of V,
        L1,L2 for Linear_Combination of V;

theorem
  conv A c=conv If & If is non empty & conv A misses Int If implies
    ex B be Subset of V st B c< If & conv A c= conv B
  proof
    assume that
    A1: conv A c=conv If and
    A2: If is non empty and
    A3: conv A misses Int If;
    reconsider If as non empty finite affinely-independent Subset of V by A2;
      set YY={B where B is Subset of V:B c=If & ex x st x in conv A &
        x in Int B};
      YY c=bool the carrier of V
      proof
        let x be object;
        assume x in YY;
        then ex B be Subset of V st B=x & B c=If &
          ex y st y in conv A & y in Int B;
        hence thesis;
      end;
      then reconsider YY as Subset-Family of V;

      take U=union YY;
      A4: conv A c=conv U
      proof
        let v be object;
        assume A5: v in conv A;
        then v in conv If by A1;
        then v in union{Int B where B is Subset of V:B c=If} by Th8;
        then consider IB be set such that
        A6: v in IB and
        A7: IB in {Int B where B is Subset of V:B c=If} by TARSKI:def 4;
        consider B be Subset of V such that
        A8: IB=Int B and
        A9: B c=If by A7;
        Int B c=conv B by Lm2;
        then A10: v in conv B by A6,A8;
        B in YY by A5,A6,A8,A9;
        then conv B c=conv U by RLAFFIN1:3,ZFMISC_1:74;
        hence thesis by A10;
      end;
      A11: U c=If
      proof
        let x be object;
        assume x in U;
        then consider b be set such that
        A12: x in b and
        A13: b in YY by TARSKI:def 4;
        ex B be Subset of V st b=B & B c=If & ex y st y in conv A &
          y in Int B by A13;
        hence thesis by A12;
      end;
      U<>If
      proof
        defpred P[object,object] means
          for B be Subset of V st B=$2 holds$1 in B & ex x st x in conv A &
            x in Int B;
        assume A14: U=If;
A15: for x being object st x in If ex y being object st y in bool If & P[x,y]
        proof
          let x be object;
          assume x in If;
          then consider b be set such that
          A16: x in b and
          A17: b in YY by A14,TARSKI:def 4;
          consider B be Subset of V such that
          A18: b=B & B c=If & ex y st y in conv A & y in Int B by A17;
          take B;
          thus thesis by A16,A18;
        end;
        consider p be Function of If,bool If such that
A19: for x being object st x in If holds P[x,p.x] from FUNCT_2:sch 1(A15);
        defpred Q[object,object] means
        for B be Subset of V st B=p.$1 holds$2 in conv A & $2 in Int B;
        A20: dom p=If by FUNCT_2:def 1;
        A21: for x being object st x in If
ex y being object st y in the carrier of V & Q[x,y]
        proof
          let x be object;
          assume A22: x in If;
          then p.x in rng p by A20,FUNCT_1:def 3;
          then reconsider px=p.x as Subset of V by XBOOLE_1:1;
          consider y such that
          A23: y in conv A & y in Int px by A19,A22;
          take y;
          thus thesis by A23;
        end;
        consider q be Function of If,V such that
A24: for x being object st x in If holds Q[x,q.x] from FUNCT_2:sch 1(A21);
        reconsider R=rng q as non empty finite Subset of V;
        A25: R c=conv A
        proof
          let y be object;
          assume y in R;
          then consider x being object such that
          A26: x in dom q and
          A27: y=q.x by FUNCT_1:def 3;
          p.x in rng p by A20,A26,FUNCT_1:def 3;
          then reconsider px=p.x as Subset of V by XBOOLE_1:1;
          px=p.x;
          hence thesis by A24,A26,A27;
        end;
        then A28: R c=conv U by A4;
        A29: conv R c=conv A by A25,CONVEX1:30;
        A30: dom q=If by FUNCT_2:def 1;
        A31: 1/card R*card R=card R/card R by XCMPLX_1:99
        .=1 by XCMPLX_1:60;
        consider L be Linear_Combination of R such that
        A32: Sum L=1/card R*Sum R and
        A33: sum L=1/card R*card R and
        A34: L=(ZeroLC V)+*(R-->1/card R) by Th15;
        set SL=Sum L;
        set SLIf=SL|--If;
        Sum L=(center_of_mass V).R by A32,Def2;
        then A35: Sum L in conv R by Th16;
        A36: dom(R-->1/card R)=R;
        A37: now let x;
               assume A38: x in R;
               hence L.x=(R-->1/card R).x by A34,A36,FUNCT_4:13
               .=1/card R by A38,FUNCOP_1:7;
        end;
        A39: R c=Carrier L
        proof
          let x be object;
          assume A40: x in R;
          then L.x<>0 by A37;
          hence thesis by A40;
        end;
        A41: conv U c=conv If by A11,RLAFFIN1:3;
        then A42: R c=conv If by A28;
        then A43: conv R c=conv If by CONVEX1:30;
        then A44: SL in conv If by A35;
        A45: R c=conv If by A28,A41;
        Carrier L c=R by RLVECT_2:def 6;
        then A46: R=Carrier L by A39;
        A47: If c=Carrier SLIf
        proof
          let x be object;
          assume A48: x in If;
          then consider F be FinSequence of REAL,
            G be FinSequence of V such that
          A49: SLIf.x=Sum F and
          A50: len G=len F and
          G is one-to-one and
          A51: rng G=Carrier L and
          A52: for n st n in dom F holds F.n=L.(G.n)*(G.n|--If).x
            by A31,A33,A42,Th3;
          A53: p.x in rng p by A20,A48,FUNCT_1:def 3;
          then reconsider px=p.x as Subset of V by XBOOLE_1:1;
          A54: Int px c=conv px by Lm2;
          A55: q.x in Int px by A24,A48;
          then A56: q.x in conv px by A54;
          A57: x in px by A19,A48;
          A58: conv px c=Affin px by RLAFFIN1:65;
          A59: px is affinely-independent by A53,RLAFFIN1:43;
          then Sum(q.x|--px)=q.x by A56,A58,RLAFFIN1:def 7;
          then A60: Carrier(q.x|--px)=px by A54,A55,A59,Th11,RLAFFIN1:71;
          q.x|--px=q.x|--If by A53,A56,A58,RLAFFIN1:77;
          then A61: (q.x|--If).x<>0 by A57,A60,RLVECT_2:19;
          conv px c=conv If by A53,RLAFFIN1:3;
          then A62: (q.x|--If).x>=0 by A48,A56,RLAFFIN1:71;
          A63: q.x in R by A30,A48,FUNCT_1:def 3;
          then A64: L.(q.x)=1/card R by A37;
          A65: dom G=dom F by A50,FINSEQ_3:29;
          A66: now let m be Nat;
                  assume A67: m in dom F;
                  then G.m in R by A46,A51,A65,FUNCT_1:def 3;
                  then A68: L.(G.m)>0 & (G.m|--If).x>=0
                    by A37,A45,A48,RLAFFIN1:71;
                  F.m=L.(G.m)*(G.m|--If).x by A52,A67;
                  hence 0<=F.m by A68;
          end;
          consider n be object such that
          A69: n in dom G and
          A70: G.n=q.x by A39,A51,A63,FUNCT_1:def 3;
          F.n=L.(q.x)*(q.x|--If).x by A52,A65,A69,A70;
          then SLIf.x>0 by A49,A61,A62,A64,A65,A66,A69,RVSUM_1:85;
          hence thesis by A48;
        end;
        Carrier SLIf c=If by RLVECT_2:def 6;
        then Carrier SLIf=If & SLIf is convex
          by A47,A35,A43,RLAFFIN1:71;
        then conv If c=Affin If & Sum SLIf in Int If by Th12,RLAFFIN1:65;
        then SL in Int If by A44,RLAFFIN1:def 7;
        hence contradiction by A3,A29,A35,XBOOLE_0:3;
      end;
      hence thesis by A4,A11;
  end;
