Section T16.
Context `{T2D:Tarski_2D}.
Context `{TE:@Tarski_euclidean Tn TnEQD}.
(** Lemma 16.2 in dimension 2. *)
(** As we are in dimension 2, we skip 16.3 which is only needed to prove 16.4 in dimension n. *)

Lemma square_distance_formula :
forall O E E' S U1 U2 P Q PX PY QX QY PQ PQ2 PXMQX PYMQY PXMQX2 PYMQY2 F,
Cd O E S U1 U2 P PX PY -> Cd O E S U1 U2 Q QX QY -> Is_length O E E' P Q PQ ->
Prod O E E' PQ PQ PQ2 -> Diff O E E' PX QX PXMQX ->
Prod O E E' PXMQX PXMQX PXMQX2 -> Diff O E E' PY QY PYMQY ->
Prod O E E' PYMQY PYMQY PYMQY2 -> Sum O E E' PXMQX2 PYMQY2 F ->
PQ2 = F.