/- Copyright 2025 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. -/ import FormalConjecturesUtil

Testing Graph Invariants

This file contains tests for graph invariants on 5 specific concrete graphs:

    HouseGraph: A graph on 5 vertices.

    K4: The complete graph on 4 vertices.

    PetersenGraph: The Petersen graph on 10 vertices.

    C6: The cycle graph on 6 vertices.

    Star5: The star graph with 5 leaves (6 vertices total).

Tests cover: independence_number, dominationNumber, average_distance, diameter, radius, girth, order, size, szeged_index, wiener_index, min_degree, max_degree, average_degree, matching_number, residue, annihilation_number, cvetkovic.

open SimpleGraphnamespace WrittenOnTheWallII.Test

House Graph: Square 0-1-2-3-0 with roof 4 connected to 2,3.

abbrev HouseGraph : SimpleGraph (Fin 5) := SimpleGraph.fromEdgeSet { s(0, 1), s(1, 2), s(2, 3), s(3, 0), s(2, 4), s(3, 4) }

K4: Complete graph on 4 vertices.

abbrev K4 : SimpleGraph (Fin 4) := completeGraph (Fin 4)

Petersen Graph on 10 vertices.

abbrev PetersenGraph : SimpleGraph (Fin 10) := SimpleGraph.fromEdgeSet { -- Outer Cycle s(0, 1), s(1, 2), s(2, 3), s(3, 4), s(4, 0), -- Spokes s(0, 5), s(1, 6), s(2, 7), s(3, 8), s(4, 9), -- Inner Star s(5, 7), s(7, 9), s(9, 6), s(6, 8), s(8, 5) }

C6: Cycle graph on 6 vertices.

abbrev C6 : SimpleGraph (Fin 6) := cycleGraph 6

Star5: Star graph with center 0 and 5 leaves.

