introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
19.2 kB
import OAI.Combinatorics.Crossing.DrawingDefinition
import Mathlib.Algebra.BigOperators.Group.Finset.Basic
import Mathlib.Analysis.SpecialFunctions.Complex.Arg
import Mathlib.Data.Set.Card
import Mathlib.Order.Lattice.Nat
import Mathlib.Topology.OpenPartialHomeomorph.Defs
import Mathlib.Topology.Path
namespace OAI
/-! Continuous graph drawings, proper spatial crossings, incidence, and endpoint properties. -/
section
/-!
The coordinate plane has its usual topology; every Euclidean circle below is
specified by squaredLength, not by the product norm.
-/
noncomputable section
open Set
open scoped BigOperators Classical
namespace Paper170
abbrev Plane := ℝ Γ— ℝ
def squaredLength (x : Plane) : ℝ := x.1 ^ 2 + x.2 ^ 2
def det2 (x y : Plane) : ℝ := x.1 * y.2 - x.2 * y.1
def segmentPoint (a b : Plane) (t : ℝ) : Plane := (1 - t) β€’ a + t β€’ b
/-- One chosen orientation of each edge of a finite simple graph. -/
structure Graph (V E : Type) where
src : E β†’ V
dst : E β†’ V
loopless : βˆ€ e, src e β‰  dst e
simple : βˆ€ e f, ((src e = src f ∧ dst e = dst f) ∨
(src e = dst f ∧ dst e = src f)) β†’ e = f
abbrev CompleteEdge (n : β„•) := {p : Fin n Γ— Fin n // p.1 < p.2}
instance (n : β„•) : Fintype (CompleteEdge n) := Fintype.ofFinite _
def completeGraph (n : β„•) : Graph (Fin n) (CompleteEdge n) where
src e := e.val.1
dst e := e.val.2
loopless e := ne_of_lt e.property
simple e f h := by
rcases h with h | h
Β· exact Subtype.ext (Prod.ext h.1 h.2)
Β· have he := e.property
have hf := f.property
rw [h.1, h.2] at he
exact (lt_asymm he hf).elim
variable {V E : Type} (G : Graph V E)
namespace Graph
abbrev IncidentEdge (v : V) := {e : E // G.src e = v ∨ G.dst e = v}
end Graph
/-- Actual injective continuous edge arcs, with unrestricted routing. -/
structure ContinuousDrawing where
vertex : V β†’ Plane
vertex_injective : Function.Injective vertex
edge : βˆ€ e : E, Path (vertex (G.src e)) (vertex (G.dst e))
edge_injective : βˆ€ e, Function.Injective (edge e)
interior_avoids_vertices : βˆ€ e t, t ∈ Ioo (0 : unitInterval) 1 β†’
βˆ€ v, edge e t β‰  vertex v
variable {G}
def edgeInterior (D : ContinuousDrawing G) (e : E) : Set Plane :=
D.edge e '' Ioo (0 : unitInterval) 1
/-- A proper double crossing is locally homeomorphic to two coordinate axes. -/
structure ProperCrossing (A B : Set Plane) (x : Plane) : Prop where
chart_exists : βˆƒ chart : OpenPartialHomeomorph Plane Plane,
x ∈ chart.source ∧ chart x = (0, 0) ∧
chart '' (chart.source ∩ A) = chart.target ∩ {y | y.2 = 0} ∧
chart '' (chart.source ∩ B) = chart.target ∩ {y | y.1 = 0}
/-- Spatial intersection points. Different meetings of the same pair remain distinct. -/
def crossingPoints (D : ContinuousDrawing G) : Set Plane :=
{x | βˆƒ e f : E, e β‰  f ∧ x ∈ edgeInterior D e ∧ x ∈ edgeInterior D f}
structure AdmissibleDrawing (G : Graph V E) extends ContinuousDrawing G where
crossings_finite : (crossingPoints toContinuousDrawing).Finite
crossings_proper : βˆ€ e f, e β‰  f β†’ βˆ€ x,
x ∈ edgeInterior toContinuousDrawing e β†’ x ∈ edgeInterior toContinuousDrawing f β†’
ProperCrossing (edgeInterior toContinuousDrawing e) (edgeInterior toContinuousDrawing f) x
no_triples : βˆ€ e f g, e β‰  f β†’ e β‰  g β†’ f β‰  g β†’
edgeInterior toContinuousDrawing e ∩ edgeInterior toContinuousDrawing f ∩
edgeInterior toContinuousDrawing g = βˆ…
def crossingCount (D : AdmissibleDrawing G) : β„• := D.crossings_finite.toFinset.card
/-- The minimum spatial crossing count over admissible drawings. -/
def ordinaryCrossingNumber (G : Graph V E) : β„• := sInf (range (@crossingCount V E G))
/-- A finite affine parametrization of the actual path. -/
structure PolygonalParametrization {a b : Plane} (Ξ³ : Path a b) where
pieces : β„•
positive : 0 < pieces
knot : Fin (pieces + 1) β†’ unitInterval
increasing : StrictMono knot
first : knot 0 = 0
last : knot (Fin.last pieces) = 1
affine : βˆ€ i : Fin pieces, βˆ€ t : unitInterval,
knot i.castSucc ≀ t β†’ t ≀ knot i.succ β†’
Ξ³ t = segmentPoint (Ξ³ (knot i.castSucc)) (Ξ³ (knot i.succ))
(((t : ℝ) - knot i.castSucc) / ((knot i.succ : ℝ) - knot i.castSucc))
def PolygonalParametrization.vertices {a b : Plane} {Ξ³ : Path a b}
(P : PolygonalParametrization Ξ³) (i : β„•) : Plane :=
γ (P.knot ⟨min i P.pieces, Nat.lt_succ_of_le (Nat.min_le_right _ _)⟩)
/-- A convenient subdivision of a normalized drawing. Avoiding subdivision
knots at crossings is additional presentation data, obtained by the normalization theorem. -/
structure NormalizedDrawing (G : Graph V E) extends AdmissibleDrawing G where
polygonal : βˆ€ e, PolygonalParametrization (edge e)
no_adjacent : βˆ€ e f, e β‰  f β†’
(G.src e = G.src f ∨ G.src e = G.dst f ∨ G.dst e = G.src f ∨ G.dst e = G.dst f) β†’
Disjoint (edgeInterior toContinuousDrawing e) (edgeInterior toContinuousDrawing f)
crossings_not_knots : βˆ€ e (i : Fin ((polygonal e).pieces + 1)),
edge e ((polygonal e).knot i) βˆ‰ crossingPoints toContinuousDrawing
/-- Directed open-segment intersection, with the ordinary determinant sign. -/
def segmentIntersection (a b c d : Plane) : ℝ :=
if βˆƒ s ∈ Ioo (0 : ℝ) 1, βˆƒ t ∈ Ioo (0 : ℝ) 1,
segmentPoint a b s = segmentPoint c d t then
if 0 < det2 (b - a) (d - c) then 1
else if det2 (b - a) (d - c) < 0 then -1 else 0
else 0
def interiorIntersection (N : NormalizedDrawing G) (e f : E) : ℝ :=
if e = f then 0 else
βˆ‘ i ∈ Finset.range (N.polygonal e).pieces,
βˆ‘ j ∈ Finset.range (N.polygonal f).pieces,
segmentIntersection ((N.polygonal e).vertices i) ((N.polygonal e).vertices (i + 1))
((N.polygonal f).vertices j) ((N.polygonal f).vertices (j + 1))
def outwardSpoke (N : NormalizedDrawing G) (v : V) (e : E) : Plane :=
if G.src e = v then (N.polygonal e).vertices 1 - (N.polygonal e).vertices 0
else (N.polygonal e).vertices ((N.polygonal e).pieces - 1) -
(N.polygonal e).vertices (N.polygonal e).pieces
def spokeAngle (cut : ℝ) (a : Plane) : ℝ :=
Complex.arg (Complex.exp (-(cut : β„‚) * Complex.I) * (⟨a.1, a.2⟩ : β„‚))
/-- The linear local orders are witnessed by the actual counterclockwise angles,
with a cut in a gap. No intersection identity is part of this data. -/
structure SpokeOrders (N : NormalizedDrawing G) where
cut : V β†’ ℝ
order : βˆ€ v, LinearOrder (G.IncidentEdge v)
cut_avoids : βˆ€ v (e : G.IncidentEdge v), spokeAngle (cut v) (outwardSpoke N v e.val) β‰  Real.pi
compatible : βˆ€ v (e f : G.IncidentEdge v),
@LT.lt _ (order v).toLT e f ↔
spokeAngle (cut v) (outwardSpoke N v e.val) <
spokeAngle (cut v) (outwardSpoke N v f.val)
def endpointSign (G : Graph V E) (v : V) (e : E) : ℝ :=
if G.src e = v then 1 else if G.dst e = v then -1 else 0
def spokeComparison {N : NormalizedDrawing G} (O : SpokeOrders N) (v : V) (e f : E) : ℝ :=
if he : G.src e = v ∨ G.dst e = v then if hf : G.src f = v ∨ G.dst f = v then
if @LT.lt _ (O.order v).toLT ⟨e, he⟩ ⟨f, hf⟩ then 1
else if @LT.lt _ (O.order v).toLT ⟨f, hf⟩ ⟨e, he⟩ then -1 else 0
else 0 else 0
variable [Fintype V] [Fintype E]
def cycleIntersection {N : NormalizedDrawing G} (O : SpokeOrders N) (e f : E) : ℝ :=
interiorIntersection N e f + (1 / 2 : ℝ) *
βˆ‘ v, endpointSign G v e * endpointSign G v f * spokeComparison O v e f
def edgePairing (J : E β†’ E β†’ ℝ) (z z' : E β†’ ℝ) : ℝ :=
βˆ‘ e, βˆ‘ f, z e * z' f * J e f
def boundary (G : Graph V E) (z : E β†’ ℝ) (v : V) : ℝ :=
βˆ‘ e, z e * ((if G.dst e = v then 1 else 0) - (if G.src e = v then 1 else 0))
def completeEdgeVector {n : β„•} (i p : Fin n) : CompleteEdge n β†’ ℝ :=
fun e => if e.val.1 = i ∧ e.val.2 = p then 1
else if e.val.1 = p ∧ e.val.2 = i then -1 else 0
def rawCycleIntersection {n : β„•} {N : NormalizedDrawing (completeGraph n)}
(O : SpokeOrders N) (i p k q : Fin n) : ℝ :=
edgePairing (cycleIntersection O) (completeEdgeVector i p) (completeEdgeVector k q)
/-- A simple combinatorial cycle with a chosen direction of traversal. -/
structure SimpleCycle (G : Graph V E) where
length : β„•
three_le : 3 ≀ length
vertex : Fin length β†’ V
vertex_injective : Function.Injective vertex
edge : Fin length β†’ E
follows : βˆ€ i,
let j : Fin length := ⟨(i.val + 1) % length,
Nat.mod_lt _ (lt_of_lt_of_le (by decide : 0 < 3) three_le)⟩
(G.src (edge i) = vertex i ∧ G.dst (edge i) = vertex j) ∨
(G.dst (edge i) = vertex i ∧ G.src (edge i) = vertex j)
def SimpleCycle.edgeChain (C : SimpleCycle G) : E β†’ ℝ :=
fun e => βˆ‘ i, if C.edge i = e then (if G.src e = C.vertex i then 1 else -1) else 0
def polygonIntersection (v w : β„• β†’ Plane) (n m : β„•) : ℝ :=
βˆ‘ i ∈ Finset.range n, βˆ‘ j ∈ Finset.range m,
segmentIntersection (v i) (v (i + 1)) (w j) (w (j + 1))
/-- Only proper interior meetings between the two polygonal walks. -/
structure TransversePolygons (v w : β„• β†’ Plane) (n m : β„•) : Prop where
left_vertices_avoid : βˆ€ i, i ≀ n β†’ βˆ€ j, j < m β†’ βˆ€ t ∈ Icc (0 : ℝ) 1,
v i β‰  segmentPoint (w j) (w (j + 1)) t
right_vertices_avoid : βˆ€ j, j ≀ m β†’ βˆ€ i, i < n β†’ βˆ€ t ∈ Icc (0 : ℝ) 1,
w j β‰  segmentPoint (v i) (v (i + 1)) t
transverse : βˆ€ i, i < n β†’ βˆ€ j, j < m β†’
(βˆƒ s ∈ Ioo (0 : ℝ) 1, βˆƒ t ∈ Ioo (0 : ℝ) 1,
segmentPoint (v i) (v (i + 1)) s = segmentPoint (w j) (w (j + 1)) t) β†’
det2 (v (i + 1) - v i) (w (j + 1) - w j) β‰  0
def circleComparison (cut : ℝ) (a b : Plane) : ℝ :=
if spokeAngle cut a < spokeAngle cut b then 1
else if spokeAngle cut b < spokeAngle cut a then -1 else 0
def inversion (z : Plane) : Plane := (z.1 / squaredLength z, z.2 / squaredLength z)
end Paper170
end
end
section
/-! Converting actual nonvertex trace contacts to the exact crossing-point definition. -/
noncomputable section
open Zarankiewicz
variable {Vertex Edge : Type} {graph : Paper170.Graph Vertex Edge}
namespace Paper170Geometry
theorem edgeInterior_subset_range (D : Paper170.ContinuousDrawing graph) (e : Edge) :
Paper170.edgeInterior D e βŠ† Set.range (D.edge e) := by
rintro x ⟨t,_,he⟩
exact ⟨t,he⟩
theorem edgeInterior_of_range_not_vertices (D : Paper170.ContinuousDrawing graph) (e : Edge)
(x : Plane) (hx : x ∈ Set.range (D.edge e)) (hvertex : βˆ€ j, x β‰  D.vertex j) :
x ∈ Paper170.edgeInterior D e := by
obtain ⟨t,he⟩ := hx
have ht0 : t β‰  0 := by
intro ht
subst t
exact hvertex _ (he.symm.trans (D.edge e).source)
have ht1 : t β‰  1 := by
intro ht
subst t
exact hvertex _ (he.symm.trans (D.edge e).target)
exact ⟨t,⟨lt_of_le_of_ne (show 0 ≀ t from t.property.1) (Ne.symm ht0),
lt_of_le_of_ne (show t ≀ 1 from t.property.2) ht1⟩,he⟩
theorem edgeInterior_not_vertex (D : Paper170.ContinuousDrawing graph) (e : Edge)
(x : Plane) (hx : x ∈ Paper170.edgeInterior D e) (j : Vertex) : x β‰  D.vertex j := by
obtain ⟨t,ht,he⟩ := hx
exact fun hj => D.interior_avoids_vertices e t ht j (he.trans hj)
theorem crossing_of_ranges_not_vertices (D : Paper170.ContinuousDrawing graph) (e f : Edge)
(hef : e β‰  f) (x : Plane) (he : x ∈ Set.range (D.edge e)) (hf : x ∈ Set.range (D.edge f))
(hv : βˆ€ j, x β‰  D.vertex j) : x ∈ Paper170.crossingPoints D :=
⟨e,f,hef,edgeInterior_of_range_not_vertices D e x he hv,edgeInterior_of_range_not_vertices D f x hf hv⟩
end Paper170Geometry
end
end
section
namespace Paper170Geometry
variable {Vertex Edge : Type} {graph : Paper170.Graph Vertex Edge}
theorem drawing_edge_vertex_parameter (D : Paper170.ContinuousDrawing graph) (e : Edge)
(t : unitInterval) (v : Vertex) (he : D.edge e t=D.vertex v) :
(t=0 ∧ v=(graph.src e)) ∨ (t=1 ∧ v=(graph.dst e)) := by
by_cases ht0 : t=0
Β· subst t
exact Or.inl ⟨rfl,(D.vertex_injective ((D.edge e).source.symm.trans he)).symm⟩
by_cases ht1 : t=1
Β· subst t
exact Or.inr ⟨rfl,(D.vertex_injective ((D.edge e).target.symm.trans he)).symm⟩
exact False.elim (D.interior_avoids_vertices e t
⟨lt_of_le_of_ne t.property.1 (Ne.symm ht0),lt_of_le_of_ne t.property.2 ht1⟩ v he)
end Paper170Geometry
end
section
/-! A weaker INPUT for normalization: actual simple routes with finite contacts and no triples.
The endpoint's Paper170.AdmissibleDrawing and MainTarget definitions are unchanged. -/
noncomputable section
open Zarankiewicz
variable {Vertex Edge : Type} {graph : Paper170.Graph Vertex Edge}
namespace Paper170Geometry
structure FiniteIntersectionDrawing (graph : Paper170.Graph Vertex Edge) extends Paper170.ContinuousDrawing graph where
crossings_finite : (Paper170.crossingPoints toContinuousDrawing).Finite
no_triples : βˆ€ e f g, e β‰  f β†’ e β‰  g β†’ f β‰  g β†’
Paper170.edgeInterior toContinuousDrawing e ∩ Paper170.edgeInterior toContinuousDrawing f ∩
Paper170.edgeInterior toContinuousDrawing g = βˆ…
abbrev toFiniteIntersectionDrawing (D : Paper170.AdmissibleDrawing graph) :
FiniteIntersectionDrawing graph where
toContinuousDrawing := D.toContinuousDrawing
crossings_finite := D.crossings_finite
no_triples := D.no_triples
instance admissibleToFiniteIntersectionDrawing :
CoeOut (Paper170.AdmissibleDrawing graph) (FiniteIntersectionDrawing graph) :=
⟨toFiniteIntersectionDrawing⟩
def finiteCrossingCount (D : FiniteIntersectionDrawing graph) : β„• :=
D.crossings_finite.toFinset.card
theorem finiteCrossingCount_of_admissible (D : Paper170.AdmissibleDrawing graph) :
finiteCrossingCount (D : FiniteIntersectionDrawing graph)=Paper170.crossingCount D := rfl
theorem finiteCrossingCount_eq_ncard (D : FiniteIntersectionDrawing graph) :
finiteCrossingCount D=(Paper170.crossingPoints D.toContinuousDrawing).ncard :=
(Set.ncard_eq_toFinset_card _ D.crossings_finite).symm
end Paper170Geometry
namespace Paper170.AdmissibleDrawing
abbrev toFiniteIntersectionDrawing {V E : Type} {G : Graph V E} (D : AdmissibleDrawing G) :
Paper170Geometry.FiniteIntersectionDrawing G := Paper170Geometry.toFiniteIntersectionDrawing D
end Paper170.AdmissibleDrawing
end
end
section
/-! Finite point incidence for actual drawings, retaining repeated pair crossings. -/
noncomputable section
open Zarankiewicz
variable {Vertex Edge : Type} {graph : Paper170.Graph Vertex Edge}
namespace Paper170Geometry
open scoped BigOperators Classical
/-- A minimum exists once an actual admissible drawing has been constructed.
This is the well-ordering step; construction of a drawing remains a separate obligation. -/
theorem crossingCount_attainment (Dβ‚€ : Paper170.AdmissibleDrawing graph) :
βˆƒ D : Paper170.AdmissibleDrawing graph, Paper170.crossingCount D = Paper170.ordinaryCrossingNumber graph := by
exact csInf_mem (show (Set.range (@Paper170.crossingCount Vertex Edge graph)).Nonempty from
⟨Paper170.crossingCount Dβ‚€, Dβ‚€, rfl⟩)
theorem ordinaryCrossingNumber_le_count (D : Paper170.AdmissibleDrawing graph) :
Paper170.ordinaryCrossingNumber graph ≀ Paper170.crossingCount D :=
csInf_le' ⟨D, rfl⟩
theorem crossing_incident_iff (D : Paper170.AdmissibleDrawing graph) (x : Plane)
(e f : Edge) (hef : e β‰  f)
(he : x ∈ Paper170.edgeInterior D.toContinuousDrawing e)
(hf : x ∈ Paper170.edgeInterior D.toContinuousDrawing f) (g : Edge) :
x ∈ Paper170.edgeInterior D.toContinuousDrawing g ↔ g = e ∨ g = f := by
constructor
Β· intro hg
by_contra hh
have hge : e β‰  g := by tauto
have hgf : f β‰  g := by tauto
have hmem : x ∈ Paper170.edgeInterior D.toContinuousDrawing e ∩ Paper170.edgeInterior D.toContinuousDrawing f ∩
Paper170.edgeInterior D.toContinuousDrawing g := ⟨⟨he,hf⟩,hg⟩
rw [D.no_triples e f g hef hge hgf] at hmem
exact hmem
Β· rintro (rfl | rfl) <;> assumption
/-- Every spatial crossing has exactly two incident edges; no bound is imposed
on the number of points common to that edge pair. -/
theorem crossing_two_edges (D : Paper170.AdmissibleDrawing graph) (x : Plane)
(hx : x ∈ Paper170.crossingPoints D.toContinuousDrawing) :
βˆƒ e f : Edge, e β‰  f ∧
βˆ€ g, x ∈ Paper170.edgeInterior D.toContinuousDrawing g ↔ g = e ∨ g = f := by
obtain ⟨e,f,hef,he,hf⟩ := hx
exact ⟨e,f,hef,crossing_incident_iff D x e f hef he hf⟩
/-- The actual finite set of crossing points for a specified ordered edge pair. -/
def pairCrossings (D : Paper170.AdmissibleDrawing graph) (e f : Edge) : Finset Plane :=
D.crossings_finite.toFinset.filter (fun x => e β‰  f ∧
x ∈ Paper170.edgeInterior D.toContinuousDrawing e ∧ x ∈ Paper170.edgeInterior D.toContinuousDrawing f)
theorem pairCrossings_self (D : Paper170.AdmissibleDrawing graph) (e : Edge) :
pairCrossings D e e = βˆ… := by
simp [pairCrossings]
theorem pairCrossings_comm (D : Paper170.AdmissibleDrawing graph) (e f : Edge) :
pairCrossings D e f = pairCrossings D f e := by
ext x
simp only [pairCrossings, Finset.mem_filter]
tauto
variable [Fintype Edge]
/-- Each crossing point contributes two ordered edge pairs. -/
theorem crossing_ordered_incidence (D : Paper170.AdmissibleDrawing graph) (x : Plane)
(hx : x ∈ Paper170.crossingPoints D.toContinuousDrawing) :
(βˆ‘ e : Edge, βˆ‘ f : Edge,
if e β‰  f ∧ x ∈ Paper170.edgeInterior D.toContinuousDrawing e ∧
x ∈ Paper170.edgeInterior D.toContinuousDrawing f then (1 : β„•) else 0) = 2 := by
classical
obtain ⟨e,f,hef,hinc⟩ := crossing_two_edges D x hx
simp_rw [hinc]
have hp : βˆ€ a b : Edge,
(a β‰  b ∧ (a = e ∨ a = f) ∧ (b = e ∨ b = f)) ↔
((a = e ∧ b = f) ∨ (a = f ∧ b = e)) := by
intro a b
constructor
· rintro ⟨hab, rfl | rfl, rfl | rfl⟩ <;> tauto
· rintro (⟨rfl,rfl⟩ | ⟨rfl,rfl⟩) <;> tauto
simp_rw [hp]
have hi : βˆ€ a b : Edge,
(if (a = e ∧ b = f) ∨ (a = f ∧ b = e) then (1 : β„•) else 0) =
(if a = e ∧ b = f then 1 else 0) + (if a = f ∧ b = e then 1 else 0) := by
intro a b
split_ifs <;> simp_all
simp_rw [hi, Finset.sum_add_distrib]
simp [ite_and]
/-- Sum over ordered edge pairs equals twice the number of spatial crossing points. -/
theorem sum_pairCrossings_card (D : Paper170.AdmissibleDrawing graph) :
(βˆ‘ e : Edge, βˆ‘ f : Edge, (pairCrossings D e f).card) =
2 * Paper170.crossingCount D := by
classical
simp only [pairCrossings, Finset.card_filter]
rw [Finset.sum_comm]
conv_lhs => arg 2; ext f; rw [Finset.sum_comm]
rw [Finset.sum_comm]
have he : βˆ€ x ∈ D.crossings_finite.toFinset,
(βˆ‘ f : Edge, βˆ‘ e : Edge,
if e β‰  f ∧ x ∈ Paper170.edgeInterior D.toContinuousDrawing e ∧
x ∈ Paper170.edgeInterior D.toContinuousDrawing f then (1 : β„•) else 0) = 2 := by
intro x hx
rw [Finset.sum_comm]
exact crossing_ordered_incidence D x (by simpa using hx)
simp_rw [Finset.sum_congr rfl he]
simp [Paper170.crossingCount, Nat.mul_comm]
end Paper170Geometry
end
end
end OAI