~llee454/llee454-incident-geometry/master

« back to all changes in this revision

Viewing changes to incidence.v

  • Committer: Larry Darryl Lee
  • Date: 2018-06-19 23:00:13 UTC
  • Revision ID: llee454@gmail.com-20180619230013-rz7x24h1671qesls
[Unstable] A real mess sketching out point sets based on distinct point lists.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
(*
2
 
  7:19 7:23 designing
3
 
  5:38 5:56 reviewing
 
2
  5:58 6:12 designing
 
3
  7:50 7:55 reviewing
 
4
  7:55 8:51 coding
 
5
  5:47 6:20 designing
 
6
  6:23 6:58 coding
4
7
  zojirushi $20 
5
8
 
6
9
  This module defines an abstract theory of
917
920
              (eq_refl (p :: qs))).
918
921
 
919
922
(*
920
 
 TODO Give me a list of the points guaranteed to exist by collinearity_axiom.
921
 
 
922
 
 TODO  A function that returns two other points when given a point that are proved to be different and distinct 
923
 
*)
924
 
 
925
 
(*
926
 
  Proves that at least one line passes through
927
 
  each point.
928
 
*)
929
 
Definition point_line_ex
930
 
  :  forall p : point, exists l : line, on l p = true
931
 
  := fun p
