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

Graceful Tree Conjecture (Ringel–Kotzig conjecture)

Reference: Wikipedia/Graceful_labeling

Conjectured by Ringel (1963) and Kotzig; formalized by Rosa (1967).

namespace GracefulLabelingopen SimpleGraphAll goals completed! 🐙) = Finset.Icc 1 m := let T := ; let m := T.edgeFinset.card; f, Function.Injective f (∀ (v : Unit), f v m) Finset.image (fun e Sym2.lift fun u v ((f u) - (f v)).natAbs, e) T.edgeFinset = Finset.Icc 1 m T:SimpleGraph Unit := m: := T.edgeFinset.card f, Function.Injective f (∀ (v : Unit), f v m) Finset.image (fun e Sym2.lift fun u v ((f u) - (f v)).natAbs, e) T.edgeFinset = Finset.Icc 1 m T:SimpleGraph Unit := m: := T.edgeFinset.card(Function.Injective fun x 0) (∀ (v : Unit), (fun x 0) v m) Finset.image (fun e Sym2.lift fun u v (((fun x 0) u) - ((fun x 0) v)).natAbs, e) T.edgeFinset = Finset.Icc 1 m T:SimpleGraph Unit := m: := T.edgeFinset.cardFinset.image (fun e Sym2.lift fun u v (((fun x 0) u) - ((fun x 0) v)).natAbs, e) T.edgeFinset = Finset.Icc 1 m All goals completed! 🐙All goals completed! 🐙) = Finset.Icc 1 m := let T := ; let m := T.edgeFinset.card; f, Function.Injective f (∀ (v : Fin 2), f v m) Finset.image (fun e Sym2.lift fun u v ((f u) - (f v)).natAbs, e) T.edgeFinset = Finset.Icc 1 m T:SimpleGraph (Fin 2) := m: := T.edgeFinset.card f, Function.Injective f (∀ (v : Fin 2), f v m) Finset.image (fun e Sym2.lift fun u v ((f u) - (f v)).natAbs, e) T.edgeFinset = Finset.Icc 1 m T:SimpleGraph (Fin 2) := m: := T.edgeFinset.cardFunction.Injective Fin.val (∀ (v : Fin 2), v m) Finset.image (fun e Sym2.lift fun u v (u - v).natAbs, e) T.edgeFinset = Finset.Icc 1 m refine Fin.val_injective, T:SimpleGraph (Fin 2) := m: := T.edgeFinset.card (v : Fin 2), v m All goals completed! 🐙, ?_ let T := ; let m := T.edgeFinset.card; Finset.image (fun e Sym2.lift fun u v (u - v).natAbs, e) T.edgeFinset = Finset.Icc 1 m All goals completed! 🐙

Every tree admits a graceful labeling.

A graceful labeling of a tree $T$ with $m$ edges is an injective map $f : V \to {0, \dots, m}$ such that the multiset of absolute differences $|f(u) - f(v)|$ over edges ${u,v}$ of $T$ equals ${1, \dots, m}$.

All goals completed! 🐙) = Finset.Icc 1 m := V:Type u_1inst✝²:Fintype Vinst✝¹:DecidableEq VT:SimpleGraph Vinst✝:DecidableRel T.AdjhT:T.IsTreelet m := T.edgeFinset.card; f, Function.Injective f (∀ (v : V), f v m) Finset.image (fun e Sym2.lift fun u v ((f u) - (f v)).natAbs, e) T.edgeFinset = Finset.Icc 1 m All goals completed! 🐙end GracefulLabeling