Skip to content

feat(Combinatorics/SimpleGraph/Paths): existence of longest paths/trails/cycles/circuits#41522

Open
SnirBroshi wants to merge 3 commits into
leanprover-community:masterfrom
SnirBroshi:feature/simple-graph/longest-paths
Open

feat(Combinatorics/SimpleGraph/Paths): existence of longest paths/trails/cycles/circuits#41522
SnirBroshi wants to merge 3 commits into
leanprover-community:masterfrom
SnirBroshi:feature/simple-graph/longest-paths

Conversation

@SnirBroshi

@SnirBroshi SnirBroshi commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

We already have the existence of a longest path/trail. This adds:

  • the existence of a longest cycle/circuit in non-acyclic graphs
  • the existence of a longest path/trail from a specific vertex
  • the existence of a longest path/trail between specific endpoints
  • the existence of a longest cycle/circuit from a specific vertex

exists_isTrail_forall_length_le_of_pred is the common argument that works for any predicate on trails, which is then used to prove the 10 versions mentioned above.
I know this looks a bit ugly, but taking a longest path/trail/cycle/circuit is a useful proof technique.

Open in Gitpod

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

PR summary 7d3065d46a

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

+ Reachable.exists_isPath_forall_isPath_length_le_length
+ Reachable.exists_isTrail_forall_isTrail_length_le_length
+ _root_.SimpleGraph.exists_isPath_forall_isPath_length_le_length
+ _root_.SimpleGraph.exists_isPath_forall_isPath_length_le_length'
+ _root_.SimpleGraph.exists_isTrail_forall_isTrail_length_le_length
+ _root_.SimpleGraph.exists_isTrail_forall_isTrail_length_le_length'
+ _root_.SimpleGraph.exists_isTrail_forall_length_le_of_pred
+ exists_isCircuit_forall_isCircuit_length_le_length
+ exists_isCircuit_forall_isCircuit_length_le_length'
+ exists_isCycle_forall_isCycle_length_le_length
+ exists_isCycle_forall_isCycle_length_le_length'
+ isAcyclic_iff_forall_not_isCircuit
+ isAcyclic_iff_forall_not_isCycle
+ not_isAcyclic_iff_exists_isCircuit
+ not_isAcyclic_iff_exists_isCycle

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

Declarations diff (Lean)

Lean-aware diff — post-build, computed from the Lean environment (commit 7d3065d).

  • +19 new declarations
  • −0 removed declarations
+SimpleGraph.Reachable.exists_isPath_forall_isPath_length_le_length
+SimpleGraph.Reachable.exists_isTrail_forall_isTrail_length_le_length
+SimpleGraph.Walk.IsCircuit.hcongr_4
+SimpleGraph.Walk.IsCycle.hcongr_4
+SimpleGraph.Walk.IsPath.hcongr_5
+SimpleGraph.Walk.IsTrail.hcongr_5
+SimpleGraph.exists_isCircuit_forall_isCircuit_length_le_length
+SimpleGraph.exists_isCircuit_forall_isCircuit_length_le_length'
+SimpleGraph.exists_isCycle_forall_isCycle_length_le_length
+SimpleGraph.exists_isCycle_forall_isCycle_length_le_length'
+SimpleGraph.exists_isPath_forall_isPath_length_le_length
+SimpleGraph.exists_isPath_forall_isPath_length_le_length'
+SimpleGraph.exists_isTrail_forall_isTrail_length_le_length
+SimpleGraph.exists_isTrail_forall_isTrail_length_le_length'
+SimpleGraph.exists_isTrail_forall_length_le_of_pred
+SimpleGraph.isAcyclic_iff_forall_not_isCircuit
+SimpleGraph.isAcyclic_iff_forall_not_isCycle
+SimpleGraph.not_isAcyclic_iff_exists_isCircuit
+SimpleGraph.not_isAcyclic_iff_exists_isCycle

No changes to strong technical debt.

No changes to weak technical debt.

Current commit 7d3065d46a
Reference commit 80ffd59621

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@github-actions github-actions Bot added the t-combinatorics Combinatorics label Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-combinatorics Combinatorics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant