reserve p1,p2,p3,p4,p5,p6,p,pc for Point of TOP-REAL 2;
reserve a,b,c,r,s for Real;

theorem Th7:
  a = |.p1-p2.| & b = |.p3-p2.| & c = |.p3-p1.| implies c^2 = a^2 +
  b^2 - 2*a*b * cos angle(p1,p2,p3)
proof
  assume that
A1: a = |.p1-p2.| & b = |.p3-p2.| and
A2: c = |.p3-p1.|;
  per cases;
  suppose
A3: p1=p2;
    then |.p1-p2.| = |.0.TOP-REAL 2.| by RLVECT_1:5
      .= 0 by EUCLID_2:39;
    hence thesis by A1,A2,A3;
  end;
  suppose
A4: p1<>p2;
    per cases;
    suppose
A5:   p2=p3;
      then |.p3-p2.| = |.0.TOP-REAL 2.| by RLVECT_1:5
        .= 0 by EUCLID_2:39;
      then |.p1-p2.|^2 + |.p3-p2.|^2 - 2*|.p1-p2.|*|.p3-p2.|*cos angle(p1,p2,
      p3) = |.-(p1 - p2).|^2 by EUCLID:71
        .= |.p2 - p1.|^2 by RLVECT_1:33;
      hence thesis by A1,A2,A5;
    end;
    suppose
A6:   p2<>p3;
      set c2 = euc2cpx(p3-p2);
      set c1 = euc2cpx(p1-p2);
A7:   now
        assume
A8:     c1=0 or c2=0;
        per cases by A8;
        suppose
          c1=0;
          hence contradiction by A4,EUCLID_3:18,RLVECT_1:21;
        end;
        suppose
          c2=0;
          hence contradiction by A6,EUCLID_3:18,RLVECT_1:21;
        end;
      end;
A9:   now
        assume
A10:    |.c1.|*|.c2.|=0;
        per cases by A10;
        suppose
          |.c1.|=0;
          hence contradiction by A7,COMPLEX1:45;
        end;
        suppose
          |.c2.|=0;
          hence contradiction by A7,COMPLEX1:45;
        end;
      end;
A11:  a^2+b^2-c^2 = |.p1.|^2-2*|(p2, p1)|+|.p2.|^2+|.p3-p2.|^2- |.p3-p1.|
      ^2 by A1,A2,EUCLID_2:46
        .= |.p1.|^2-2*|(p2, p1)|+|.p2.|^2 + |.p3-p2.|^2 -(|.p3.|^2-2*|(p1,
      p3)|+|.p1.|^2) by EUCLID_2:46
        .= -2*|(p2, p1)|+|.p2.|^2 + |.p3-p2.|^2 - |.p3.|^2 + 2*|(p1, p3)|
        .= -2*|(p2, p1)|+|.p2.|^2 + (|.p3.|^2-2*|(p2, p3)|+|.p2.|^2) - |.p3
      .|^2 + 2*|(p1, p3)| by EUCLID_2:46
        .= 2*(- |(p2,p1)|+|.p2.|^2 - |(p2, p3)|+ |(p1, p3)|);
      |.p1-p2.|*|.p3-p2.|*cos angle(p1,p2,p3) = |.p1-p2.|*|.p3-p2.|*cos
      angle(c1,c2) by Lm7
        .= |.c1.|*|.p3-p2.|*cos angle(c1,c2) by Lm16
        .= |.c1.|*|.c2.|*cos angle(c1,c2) by Lm16
        .= |.c1.|*|.c2.|*(Re (c1.|.c2)/(|.c1.|*|.c2.|)) by A7,COMPLEX2:69
        .= (Re (c1.|.c2)/((|.c1.|*|.c2.|)/(|.c1.|*|.c2.|))) by XCMPLX_1:81
        .= Re (c1.|.c2)/1 by A9,XCMPLX_1:60
        .= (p1`1 - p2`1)*(p3`1 - p2`1)+(p1`2 - p2`2)*(p3`2 - p2`2) by Lm16
        .= p1`1*p3`1+p1`2*p3`2 -p1`1*p2`1-p2`1*p3`1+p2`1*p2`1+ (-p1`2*p2`2-
      p2`2*p3`2+p2`2*p2`2)
        .= |(p1,p3)|-p1`1*p2`1-p2`1*p3`1+p2`1*p2`1+ (-p1`2*p2`2-p2`2*p3`2+p2
      `2*p2`2) by EUCLID_3:41
        .= |(p1,p3)|-(p1`1*p2`1+p1`2*p2`2)-p2`1*p3`1+p2`1*p2`1+ (-p2`2*p3`2+
      p2`2*p2`2)
        .= |(p1,p3)|- |(p1,p2)|-p2`1*p3`1+p2`1*p2`1+ (-p2`2*p3`2+p2`2*p2`2)
      by EUCLID_3:41
        .= |(p1,p3)|- |(p1,p2)|-(p2`1*p3`1+p2`2*p3`2)+p2`1*p2`1+p2`2*p2`2
        .= |(p1,p3)|- |(p1,p2)|- |(p2,p3)|+p2`1*p2`1+p2`2*p2`2 by EUCLID_3:41
        .= |(p1,p3)|- |(p1,p2)|- |(p2,p3)|+(p2`1*p2`1+p2`2*p2`2)
        .= |(p1,p3)|- |(p1,p2)|- |(p2,p3)|+|(p2,p2)| by EUCLID_3:41
        .= |(p1,p3)|- |(p1,p2)|- |(p2,p3)|+|.p2.|^2 by EUCLID_2:36;
      hence thesis by A1,A11;
    end;
  end;
end;
