Require Export GeoCoq.Tarski_dev.Ch12_parallel_inter_dec.
Require Export GeoCoq.Tarski_dev.Annexes.Tagged_predicates.
Ltac image_6 A B P' H P:=
let T:= fresh in assert (T:= l10_6_existence A B P' H);
ex_and T P.
Ltac image A B P P':=
let T:= fresh in assert (T:= l10_2_existence A B P);
ex_and T P'.
Ltac perp A B C X :=
match goal with
| H:(~Col A B C) |- _ =>
let T:= fresh in assert (T:= l8_18_existence A B C H);
ex_and T X
end.
Ltac parallel A B C D P :=
match goal with
| H:(A <> B) |- _ =>
let T := fresh in assert(T:= parallel_existence A B P H);
ex_and T C
end.
Ltac par_strict :=
repeat
match goal with
| H: Par_strict ?A ?B ?C ?D |- _ =>
let T := fresh in not_exist_hyp (Par_strict B A D C); assert (T := par_strict_comm A B C D H)
| H: Par_strict ?A ?B ?C ?D |- _ =>
let T := fresh in not_exist_hyp (Par_strict C D A B); assert (T := par_strict_symmetry A B C D H)
| H: Par_strict ?A ?B ?C ?D |- _ =>
let T := fresh in not_exist_hyp (Par_strict B A C D); assert (T := par_strict_left_comm A B C D H)
| H: Par_strict ?A ?B ?C ?D |- _ =>
let T := fresh in not_exist_hyp (Par_strict A B D C); assert (T := par_strict_right_comm A B C D H)
end.
Ltac clean_trivial_hyps :=
repeat
match goal with
| H:(Cong ?X1 ?X1 ?X2 ?X2) |- _ => clear H
| H:(Cong ?X1 ?X2 ?X2 ?X1) |- _ => clear H
| H:(Cong ?X1 ?X2 ?X1 ?X2) |- _ => clear H
| H:(Bet ?X1 ?X1 ?X2) |- _ => clear H
| H:(Bet ?X2 ?X1 ?X1) |- _ => clear H
| H:(Col ?X1 ?X1 ?X2) |- _ => clear H
| H:(Col ?X2 ?X1 ?X1) |- _ => clear H
| H:(Col ?X1 ?X2 ?X1) |- _ => clear H
| H:(Par ?X1 ?X2 ?X1 ?X2) |- _ => clear H
| H:(Par ?X1 ?X2 ?X2 ?X1) |- _ => clear H
| H:(Per ?X1 ?X2 ?X2)     |- _ => clear H
| H:(Per ?X1 ?X1 ?X2)     |- _ => clear H
| H:(Midpoint ?X1 ?X1 ?X1) |- _ => clear H
end.
Ltac show_distinct2 := unfold not;intro;treat_equalities; try (solve [intuition]).
Ltac symmetric A B A' :=
let T := fresh in assert(T:= symmetric_point_construction A B);
ex_and T A'.
Tactic Notation "Name" ident(X) "the" "symmetric" "of" ident(A) "wrt" ident(C) :=
symmetric A C X.
Ltac sfinish := repeat match goal with
| |- Bet ?A ?B ?C => Between; eBetween
| |- Col ?A ?B ?C => Col;ColR
| |- ~ Col ?A ?B ?C => Col
| |- ~ Col ?A ?B ?C => intro;search_contradiction
| |- Par ?A ?B ?C ?D => Par
| |- Par_strict ?A ?B ?C ?D => Par
| |- Perp ?A ?B ?C ?D => Perp
| |- Perp_at ?A ?B ?C ?D ?E => Perp
| |- Per ?A ?B ?C => Perp
| |- Cong ?A ?B ?C ?D => Cong;eCong
| |- Midpoint ?A ?B ?C => Midpoint
| |- ?A<>?B => apply swap_diff;assumption
| |- ?A<>?B => intro;treat_equalities; solve [search_contradiction]
| |- ?G1 /\ ?G2 => split
| |- _ => try assumption
end.
Ltac clean_reap_hyps :=
clean_duplicated_hyps;
repeat
match goal with
| H:(Parallelogram ?A ?B ?C ?D), H2 : Parallelogram ?B ?C ?D ?A |- _ => clear H2
| H:(Parallelogram ?A ?B ?C ?D), H2 : Parallelogram ?C ?D ?A ?B |- _ => clear H2
| H:(Parallelogram ?A ?B ?C ?D), H2 : Parallelogram ?D ?A ?B ?C |- _ => clear H2
| H:(Parallelogram ?A ?B ?C ?D), H2 : Parallelogram ?D ?C ?B ?A |- _ => clear H2
| H:(Parallelogram ?A ?B ?C ?D), H2 : Parallelogram ?C ?B ?A ?D |- _ => clear H2
| H:(Parallelogram ?A ?B ?C ?D), H2 : Parallelogram ?B ?A ?D ?C |- _ => clear H2
| H:(Parallelogram ?A ?B ?C ?D), H2 : Parallelogram ?A ?D ?C ?B |- _ => clear H2
| H:(Par ?A ?B ?C ?D), H2 : Par ?A ?B ?D ?C |- _ => clear H2
| H:(Par ?A ?B ?C ?D), H2 : Par ?C ?D ?A ?B |- _ => clear H2
| H:(Par ?A ?B ?C ?D), H2 : Par ?C ?D ?B ?A |- _ => clear H2
| H:(Par ?A ?B ?C ?D), H2 : Par ?D ?C ?B ?A |- _ => clear H2
| H:(Par ?A ?B ?C ?D), H2 : Par ?D ?C ?A ?B |- _ => clear H2
| H:(Par ?A ?B ?C ?D), H2 : Par ?B ?A ?C ?D |- _ => clear H2
| H:(Par ?A ?B ?C ?D), H2 : Par ?B ?A ?D ?C |- _ => clear H2
| H:(Par_strict ?A ?B ?C ?D), H2 : Par_strict ?A ?B ?D ?C |- _ => clear H2
| H:(Par_strict ?A ?B ?C ?D), H2 : Par_strict ?C ?D ?A ?B |- _ => clear H2
| H:(Par_strict ?A ?B ?C ?D), H2 : Par_strict ?C ?D ?B ?A |- _ => clear H2
| H:(Par_strict ?A ?B ?C ?D), H2 : Par_strict ?D ?C ?B ?A |- _ => clear H2
| H:(Par_strict ?A ?B ?C ?D), H2 : Par_strict ?D ?C ?A ?B |- _ => clear H2
| H:(Par_strict ?A ?B ?C ?D), H2 : Par_strict ?B ?A ?C ?D |- _ => clear H2
| H:(Par_strict ?A ?B ?C ?D), H2 : Par_strict ?B ?A ?D ?C |- _ => clear H2
| H:(Perp ?A ?B ?C ?D), H2 : Perp ?A ?B ?D ?C |- _ => clear H2
| H:(Perp ?A ?B ?C ?D), H2 : Perp ?C ?D ?A ?B |- _ => clear H2
| H:(Perp ?A ?B ?C ?D), H2 : Perp ?C ?D ?B ?A |- _ => clear H2
| H:(Perp ?A ?B ?C ?D), H2 : Perp ?D ?C ?B ?A |- _ => clear H2
| H:(Perp ?A ?B ?C ?D), H2 : Perp ?D ?C ?A ?B |- _ => clear H2
| H:(Perp ?A ?B ?C ?D), H2 : Perp ?B ?A ?C ?D |- _ => clear H2
| H:(Perp ?A ?B ?C ?D), H2 : Perp ?B ?A ?D ?C |- _ => clear H2
| H:(Perp_at ?X ?A ?B ?C ?D), H2 : Perp_at ?X ?A ?B ?D ?C |- _ => clear H2
| H:(Perp_at ?X ?A ?B ?C ?D), H2 : Perp_at ?X ?C ?D ?A ?B |- _ => clear H2
| H:(Perp_at ?X ?A ?B ?C ?D), H2 : Perp_at ?X ?C ?D ?B ?A |- _ => clear H2
| H:(Perp_at ?X ?A ?B ?C ?D), H2 : Perp_at ?X ?D ?C ?B ?A |- _ => clear H2
| H:(Perp_at ?X ?A ?B ?C ?D), H2 : Perp_at ?X ?D ?C ?A ?B |- _ => clear H2
| H:(Perp_at ?X ?A ?B ?C ?D), H2 : Perp_at ?X ?B ?A ?C ?D |- _ => clear H2
| H:(Perp_at ?X ?A ?B ?C ?D), H2 : Perp_at ?X ?B ?A ?D ?C |- _ => clear H2
| H:(Per ?A ?B ?C), H2 : Per ?C ?B ?A |- _ => clear H2
| H:(Midpoint ?A ?B ?C), H2 : Midpoint ?A ?C ?B |- _ => clear H2
| H:(~Col ?A ?B ?C), H2 : (~Col ?B ?A ?C) |- _ => clear H2
| H:(~Col ?A ?B ?C), H2 : (~Col ?B ?C ?A) |- _ => clear H2
| H:(~Col ?A ?B ?C), H2 : (~Col ?C ?B ?A) |- _ => clear H2
| H:(~Col ?A ?B ?C), H2 : (~Col ?C ?A ?B) |- _ => clear H2
| H:(~Col ?A ?B ?C), H2 : (~Col ?A ?C ?B) |- _ => clear H2
| H:(Col ?A ?B ?C), H2 : Col ?A ?C ?B |- _ => clear H2
| H:(Col ?A ?B ?C), H2 : Col ?B ?A ?C |- _ => clear H2
| H:(Col ?A ?B ?C), H2 : Col ?B ?C ?A |- _ => clear H2
| H:(Col ?A ?B ?C), H2 : Col ?C ?B ?A |- _ => clear H2
| H:(Col ?A ?B ?C), H2 : Col ?C ?A ?B |- _ => clear H2
| H:(Bet ?A ?B ?C), H2 : Bet ?C ?B ?A |- _ => clear H2
| H:(Cong ?A ?B ?C ?D), H2 : Cong ?A ?B ?D ?C |- _ => clear H2
| H:(Cong ?A ?B ?C ?D), H2 : Cong ?C ?D ?A ?B |- _ => clear H2
| H:(Cong ?A ?B ?C ?D), H2 : Cong ?C ?D ?B ?A |- _ => clear H2
| H:(Cong ?A ?B ?C ?D), H2 : Cong ?D ?C ?B ?A |- _ => clear H2
| H:(Cong ?A ?B ?C ?D), H2 : Cong ?D ?C ?A ?B |- _ => clear H2
| H:(Cong ?A ?B ?C ?D), H2 : Cong ?B ?A ?C ?D |- _ => clear H2
| H:(Cong ?A ?B ?C ?D), H2 : Cong ?B ?A ?D ?C |- _ => clear H2
| H:(?A<>?B), H2 : (?B<>?A) |- _ => clear H2
end.
Ltac tag_hyps :=
repeat
match goal with
| H : ?A <> ?B |- _ => apply Diff_Diff_tagged in H
| H : Cong ?A ?B ?C ?D |- _ => apply Cong_Cong_tagged in H
| H : Bet ?A ?B ?C |- _ => apply Bet_Bet_tagged in H
| H : Col ?A ?B ?C |- _ => apply Col_Col_tagged in H
| H : ~ Col ?A ?B ?C |- _ => apply NCol_NCol_tagged in H
| H : Midpoint ?A ?B ?C |- _ => apply Mid_Mid_tagged in H
| H : Per ?A ?B ?C |- _ => apply Per_Per_tagged in H
| H : Perp_at ?X ?A ?B ?C ?D |- _ => apply Perp_in_Perp_in_tagged in H
| H : Perp ?A ?B ?C ?D |- _ => apply Perp_Perp_tagged in H
| H : Par_strict ?A ?B ?C ?D |- _ => apply Par_strict_Par_strict_tagged in H
| H : Par ?A ?B ?C ?D |- _ => apply Par_Par_tagged in H
| H : Parallelogram ?A ?B ?C ?D |- _ => apply Plg_Plg_tagged in H
end.
Ltac permutation_intro_in_goal :=
match goal with
| |- Par ?A ?B ?C ?D => apply Par_cases
| |- Par_strict ?A ?B ?C ?D => apply Par_strict_cases
| |- Perp ?A ?B ?C ?D => apply Perp_cases
| |- Perp_at ?X ?A ?B ?C ?D => apply Perp_in_cases
| |- Per ?A ?B ?C => apply Per_cases
| |- Midpoint ?A ?B ?C => apply Mid_cases
| |- ~ Col ?A ?B ?C => apply NCol_cases
| |- Col ?A ?B ?C => apply Col_cases
| |- Bet ?A ?B ?C => apply Bet_cases
| |- Cong ?A ?B ?C ?D => apply Cong_cases
end.
Ltac perm_apply t :=
permutation_intro_in_goal;
try_or ltac:(apply t;solve [finish]).
Ltac assert_ncols :=
repeat
match goal with
| H:OS ?A ?B ?X ?Y |- _ =>
not_exist_hyp_perm_ncol A B X;assert (~ Col A B X) by (apply(one_side_not_col123 A B X Y);finish)
| H:OS ?A ?B ?X ?Y |- _ =>
not_exist_hyp_perm_ncol A B Y;assert (~ Col A B Y) by (apply(one_side_not_col124 A B X Y);finish)
| H:TS ?A ?B ?X ?Y |- _ =>
not_exist_hyp_perm_ncol A B X;assert (~ Col A B X) by (apply(two_sides_not_col A B X Y);finish)
| H:TS ?A ?B ?X ?Y |- _ =>
not_exist_hyp_perm_ncol A B Y;assert (~ Col A B Y) by (apply(two_sides_not_col A B Y X);finish)
| H:~ Coplanar ?A ?B ?C ?D |- _ =>
let h := fresh in
not_exist_hyp_perm4 A B C D;
assert (h := ncop__ncols A B C D H);decompose [and] h;clear h;clean_reap_hyps
| H:Par_strict ?A ?B ?C ?D |- _ =>
let h := fresh in
not_exist_hyp_perm4 A B C D;
assert (h := par_strict_not_cols A B C D H);decompose [and] h;clear h;clean_reap_hyps
| H:Parallelogram_strict ?A ?B ?C ?D |- _ =>
let h := fresh in
not_exist_hyp_perm4 A B C D;
assert (h := plgs_not_col A B C D H);decompose [and] h;clear h;clean_reap_hyps
end.
Section Quadrilateral_inter_dec_1.
Context `{TE:Tarski_euclidean}.

Lemma plg_mid_2 :
forall A B C D I,
Parallelogram A B C D ->
Midpoint I A C ->
Midpoint I B D.