(***********************************************)
(* Unification tactic for signed areas         *)
(***********************************************)
(* Simplification is necessary for termination *)
(***********************************************)

Ltac uniformize_signed_areas_goal :=
  repeat
   match goal with
   |  |- context [(- - ?X1)] =>
       replace (- - X1) with X1 by apply simplring1
   |  |- context [(S ?X1 ?X1 ?X2)] =>
       replace (S X1 X1 X2) with 0 by apply trivial_col1
   |  |- context [(S ?X2 ?X1 ?X1)] =>
       replace (S X2 X1 X1) with 0 by apply trivial_col2
   |  |- context [(S ?X1 ?X2 ?X1)] =>
       replace (S X1 X2 X1) with 0 by apply trivial_col3
   |  |- context [(S ?X1 ?X2 ?X3)] =>
    ( let Truc := fresh in
    match goal with
       |  |- context [(S ?X4 ?X5 ?X6)] =>
            (assert (Truc : S X4 X5 X6 = - S X1 X2 X3);
             [ apply S_3 || apply S_2 || apply S_4
             | rewrite Truc; clear Truc ]) ||
             (assert (Truc : S X4 X5 X6 = S X1 X2 X3);
               [ apply S_0 || apply S_1 | rewrite Truc; clear Truc ])
       end)
   end.Ltac generalize_all_areas :=
   repeat match goal with
          H: context [(S ?X1 ?X2 ?X3)] |- _=> revert H
 end.Ltac uniformize_signed_areas :=
  generalize_all_areas;uniformize_signed_areas_goal;intros.

(* Specifications: *)
Lemma S4Simpl_1 : forall A B C : Point, S4 A B B C = S A B C.
Lemma S4Simpl_2 : forall A B C : Point, S4 A B C C = S A B C.
Lemma S4Simpl_3 : forall A B C : Point, S4 A A B C = S A B C.
Lemma S4Simpl_4 : forall A B C : Point, S4 A B C A = S A B C.
Lemma S4Simpl_5 : forall A C D : Point, S4 C A D A = 0.
Lemma S4Simpl_6 : forall A C D : Point, S4 A C A D = 0.
Lemma half : 1- 1/2 = 1/2.