abbrev Star5 : SimpleGraph (Fin 1 Fin 5) := completeBipartiteGraph (Fin 1) (Fin 5)instance : DecidableRel Star5.Adj := DecidableRel Star5.Adj DecidableRel { Adj := fun v w v.isLeft = true w.isRight = true v.isRight = true w.isLeft = true, symm := , loopless := }.Adj; All goals completed! 🐙HouseGraph.computable_indep_num = 2; All goals completed! 🐙HouseGraph.computable_dom_num = 2; All goals completed! 🐙(7 / 5) = 7 / 5 All goals completed! 🐙HouseGraph.computable_ediam = 2 exact_mod_cast (HouseGraph.computable_ediam = 2 All goals completed! 🐙 : computable_ediam HouseGraph = 2)HouseGraph.computable_radius = 2 exact_mod_cast (HouseGraph.computable_radius = 2 All goals completed! 🐙 : computable_radius HouseGraph = 2)hcyc:(Walk.cons (Walk.cons (Walk.cons Walk.nil))).IsCycleHouseGraph.girth = 3 hcyc:(Walk.cons (Walk.cons (Walk.cons Walk.nil))).IsCycleHouseGraph.girth 3 All goals completed! 🐙Fintype.card (Fin 5) = 5 All goals completed! 🐙@[category test, AMS 5] theorem house_size : HouseGraph.edgeFinset.card = 6 := HouseGraph.edgeFinset.card = 6 All goals completed! 🐙HouseGraph.computable_szeged_index = 24; All goals completed! 🐙HouseGraph.computable_wiener = 14; All goals completed! 🐙@[category test, AMS 5] theorem house_min_deg : HouseGraph.minDegree = 2 := HouseGraph.minDegree = 2 All goals completed! 🐙@[category test, AMS 5] theorem house_max_deg : HouseGraph.maxDegree = 3 := HouseGraph.maxDegree = 3 All goals completed! 🐙@[category test, AMS 5] theorem house_avg_deg : averageDegree HouseGraph = 12/5 := HouseGraph.averageDegree = 12 / 5 (∑ v, (HouseGraph.degree v)) / (Fintype.card (Fin 5)) = 12 / 5; v, (HouseGraph.degree v) = 12; All goals completed! 🐙hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})Disjoint {0, 1} {2, 3}; All goals completed! 🐙) hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})(fun M M.edgeSet.toFinset.card) (HouseGraph.subgraphOfAdj HouseGraph.subgraphOfAdj ) = 2 All goals completed! 🐙@[category test, AMS 5] theorem house_residue : residue HouseGraph = 2 := HouseGraph.residue = 2 residueAux ((Multiset.map (fun v HouseGraph.degree v) Finset.univ.val).sort fun x1 x2 x1 x2) = 2; All goals completed! 🐙@[category test, AMS 5] theorem house_annihilation : annihilationNumber HouseGraph = 3 := HouseGraph.annihilationNumber = 3 All goals completed! 🐙@[category test, AMS 5] theorem house_cvetkovic : cvetkovic HouseGraph = 3 := HouseGraph.cvetkovic = 3 All goals completed! 🐙K4.computable_indep_num = 1; All goals completed! 🐙K4.computable_dom_num = 1; All goals completed! 🐙1 = 1 All goals completed! 🐙K4.computable_ediam = 1 exact_mod_cast (K4.computable_ediam = 1 All goals completed! 🐙 : computable_ediam K4 = 1)K4.computable_radius = 1 exact_mod_cast (K4.computable_radius = 1 All goals completed! 🐙 : computable_radius K4 = 1)hcyc:(Walk.cons (Walk.cons (Walk.cons Walk.nil))).IsCycleK4.girth = 3 hcyc:(Walk.cons (Walk.cons (Walk.cons Walk.nil))).IsCycleK4.girth 3 All goals completed! 🐙Fintype.card (Fin 4) = 4 All goals completed! 🐙@[category test, AMS 5] theorem K4_size : K4.edgeFinset.card = 6 := K4.edgeFinset.card = 6 All goals completed! 🐙K4.computable_szeged_index = 6; All goals completed! 🐙K4.computable_wiener = 6; All goals completed! 🐙@[category test, AMS 5] theorem K4_min_deg : K4.minDegree = 3 := K4.minDegree = 3 All goals completed! 🐙@[category test, AMS 5] theorem K4_max_deg : K4.maxDegree = 3 := K4.maxDegree = 3 All goals completed! 🐙@[category test, AMS 5] theorem K4_avg_deg : averageDegree K4 = 3 := K4.averageDegree = 3 (∑ v, (K4.degree v)) / (Fintype.card (Fin 4)) = 3; All goals completed! 🐙hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})Disjoint {0, 1} {2, 3}; All goals completed! 🐙) hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})(fun M M.edgeSet.toFinset.card) (K4.subgraphOfAdj K4.subgraphOfAdj ) = 2 All goals completed! 🐙@[category test, AMS 5] theorem K4_residue : residue K4 = 1 := K4.residue = 1 residueAux ((Multiset.map (fun v K4.degree v) Finset.univ.val).sort fun x1 x2 x1 x2) = 1; All goals completed! 🐙@[category test, AMS 5] theorem K4_annihilation : annihilationNumber K4 = 2 := K4.annihilationNumber = 2 All goals completed! 🐙@[category test, AMS 5] theorem K4_cvetkovic : cvetkovic K4 = 1 := K4.cvetkovic = 1 All goals completed! 🐙PetersenGraph.computable_indep_num = 4; All goals completed! 🐙PetersenGraph.computable_dom_num = 3; All goals completed! 🐙(5 / 3) = 5 / 3 All goals completed! 🐙PetersenGraph.computable_ediam = 2 exact_mod_cast (PetersenGraph.computable_ediam = 2 All goals completed! 🐙 : computable_ediam PetersenGraph = 2)PetersenGraph.computable_radius = 2 exact_mod_cast (PetersenGraph.computable_radius = 2 All goals completed! 🐙 : computable_radius PetersenGraph = 2)@[category test, AMS 5] theorem petersen_girth : PetersenGraph.girth = 5 := PetersenGraph.girth = 5 All goals completed! 🐙Fintype.card (Fin 10) = 10 All goals completed! 🐙@[category test, AMS 5] theorem petersen_size : PetersenGraph.edgeFinset.card = 15 := PetersenGraph.edgeFinset.card = 15 All goals completed! 🐙PetersenGraph.computable_szeged_index = 135; All goals completed! 🐙PetersenGraph.computable_wiener = 75; All goals completed! 🐙@[category test, AMS 5] theorem petersen_min_deg : PetersenGraph.minDegree = 3 := PetersenGraph.minDegree = 3 All goals completed! 🐙@[category test, AMS 5] theorem petersen_max_deg : PetersenGraph.maxDegree = 3 := PetersenGraph.maxDegree = 3 All goals completed! 🐙@[category test, AMS 5] theorem petersen_avg_deg : averageDegree PetersenGraph = 3 := PetersenGraph.averageDegree = 3 (∑ v, (PetersenGraph.degree v)) / (Fintype.card (Fin 10)) = 3; (∑ v, (PetersenGraph.degree v)) / 10 = 3; All goals completed! 🐙hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})Disjoint {0, 5} {1, 6}; All goals completed! 🐙) hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})(PetersenGraph.subgraphOfAdj ).IsMatching All goals completed! 🐙 hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})Disjoint (PetersenGraph.subgraphOfAdj PetersenGraph.subgraphOfAdj ).support (PetersenGraph.subgraphOfAdj ).support hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})Disjoint (PetersenGraph.subgraphOfAdj PetersenGraph.subgraphOfAdj ).verts (PetersenGraph.subgraphOfAdj ).verts All goals completed! 🐙 hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})(PetersenGraph.subgraphOfAdj ).IsMatching All goals completed! 🐙 hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})Disjoint (PetersenGraph.subgraphOfAdj PetersenGraph.subgraphOfAdj PetersenGraph.subgraphOfAdj ).support (PetersenGraph.subgraphOfAdj ).support hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})Disjoint (PetersenGraph.subgraphOfAdj PetersenGraph.subgraphOfAdj PetersenGraph.subgraphOfAdj ).verts (PetersenGraph.subgraphOfAdj ).verts All goals completed! 🐙 hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})(PetersenGraph.subgraphOfAdj ).IsMatching All goals completed! 🐙 hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})Disjoint (PetersenGraph.subgraphOfAdj PetersenGraph.subgraphOfAdj PetersenGraph.subgraphOfAdj PetersenGraph.subgraphOfAdj ).support (PetersenGraph.subgraphOfAdj ).support hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})Disjoint (PetersenGraph.subgraphOfAdj PetersenGraph.subgraphOfAdj PetersenGraph.subgraphOfAdj PetersenGraph.subgraphOfAdj ).verts (PetersenGraph.subgraphOfAdj ).verts All goals completed! 🐙 hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})(fun M M.edgeSet.toFinset.card) (PetersenGraph.subgraphOfAdj PetersenGraph.subgraphOfAdj PetersenGraph.subgraphOfAdj PetersenGraph.subgraphOfAdj PetersenGraph.subgraphOfAdj ) = 5 All goals completed! 🐙@[category test, AMS 5] theorem petersen_residue : residue PetersenGraph = 3 := PetersenGraph.residue = 3 residueAux ((Multiset.map (fun v PetersenGraph.degree v) Finset.univ.val).sort fun x1 x2 x1 x2) = 3; All goals completed! 🐙@[category test, AMS 5] theorem petersen_annihilation : annihilationNumber PetersenGraph = 5 := PetersenGraph.annihilationNumber = 5 All goals completed! 🐙@[category test, AMS 5] theorem petersen_cvetkovic : cvetkovic PetersenGraph = 4 := PetersenGraph.cvetkovic = 4 All goals completed! 🐙C6.computable_indep_num = 3; All goals completed! 🐙C6.computable_dom_num = 2; All goals completed! 🐙(9 / 5) = 9 / 5 All goals completed! 🐙C6.computable_ediam = 3 exact_mod_cast (C6.computable_ediam = 3 All goals completed! 🐙 : computable_ediam C6 = 3)C6.computable_radius = 3 exact_mod_cast (C6.computable_radius = 3 All goals completed! 🐙 : computable_radius C6 = 3)@[category test, AMS 5] theorem C6_girth : C6.girth = 6 := C6.girth = 6 All goals completed! 🐙Fintype.card (Fin 6) = 6 All goals completed! 🐙@[category test, AMS 5] theorem C6_size : C6.edgeFinset.card = 6 := C6.edgeFinset.card = 6 All goals completed! 🐙C6.computable_szeged_index = 54; All goals completed! 🐙C6.computable_wiener = 27; All goals completed! 🐙@[category test, AMS 5] theorem C6_min_deg : C6.minDegree = 2 := C6.minDegree = 2 All goals completed! 🐙@[category test, AMS 5] theorem C6_max_deg : C6.maxDegree = 2 := C6.maxDegree = 2 All goals completed! 🐙@[category test, AMS 5] theorem C6_avg_deg : averageDegree C6 = 2 := C6.averageDegree = 2 (∑ v, (C6.degree v)) / (Fintype.card (Fin 6)) = 2; (∑ v, (C6.degree v)) / 6 = 2; All goals completed! 🐙hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})Disjoint {0, 1} {2, 3}; All goals completed! 🐙) hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})(C6.subgraphOfAdj ).IsMatching All goals completed! 🐙 hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})Disjoint (C6.subgraphOfAdj C6.subgraphOfAdj ).support (C6.subgraphOfAdj ).support hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})Disjoint (C6.subgraphOfAdj C6.subgraphOfAdj ).verts (C6.subgraphOfAdj ).verts All goals completed! 🐙 hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})(fun M M.edgeSet.toFinset.card) (C6.subgraphOfAdj C6.subgraphOfAdj C6.subgraphOfAdj ) = 3 All goals completed! 🐙@[category test, AMS 5] theorem C6_residue : residue C6 = 2 := C6.residue = 2 residueAux ((Multiset.map (fun v C6.degree v) Finset.univ.val).sort fun x1 x2 x1 x2) = 2; All goals completed! 🐙@[category test, AMS 5] theorem C6_annihilation : annihilationNumber C6 = 3 := C6.annihilationNumber = 3 All goals completed! 🐙@[category test, AMS 5] theorem C6_cvetkovic : cvetkovic C6 = 3 := C6.cvetkovic = 3 All goals completed! 🐙Star5.computable_indep_num = 5; All goals completed! 🐙Star5.computable_dom_num = 1; All goals completed! 🐙(5 / 3) = 5 / 3 All goals completed! 🐙Star5.computable_ediam = 2 exact_mod_cast (Star5.computable_ediam = 2 All goals completed! 🐙 : computable_ediam Star5 = 2)Star5.computable_radius = 1 exact_mod_cast (Star5.computable_radius = 1 All goals completed! 🐙 : computable_radius Star5 = 1)key: (b : Fin 5) (c : Star5.Walk (Sum.inr b) (Sum.inr b)), ¬c.IsCyclea:Fin 1c:Star5.Walk (Sum.inl a) (Sum.inl a)hc:c.IsCycleh1:Star5.Adj (Sum.inl a) c.sndb:Fin 5hb:c.snd = Sum.inr bFalse key: (b : Fin 5) (c : Star5.Walk (Sum.inr b) (Sum.inr b)), ¬c.IsCyclea:Fin 1c:Star5.Walk (Sum.inl a) (Sum.inl a)hc:c.IsCycleh1:Star5.Adj (Sum.inl a) c.sndb:Fin 5hb:c.snd = Sum.inr bhmem:Sum.inr b c.supportFalse All goals completed! 🐙Fintype.card (Fin 1 Fin 5) = 6 All goals completed! 🐙@[category test, AMS 5] theorem Star5_size : Star5.edgeFinset.card = 5 := Star5.edgeFinset.card = 5 All goals completed! 🐙Star5.computable_szeged_index = 25; All goals completed! 🐙Star5.computable_wiener = 25; All goals completed! 🐙@[category test, AMS 5] theorem Star5_min_deg : Star5.minDegree = 1 := Star5.minDegree = 1 All goals completed! 🐙@[category test, AMS 5] theorem Star5_max_deg : Star5.maxDegree = 5 := Star5.maxDegree = 5 All goals completed! 🐙@[category test, AMS 5] theorem Star5_avg_deg : averageDegree Star5 = 5/3 := Star5.averageDegree = 5 / 3 (∑ v, (Star5.degree v)) / (Fintype.card (Fin 1 Fin 5)) = 5 / 3; ((Star5.degree (Sum.inl 0)) + a₂, (Star5.degree (Sum.inr a₂))) / 6 = 5 / 3; All goals completed! 🐙hle: (M : Star5.Subgraph), M.IsMatching M.edgeSet.toFinset.card 1hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})Star5.matchingNumber = 1 hle: (M : Star5.Subgraph), M.IsMatching M.edgeSet.toFinset.card 1hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})(have matchings := {M | M.IsMatching}; sSup ((fun M M.edgeSet.toFinset.card) '' matchings)) = 1 hle: (M : Star5.Subgraph), M.IsMatching M.edgeSet.toFinset.card 1hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})(have matchings := {M | M.IsMatching}; sSup ((fun M M.edgeSet.toFinset.card) '' matchings)) 1hle: (M : Star5.Subgraph), M.IsMatching M.edgeSet.toFinset.card 1hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})1 have matchings := {M | M.IsMatching}; sSup ((fun M M.edgeSet.toFinset.card) '' matchings) hle: (M : Star5.Subgraph), M.IsMatching M.edgeSet.toFinset.card 1hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})(have matchings := {M | M.IsMatching}; sSup ((fun M M.edgeSet.toFinset.card) '' matchings)) 1 apply csSup_le (Set.Nonempty.image _ , hle: (M : Star5.Subgraph), M.IsMatching M.edgeSet.toFinset.card 1hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching}) {M | M.IsMatching} All goals completed! 🐙) hle: (M : Star5.Subgraph), M.IsMatching M.edgeSet.toFinset.card 1hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})M:Star5.SubgraphhM:M {M | M.IsMatching}(fun M M.edgeSet.toFinset.card) M 1 hle: (M : Star5.Subgraph), M.IsMatching M.edgeSet.toFinset.card 1hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})M:Star5.SubgraphhM:M {M | M.IsMatching}M.edgeSet.toFinset.card 1 All goals completed! 🐙 hle: (M : Star5.Subgraph), M.IsMatching M.edgeSet.toFinset.card 1hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})1 have matchings := {M | M.IsMatching}; sSup ((fun M M.edgeSet.toFinset.card) '' matchings) hle: (M : Star5.Subgraph), M.IsMatching M.edgeSet.toFinset.card 1hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})1 (fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching} refine Star5.subgraphOfAdj (show Star5.Adj (Sum.inl 0) (Sum.inr 0) Star5.matchingNumber = 1 All goals completed! 🐙), ?_, ?_ hle: (M : Star5.Subgraph), M.IsMatching M.edgeSet.toFinset.card 1hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})Star5.subgraphOfAdj {M | M.IsMatching} All goals completed! 🐙 hle: (M : Star5.Subgraph), M.IsMatching M.edgeSet.toFinset.card 1hbdd:BddAbove ((fun M M.edgeSet.toFinset.card) '' {M | M.IsMatching})(fun M M.edgeSet.toFinset.card) (Star5.subgraphOfAdj ) = 1 All goals completed! 🐙@[category test, AMS 5] theorem Star5_residue : residue Star5 = 5 := Star5.residue = 5 residueAux ((Multiset.map (fun v Star5.degree v) Finset.univ.val).sort fun x1 x2 x1 x2) = 5; All goals completed! 🐙@[category test, AMS 5] theorem Star5_annihilation : annihilationNumber Star5 = 5 := Star5.annihilationNumber = 5 All goals completed! 🐙@[category test, AMS 5] theorem Star5_cvetkovic : cvetkovic Star5 = 5 := Star5.cvetkovic = 5 All goals completed! 🐙end WrittenOnTheWallII.Test