End Grid.

(* Specifications: *)
Lemma pj_uniqueness : forall O E E' A A' A'', ~Col O E E' -> Col O E A -> Col O E' A' -> Col O E' A'' -> Pj E E' A A' -> Pj E E' A A'' -> A' = A''.
Lemma pj_right_comm : forall A B C D, Pj A B C D -> Pj A B D C.
Lemma pj_left_comm : forall A B C D, Pj A B C D -> Pj B A C D.
Lemma pj_comm : forall A B C D, Pj A B C D -> Pj B A D C.
(** Lemma 14.13 *)
(** Parallel projection on the second axis preserves sums. *)
Lemma proj_preserves_sum :
forall O E E' A B C A' B' C',
Sum O E E' A B C ->
Ar1 O E' A' B' C' ->
Pj E E' A A' ->
Pj E E' B B' ->
Pj E E' C C' ->
Sum O E' E A' B' C'.
(** Lemma 14.14 *)
Lemma sum_assoc_1 : forall O E E' A B C AB BC ABC,
Sum O E E' A B AB -> Sum O E E' B C BC -> Sum O E E' A BC ABC ->
Sum O E E' AB C ABC.
Lemma sum_assoc_2 : forall O E E' A B C AB BC ABC,
Sum O E E' A B AB ->
Sum O E E' B C BC ->
Sum O E E' AB C ABC ->
Sum O E E' A BC ABC.
Lemma sum_assoc : forall O E E' A B C AB BC ABC,
Sum O E E' A B AB ->
Sum O E E' B C BC ->
(Sum O E E' A BC ABC <-> Sum O E E' AB C ABC).
(** Lemma 14.15 *)
(** The choice of E' does not affect sum. *)
Lemma sum_y_axis_change :
forall O E E' E'' A B C,
Sum O E E' A B C ->
~ Col O E E'' ->
Sum O E E'' A B C.
(** Lemma 14.16 *)
(** The choice of E does not affect sum. *)
Lemma sum_x_axis_unit_change :
forall O E E' U A B C,
Sum O E E' A B C ->
Col O E U ->
U <> O ->
Sum O U E' A B C.
Lemma change_grid_sum_0 :
forall O E E' A B C O' A' B' C',
Par_strict O E O' E' ->
Ar1 O E A B C ->
Ar1 O' E' A' B' C' ->
Pj O O' E E' ->
Pj O O' A A' ->
Pj O O' B B' ->
Pj O O' C C' ->
Sum O E E' A B C ->
A = O ->
Sum O' E' E A' B' C'.
Lemma change_grid_sum :
forall O E E' A B C O' A' B' C',
Par_strict O E O' E' ->
Ar1 O E A B C ->
Ar1 O' E' A' B' C' ->
Pj O O' E E' ->
Pj O O' A A' ->
Pj O O' B B' ->
Pj O O' C C' ->
Sum O E E' A B C ->
Sum O' E' E A' B' C'.
Lemma double_null_null : forall O E E' A, Sum O E E' A A O -> A = O.
Lemma not_null_double_not_null : forall O E E' A C, Sum O E E' A A C -> A <> O -> C <> O.
Lemma double_not_null_not_nul : forall O E E' A C, Sum O E E' A A C -> C <> O -> A <> O.
Lemma diff_ar2 : forall O E E' A B AMB, Diff O E E' A B AMB -> Ar2 O E E' A B AMB.
Lemma diff_null : forall O E E' A, ~Col O E E' -> Col O E A -> Diff O E E' A A O.
Lemma diff_exists : forall O E E' A B, ~Col O E E' -> Col O E A -> Col O E B ->  exists D, Diff O E E' A B D.
Lemma diff_uniqueness : forall O E E' A B D1 D2, Diff O E E' A B D1 -> Diff O E E' A B D2 -> D1 = D2.
Lemma sum_ar2 : forall O E E' A B C, Sum O E E' A B C -> Ar2 O E E' A B C.
Lemma diff_A_O : forall O E E' A, ~Col O E E' -> Col O E A ->  Diff O E E' A O A.
Lemma diff_O_A : forall O E E' A mA,
~ Col O E E' -> Opp O E E' A mA -> Diff O E E' O A mA.
Lemma diff_O_A_opp : forall O E E' A mA, Diff O E E' O A mA -> Opp O E E' A mA.
Lemma diff_uniquenessA : forall O E E' A A' B C,
Diff O E E' A B C -> Diff O E E' A' B C -> A = A'.
Lemma diff_uniquenessB : forall O E E' A B B' C,
Diff O E E' A B C -> Diff O E E' A B' C -> B = B'.
Lemma diff_null_eq : forall O E E' A B, Diff O E E' A B O -> A = B.
Lemma midpoint_opp: forall O E E' A B,
Ar2 O E E' O A B -> Midpoint O A B -> Opp O E E' A B.
Lemma sum_diff : forall O E E' A B S, Sum O E E' A B S -> Diff O E E' S A B.
Lemma diff_sum : forall O E E' A B S, Diff O E E' S A B -> Sum O E E' A B S.
Lemma diff_opp : forall O E E' A B AmB BmA,
Diff O E E' A B AmB -> Diff O E E' B A BmA -> Opp O E E' AmB BmA.
Lemma sum_stable : forall O E E' A B C S1 S2 , A = B -> Sum O E E' A C S1 -> Sum O E E' B C S2 -> S1 = S2.
Lemma diff_stable : forall O E E' A B C D1 D2 , A = B -> Diff O E E' A C D1 -> Diff O E E' B C D2 -> D1 = D2.
Lemma plg_to_sum : forall O E E' A B C, Ar2 O E E' A B C ->Parallelogram_flat O A C B -> Sum O E E' A B C.
Lemma opp_midpoint :
forall O E E' A MA,
Opp O E E' A MA ->
Midpoint O A MA.
Lemma diff_to_plg : forall O E E' A B dBA, A <> O \/ B <> O -> Diff O E E' B A dBA -> Parallelogram_flat O A B dBA.
Lemma sum3_col : forall O E E' A B C S, sum3 O E E' A B C S -> ~Col O E E' /\ Col O E A /\ Col O E B /\ Col O E C /\ Col O E S.
Lemma sum3_permut : forall O E E' A B C S, sum3 O E E' A B C S -> sum3 O E E' C A B S.
Lemma sum3_comm_1_2 : forall O E E' A B C S, sum3 O E E' A B C S -> sum3 O E E' B A C S.
Lemma sum3_comm_2_3 : forall O E E' A B C S, sum3 O E E' A B C S -> sum3 O E E' A C B S.
Lemma sum3_exists : forall O E E' A B C, Ar2 O E E' A B C -> exists S, sum3 O E E' A B C S.
Lemma sum3_uniqueness : forall O E E' A B C S1 S2, sum3 O E E' A B C S1 -> sum3 O E E' A B C S2 -> S1 = S2.
Lemma sum4_col : forall O E E' A B C D S, Sum4 O E E' A B C D S ->  ~Col O E E' /\ Col O E A /\ Col O E B /\ Col O E C /\ Col O E D /\ Col O E S.
Lemma sum22_col : forall O E E' A B C D S, sum22 O E E' A B C D S ->  ~Col O E E' /\ Col O E A /\ Col O E B /\ Col O E C /\ Col O E D /\ Col O E S.
Lemma sum_to_sum3 : forall O E E' A B AB X S, Sum O E E' A B AB -> Sum O E E' AB X S -> sum3 O E E' A B X S.
Lemma sum3_to_sum4 : forall O E E' A B C X ABC S , sum3 O E E' A B C ABC -> Sum O E E' ABC X S -> Sum4 O E E' A B C X S.
Lemma sum_A_exists : forall O E E' A AB, Ar2 O E E' A AB O -> exists B, Sum O E E' A B AB.
Lemma sum_B_exists : forall O E E' B AB, Ar2 O E E' B AB O -> exists A, Sum O E E' A B AB.
Lemma sum4_equiv : forall O E E' A B C D S, Sum4 O E E' A B C D S <-> sum22 O E E' A B C D S.
Lemma sum4_permut: forall O E E' A B C D S, Sum4 O E E' A B C D S -> Sum4 O E E' D A B C S.
(* a + b + c + d = d + a + b + c *)
Lemma sum22_permut : forall O E E' A B C D S, sum22 O E E' A B C D S -> sum22 O E E' D A B C S.
Lemma sum4_comm : forall O E E' A B C D S, Sum4 O E E' A B C D S -> Sum4 O E E' B A C D S.
(* a + b + c + d = b + a + c + d *)
Lemma sum22_comm : forall O E E' A B C D S, sum22 O E E' A B C D S -> sum22 O E E' B A C D S.
(* a + b + c + d = b  c + a + d *)
Lemma sum_abcd : forall O E E' A B C D AB CD BC AD S,
Sum O E E' A B AB -> Sum O E E' C D CD -> Sum O E E' B C BC ->
Sum O E E' A D AD -> Sum O E E' AB CD S ->
Sum O E E' BC AD S.
(* (b - a) + (c - b) = (c - a) *)
Lemma sum_diff_diff_a : forall O E E' A B C dBA dCB dCA,
Diff O E E' B A dBA -> Diff O E E' C B dCB -> Diff O E E' C A dCA ->
Sum O E E' dCB dBA dCA.
Lemma sum_diff_diff_b : forall O E E' A B C dBA dCB dCA,
Diff O E E' B A dBA -> Diff O E E' C B dCB -> Sum O E E' dCB dBA dCA ->
Diff O E E' C A dCA.
(* (x + y) - (a + b) = (x - a) + (y - b) *)
Lemma sum_diff2_diff_sum2_a : forall O E E' A B C X Y Z dXA dYB dZC,
Sum O E E' A B C -> Sum O E E' X Y Z -> Diff O E E' X A dXA ->
Diff O E E' Y B dYB -> Sum O E E' dXA dYB dZC ->
Diff O E E' Z C dZC.
Lemma sum_diff2_diff_sum2_b : forall O E E' A B C X Y Z dXA dYB dZC,
Sum O E E' A B C -> Sum O E E' X Y Z -> Diff O E E' X A dXA ->
Diff O E E' Y B dYB -> Diff O E E' Z C dZC ->
Sum O E E' dXA dYB dZC .
Lemma sum_opp : forall O E E' X MX, Sum O E E' X MX O -> Opp O E E' X MX.
Lemma sum_diff_diff : forall O E E' AX BX CX AXMBX AXMCX BXMCX,
Diff O E E' AX BX AXMBX -> Diff O E E' AX CX AXMCX ->
Diff O E E' BX CX BXMCX ->
Sum O E E' AXMBX BXMCX AXMCX.
(** Lemma 14.17 *)
Lemma prod_0_l : forall O E E' A,
~ Col O E E' -> Col O E A -> Prod O E E' O A O.
Lemma prod_0_r : forall O E E' A,
~ Col O E E' -> Col O E A -> Prod O E E' A O O.
(** Lemma 14.18 *)
Lemma prod_1_l : forall O E E' A,
~ Col O E E' -> Col O E A ->  Prod O E E' E A A.
Lemma prod_1_r : forall O E E' A,
~ Col O E E' -> Col O E A -> Prod O E E' A E A.
(** Lemma 14.19 *)
Lemma inv_exists : forall O E E' A,
~ Col O E E' -> Col O E A -> A <> O ->
exists IA, Prod O E E' IA A E.
(** Lemma 14.20 *)
(** The choice of E' does not affect product *)
Lemma prod_null : forall O E E' A B, Prod O E E' A B O -> A = O \/ B = O.
Lemma prod_y_axis_change : forall O E E' E'' A B C,
Prod O E E' A B C -> ~ Col O E E'' -> Prod O E E'' A B C.
(** Lemma 14.22 *)
(** Parallel projection on the second axis preserves products. *)
Lemma proj_preserves_prod : forall O E E' A B C A' B' C',
Prod O E E' A B C -> Ar1 O E' A' B' C' ->
Pj E E' A A' -> Pj E E' B B' -> Pj E E' C C' ->
Prod O E' E A' B' C'.
(** Lemma 14.23 *)
(** Product is associative.*)
Lemma prod_assoc1 : forall O E E' A B C AB BC ABC,
Prod O E E' A B AB -> Prod O E E' B C BC ->
(Prod O E E' A BC ABC -> Prod O E E' AB C ABC).
Lemma prod_assoc2 : forall O E E' A B C AB BC ABC,
Prod O E E' A B AB -> Prod O E E' B C BC ->
(Prod O E E' AB C ABC -> Prod O E E' A BC ABC).
Lemma prod_assoc : forall O E E' A B C AB BC ABC,
Prod O E E' A B AB -> Prod O E E' B C BC ->
(Prod O E E' A BC ABC <-> Prod O E E' AB C ABC).
Lemma prod_comm : forall O E E' A B C, Prod O E E' A B C -> Prod O E E' B A C.
(** Lemma 14.24 *)
(** Left distributivity of product over sum.*)
Lemma prod_O_l_eq : forall O E E' B C, Prod O E E' O B C -> C = O.
Lemma prod_O_r_eq : forall O E E' A C, Prod O E E' A O C -> C = O.
Lemma prod_uniquenessA : forall O E E' A A' B C,
B <> O -> Prod O E E' A B C -> Prod O E E' A' B C -> A = A'.
Lemma prod_uniquenessB : forall O E E' A B B' C,
A <> O -> Prod O E E' A B C -> Prod O E E' A B' C -> B = B'.
(** Lemma 14.25 *)
(** Left distributivity of product over sum.*)
Lemma distr_l : forall O E E' A B C D AB AC AD,
Sum O E E' B C D -> Prod O E E' A B AB -> Prod O E E' A C AC ->
(Prod O E E' A D AD -> Sum O E E' AB AC AD).
(** Lemma 14.24 *)
(** Right distributivity of product over sum.*)
Lemma distr_r : forall O E E' A B C D AC BC DC,
Sum O E E' A B D -> Prod O E E' A C AC -> Prod O E E' B C BC ->
(Prod O E E' D C DC -> Sum O E E' AC BC DC).