Planar orientations, directed cycles, and acyclic two-colorings
Definitionopg169_planar_dichromaticThis module couples a binary directed relation to an underlying finite simple graph by requiring exactly one direction on every edge and no arcs on nonedges. Planarity is represented by an injective crossing-free straight-line drawing of the underlying graph.
A directed cycle is a cyclic list of at least three distinct vertices following directed arcs. A two-coloring is valid when neither full induced color class contains such a cycle; colors may be unused. Strong connectivity uses nonempty reflexive-transitive directed reachability.
A least-order counterexample is planar, uncolorable, and smaller than every other uncolorable planar orientation in the same universe. The module also defines the underlying minimum-degree-three condition.
import Mathlib.Combinatorics.SimpleGraph.Finite
import Mathlib.Data.Real.Basic
import Mathlib.Logic.Relation
import Mathlib.Data.Set.Card
namespace OPG169
universe u
abbrev Digraph (V : Type u) := V → V → Prop
abbrev Point := ℝ × ℝ
def pointOnSegment (a b : Point) (t : ℝ) : Point :=
((1 - t) * a.1 + t * b.1, (1 - t) * a.2 + t * b.2)
def closedSegment (a b : Point) : Set Point :=
{x | ∃ t : ℝ, 0 ≤ t ∧ t ≤ 1 ∧ x = pointOnSegment a b t}
/-- A straight-line planar embedding of the underlying simple graph. -/
def IsPlanar {V : Type u} (G : SimpleGraph V) : Prop :=
∃ p : V → Point,
Function.Injective p ∧
(∀ ⦃a b v : V⦄, G.Adj a b → v ≠ a → v ≠ b → p v ∉ closedSegment (p a) (p b)) ∧
(∀ ⦃a b c d : V⦄, G.Adj a b → G.Adj c d →
a ≠ c → a ≠ d → b ≠ c → b ≠ d →
Disjoint (closedSegment (p a) (p b)) (closedSegment (p c) (p d)))
/-- `D` chooses exactly one direction for every edge of `G` and no arcs for
nonedges. -/
def IsOrientationOf {V : Type u} (D : Digraph V) (G : SimpleGraph V) : Prop :=
(∀ v : V, ¬ D v v) ∧
(∀ ⦃u v : V⦄, D u v → G.Adj u v) ∧
∀ ⦃u v : V⦄, G.Adj u v →
(D u v ∨ D v u) ∧ ¬ (D u v ∧ D v u)
/-- A list of at least two distinct vertices joined cyclically by directed
arcs. In an orientation of a simple graph such a cycle necessarily has at
least three vertices. -/
def IsDirectedCycle {V : Type u} (D : Digraph V) (vs : List V) : Prop :=
∃ x y : V, ∃ middle : List V,
vs = x :: (middle ++ [y]) ∧ 3 ≤ vs.length ∧
vs.Nodup ∧ vs.Chain' D ∧ D y x
/-- The vertices of one color induce an acyclic digraph. -/
def ColorClassAcyclic {V : Type u} (D : Digraph V)
(color : V → Fin 2) (k : Fin 2) : Prop :=
¬ ∃ vs : List V,
IsDirectedCycle D vs ∧ ∀ v ∈ vs, color v = k
/-- A two-coloring in which both full induced color classes are acyclic.
Either color may be unused. -/
def IsAcyclicTwoColoring {V : Type u} (D : Digraph V)
(color : V → Fin 2) : Prop :=
∀ k : Fin 2, ColorClassAcyclic D color k
def HasAcyclicTwoColoring {V : Type u} (D : Digraph V) : Prop :=
∃ color : V → Fin 2, IsAcyclicTwoColoring D color
/-- Nonempty strong connectivity under directed reachability. -/
def IsStronglyConnected {V : Type u} (D : Digraph V) : Prop :=
Nonempty V ∧ ∀ u v : V, Relation.ReflTransGen D u v
/-- A counterexample of least vertex order among all finite planar
orientations in the same universe. -/
def IsLeastOrderCounterexample {V : Type u} [Fintype V]
(G : SimpleGraph V) (D : Digraph V) : Prop :=
IsPlanar G ∧ IsOrientationOf D G ∧ ¬ HasAcyclicTwoColoring D ∧
∀ (W : Type u) [Fintype W] (H : SimpleGraph W) (E : Digraph W),
IsPlanar H → IsOrientationOf E H →
Fintype.card W < Fintype.card V → HasAcyclicTwoColoring E
/-- Every vertex of the underlying graph has degree at least three. -/
def HasMinimumDegreeThree {V : Type u} (G : SimpleGraph V) : Prop :=
∀ v : V, 3 ≤ (G.neighborSet v).encard
end OPG169Read-back
What the Lean code literally says, in plain math · gpt-5.6-luna
Digraph. For a type , a digraph on is a binary relation: for vertices , means there is a directed arc from to .
Point and segment definitions. A point is an ordered pair of real numbers. For points and and a real number , pointOnSegment is the point . The closed segment from to is the set of points for which there exists a real with and .
Planarity. For a simple graph on a type , IsPlanar G means that there exists an injective map such that: whenever and are adjacent in and is different from both and , does not lie on the closed segment from to ; and whenever is adjacent to , is adjacent to , and , , , and , the closed segments from to and from to are disjoint.
Orientation. IsOrientationOf D G means that has no loops, every directed arc of joins adjacent vertices of , and for every edge joining and , exactly one of and holds.
Directed cycle. IsDirectedCycle D vs means that there exist vertices and a list middle such that followed by the elements of middle and then , that has length at least , that no vertex occurs more than once in , that every consecutive pair of vertices in is joined by a directed arc of , and that holds.
Acyclic color classes. Given a digraph , a coloring and a color , ColorClassAcyclic D color k means that there is no directed cycle all of whose vertices receive color . IsAcyclicTwoColoring D color means this holds for each of the two colors, and HasAcyclicTwoColoring D means that at least one coloring has this property; either color is allowed to be unused.
Strong connectivity. IsStronglyConnected D means that is nonempty and, for every pair of vertices , there is a finite directed walk from to using zero or more arcs of ; in particular, walks of length zero are allowed.
Least-order counterexample. For a type equipped with a finite-type structure, a simple graph on and a digraph on , IsLeastOrderCounterexample G D means that is planar, is an orientation of , has no acyclic two-coloring, and, for every type in the same universe equipped with a finite-type structure, every simple graph on , and every digraph on , if is planar, is an orientation of , and the finite cardinality of is strictly smaller than that of , then has an acyclic two-coloring.
Minimum degree. HasMinimumDegreeThree G means that every vertex has a neighbor set in whose cardinality is at least .
Confirmed by the mission captain (proposal self-audit).