FormalConjecturesForMathlib/Combinatorics/SimpleGraph/Residue.lean

GitHub source file

Explanation legend Lean4 Domain Explanation Language (L4DEL)

L4DEL explanations are a separate layer. They do not change the Lean source. Intuition is explanatory prose; numbered items are a reading path; sources link the wording back to evidence.

L4DEL
Lean4 Domain Explanation Language

Credit: The upstream authors and contributors retain credit for the project and mathematics. lean4-explainer only renders their pinned source and adds the separately disclosed explanation layer.

Project sources: Pinned project documentation, Formal Conjectures paper, arXiv v1

4 declarations, 0 contain sorry, 0 declared as axioms

Residue

The residue of a graph is the number of zeros remaining after iteratively applying the Havel-Hakimi algorithm to the degree sequence until all remaining degrees are zero.

Imports (2)
Imported by 2 files
  1. def SimpleGraph.havelHakimiStep Helper function: Performs one step of the Havel-Hakimi reduction on a degree sequence line 41 source

    Source documentation

    Helper function: Performs one step of the Havel-Hakimi reduction on a degree sequence. Assumes the input list s is sorted descending. Removes the first element d, decrements the next d elements by 1, and re-sorts the list descending.

    Note: when s is the list of vertices arising from a simple graph, if the first index is s then the degree list always has length at least s+1 so this makes sense.

    standard axioms: Quot.sound, propext what this means

    Statement uses: List, Nat

    Proof uses: SimpleGraph.havelHakimiStep.match_2, Unit, List.nil, SimpleGraph.havelHakimiStep.match_1, Prod, List.splitAt, List.map, HSub.hSub, OfNat.ofNat, List.mergeSort, HAppend.hAppend, Decidable.decide, GE.ge

    7 instances, coercions and auxiliary constants left out.

    def havelHakimiStep (s : List ℕ) : List ℕ :=
    …
  2. theorem SimpleGraph.havelHakimiStep_length_cons havelHakimiStep drops the list length by exactly one on a nonempty list: (havelHakimiStep (d :: rest)).length = rest.length line 58 source

    Source documentation

    havelHakimiStep drops the list length by exactly one on a nonempty list: (havelHakimiStep (d :: rest)).length = rest.length. splitAt partitions rest, and map, ++, and mergeSort all preserve the total length while the head d is dropped. This is the termination measure for the well-founded residueAux below.

    standard axioms: Classical.choice, Quot.sound, propext what this means

    Statement uses: Nat, List, Eq, List.length, SimpleGraph.havelHakimiStep, List.cons

    1 instances, coercions and auxiliary constants left out.

    Tactic trace: 1 steps

    Open to load the checked before-and-after goal states.

    theorem havelHakimiStep_length_cons (d : ℕ) (rest : List ℕ) :
        (havelHakimiStep (d :: rest)).length = rest.length := by
    …

    Mentions: SimpleGraph.havelHakimiStep

  3. def SimpleGraph.residueAux Auxiliary function to calculate the residue recursively line 68 source

    Source documentation

    Auxiliary function to calculate the residue recursively. Applies Havel-Hakimi steps until the sequence consists only of zeros or is empty. Defined by well-founded recursion on the list length (via havelHakimiStep_length_cons), so that it admits equational and inductive reasoning.

    standard axioms: Classical.choice, Quot.sound, propext what this means

    Statement uses: List, Nat

    Proof uses: WellFounded.Nat.fix, List.length, InvImage, LT.lt, SimpleGraph.residueAux.match_1, Unit, List.nil, OfNat.ofNat, List.cons, HAdd.hAdd, SimpleGraph.havelHakimiStep

    5 instances, coercions and auxiliary constants left out.

    Tactic trace: 3 steps

    Open to load the checked before-and-after goal states.

    def residueAux : List ℕ → ℕ
      | [] => 0        -- Empty sequence, residue is 0.
      | 0 :: s => 1 + s.length -- If the largest degree is 0 (and the list is sorted), all are 0.
      | d :: rest => residueAux (havelHakimiStep (d :: rest)) -- Apply one reduction step and recurse.
    termination_by l => l.length
    decreasing_by
      simp_wf
      rw [havelHakimiStep_length_cons]
      omega
    
    /--
    Computes the residue of a graph `G`, i.e. the number of zeros remaining after iteratively

    Mentions: SimpleGraph.residue, SimpleGraph.havelHakimiStep, SimpleGraph.l, SimpleGraph.havelHakimiStep_length_cons

  4. def SimpleGraph.residue Documented declaration: residue line 83 source

    Source documentation

    Computes the residue of a graph G, i.e. the number of zeros remaining after iteratively applying the Havel-Hakimi algorithm to the degree sequence until all remaining degrees are zero. Starts with the descending degree sequence and applies the Havel-Hakimi process.

    standard axioms: Classical.choice, Quot.sound, propext what this means

    Statement uses: Fintype, SimpleGraph, DecidableRel, SimpleGraph.Adj, Nat

    Proof uses: SimpleGraph.residueAux, Multiset.sort, Multiset.map, SimpleGraph.degree, Membership.mem, Set, SimpleGraph.neighborSet, Finset.val, Finset.univ, GE.ge

    11 instances, coercions and auxiliary constants left out.

    noncomputable def residue (G : SimpleGraph α) [DecidableRel G.Adj] : ℕ :=
    …