Skip to content

feat(Combinatorics/HypergraphLike): add graph-like class - #43768

Open
Jun2M wants to merge 29 commits into
leanprover-community:masterfrom
Jun2M:HypergraphLikeGraphLike
Open

Jun2M wants to merge 29 commits into
leanprover-community:masterfrom
Jun2M:HypergraphLikeGraphLike

Conversation

@Jun2M

@Jun2M Jun2M commented Sep 13, 2026 •

Copy link
Copy Markdown
Collaborator

Introduces HyperGraphLike.GraphLike class that certifies that the object is a normal graph not hypergraph.

GraphLike class is a bit different than the naive implementation of asserting it IsUniform 2. Uniformity is kept by involutive function other' that exchanges the two incidences of an edge. Then, each edge must have at least one source incidence and at least one target incidence, to maintain the expected behaviour for directed graphs and undirected graphs. For example, if an edge e has two incidences that are only source and not target, any hypergraph with e is not graphLike.

Codex assisted with implementation and review; the code was subsequently reviewed and revised by the me.

Co-authored-by: OpenAI Codex [email protected]


@github-actions github-actions Bot added the t-combinatorics Combinatorics label Sep 13, 2026
@Jun2M Jun2M changed the title feat(Combinatorics/HypergraphLike): add graph-like structures feat(Combinatorics/HypergraphLike): add graph-like class Sep 13, 2026
@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 Sep 13, 2026
@mathlib-dependent-issues

Copy link
Copy Markdown

This PR/issue depends on:

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

PR summary 7ab944b174

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Combinatorics.HypergraphLike.Basic (new file) 352
Mathlib.Combinatorics.HypergraphLike.Degree (new file) 1014
Mathlib.Combinatorics.HypergraphLike.GraphLike (new file) 1015

Declarations diff (regex)

