reserve n for Nat,
        lambda,lambda2,mu,mu2 for Real,
        x1,x2 for Element of REAL n,
        An,Bn,Cn for Point of TOP-REAL n,
        a for Real;
 reserve Pn,PAn,PBn for Element of REAL n,
         Ln for Element of line_of_REAL n;
reserve A,B,C for Point of TOP-REAL 2;

theorem Th9:
  |.A-B.| = |.A-C.| + |.C-B.| implies C in LSeg(A,B)
  proof
    assume
A1: |.A-B.| = |.A-C.| + |.C-B.|; then
A2: |.B-A.| = |.A-C.| + |.C-B.| by EUCLID_6:43
           .= |.A-C.| + |.B-C.| by EUCLID_6:43;
    per cases;
    suppose A=B;
      then |.A-C.| = 0 & |.C-B.| = 0 by A1,EUCLID_6:42;
      then A=C & C=B by EUCLID_6:42;
      hence thesis by RLTOPSP1:68;
    end;
    suppose
A3:   A<>B;
      per cases;
      suppose C=A or C=B;
        hence thesis by RLTOPSP1:68;
      end;
      suppose
A4:     C<>A & C<>B;
        set a = |.A-B.|,b = |.C-B.|, c = |.C-A.|;
        a * b <> 0
        proof
          assume a * b = 0;
          then 0 = a * b / b
                .= a by A4,EUCLID_6:42,XCMPLX_1:89;
          hence thesis by A3,EUCLID_6:42;
        end;
        then
A5:     2 * a * b <> 0;
        c = a - b by A1,EUCLID_6:43;
        then
A6:     c^2 = (a-b) * (a-b) by SQUARE_1:def 1
           .= a * a - 2 * a * b + b * b
           .= a^2 -2 * a * b + b * b by SQUARE_1:def 1
           .= a^2 -2 * a * b + b^2 by SQUARE_1:def 1;
        c^2 = a^2+b^2-2*a*b*cos angle(A,B,C) by EUCLID_6:7;
        then
A7:     cos angle(A,B,C) = 1 & 0 <= angle(A,B,C) < 2*PI
                by A6,A5,EUCLID11:2,XCMPLX_1:7;
        A,B,C are_mutually_distinct by A3,A4;
        then
A8:     angle(B,C,A)=PI or angle(B,A,C)=PI by A7,COMPTRIG:61,MENELAUS:8;
        not A in LSeg(B,C)
        proof
          assume A in LSeg(B,C);
          then |.B-C.| = |.A-C.| + |.B-C.| + |.A-C.| by A2,Th8
                      .= 2 * |.A-C.| + |.B-C.|;
          hence contradiction by A4,EUCLID_6:42;
        end;
        hence thesis by A8,EUCLID_6:11;
      end;
    end;
  end;
