Bounded reachability
Lax733996.Reachability · concepts/Lax733996/Reachability.lean · lax-733996
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
A directed graph on vertices is given by its Boolean adjacency matrix. A walk may repeat vertices. The recursive reachability test divides the length bound in two and enumerates possible middle vertices.
Concept map
In the paper
- page 1 of this submission's paper
Lean source view on GitHub
| 1 | import Mathlib.Data.List.FinRange |
| 2 | import Mathlib.Logic.Relation |
| 3 | |
| 4 | set_option backward.isDefEq.respectTransparency false |
| 5 | |
| 6 | /-! |
| 7 | --- |
| 8 | title: Bounded reachability |
| 9 | type: definition |
| 10 | --- |
| 11 | A directed graph on vertices is given by its Boolean adjacency matrix. |
| 12 | A walk may repeat vertices. The recursive reachability test divides the |
| 13 | length bound in two and enumerates possible middle vertices. |
| 14 | -/ |
| 15 | |
| 16 | namespace Lax733996.Reachability |
| 17 | |
| 18 | abbrev Graph (N : ℕ) := Fin N → Fin N → Bool |
| 19 | |
| 20 | inductive Walk {α : Type} (R : α → α → Prop) : ℕ → α → α → Prop |
| 21 | | nil (a : α) : Walk R 0 a a |
| 22 | | tail {n : ℕ} {a b c : α} : Walk R n a b → R b c → Walk R (n + 1) a c |
| 23 | |
| 24 | def Within {α : Type} (R : α → α → Prop) (n : ℕ) (a b : α) : Prop := |
| 25 | ∃ k ≤ n, Walk R k a b |
| 26 | |
| 27 | def Reachable {N : ℕ} (G : Graph N) (a b : Fin N) : Prop := |
| 28 | Relation.ReflTransGen (fun u v => G u v = true) a b |
| 29 | |
| 30 | def search {N : ℕ} (G : Graph N) : ℕ → Fin N → Fin N → Bool |
| 31 | | 0, a, b => decide (a = b) || G a b |
| 32 | | k + 1, a, b => (List.finRange N).any fun m => search G k a m && search G k m b |
| 33 | |
| 34 | end Lax733996.Reachability |
| 35 |
Builds on
none
From Mathlib
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments