reserve x,y for set;
reserve G for Graph;
reserve vs,vs9 for FinSequence of the carrier of G;
reserve IT for oriented Chain of G;
reserve N for Nat;
reserve n,m,k,i,j for Nat;
reserve r,r1,r2 for Real;
reserve X for non empty set;

theorem Th16:
  for p1,p2,p3 being Point of TOP-REAL n st (ex x being set st x<>
p2 & x in LSeg(p1,p2)/\ LSeg(p2,p3)) holds p1 in LSeg(p2,p3) or p3 in LSeg(p1,
  p2)
proof
  let p1,p2,p3 be Point of TOP-REAL n;
  given x being set such that
A1: x<>p2 and
A2: x in LSeg(p1,p2)/\ LSeg(p2,p3);
  reconsider p=x as Point of TOP-REAL n by A2;
A3: p in { (1-r1)*p1 + r1*p2 : 0 <= r1 & r1 <= 1 } by A2,XBOOLE_0:def 4;
A4: p in { (1-r2)*p2 + r2*p3 : 0 <= r2 & r2 <= 1 } by A2,XBOOLE_0:def 4;
  consider r1 such that
A5: p=(1-r1)*p1 + r1*p2 and
  0 <= r1 and
A6: r1 <= 1 by A3;
  consider r2 such that
A7: p=(1-r2)*p2 + r2*p3 and
A8: 0 <= r2 and
  r2 <= 1 by A4;
  per cases;
  suppose
A9: r1>=1-r2;
    now
      per cases;
      case
A10:    r2<>0;
        r2*p3=(1-r1)*p1 + r1*p2-(1-r2)*p2 by A5,A7,RLVECT_4:1;
        then r2*p3=(1-r1)*p1 + (r1*p2-(1-r2)*p2) by RLVECT_1:def 3;
        then r2"*(r2*p3)=r2"*((1-r1)*p1 + (r1-(1-r2))*p2) by RLVECT_1:35;
        then (r2"*r2)*p3=r2"*((1-r1)*p1 + (r1-(1-r2))*p2) by RLVECT_1:def 7;
        then 1*p3=r2"*((1-r1)*p1 + (r1-(1-r2))*p2) by A10,XCMPLX_0:def 7;
        then
A11:    p3=r2"*((1-r1)*p1 + (r1-(1-r2))*p2) by RLVECT_1:def 8
          .=r2"*((1-r1)*p1) +r2"*((r1-(1-r2))*p2) by RLVECT_1:def 5
          .=(r2"*(1-r1))*p1 +r2"*((r1-(1-r2))*p2) by RLVECT_1:def 7
          .=(r2"*(1-r1))*p1 +(r2"*(r1-(1-r2)))*p2 by RLVECT_1:def 7;
        r1<=1+(0 qua Nat) by A6;
        then r1-1<=0 by XREAL_1:20;
        then r1-1+r2<=0 qua Nat+r2 by XREAL_1:6;
        then
A12:    r2"*(r1-(1-r2))<=r2"*r2 by A8,XREAL_1:64;
        r2"*(1-r1) +r2"*(r1-(1-r2))=r2"*(1-1+r2) .=1 by A10,XCMPLX_0:def 7;
        then
A13:    r2"*(1-r1)=1-r2"*(r1-(1-r2));
        (r1-(1-r2))>=0 by A9,XREAL_1:48;
        hence thesis by A8,A11,A13,A12;
      end;
      case
        r2=0;
        then p=1*p2+0.TOP-REAL n by A7,RLVECT_1:10;
        then p=p2+0.TOP-REAL n by RLVECT_1:def 8;
        hence thesis by A1,RLVECT_1:4;
      end;
    end;
    hence thesis;
  end;
  suppose
A14: r1<1-r2;
    set s2=1-r1;
    set s1=1-r2;
    1-s2+s2<=1+s2 by A6,XREAL_1:6;
    then
A15: 1-1<=s2 by XREAL_1:20;
A16: 0 qua Nat+s1<=1-s1+s1 by A8,XREAL_1:6;
    now
      per cases;
      case
A17:    s2<>0;
        s2*p1=(1-s1)*p3 + s1*p2-(1-s2)*p2 by A5,A7,RLVECT_4:1
          .=(1-s1)*p3 + (s1*p2-(1-s2)*p2) by RLVECT_1:def 3
          .=(1-s1)*p3 + (s1-(1-s2))*p2 by RLVECT_1:35;
        then (s2"*s2)*p1=s2"*((1-s1)*p3 + (s1-(1-s2))*p2) by RLVECT_1:def 7;
        then 1*p1=s2"*((1-s1)*p3 + (s1-(1-s2))*p2) by A17,XCMPLX_0:def 7;
        then p1=s2"*((1-s1)*p3 + (s1-(1-s2))*p2) by RLVECT_1:def 8
          .=s2"*((1-s1)*p3) +s2"*((s1-(1-s2))*p2) by RLVECT_1:def 5
          .=(s2"*(1-s1))*p3 +s2"*((s1-(1-s2))*p2) by RLVECT_1:def 7;
        then
A18:    p1=(s2"*(1-s1))*p3 +(s2"*(s1-(1-s2)))*p2 by RLVECT_1:def 7;
        s1<=1+(0 qua Nat) by A16;
        then s1-1<=0 by XREAL_1:20;
        then s1-1+s2<=0 qua Nat+s2 by XREAL_1:6;
        then
A19:    s2"*(s1-(1-s2))<=s2"*s2 by A15,XREAL_1:64;
        s2"*(1-s1) +s2"*(s1-(1-s2))=s2"*(1-1+s2) .=1 by A17,XCMPLX_0:def 7;
        then
A20:    s2"*(1-s1)=1-s2"*(s1-(1-s2));
        (s1-(1-s2))>=0 by A14,XREAL_1:48;
        then p1 in {(1-r)*p3+r*p2:0<=r & r<=1} by A15,A18,A20,A19;
        hence thesis by RLTOPSP1:def 2;
      end;
      case
        s2=0;
        then p=1*p2+0.TOP-REAL n by A5,RLVECT_1:10;
        then p=p2+0.TOP-REAL n by RLVECT_1:def 8;
        hence thesis by A1,RLVECT_1:4;
      end;
    end;
    hence thesis;
  end;
end;
