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;
reserve x,y,z,y1,y2 for Element of REAL 2;
reserve L,L1,L2,L3,L4 for Element of line_of_REAL 2;
reserve D,E,F for Point of TOP-REAL 2;
reserve b,c,d,r,s for Real;

theorem Th45:
  A <> B & |.C-A.| = |.C-B.| implies C in the_perpendicular_bisector(A,B)
  proof
    assume that
A1: A <> B and
A2: |.C-A.| = |.C-B.|;
    assume
A3: not C in the_perpendicular_bisector(A,B);
    consider L1, L2 be Element of line_of_REAL 2 such that
    the_perpendicular_bisector(A,B) = L2 and
A4: L1 = Line(A,B) and
A5: L1 _|_ L2 and
    L1 /\ L2 = {the_midpoint_of_the_segment(A,B)} by A1,Def2;
    reconsider rA=A,rB=B,rC=C as Element of REAL 2 by EUCLID:22;
    L1 is being_line by A5,EUCLIDLP:67;
    then consider L3 such that
A6: rC in L3 and
A7: L1 _|_ L3 by Th35;
    consider x such that
A8: L1 /\ L3 = {x} by A7,Th33;
    reconsider D=x as Point of TOP-REAL 2 by EUCLID:22;
A9: D in L1/\L3 by A8,TARSKI:def 1;
A10:
    now
      assume A=D or C=D or B=D;
      then per cases;
      suppose
A11:    A=D;
        now
          thus L1 _|_ L3 by A7;
          thus A in L3 /\ L1 by A11,A8,TARSKI:def 1;
          thus C in L3 & B in L1 by A6,A4,RLTOPSP1:72;
          A<>C
          proof
            assume
A12:        A=C;
            then |.C-B.| = 0 by A2,EUCLID_6:42;
            hence contradiction by A12,A1,EUCLID_6:42;
          end;
          hence A<>C & B<>A by A1;
        end;
        then
A13:    cos angle(C,A,B) = 0 by SIN_COS:77,Th38;
        set z1=|.B-C.|;
        set z2=|.C-A.|;
        set z3=|.B-A.|;
A14:    z1^2 = z2^2+z3^2-2*z2*z3*cos angle(C,A,B) by EUCLID_6:7
            .= z2^2+z3^2 by A13;
        z1^2 = z1^2+z3^2 by A14,A2,EUCLID_6:43;
        then z3=0 by SQUARE_1:12;
        hence contradiction by A1,EUCLID_6:42;
      end;
      suppose C=D;
        then C in L1/\L3 by A8,TARSKI:def 1;
        then
A15:    C in Line(A,B) by A4,XBOOLE_0:def 4;
A16:    |.A-C.| = |.C-B.| by A2,EUCLID_6:43
               .= |.B-C.| by EUCLID_6:43;
        then C in LSeg(A,B) by A15,Th42;
        then C = the_midpoint_of_the_segment(A,B) by A16,Th28;
        hence contradiction by A3,A1,Th43;
      end;
      suppose
A17:    B=D;
        now
          thus L1 _|_ L3 by A7;
          thus B in L3 /\ L1 by A17,A8,TARSKI:def 1;
          thus C in L3 & A in L1 by A6,A4,RLTOPSP1:72;
          B<>C
          proof
            assume
A18:        B=C;
            then |.C-A.| = 0 by A2,EUCLID_6:42;
            hence contradiction by A18,A1,EUCLID_6:42;
          end;
          hence B<>C & B<>A by A1;
        end;
        then
A19:    angle(C,B,A) = PI/2 or angle(C,B,A) = PI + PI/2 by Th38;
        set z1=|.A-C.|;
        set z2=|.C-B.|;
        set z3=|.A-B.|;
        z1^2 = z2^2+z3^2-2*z2*z3*cos angle(C,B,A) by EUCLID_6:7
            .= z2^2+z3^2 by A19,SIN_COS:77;
        then z1^2 = z1^2+z3^2 by A2,EUCLID_6:43;
        then z3 = 0 by SQUARE_1:12;
        hence contradiction by A1,EUCLID_6:42;
      end;
    end;
A20: L1 _|_ L3 & D in L1 /\ L3 & A in L1 & C in L3 &
    A <> D & C <> D by A7,A8,TARSKI:def 1,A4,RLTOPSP1:72,A6,A10;
A21: L1 _|_ L3 & D in L1 /\ L3 & B in L1 & C in L3 &
    B <> D & C <> D by A7,A8,TARSKI:def 1,A4,RLTOPSP1:72,A6,A10;
    set a1 = |.A-D.|;
    set b1 = |.C-D.|;
    set c1 = |.C-A.|;
A22: c1^2 = a1^2 + b1^2 - 2 * a1 * b1 * cos angle(A,D,C) by EUCLID_6:7
        .= a1^2 + b1^2 - 2 * a1 * b1 * 0 by A20,SIN_COS:77,Th38
        .= a1^2 + b1^2;
    set a2 = |.B-D.|;
    set b2 = |.C-D.|;
    set c2 = |.C-B.|;
    c2^2 = a2^2 + b2^2 - 2 * a2 * b2 * cos angle(B,D,C) by EUCLID_6:7
        .= a2^2 + b2^2 - 2 * a2 * b2 * 0 by A21,Th38,SIN_COS:77
        .= a2^2 + b2^2;
    then
A23: a1^2 + b1^2 = a2^2+b2^2 by A2,A22;
    now
      assume a1 = -a2;
      then -(-a2) <= -0;
      then a2 = 0;
      hence contradiction by A10,EUCLID_6:42;
    end;
    then D in L1 & |.A-D.|=|.B-D.| by SQUARE_1:40,A9,A23,XBOOLE_0:def 4;
    then D in LSeg(A,B) & |.A-D.| = |.B-D.| by A4,Th42;
    then D = the_midpoint_of_the_segment(A,B) & D in L3
      by Th28,A9,XBOOLE_0:def 4;
    hence contradiction by A3,A6,A1,A4,A7,Th44;
  end;
