/- Copyright 2026 The Formal Conjectures Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -/ module public import Mathlib.Combinatorics.SimpleGraph.Metric public import Mathlib.Order.BourbakiWitt public import Mathlib.Tactic.Ring.Basic public import FormalConjecturesForMathlib.Combinatorics.SimpleGraph.VertexDistance@[expose] public sectionnamespace SimpleGraphvariable {α : Type*} [Fintype α] [DecidableEq α]

Auxiliary function for Szeged index: counts vertices closer to u than v.

noncomputable def szeged_aux (G : SimpleGraph α) (u v : α) : := (Finset.univ.filter (fun w => G.edist w u < G.edist w v)).card

The Szeged index of G.

This is define as the sum ∑_{uv ∈ E(G)} n_u(u,v) * n_v(u,v) where n_u(uv) is the number of vertices closer to u than v.

noncomputable def szegedIndex (G : SimpleGraph α) [DecidableRel G.Adj] : := e G.edgeFinset, e.lift fun u v => szeged_aux G u v * szeged_aux G v u, α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adje:Sym2 α (a₁ a₂ : α), (fun u v G.szeged_aux u v * G.szeged_aux v u) a₁ a₂ = (fun u v G.szeged_aux u v * G.szeged_aux v u) a₂ a₁ All goals completed! 🐙

Computable Szeged auxiliary: count vertices closer to u than v.

def computable_szeged_aux (G : SimpleGraph α) [DecidableRel G.Adj] (u v : α) : := (Finset.univ.filter (fun w => computable_dist G w u < computable_dist G w v)).card

Computable Szeged index.

def computable_szeged_index (G : SimpleGraph α) [DecidableRel G.Adj] : := e G.edgeFinset, Sym2.lift fun u v => computable_szeged_aux G u v * computable_szeged_aux G v u, fun a b => α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adje:Sym2 αa:αb:α(fun u v G.computable_szeged_aux u v * G.computable_szeged_aux v u) a b = (fun u v G.computable_szeged_aux u v * G.computable_szeged_aux v u) b a All goals completed! 🐙 eAll goals completed! 🐙 α:Type u_1G:SimpleGraph αu:αv:αhadj:G.Adj u vw:αhru:¬G.Reachable w uG.edist w u < G.edist w v G.dist w u < G.dist w v α:Type u_1G:SimpleGraph αu:αv:αhadj:G.Adj u vw:αhru:¬G.Reachable w uhrv:¬G.Reachable w vG.edist w u < G.edist w v G.dist w u < G.dist w v All goals completed! 🐙All goals completed! 🐙α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adje:Sym2 αu:αv:αhe:s(u, v) G.edgeFinsethadj:G.Adj u vG.szeged_aux u v * G.szeged_aux v u = G.computable_szeged_aux u v * G.computable_szeged_aux v u α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adje:Sym2 αu:αv:αhe:s(u, v) G.edgeFinsethadj:G.Adj u vG.szeged_aux u v = G.computable_szeged_aux u vα:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adje:Sym2 αu:αv:αhe:s(u, v) G.edgeFinsethadj:G.Adj u vG.szeged_aux v u = G.computable_szeged_aux v u α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adje:Sym2 αu:αv:αhe:s(u, v) G.edgeFinsethadj:G.Adj u vG.szeged_aux u v = G.computable_szeged_aux u v All goals completed! 🐙 α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adje:Sym2 αu:αv:αhe:s(u, v) G.edgeFinsethadj:G.Adj u vG.szeged_aux v u = G.computable_szeged_aux v u All goals completed! 🐙end SimpleGraph