+ Adj.left_mem_vertexSet
+ Adj.right_mem_vertexSet
+ GraphLike
+ GraphLike.ofEOrderEqTwo
+ GraphLike.ofEOrderEqTwoOfEdgeMap
+ GraphLike.ofOrderEqTwo
+ GraphLike.ofOrderEqTwoOfEdgeMap
+ HyperGraphLike
+ IsLink.adj
+ IsLink.edge_mem_edgeSet
+ IsLink.eq_of_mem_incVerts_of_ne
+ IsLink.eq_or_eq_of_isLink
+ IsLink.eq_or_eq_of_isLink_of_eorder_eq_two
+ IsLink.eq_or_eq_of_isLink_of_order_eq_two
+ IsLink.incVerts_eq
+ IsLink.incVerts_eq_of_eorder_eq_two
+ IsLink.incVerts_eq_of_order_eq_two
+ IsLink.isLink_iff_eq
+ IsLink.left_eq_or_eq
+ IsLink.left_mem_incVerts
+ IsLink.left_mem_vertexSet
+ IsLink.left_unique
+ IsLink.left_unique_of_eorder_eq_two
+ IsLink.left_unique_of_order_eq_two
+ IsLink.mem_incEdges_left
+ IsLink.mem_incEdges_right
+ IsLink.mem_incVerts_iff
+ IsLink.one_lt_eorder
+ IsLink.one_lt_order
+ IsLink.pair_subset_incVerts
+ IsLink.right_eq_or_eq
+ IsLink.right_mem_incVerts
+ IsLink.right_mem_vertexSet
+ IsLink.right_unique
+ IsLink.right_unique_of_eorder_eq_two
+ IsLink.right_unique_of_order_eq_two
+ IsSource.mem_incs
+ IsTarget.mem_incs
+ adj_iff_exists_incidence
+ adj_iff_of_verts_eq_singleton
+ attach
+ attach_image_incs_of_edegree_pos
+ attach_mem_incVerts
+ attach_mem_verts
+ attach_preimage_singleton_injOn
+ attach_surjOn_iff
+ biUnion_edgeFiber
+ biUnion_vertexFiber
+ degree
+ degree_attach_pos
+ degree_eq_ncard_vertexFiber
+ degree_eq_zero
+ degree_eq_zero_iff_forall_notMem_incVerts
+ degree_eq_zero_iff_incEdges_eq_empty
+ degree_eq_zero_of_incs_eq_empty
+ degree_eq_zero_of_infinite
+ degree_le_ncard_incs
+ degree_of_notMem_verts
+ degree_pos
+ degree_pos_iff_exists_mem_incVerts
+ degree_pos_iff_nonempty_incEdges
+ edegree
+ edegree_attach_pos
+ edegree_eq_encard_vertexFiber
+ edegree_eq_top_iff
+ edegree_eq_zero
+ edegree_eq_zero_iff_forall_notMem_incVerts
+ edegree_eq_zero_iff_incEdges_eq_empty
+ edegree_eq_zero_of_incs_eq_empty
+ edegree_le_encard_incs
+ edegree_lt_top_iff
+ edegree_lt_top_of_finite
+ edegree_of_notMem_verts
+ edegree_pos
+ edegree_pos_iff_exists_mem_incVerts
+ edegree_pos_iff_nonempty_incEdges
+ edgeFiber
+ edgeFiber_edgeMap
+ edgeFiber_eq_inter_preimage
+ edgeFiber_subset_incs
+ edgeMap
+ edgeMap_eq_iff
+ edgeMap_image_incs
+ edgeMap_image_incs_of_eorder_pos
+ edgeMap_mem_edges
+ edgeMap_mem_incEdges
+ edgeMap_other
+ edgeMap_preimage_singleton_injOn
+ edgeMap_preimage_singleton_injOn_of_GraphLike
+ edgeMap_range
+ edgeMap_range_of_eorder_pos
+ edgeMap_surjOn
+ edgeMap_surjOn_iff
+ edges_eq_empty_iff_forall_not_adj
+ edges_eq_empty_iff_forall_not_isLink
+ edges_eq_setOf_exists_isLink
+ encard_incEdges_le_edegree
+ encard_incVerts_le_eorder
+ eorder
+ eorder_edgeMap_pos
+ eorder_eq_encard_edgeFiber
+ eorder_eq_top_iff
+ eorder_eq_two
+ eorder_eq_zero
+ eorder_eq_zero_of_incs_eq_empty
+ eorder_le_encard_incs
+ eorder_le_two
+ eorder_lt_top_iff
+ eorder_lt_top_of_finite
+ eorder_of_notMem_edges
+ eorder_pos
+ eq_or_eq_or_eq_of_mem_incVerts
+ exists_isLink_of_mem_edgeSet
+ exists_isSource_of_mem_edgeSet
+ exists_isTarget_of_mem_edgeSet
+ exists_pair_edgeMap_iff
+ finite_edgeFiber_of_order_pos
+ finite_vertexFiber_of_degree_pos
+ iUnion_edgeFiber
+ iUnion_vertexFiber
+ incEdges
+ incEdges_eq_empty
+ incEdges_eq_image
+ incEdges_nonempty
+ incEdges_of_notMem_verts
+ incEdges_subset_edges
+ incVerts
+ incVerts_encard_le_two
+ incVerts_eq_empty
+ incVerts_eq_image
+ incVerts_ncard_le_two
+ incVerts_nonempty
+ incVerts_of_notMem_edges
+ incVerts_subset_verts
+ incs_eq_empty_of_edges_eq_empty
+ incs_eq_empty_of_verts_eq_empty
+ instance [Finite I(G)] : Finite (edgeFiber G e)
+ instance [Finite I(G)] : Finite (vertexFiber G v)
+ isLink_attach
+ isLink_iff_exists_incidence
+ isLink_iff_of_verts_eq_singleton
+ mem_edgeFiber
+ mem_edges_iff_exists_isLink
+ mem_edges_iff_incVerts_nonempty
+ mem_edges_of_eorder_pos
+ mem_edges_of_mem_edgeFiber
+ mem_edges_of_mem_incVerts
+ mem_edges_of_order_pos
+ mem_incEdges
+ mem_incEdges_iff_exists_incidence
+ mem_incVerts_iff_exists_incidence
+ mem_vertexFiber
+ mem_verts_of_degree_pos
+ mem_verts_of_edegree_pos
+ mem_verts_of_mem_incEdges
+ mem_verts_of_mem_vertexFiber
+ natCast_degree
+ natCast_degree_of_finite
+ natCast_order
+ natCast_order_of_finite
+ ncard_incEdges_le_degree
+ ncard_incVerts_le_order
+ not_adj_of_notMem_verts
+ not_adj_of_notMem_verts_right
+ not_isLink_of_notMem_edges
+ one_lt_eorder_iff
+ one_lt_order_iff
+ order
+ order_edgeMap_pos
+ order_eq_ncard_edgeFiber
+ order_eq_two
+ order_eq_zero
+ order_eq_zero_of_incs_eq_empty
+ order_eq_zero_of_infinite
+ order_le_ncard_incs
+ order_le_two
+ order_of_notMem_edges
+ order_pos
+ other
+ other_inj
+ other_injOn
+ other_mem
+ other_ne
+ other_other
+ pairwise_disjoint_edgeFiber
+ pairwise_disjoint_vertexFiber
+ sum_degree
+ sum_degree_eq_sum_order
+ sum_edegree
+ sum_edegree_eq_sum_eorder
+ sum_eorder
+ sum_order
+ toNat_edegree
+ toNat_eorder
+ val_attach'_eq_attach
+ val_edgeMap'_eq_edgeMap
+ vertexFiber
+ vertexFiber_eq_inter_preimage
+ vertexFiber_subset_incs

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 -- unavailable)

⚠️ No declarations diff yet: there is no built master snapshot at this PR's merge-base (typically a bors-batch intermediate that CI never built). Merge master into this PR and push to refresh.


No changes to strong technical debt.

Increase in weak tech debt: (relative, absolute) = (3.00, 0.00)
Current number Change Type (weak)
exposed public sections 5064 3

Current commit 7ab944b174
Reference commit 38f65a093a

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) t-combinatorics Combinatorics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant