Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Labeled Tree Basic

Definition
AnalyticCombinatorics_Ch7_SingularityApp_LabeledTreeBasic

by FormallyCorrect · Oct 28, 2026 · Mathlib 777aaa6 (Lean v4.29.0-rc3)

analytic-combinatoricslean4tree-models

The mathematical objects and operations are specified by the following source definitions.

def LabeledTree (n : ℕ) : Type :=
  {G : SimpleGraph (Fin n) // G.IsTree}
def RootedLabeledTree (n : ℕ) : Type :=
  LabeledTree n × Fin n
Definition code
import Mathlib

set_option autoImplicit true
set_option relaxedAutoImplicit false
set_option maxSynthPendingDepth 3


/-!
# Labelled trees on a finite vertex set

We introduce the genuine combinatorial object underlying Cayley's formula: the
type of labelled trees on `Fin n`, namely simple graphs on `Fin n` that are
trees (connected and acyclic), and the rooted version.  These are finite types.

The cardinality results (`card (LabeledTree n) = n^(n-2)`,
`card (RootedLabeledTree n) = n^(n-1)`) and the connection to the banked
`cayleyRootedTree` are established in `Prufer.lean` / `Cayley.lean`.
-/

namespace AnalyticCombinatorics.Ch7.SingularityApp.LabeledTreeNS

/-- A labelled tree on `n` vertices: a simple graph on `Fin n` that is a tree. -/
def LabeledTree (n : ℕ) : Type :=
  {G : SimpleGraph (Fin n) // G.IsTree}

/-- A rooted labelled tree on `n` vertices. -/
def RootedLabeledTree (n : ℕ) : Type :=
  LabeledTree n × Fin n

instance instFiniteLabeledTree (n : ℕ) : Finite (LabeledTree n) := by
  unfold LabeledTree; infer_instance

noncomputable instance instFintypeLabeledTree (n : ℕ) : Fintype (LabeledTree n) :=
  Fintype.ofFinite _

noncomputable instance instFintypeRootedLabeledTree (n : ℕ) :
    Fintype (RootedLabeledTree n) := by
  unfold RootedLabeledTree; infer_instance

end AnalyticCombinatorics.Ch7.SingularityApp.LabeledTreeNS
Source
https://github.com/xiangyazi24/AnalyticCombinatorics/blob/f6f3f1cebdae245a61d9d71e6b47c69fbd096fe3/AnalyticCombinatorics/Ch7/SingularityApp/LabeledTreeBasic.lean. Source code: Apache-2.0; https://github.com/xiangyazi24/AnalyticCombinatorics/blob/f6f3f1cebdae245a61d9d71e6b47c69fbd096fe3/LICENSE

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