Draft — mutable and not usable as a dependency; its citation marks the draft state.

Lax307052.Reachability

Bounded reachability

concepts/Lax307052/Reachability.lean · lax-307052

definition

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Concept map

    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    Definition

    A directed graph on NN 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.

    Lean source view on GitHub

    1import Mathlib.Data.List.FinRange
    2import Mathlib.Logic.Relation
    3
    4/-!
    5---
    6title: Bounded reachability
    7type: definition
    8---
    9A directed graph on NN vertices is given by its Boolean adjacency matrix.
    10A walk may repeat vertices. The recursive reachability test divides the
    11length bound in two and enumerates possible middle vertices.
    12-/
    13
    14namespace Lax307052.Reachability
    15
    16abbrev Graph (N : ℕ) := Fin N → Fin N → Bool
    17
    18inductive Walk {α : Type} (R : α → α → Prop) : ℕ → α → α → Prop
    19 | nil (a : α) : Walk R 0 a a
    20 | tail {n : ℕ} {a b c : α} : Walk R n a b → R b c → Walk R (n + 1) a c
    21
    22def Within {α : Type} (R : α → α → Prop) (n : ℕ) (a b : α) : Prop :=
    23 ∃ k ≤ n, Walk R k a b
    24
    25def Reachable {N : ℕ} (G : Graph N) (a b : Fin N) : Prop :=
    26 Relation.ReflTransGen (fun u v => G u v = true) a b
    27
    28def search {N : ℕ} (G : Graph N) : ℕ → Fin N → Fin N → Bool
    29 | 0, a, b => decide (a = b) || G a b
    30 | k + 1, a, b => (List.finRange N).any fun m => search G k a m && search G k m b
    31
    32end Lax307052.Reachability
    33

    Community review

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above; your ORCID profile must share a public name.

    0 comments

    Loading discussion…