Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Oriented (signed) incidence matrix of a simple graph

Definition
ClassicalGaps_orientedIncMatrix

by Rizwan G Mir · Sep 24, 2026 · Mathlib c5ea003 (Lean v4.30.0)

The signed incidence matrix of a finite simple graph G, using an arbitrary vertex ordering from Fintype.equivFin to orient each edge. Fills the gap flagged in Mathlib's SimpleGraph.IncMatrix TODO ('Define the oriented incidence matrices for oriented graphs').

Definition code
import Mathlib

open Classical

namespace ClassicalGaps

/-- The oriented (signed) incidence matrix of a finite simple graph `G`, using the
arbitrary linear order on `V` coming from `Fintype.equivFin`. The `(i, e)` entry is
`1` if `i` is the "smaller-indexed" endpoint of edge `e`, `-1` if `i` is the
"larger-indexed" endpoint, and `0` if `i` is not an endpoint of `e` or `e` is not an
edge of `G`. This fills the gap flagged in Mathlib's `SimpleGraph.IncMatrix` TODO
("Define the oriented incidence matrices for oriented graphs"). -/
noncomputable def orientedIncMatrix {V : Type*} [Fintype V] [DecidableEq V]
    (G : SimpleGraph V) [DecidableRel G.Adj] : Matrix V (Sym2 V) ℝ :=
  Matrix.of fun i e =>
    if h : i ∈ e ∧ e ∈ G.edgeSet then
      if (Fintype.equivFin V i).val < (Fintype.equivFin V (Sym2.Mem.other' h.1)).val then 1 else -1
    else 0

end ClassicalGaps

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me