(** The following development is inspired by The Foundations of Geometry and the Non-Euclidean Plane, by George E Martin, chapter 22 *)

(* Specifications: *)
(** Additivity of the defect : if C1 is between A and C, the defect of ABC is the sum of the defects of ABC1 and BC1C. In this proof, we have to exclude the semi-elliptical case so that the sums of angles behave. *)
Lemma t22_16_1 :
~ hypothesis_of_obtuse_saccheri_quadrilaterals ->
forall A B C C1 D E F G H I K L M,
Bet A C1 C -> Defect A B C1 D E F -> Defect B C1 C G H I ->
SumA D E F G H I K L M ->
SAMS D E F G H I /\ Defect A B C K L M.
Lemma t22_16_1bis :
~ hypothesis_of_obtuse_saccheri_quadrilaterals ->
forall A B C C1 D E F G H I K L M,
Bet A C1 C ->
Defect A B C1 D E F -> Defect B C1 C G H I -> Defect A B C K L M ->
SAMS D E F G H I /\ SumA D E F G H I K L M.
Lemma t22_16_2aux :
~ hypothesis_of_obtuse_saccheri_quadrilaterals ->
forall A B C D A1 A2 A3 B1 B2 B3 C1 C2 C3 D1 D2 D3 O P Q R,
Defect A B C D1 D2 D3 -> Defect A B D C1 C2 C3 ->
Defect A D C B1 B2 B3 -> Defect C B D A1 A2 A3 ->
Bet A O C -> Bet B O D -> Col A B C -> SumA D1 D2 D3 B1 B2 B3 P Q R ->
SAMS C1 C2 C3 A1 A2 A3 /\ SumA C1 C2 C3 A1 A2 A3 P Q R.
Lemma t22_16_2aux1 :
~ hypothesis_of_obtuse_saccheri_quadrilaterals ->
forall A B C D A1 A2 A3 B1 B2 B3 C1 C2 C3 D1 D2 D3 O P Q R,
Defect A B C D1 D2 D3 -> Defect A B D C1 C2 C3 ->
Defect A D C B1 B2 B3 -> Defect C B D A1 A2 A3 ->
Bet A O C -> Bet B O D -> Col A B D -> SumA D1 D2 D3 B1 B2 B3 P Q R ->
SAMS C1 C2 C3 A1 A2 A3 /\ SumA C1 C2 C3 A1 A2 A3 P Q R.
(** In a convex quadrilateral ABCD, the sum of the defects of ABC and ADC is equal to the sum of the defects of ABD and CBD. We add some hypotheses to make the proof easier *)
Lemma t22_16_2 :
~ hypothesis_of_obtuse_saccheri_quadrilaterals ->
forall A B C D A1 A2 A3 B1 B2 B3 C1 C2 C3 D1 D2 D3 O P Q R,
Defect A B C D1 D2 D3 -> Defect A B D C1 C2 C3 ->
Defect A D C B1 B2 B3 -> Defect C B D A1 A2 A3 ->
Bet A O C -> Bet B O D ->
SAMS D1 D2 D3 B1 B2 B3 -> SumA D1 D2 D3 B1 B2 B3 P Q R ->
SAMS C1 C2 C3 A1 A2 A3 /\ SumA C1 C2 C3 A1 A2 A3 P Q R.