File size: 1,722 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | import Mathlib
namespace OAI
namespace PlanarHalving
abbrev Point := β Γ β
def orient (p q r : Point) : β :=
(q.1 - p.1) * (r.2 - p.2) - (q.2 - p.2) * (r.1 - p.1)
def GeneralPosition {n : β} (P : Fin n β Point) : Prop :=
Function.Injective P β§ β i j l, i β j β j β l β i β l β
orient (P i) (P j) (P l) β 0
noncomputable def sideCount {n : β} (P : Fin n β Point) (i j : Fin n) : β :=
(Finset.univ.filter fun l => 0 < orient (P i) (P j) (P l)).card
noncomputable def halvingCount {n : β} (P : Fin n β Point) : β :=
(Finset.univ.filter fun ij : Fin n Γ Fin n =>
ij.1 < ij.2 β§ sideCount P ij.1 ij.2 = (n - 2) / 2 β§
sideCount P ij.2 ij.1 = (n - 2) / 2).card
noncomputable def slope (p q : Point) : β := (q.2 - p.2) / (q.1 - p.1)
def Generic {n : β} (P : Fin n β Point) : Prop :=
GeneralPosition P β§
(β i j, i β j β (P i).1 β (P j).1) β§
(β i j a b, i < j β a < b β slope (P i) (P j) = slope (P a) (P b) β
i = a β§ j = b) β§
(β i j a b c d, i < j β a < b β c < d β
(i, j) β (a, b) β (c, d) β (i, j) β (c, d) β (a, b) β
β z : Point, z β openSegment β (P i) (P j) β
z β openSegment β (P a) (P b) β z β segment β (P c) (P d))
noncomputable def belowCount {n : β} (P : Fin n β Point) (i j : Fin n) : β :=
let s := slope (P i) (P j)
(Finset.univ.filter fun l => (P l).2 - s * (P l).1 <
(P i).2 - s * (P i).1).card
noncomputable def switchCount {n : β} (P : Fin n β Point) (k : β) : β :=
(Finset.univ.filter fun ij : Fin n Γ Fin n =>
ij.1 < ij.2 β§ 0 < k β§ k < n β§ belowCount P ij.1 ij.2 = k - 1).card
end PlanarHalving
end OAI
|