Skip to content

feat(Combinatorics/Quiver): simple paths, cycles and induced quivers - #39916

Closed
mkaratarakis wants to merge 23 commits into
leanprover-community:masterfrom
mkaratarakis:pf/port/quiver-path
Closed

mkaratarakis wants to merge 23 commits into
leanprover-community:masterfrom
mkaratarakis:pf/port/quiver-path

Conversation

@mkaratarakis

@mkaratarakis mkaratarakis commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

This adds some basic API for paths in a quiver, modelled on what we already have for SimpleGraph.Walk.

  • Quiver.Path.IsSimple, Quiver.Path.IsPath and Quiver.Path.IsCycle, plus Quiver.IsAcyclic
  • the vertices a path visits, as a Set and as a Finset
  • Quiver.Path.replicate, the n-fold composition of a loop with itself
  • Quiver.induce, the quiver induced on a set of vertices (cf. SimpleGraph.induce)

The main results are that a path revisiting a vertex can be shortened by cutting out the loop, that a shortest path is simple, and that a simple path has length at most card V - 1.

Joint work with @or4nge19.


Open in Gitpod

@github-actions

github-actions Bot commented May 27, 2026 •

Copy link
Copy Markdown

PR summary ffa2725c5d

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Combinatorics.Quiver.Path.Replicate (new file) 207
Mathlib.Combinatorics.Quiver.Induced (new file) 487
Mathlib.Combinatorics.Quiver.Path.Cycle (new file) 521
Mathlib.Combinatorics.Quiver.Path.Simple (new file) 593

Declarations diff (regex)

+ IsAcyclic
+ IsAcyclic.eq_nil
+ IsAcyclic.not_isCycle
+ IsCycle
+ IsPath
+ IsPath.isSimple
+ IsPath.nil
+ IsSimple
+ activeVertices
+ activeVertices_cons
+ activeVertices_nil
+ card_vertexFinset_of_isPath
+ exists_length_add_eq_of_getElem_eq
+ exists_length_lt_of_not_isPath
+ exists_pos_length_lt_of_not_isSimple
+ inducePrefunctor
+ isPath_cons
+ isPath_of_shortest
+ isSimple_of_minimal_length
+ length_le_card_minus_one_of_isSimple
+ length_replicate
+ mapPath_inducePrefunctor_mem_vertices
+ mem_activeVertices
+ mem_vertices_to_active
+ path_decomposition_first_edge
+ path_decomposition_last_edge
+ replicate
+ replicate_succ
+ replicate_zero
+ vertexFinset
++ induce

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 ffa2725).

  • +32 new declarations
  • −0 removed declarations
+Quiver.IsAcyclic
+Quiver.IsAcyclic.eq_nil
+Quiver.IsAcyclic.not_isCycle
+Quiver.Path.IsCycle
+Quiver.Path.IsPath
+Quiver.Path.IsPath.isSimple
+Quiver.Path.IsPath.nil
+Quiver.Path.IsSimple
+Quiver.Path.activeVertices
+Quiver.Path.activeVertices_cons
+Quiver.Path.activeVertices_nil
+Quiver.Path.card_vertexFinset_of_isPath
+Quiver.Path.exists_length_add_eq_of_getElem_eq
+Quiver.Path.exists_length_lt_of_not_isPath
+Quiver.Path.exists_pos_length_lt_of_not_isSimple
+Quiver.Path.induce
+Quiver.Path.isPath_cons
+Quiver.Path.isPath_of_shortest
+Quiver.Path.isSimple_of_minimal_length
+Quiver.Path.length_le_card_minus_one_of_isSimple
+Quiver.Path.length_replicate
+Quiver.Path.mapPath_inducePrefunctor_mem_vertices
+Quiver.Path.mem_activeVertices
+Quiver.Path.mem_vertices_to_active
+Quiver.Path.path_decomposition_first_edge
+Quiver.Path.path_decomposition_last_edge
+Quiver.Path.replicate
+Quiver.Path.replicate_succ
+Quiver.Path.replicate_zero
+Quiver.Path.vertexFinset
+Quiver.induce
+Quiver.inducePrefunctor

No changes to strong technical debt.

Increase in weak tech debt: (relative, absolute) = (4.00, 0.00)
Current number Change Type (weak)
5104 4 exposed public sections

Current commit ffa2725c5d
Reference commit 74e558e2f8

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.py 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).

@mathlib-dependent-issues mathlib-dependent-issues Bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label May 27, 2026
@mkaratarakis
mkaratarakis force-pushed the pf/port/quiver-path branch 4 times, most recently from dba8080 to 0ce55c7 Compare May 27, 2026 18:46
@mkaratarakis
mkaratarakis force-pushed the pf/port/quiver-path branch from 0ce55c7 to 8217ce8 Compare May 27, 2026 19:34
@github-actions github-actions Bot added the large-import Automatically added label for PRs with a significant increase in transitive imports label May 28, 2026
@mkaratarakis
mkaratarakis force-pushed the pf/port/quiver-path branch from c8eb64d to c10f478 Compare May 29, 2026 14:10
@github-actions github-actions Bot removed the large-import Automatically added label for PRs with a significant increase in transitive imports label May 29, 2026
@github-actions github-actions Bot added the large-import Automatically added label for PRs with a significant increase in transitive imports label May 29, 2026
@or4nge19

Copy link
Copy Markdown
Contributor

Thanks for the initial comments, we have substantially refactored the code and removed some redundancies. There may be still be some better integration between this and #39913.

@github-actions github-actions Bot removed the large-import Automatically added label for PRs with a significant increase in transitive imports label May 29, 2026
@github-actions github-actions Bot added the WIP Work in progress label Aug 25, 2026
@mkaratarakis

Copy link
Copy Markdown
Contributor Author

-WIP

@github-actions github-actions Bot removed the WIP Work in progress label Aug 26, 2026
@mkaratarakis

Copy link
Copy Markdown
Contributor Author

@YaelDillies

@YaelDillies

Copy link
Copy Markdown
Contributor

Maths should be named intrinsically, not according to what it will be used for. Surely these are not called "paths for Perron-Frobenius" in the literature? Can you adapt the PR title and filenames accordingly?

@YaelDillies YaelDillies self-assigned this Sep 29, 2026
@YaelDillies YaelDillies added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Sep 29, 2026
@mkaratarakis mkaratarakis changed the title feat(Combinatorics/Quiver/Path): paths for Perron–Frobenius feat(Combinatorics/Quiver): simple paths, cycles and induced quivers Oct 17, 2026
@mkaratarakis

Copy link
Copy Markdown
Contributor Author

-awaiting-author

@github-actions github-actions Bot removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Oct 17, 2026

@YaelDillies YaelDillies left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you maybe open one PR per file? I don't really see the files as very connected to each other and I expect it would make reviewing faster if they could be reviewed independently

@mkaratarakis

Copy link
Copy Markdown
Contributor Author

-awaiting-author

@github-actions github-actions Bot removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Oct 19, 2026
@YaelDillies

Copy link
Copy Markdown
Contributor

Should this PR depend on the new ones?

@mkaratarakis

Copy link
Copy Markdown
Contributor Author

No, it's replaced by #45032–#45035, so I'm closing it.

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.

4 participants