FormalConjecturesForMathlib/Combinatorics/SimpleGraph/Residue.lean
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.
- def
SimpleGraph.havelHakimiStepHelper function: Performs one step of the Havel-Hakimi reduction on a degree sequence line 41 sourceSource documentation
Helper function: Performs one step of the Havel-Hakimi reduction on a degree sequence. Assumes the input list
sis sorted descending. Removes the first elementd, decrements the nextdelements by 1, and re-sorts the list descending.Note: when
sis the list of vertices arising from a simple graph, if the first index issthen the degree list always has length at leasts+1so this makes sense.standard axioms: Quot.sound, propext what this means
Statement uses:
List,NatProof 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.ge7 instances, coercions and auxiliary constants left out.
def havelHakimiStep (s : List ℕ) : List ℕ := …
- theorem
SimpleGraph.havelHakimiStep_length_conshavelHakimiStepdrops the list length by exactly one on a nonempty list:(havelHakimiStep (d :: rest)).length = rest.lengthline 58 sourceSource documentation
havelHakimiStepdrops the list length by exactly one on a nonempty list:(havelHakimiStep (d :: rest)).length = rest.length.splitAtpartitionsrest, andmap,++, andmergeSortall preserve the total length while the headdis dropped. This is the termination measure for the well-foundedresidueAuxbelow.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,List,Eq,List.length, SimpleGraph.havelHakimiStep,List.cons1 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
- def
SimpleGraph.residueAuxAuxiliary function to calculate the residue recursively line 68 sourceSource 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,NatProof uses:
WellFounded.Nat.fix,List.length,InvImage,LT.lt,SimpleGraph.residueAux.match_1,Unit,List.nil,OfNat.ofNat,List.cons,HAdd.hAdd, SimpleGraph.havelHakimiStep5 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
- def
SimpleGraph.residueDocumented declaration: residue line 83 sourceSource 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,NatProof uses: SimpleGraph.residueAux,
Multiset.sort,Multiset.map,SimpleGraph.degree,Membership.mem,Set,SimpleGraph.neighborSet,Finset.val,Finset.univ,GE.ge11 instances, coercions and auxiliary constants left out.
noncomputable def residue (G : SimpleGraph α) [DecidableRel G.Adj] : ℕ := …