932
 
       => ex_ind (fun q =>
933
 
          ex_ind (fun r =>
934
 
          ex_ind (
935
 
            fun (s : point) (H : distinct q r s /\ noncollinear q r s)
936
 
              => let qs := q :: r :: s :: nil in
937
 
                 bool_dec0
938
 
                   (fun _ => exists l : line, on l p = true)
939
 
                   (fun H : points_differentb p qs = true
940
 
                     => let H0
941
 
                          :  p <> q
942
 
                          := points_differentb_head p q (r :: s :: nil) H in
943
 
                        ex_ind
944
 
                          (fun l (H1 : unique (fun l => on l p = true /\ on l q = true) l)
945
 
                            => ex_intro
946
 
                                 (fun l => on l p = true)
947
 
                                 l
948
 
                                 (proj1 (proj1 H1)))
949
 
                          (points_line_axiom p q H0))
950
 
                   (fun H : points_differentb p qs = false
951
 
                     => 
952
 
 
953
 
 
954
 
                            
955
 
(*
956
923
  Accepts a line and a list of points and returns
957
924
  true iff all the ppints lie on the line.
958
925
*)
959
926
Definition points_on
960
927
  :  line -> list point -> bool
961
 
  := fun l ps => forallb (fun p => on l p) ps.
 
928
  := fun l => forallb (on l).
962
929
 
963
930
(*
964
931
  Accepts a list of points and asserts that they
1015
982
                   points_on l qs)
1016
983
              ps).
1017
984
 
 
985
(*
 
986
*)
 
987
Definition point_set
 
988
  :  Set
 
989
  := { ps : list point | points_distinct ps }.
 
990
 
 
991
(*
 
992
*)
 
993
Definition point_set_list
 
994
  :  point_set -> list point
 
995
  := proj1_sig.
 
996
 
 
997
(*
 
998
*)
 
999
Definition point_set_distinct
 
1000
  :  forall ps : point_set, points_distinct (point_set_list ps)
 
1001
  := proj2_sig.
 
1002
 
 
1003
(*
 
1004
*)
 
1005
Definition point_set_in
 
1006
  :  point -> point_set -> Prop
 
1007
  := fun p ps
 
1008
       => In p (point_set_list ps).
 
1009
 
 
1010
(*
 
1011
*)
 
1012
Definition point_set_in_dec
 
1013
  :  forall (p : point) (ps : point_set), {point_set_in p ps} + {~ point_set_in p ps}
 
1014
 
 
1015
(*
 
1016
*)
 
1017
Definition point_set_subset
 
1018
  :  point_set -> point_set -> Prop
 
1019
  := fun ps qs
 
1020
       => forall p : point, point_set_in p ps -> point_set_in p qs.
 
1021
 
 
1022
(*
 
1023
*)
 
1024
Definition point_set_disjoint
 
1025
  :  point_set -> point_set -> Prop
 
1026
  := fun ps qs
 
1027
       => forall p : point, point_set_in p ps -> ~ point_set_in p qs.
 
1028
 
 
1029
(*
 
1030
*)
 
1031
Definition point_set_disjoint_sym
 
1032
  :  forall ps qs : point_set, point_set_disjoint ps qs -> point_set_disjoint qs ps
 
1033
 
 
1034
(*
 
1035
*)
 
1036
Definition point_set_eq
 
1037
  :  point_set -> point_set -> Prop
 
1038
  := fun ps qs
 
1039
       => point_set_subset ps qs /\ point_set_subset qs ps.
 
1040
 
 
1041
(*
 
1042
*)
 
1043
Definition point_set_nil
 
1044
  :  point_set
 
1045
  := exist
 
1046
       (fun ps => points_distinct ps)
 
1047
       nil
 
1048
       points_distinct_nil.
 
1049
 
 
1050
(*
 
1051
*)
 
1052
Definition point_set_difference_strong
 
1053
  :  forall ps qs : point_set, {rs : point_set | forall p : point, point_set_in p ps /\ ~ point_set_in p qs -> point_set_in p rs}
 
1054
 
 
1055
(*
 
1056
 
 
1057
(*
 
1058
*)
 
1059
Definition point_set_singleton
 
1060
  :  forall p : point -> {ps : point_set | unique (fun q : point => point_set_is q ps) p}
 
1061
 
 
1062
(*
 
1063
*)
 
1064
Definition point_set_add
 
1065
  :  forall (p : point) (ps : point_set), {qs : list point | point_set_eq (point_set_difference qs ps) (point_
 
1066
  := fun p ps
 
1067
       => 
 
1068
 
 
1069
(*
 
1070
*)
 
1071
Definition point_set_remove
 
1072
  :  forall (p : point) (ps : point_set), point_set_in p ps -> {qs : point_set | point_set_subset qs ps /\ ~ point_set_in p qs}
 
1073
 
 
1074
(*
 
1075
*)
 
1076
Definition point_set_replace_collinear
 
1077
  :  forall 
 
1078
 
 
1079
(*
 
1080
 TODO Give me a list of the points guaranteed to exist by collinearity_axiom.
 
1081
 
 
1082
 TODO  A function that returns two other points when given a point that are proved to be different and distinct 
 
1083
 
 
1084
  : {ps : list point
 
1085
      | points_distinct ps /\
 
1086
        length ps = 3
 
1087
 
 
1088
  points_others
 
1089
    : forall p : point, exists q : point, exists r : point, distinct p q r /\ noncollinear p q r
 
1090
 
 
1091
  my goal was to call the collinearity axiom to get three distinct noncollinear points q r s
 
1092
  then form these in a list ps := q :: r :: s :: nil
 
1093
  prove the elements were distinct using points_distinct_cons
 
1094
  use cases over points_In_dec
 
1095
    if p is in ps
 
1096
      call points_distinct_remove to get qs where qs is distinct and doesnt contain
 
1097
      in this case we can prove that p :: qs is noncollinear but we'd need to deepen our theory (points_collinear + thms).
 
1098
    if p is not in ps
 
1099
      we can take the first two points and use points_different_head and points_different_tail iterative to prove they are all different 
 
1100
 
 
1101
  goal
 
1102
    : forall (p : point) (ps : list point) (H : points_distinct ps), points_noncollinear ps -> forall H0 : In p ps, let (qs, H1) := points_distinct_remove ps H p H0 in points_distinct (p :: qs) /\ points_noncollinear (p :: ps)
 
1103
 
 
1104
*)
 
1105
 
 
1106
(*
 
1107
*)
 
1108
Definition points_others_noncollinear
 
1109
  : forall p : point, exists q : point, exists r : point, distinct p q r /\ noncollinear p q r
 
1110
  := fun p
 
1111
       => ex_ind (fun q : point =>
 
1112
          ex_ind (fun r : point =>
 
1113
          ex_ind
 
1114
            (fun (s : point) (H : distinct q r s /\ noncollinear q r s)
 
1115
              => let ps := (q :: r :: s :: nil) in
 
1116
                 sumbool_ind (* over In p ps *)
 
1117
                   (fun _ => exists x : point, exists y : point, distinct p x y /\ noncollinear p x y)
 
1118
                   (fun H0 : In p ps
 
1119
                     => let (qs, H1)
 
1120
                          := points_distinct_remove ps 
 
1121
                               (* TODO: points_distinct ps *)
 
1122
                               p H0 in
 
1123
                        let rs := p :: qs in
 
1124
                        let ((x, ss), H2)
 
1125
                          := points_list_destr qs
 
1126
                               (lt_0_Sn 1
 
1127
                                || a > 0 @a by (eq_add_S (proj1 (proj2 (proj2 H1))) : length qs = 2)) in
 
1128
                        let ((y, _), H3)
 
1129
                          := points_list_destr ss
 
1130
                               (lt_0_Sn 0
 
1131
                                || a > 0 @a by 
 
1132
 
 
1133
(*
 
1134
Check (eq_add_S (length (1 :: 2 :: 3 :: nil)) 3 (eq_refl (length (0 :: 1 :: 2 :: 3 :: nil))) : length (1 :: 2 :: 3 :: nil) = 3).
 
1135
*)
 
1136
 
 
1137
(*
 
1138
  Proves that at least one line passes through
 
1139
  each point.
 
1140
*)
 
1141
Definition point_line_ex
 
1142
  :  forall p : point, exists l : line, on l p = true
 
1143
  := fun p
 
1144
       => ex_ind (fun q =>
 
1145
          ex_ind (fun r =>
 
1146
          ex_ind (
 
1147
            fun (s : point) (H : distinct q r s /\ noncollinear q r s)
 
1148
              => let qs := q :: r :: s :: nil in
 
1149
                 bool_dec0
 
1150
                   (fun _ => exists l : line, on l p = true)
 
1151
                   (fun H : points_differentb p qs = true
 
1152
                     => let H0
 
1153
                          :  p <> q
 
1154
                          := points_differentb_head p q (r :: s :: nil) H in
 
1155
                        ex_ind
 
1156
                          (fun l (H1 : unique (fun l => on l p = true /\ on l q = true) l)
 
1157
                            => ex_intro
 
1158
                                 (fun l => on l p = true)
 
1159
                                 l
 
1160
                                 (proj1 (proj1 H1)))
 
1161
                          (points_line_axiom p q H0))
 
1162
                   (fun H : points_differentb p qs = false
 
1163
                     => 
 
1164
 
1018
1165
Definition points_collinearb_thm
1019
1166
  :  forall (ps : list point) (H : points_distinct ps), points_collinearb ps H = true <-> points_collinear ps
1020
1167
  := list_rec