-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(Combinatorics): define HasAdj for capturing the common structure of different kinds of (simple) graphs
#35776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /- | ||
| Copyright (c) 2026 Iván Renison. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Iván Renison | ||
| -/ | ||
| module | ||
|
|
||
| public import Mathlib.Combinatorics.HasAdj.Basic | ||
| public import Mathlib.Combinatorics.Digraph.Basic | ||
|
|
||
| /-! | ||
| In this file we make `Digraph` an instance of `HasAdj`. | ||
| -/ | ||
|
|
||
| @[expose] public section | ||
|
|
||
| variable {α : Type*} | ||
|
|
||
| instance : HasAdj α (Digraph α) where | ||
| verts _ := Set.univ | ||
| Adj G := G.Adj | ||
| left_mem_verts_of_adj _ := Set.mem_univ _ | ||
| right_mem_verts_of_adj _ := Set.mem_univ _ |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,52 @@ | ||||||||||||||
| /- | ||||||||||||||
| Copyright (c) 2026 Iván Renison. All rights reserved. | ||||||||||||||
| Released under Apache 2.0 license as described in the file LICENSE. | ||||||||||||||
| Authors: Iván Renison | ||||||||||||||
| -/ | ||||||||||||||
| module | ||||||||||||||
|
|
||||||||||||||
| public import Batteries.Data.List.Basic | ||||||||||||||
| public import Mathlib.Data.Rel | ||||||||||||||
|
|
||||||||||||||
| /-! | ||||||||||||||
| # Typeclass for different kinds of (simple) graphs | ||||||||||||||
|
|
||||||||||||||
| This module defines the typeclass `HasAdj` for capturing the common structure of different kinds of | ||||||||||||||
| (simple) graphs. | ||||||||||||||
|
|
||||||||||||||
| ## Main definitions | ||||||||||||||
|
|
||||||||||||||
| * `HasAdj`: is the main typeclass in question. The field `verts` gives the set of vertices of a | ||||||||||||||
| graph, and the field `Adj` gives the adjacency relation between vertices. | ||||||||||||||
|
|
||||||||||||||
| ## TODO | ||||||||||||||
| * Migrate from `SimpleGraph` all the results that only depend on the adjacency relation. | ||||||||||||||
|
|
||||||||||||||
| -/ | ||||||||||||||
|
|
||||||||||||||
| @[expose] public section | ||||||||||||||
|
|
||||||||||||||
| /-- Typeclass for (simple) graphs. -/ | ||||||||||||||
| class HasAdj (α : outParam Type*) (Gr : Type*) where | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
no? |
||||||||||||||
| /-- The set of vertices of the graph. -/ | ||||||||||||||
| verts (G : Gr) : Set α | ||||||||||||||
| /-- The adjacency relation of the graph. -/ | ||||||||||||||
| Adj (G : Gr) : α → α → Prop | ||||||||||||||
| /-- There is no edge of the graph outside of it vertices. -/ | ||||||||||||||
| left_mem_verts_of_adj {G : Gr} {v w : α} (h : Adj G v w) : v ∈ verts G | ||||||||||||||
| /-- There is no edge of the graph outside of it vertices. -/ | ||||||||||||||
|
Comment on lines
+35
to
+37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| right_mem_verts_of_adj {G : Gr} {v w : α} (h : Adj G v w) : w ∈ verts G | ||||||||||||||
|
|
||||||||||||||
| namespace HasAdj | ||||||||||||||
|
|
||||||||||||||
| variable {Gr : Type*} {α : Type*} [HasAdj α Gr] | ||||||||||||||
|
|
||||||||||||||
| /-- Dot notation for `left_mem_verts_of_adj`. -/ | ||||||||||||||
| lemma Adj.left_mem_verts {G : Gr} {v w : α} (h : Adj G v w) : v ∈ verts G := | ||||||||||||||
| left_mem_verts_of_adj h | ||||||||||||||
|
|
||||||||||||||
| /-- Dot notation for `right_mem_verts_of_adj`. -/ | ||||||||||||||
| lemma Adj.right_mem_verts {G : Gr} {v w : α} (h : Adj G v w) : w ∈ verts G := | ||||||||||||||
| right_mem_verts_of_adj h | ||||||||||||||
|
|
||||||||||||||
| end HasAdj | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /- | ||
| Copyright (c) 2026 Iván Renison. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Iván Renison | ||
| -/ | ||
| module | ||
|
|
||
| public import Mathlib.Combinatorics.HasAdj.Basic | ||
| public import Mathlib.Combinatorics.SimpleGraph.Basic | ||
|
|
||
| /-! | ||
| In this file we make `SimpleGraph` an instance of `HasAdj`. | ||
| -/ | ||
|
|
||
| @[expose] public section | ||
|
|
||
| variable {α : Type*} | ||
|
|
||
| instance : HasAdj α (SimpleGraph α) where | ||
| verts _ := Set.univ | ||
| Adj G := G.Adj | ||
| left_mem_verts_of_adj _ := Set.mem_univ _ | ||
| right_mem_verts_of_adj _ := Set.mem_univ _ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you merge this with
Digraph.Basic? Same forSimpleGraph